protected List<String> getActionIdsList(
      ActionRequest actionRequest, long roleId, boolean includePreselected) {

    List<String> actionIds = new ArrayList<>();

    Enumeration<String> enu = actionRequest.getParameterNames();

    while (enu.hasMoreElements()) {
      String name = enu.nextElement();

      if (name.startsWith(roleId + ActionUtil.ACTION)) {
        int pos = name.indexOf(ActionUtil.ACTION);

        String actionId = name.substring(pos + ActionUtil.ACTION.length());

        actionIds.add(actionId);
      } else if (includePreselected && name.startsWith(roleId + ActionUtil.PRESELECTED)) {

        int pos = name.indexOf(ActionUtil.PRESELECTED);

        String actionId = name.substring(pos + ActionUtil.PRESELECTED.length());

        actionIds.add(actionId);
      }
    }

    return actionIds;
  }
  public void updateKBArticlesPriorities(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    Enumeration<String> enu = actionRequest.getParameterNames();

    Map<Long, Double> resourcePrimKeyToPriorityMap = new HashMap<Long, Double>();

    while (enu.hasMoreElements()) {
      String name = enu.nextElement();

      if (!name.startsWith("priority")) {
        continue;
      }

      double priority = ParamUtil.getDouble(actionRequest, name);

      long resourcePrimKey = GetterUtil.getLong(name.substring(8));

      resourcePrimKeyToPriorityMap.put(resourcePrimKey, priority);
    }

    KBArticleServiceUtil.updateKBArticlesPriorities(
        themeDisplay.getScopeGroupId(), resourcePrimKeyToPriorityMap);
  }
  protected void updateExternalServices(ActionRequest actionRequest, PortletPreferences preferences)
      throws Exception {

    boolean imageMagickEnabled = ParamUtil.getBoolean(actionRequest, "imageMagickEnabled");
    String imageMagickPath = ParamUtil.getString(actionRequest, "imageMagickPath");
    boolean openOfficeEnabled = ParamUtil.getBoolean(actionRequest, "openOfficeEnabled");
    int openOfficePort = ParamUtil.getInteger(actionRequest, "openOfficePort");
    boolean xugglerEnabled = ParamUtil.getBoolean(actionRequest, "xugglerEnabled");

    preferences.setValue(PropsKeys.IMAGEMAGICK_ENABLED, String.valueOf(imageMagickEnabled));
    preferences.setValue(PropsKeys.IMAGEMAGICK_GLOBAL_SEARCH_PATH, imageMagickPath);
    preferences.setValue(PropsKeys.OPENOFFICE_SERVER_ENABLED, String.valueOf(openOfficeEnabled));
    preferences.setValue(PropsKeys.OPENOFFICE_SERVER_PORT, String.valueOf(openOfficePort));
    preferences.setValue(PropsKeys.XUGGLER_ENABLED, String.valueOf(xugglerEnabled));

    Enumeration<String> enu = actionRequest.getParameterNames();

    while (enu.hasMoreElements()) {
      String name = enu.nextElement();

      if (name.startsWith("imageMagickLimit")) {
        String key = name.substring(16, name.length()).toLowerCase();
        String value = ParamUtil.getString(actionRequest, name);

        preferences.setValue(PropsKeys.IMAGEMAGICK_RESOURCE_LIMIT + key, value);
      }
    }

    preferences.store();

    GhostscriptUtil.reset();
    ImageMagickUtil.reset();
  }
 /**
  * Pass all the action request parameters to the render phase by putting them into the action
  * response object. This may not be called when the action will call {@link
  * javax.portlet.ActionResponse#sendRedirect sendRedirect}.
  *
  * @param request the current action request
  * @param response the current action response
  * @see javax.portlet.ActionResponse#setRenderParameter
  */
 public static void passAllParametersToRenderPhase(
     ActionRequest request, ActionResponse response) {
   try {
     Enumeration<String> en = request.getParameterNames();
     while (en.hasMoreElements()) {
       String param = en.nextElement();
       String values[] = request.getParameterValues(param);
       response.setRenderParameter(param, values);
     }
   } catch (IllegalStateException ex) {
     // Ignore in case sendRedirect was already set.
   }
 }
  protected void updateLogLevels(ActionRequest actionRequest) throws Exception {

    Enumeration<String> enu = actionRequest.getParameterNames();

    while (enu.hasMoreElements()) {
      String name = enu.nextElement();

      if (name.startsWith("logLevel")) {
        String loggerName = name.substring(8);

        String priority = ParamUtil.getString(actionRequest, name, Level.INFO.toString());

        Log4JUtil.setLevel(loggerName, priority, true);
      }
    }
  }
  public void processActionEdit(ActionRequest request, ActionResponse response)
      throws PortletException, IOException {
    // TODO: Check Role

    // Stay in EDIT mode unless we are successful
    response.setPortletMode(PortletMode.EDIT);

    Placement placement = ToolManager.getCurrentPlacement();
    // get the site toolConfiguration, if this is part of a site.
    ToolConfiguration toolConfig = SiteService.findTool(placement.getId());
    String id = request.getParameter(LTIService.LTI_ID);
    String toolId = request.getParameter(LTIService.LTI_TOOL_ID);
    Properties reqProps = new Properties();
    Enumeration names = request.getParameterNames();
    while (names.hasMoreElements()) {
      String name = (String) names.nextElement();
      reqProps.setProperty(name, request.getParameter(name));
    }
    Object retval = m_ltiService.updateContent(Long.parseLong(id), reqProps);
    placement.save();

    response.setPortletMode(PortletMode.VIEW);
  }
  private Map<String, String> getSchedulerProperties(
      ActionRequest req, ContentImporterForm contentImporterForm) {
    Map<String, String> properties = new HashMap<String, String>(5);
    Enumeration<String> propertiesNames = req.getParameterNames();

    if (UtilMethods.isSet(contentImporterForm.getMap())) {
      properties = contentImporterForm.getMap();
    } else {
      String propertyName;
      String propertyValue;

      for (; propertiesNames.hasMoreElements(); ) {
        propertyName = propertiesNames.nextElement();
        if (propertyName.startsWith("propertyName")) {
          propertyValue = req.getParameter("propertyValue" + propertyName.substring(12));

          if (UtilMethods.isSet(req.getParameter(propertyName)) && UtilMethods.isSet(propertyValue))
            properties.put(req.getParameter(propertyName), propertyValue);
        }
      }
    }

    return properties;
  }