@Override
  public String render(RenderRequest renderRequest, RenderResponse renderResponse)
      throws PortletException {

    try {
      WikiNode node = ActionUtil.getNode(renderRequest);

      renderRequest.setAttribute(WikiWebKeys.WIKI_NODE, node);

      WikiPage page = ActionUtil.getPage(renderRequest);

      renderRequest.setAttribute(WikiWebKeys.WIKI_PAGE, page);
    } catch (Exception e) {
      if (e instanceof NoSuchNodeException
          || e instanceof NoSuchPageException
          || e instanceof PrincipalException) {

        SessionErrors.add(renderRequest, e.getClass());

        return "/wiki/error.jsp";
      } else {
        throw new PortletException(e);
      }
    }

    return "/wiki/edit_page_attachment.jsp";
  }
  @Override
  public String render(RenderRequest renderRequest, RenderResponse renderResponse)
      throws PortletException {

    Portlet portlet = null;

    try {
      portlet = ActionUtil.getPortlet(renderRequest);
    } catch (PrincipalException pe) {
      SessionErrors.add(renderRequest, pe.getClass());

      return "/error.jsp";
    } catch (Exception e) {
      throw new PortletException(e);
    }

    try {
      renderResponse.setTitle(ActionUtil.getTitle(portlet, renderRequest));

      renderRequest = ActionUtil.getWrappedRenderRequest(renderRequest, null);

      return "/publish_portlet.jsp";
    } catch (Exception e) {
      SessionErrors.add(renderRequest, e.getClass());

      return "/error.jsp";
    }
  }
Example #3
0
 public BoundMenuCommandButton(Action action) {
   this(
       CommandButtonKind.ACTION_ONLY,
       ActionUtil.lookupText(action),
       ActionUtil.lookupDescription(action),
       ActionUtil.lookupIcon(action, false),
       ActionUtil.lookupIcon(action, true),
       action);
 }
  @Override
  public ActionForward render(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig portletConfig,
      RenderRequest renderRequest,
      RenderResponse renderResponse)
      throws Exception {

    try {
      ActionUtil.getLayoutPrototype(renderRequest);
    } catch (Exception e) {
      if (e instanceof NoSuchLayoutPrototypeException || e instanceof PrincipalException) {

        SessionErrors.add(renderRequest, e.getClass().getName());

        return mapping.findForward("portlet.layout_prototypes.error");
      } else {
        throw e;
      }
    }

    return mapping.findForward(
        getForward(renderRequest, "portlet.layout_prototypes.edit_layout_prototype"));
  }
Example #5
0
  public ActionForward render(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig portletConfig,
      RenderRequest renderRequest,
      RenderResponse renderResponse)
      throws Exception {

    try {
      String cmd = ParamUtil.getString(renderRequest, Constants.CMD);

      if (!cmd.equals(Constants.ADD)) {
        ActionUtil.getFeed(renderRequest);
      }
    } catch (NoSuchFeedException nssfe) {

      // Let this slide because the user can manually input a feed id for
      // a new syndicated feed that does not yet exist.

    } catch (Exception e) {
      if (e instanceof PrincipalException) {
        SessionErrors.add(renderRequest, e.getClass().getName());

        return mapping.findForward("portlet.nss.journal.error");
      } else {
        throw e;
      }
    }

    return mapping.findForward(getForward(renderRequest, "portlet.nss.journal.edit_feed"));
  }
  @Override
  public ActionForward render(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig portletConfig,
      RenderRequest renderRequest,
      RenderResponse renderResponse)
      throws Exception {

    try {
      ActionUtil.getPasswordPolicy(renderRequest);
    } catch (Exception e) {
      if (e instanceof NoSuchPasswordPolicyException || e instanceof PrincipalException) {

        SessionErrors.add(renderRequest, e.getClass().getName());

        return mapping.findForward("portlet.password_policies_admin.error");
      } else {
        throw e;
      }
    }

    return mapping.findForward(
        getForward(
            renderRequest,
            "portlet.password_policies_admin." + "edit_password_policy_assignments"));
  }
  @Override
  public ActionForward render(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig portletConfig,
      RenderRequest renderRequest,
      RenderResponse renderResponse)
      throws Exception {

    try {
      ActionUtil.getCategory(renderRequest);
    } catch (Exception e) {
      if (e instanceof BannedUserException
          || e instanceof NoSuchCategoryException
          || e instanceof PrincipalException) {

        SessionErrors.add(renderRequest, e.getClass().getName());

        return mapping.findForward("portlet.message_boards.error");
      } else {
        throw e;
      }
    }

    return mapping.findForward("portlet.message_boards.view");
  }
Example #8
0
  private void runOnMultiple(final ICompilationUnit[] cus) {
    ICleanUp[] cleanUps = getCleanUps(cus);
    if (cleanUps == null) return;

    MultiStatus status =
        new MultiStatus(
            JavaUI.ID_PLUGIN, IStatus.OK, ActionMessages.CleanUpAction_MultiStateErrorTitle, null);
    for (int i = 0; i < cus.length; i++) {
      ICompilationUnit cu = cus[i];

      if (!ActionUtil.isOnBuildPath(cu)) {
        String cuLocation = BasicElementLabels.getPathLabel(cu.getPath(), false);
        String message =
            Messages.format(ActionMessages.CleanUpAction_CUNotOnBuildpathMessage, cuLocation);
        status.add(new Status(IStatus.INFO, JavaUI.ID_PLUGIN, IStatus.ERROR, message, null));
      }
    }
    if (!status.isOK()) {
      ErrorDialog.openError(getShell(), getActionName(), null, status);
      return;
    }

    try {
      performRefactoring(cus, cleanUps);
    } catch (InvocationTargetException e) {
      JavaPlugin.log(e);
      if (e.getCause() instanceof CoreException) showUnexpectedError((CoreException) e.getCause());
    }
  }
  @Override
  public void processAction(
      ActionMapping actionMapping,
      ActionForm actionForm,
      PortletConfig portletConfig,
      ActionRequest actionRequest,
      ActionResponse actionResponse)
      throws Exception {

    actionRequest = ActionUtil.getWrappedActionRequest(actionRequest, null);

    try {
      updateRolePermissions(actionRequest);

      addSuccessMessage(actionRequest, actionResponse);
    } catch (Exception e) {
      if (e instanceof PrincipalException) {
        SessionErrors.add(actionRequest, e.getClass());

        setForward(actionRequest, "portlet.portlet_configuration.error");
      } else {
        throw e;
      }
    }
  }
  @Override
  public ActionForward render(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig portletConfig,
      RenderRequest renderRequest,
      RenderResponse renderResponse)
      throws Exception {

    try {
      ActionUtil.getStructure(renderRequest);
    } catch (NoSuchStructureException nsse) {

      // Let this slide because the user can manually input a structure
      // key for a new structure that does not yet exist

    } catch (Exception e) {
      if (e instanceof PrincipalException) {
        SessionErrors.add(renderRequest, e.getClass());

        return mapping.findForward("portlet.dynamic_data_mapping.error");
      } else {
        throw e;
      }
    }

    return mapping.findForward(
        getForward(renderRequest, "portlet.dynamic_data_mapping.copy_structure"));
  }
  @Override
  public ActionForward render(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig portletConfig,
      RenderRequest renderRequest,
      RenderResponse renderResponse)
      throws Exception {

    try {
      ActionUtil.getWorkflowInstance(renderRequest);
    } catch (Exception e) {
      if (e instanceof WorkflowException) {

        SessionErrors.add(renderRequest, e.getClass().getName());

        return mapping.findForward("portlet.workflow_instances.error");
      } else {
        throw e;
      }
    }

    String forward = getForward(renderRequest, "portlet.workflow_instances.edit_workflow_instance");

    return mapping.findForward(forward);
  }
  @Override
  public ActionForward render(
      ActionMapping actionMapping,
      ActionForm actionForm,
      PortletConfig portletConfig,
      RenderRequest renderRequest,
      RenderResponse renderResponse)
      throws Exception {

    try {
      long nodeId = ParamUtil.getLong(renderRequest, "nodeId");

      if (nodeId > 0) {
        ActionUtil.getNode(renderRequest);
      }
    } catch (Exception e) {
      if (e instanceof NoSuchNodeException || e instanceof PrincipalException) {

        SessionErrors.add(renderRequest, e.getClass());

        return actionMapping.findForward("portlet.wiki.error");
      } else {
        throw e;
      }
    }

    return actionMapping.findForward(getForward(renderRequest, "portlet.wiki.edit_node"));
  }
  @Override
  public ActionForward render(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig portletConfig,
      RenderRequest renderRequest,
      RenderResponse renderResponse)
      throws Exception {

    try {
      String cmd = ParamUtil.getString(renderRequest, Constants.CMD);

      if (!cmd.equals(Constants.ADD)) {
        ActionUtil.getRecordSet(renderRequest);
      }
    } catch (NoSuchRecordSetException nsee) {

      // Let this slide because the user can manually input an record set
      // key for a new record set that does not yet exist

    } catch (Exception e) {
      if (e instanceof PrincipalException) {
        SessionErrors.add(renderRequest, e.getClass().getName());

        return mapping.findForward("portlet.dynamic_data_lists.error");
      } else {
        throw e;
      }
    }

    return mapping.findForward(
        getForward(renderRequest, "portlet.dynamic_data_lists.edit_record_set"));
  }
  @Override
  public ActionForward render(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig portletConfig,
      RenderRequest renderRequest,
      RenderResponse renderResponse)
      throws Exception {

    try {
      ActionUtil.getEntry(renderRequest);

      if (PropsValues.BLOGS_PINGBACK_ENABLED) {
        BlogsEntry entry = (BlogsEntry) renderRequest.getAttribute(WebKeys.BLOGS_ENTRY);

        if ((entry != null) && entry.isAllowPingbacks()) {
          HttpServletResponse response = PortalUtil.getHttpServletResponse(renderResponse);

          response.addHeader(
              "X-Pingback", PortalUtil.getPortalURL(renderRequest) + "/xmlrpc/pingback");
        }
      }
    } catch (Exception e) {
      if (e instanceof NoSuchEntryException || e instanceof PrincipalException) {

        SessionErrors.add(renderRequest, e.getClass().getName());

        return mapping.findForward("portlet.blogs.error");
      } else {
        throw e;
      }
    }

    return mapping.findForward(getForward(renderRequest, "portlet.blogs.edit_entry"));
  }
  @Override
  public ActionForward render(
      ActionMapping actionMapping,
      ActionForm actionForm,
      PortletConfig portletConfig,
      RenderRequest renderRequest,
      RenderResponse renderResponse)
      throws Exception {

    try {
      ActionUtil.getOrganization(renderRequest);
    } catch (Exception e) {
      if (e instanceof NoSuchOrganizationException || e instanceof PrincipalException) {

        SessionErrors.add(renderRequest, e.getClass());

        return actionMapping.findForward("portlet.users_admin.error");
      } else {
        throw e;
      }
    }

    return actionMapping.findForward(
        getForward(renderRequest, "portlet.users_admin.edit_organization"));
  }
  /**
   * Takes a submitted contact and adds it to the database if it passes validation.
   *
   * @param request
   * @param response
   */
  public void registerContact(ActionRequest request, ActionResponse response) throws Exception {

    _log.debug("registerContact");

    Contact contact = ActionUtil.contactFromRequest(request);
    ArrayList<String> errors = new ArrayList();
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    String community = "";
    try {
      community = themeDisplay.getScopeGroupName();
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    boolean regValid = ContactMeRegValidator.validateRegistration(contact, errors);

    if (regValid) {

      long userId = themeDisplay.getUserId();

      contact.setCreateDate(new Date(System.currentTimeMillis()));
      contact.setUserId(userId);
      contact.setStatus(Constants.CONTACT_RECEIVED);
      contact.setCommunity(community);

      ContactLocalServiceUtil.addContact(contact);
      SessionMessages.add(request, "thank-you-message");

      PortletPreferences preferences = request.getPreferences();

      long companyId = PortalUtil.getCompanyId(request);

      Message message = new Message();

      message.put("from-name", preferences.getValue("fromName", ""));
      message.put("from-address", preferences.getValue("fromEMail", ""));
      message.put("subject", preferences.getValue("subject", ""));
      message.put("body", preferences.getValue("body", ""));
      message.put("signature", preferences.getValue("signature", ""));
      message.put("to-name", contact.getFullname());
      message.put("to-address", contact.getEmail());
      message.put("community", contact.getCommunity());
      message.put("companyId", companyId);

      MessageBusUtil.sendMessage("liferay/contactme", message);

      response.setRenderParameter("jspPage", viewThankYouJSP);

    } else {
      for (String error : errors) {
        SessionErrors.add(request, error);
      }
      SessionErrors.add(request, "error-saving-contact");
      response.setRenderParameter("jspPage", viewAddContactJSP);
      request.setAttribute("cmContact", contact);
    }
  }
  protected BlogsEntry getBlogsEntry(ActionRequest actionRequest) throws Exception {

    try {
      return ActionUtil.getEntry(actionRequest);
    } catch (PrincipalException pe) {
      throw new TrackbackValidationException(
          "Blog entry must have guest view permissions to enable " + "trackbacks", pe);
    }
  }
  @Override
  protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
      throws Exception {

    long actionId = ParamUtil.getLong(resourceRequest, "actionId");

    MDRAction action = _mdrActionService.fetchAction(actionId);

    resourceRequest.setAttribute(MDRWebKeys.MOBILE_DEVICE_RULES_RULE_GROUP_ACTION, action);

    String type = ParamUtil.getString(resourceRequest, "type");

    ActionUtil.includeEditorJSP(
        getPortletConfig(resourceRequest),
        resourceRequest,
        resourceResponse,
        ActionUtil.getActionEditorJSP(type));
  }
  @Override
  public ActionForward render(
      ActionMapping actionMapping,
      ActionForm actionForm,
      PortletConfig portletConfig,
      RenderRequest renderRequest,
      RenderResponse renderResponse)
      throws Exception {

    renderRequest = ActionUtil.getWrappedRenderRequest(renderRequest, null);

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

    long groupId =
        ParamUtil.getLong(renderRequest, "resourceGroupId", themeDisplay.getScopeGroupId());

    String portletResource = ParamUtil.getString(renderRequest, "portletResource");
    String modelResource = ParamUtil.getString(renderRequest, "modelResource");
    String resourcePrimKey = ParamUtil.getString(renderRequest, "resourcePrimKey");

    String selResource = portletResource;

    if (Validator.isNotNull(modelResource)) {
      selResource = modelResource;
    }

    try {
      PermissionServiceUtil.checkPermission(groupId, selResource, resourcePrimKey);
    } catch (PrincipalException pe) {
      SessionErrors.add(renderRequest, PrincipalException.class.getName());

      setForward(renderRequest, "portlet.portlet_configuration.error");
    }

    Portlet portlet =
        PortletLocalServiceUtil.getPortletById(themeDisplay.getCompanyId(), portletResource);

    if (portlet != null) {
      renderResponse.setTitle(ActionUtil.getTitle(portlet, renderRequest));
    }

    return actionMapping.findForward(
        getForward(renderRequest, "portlet.portlet_configuration.edit_permissions"));
  }
Example #20
0
  private void run(ICompilationUnit cu) {
    if (!ActionUtil.isEditable(fEditor, getShell(), cu)) return;

    ICleanUp[] cleanUps = getCleanUps(new ICompilationUnit[] {cu});
    if (cleanUps == null) return;

    if (!ElementValidator.check(cu, getShell(), getActionName(), fEditor != null)) return;

    try {
      performRefactoring(new ICompilationUnit[] {cu}, cleanUps);
    } catch (InvocationTargetException e) {
      JavaPlugin.log(e);
      if (e.getCause() instanceof CoreException) showUnexpectedError((CoreException) e.getCause());
    }
  }
  @Override
  protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);

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

    long layoutSetBranchId = ParamUtil.getLong(actionRequest, "layoutSetBranchId");

    long layoutBranchId = ParamUtil.getLong(actionRequest, "layoutBranchId");

    StagingUtil.setRecentLayoutBranchId(
        request, layoutSetBranchId, themeDisplay.getPlid(), layoutBranchId);

    ActionUtil.addLayoutBranchSessionMessages(actionRequest, actionResponse);
  }
  @Override
  public String render(RenderRequest renderRequest, RenderResponse renderResponse)
      throws PortletException {

    try {
      ActionUtil.getGroup(renderRequest);
    } catch (Exception e) {
      if (e instanceof NoSuchGroupException || e instanceof PrincipalException) {

        SessionErrors.add(renderRequest, e.getClass());

        return "/error/error.jsp";
      } else {
        throw new PortletException(e);
      }
    }

    return getPath();
  }
  public ActionForward render(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig config,
      RenderRequest req,
      RenderResponse res)
      throws Exception {

    try {
      ActionUtil.getOrganization(req);
    } catch (Exception e) {
      if (e instanceof NoSuchOrganizationException || e instanceof PrincipalException) {

        SessionErrors.add(req, e.getClass().getName());

        return mapping.findForward("portlet.enterprise_admin.error");
      } else {
        throw e;
      }
    }

    return mapping.findForward(getForward(req, "portlet.enterprise_admin.edit_organization"));
  }
  @Override
  public String render(RenderRequest renderRequest, RenderResponse renderResponse)
      throws PortletException {

    try {
      renderRequest.setAttribute(WikiWebKeys.WIKI_IMPORTER_TRACKER, _wikiImporterTracker);

      WikiNode node = ActionUtil.getNode(renderRequest);

      renderRequest.setAttribute(WikiWebKeys.WIKI_NODE, node);
    } catch (Exception e) {
      if (e instanceof NoSuchNodeException || e instanceof PrincipalException) {

        SessionErrors.add(renderRequest, e.getClass());

        return "/wiki/error.jsp";
      } else {
        throw new PortletException(e);
      }
    }

    return "/wiki_admin/import_pages.jsp";
  }
  @Override
  public String render(RenderRequest renderRequest, RenderResponse renderResponse)
      throws PortletException {

    try {
      ActionUtil.getEntry(renderRequest);

      if (PropsValues.BLOGS_PINGBACK_ENABLED) {
        BlogsEntry entry = (BlogsEntry) renderRequest.getAttribute(WebKeys.BLOGS_ENTRY);

        if ((entry != null) && entry.isAllowPingbacks()) {
          HttpServletResponse response = PortalUtil.getHttpServletResponse(renderResponse);

          response.addHeader(
              "X-Pingback", PortalUtil.getPortalURL(renderRequest) + "/xmlrpc/pingback");
        }
      }
    } catch (Exception e) {
      if (e instanceof NoSuchEntryException || e instanceof PrincipalException) {

        SessionErrors.add(renderRequest, e.getClass());

        return "/html/portlet/blogs/error.jsp";
      } else {
        throw new PortletException(e);
      }
    }

    long assetCategoryId = ParamUtil.getLong(renderRequest, "categoryId");
    String assetCategoryName = ParamUtil.getString(renderRequest, "tag");

    if ((assetCategoryId > 0) || Validator.isNotNull(assetCategoryName)) {
      return "/html/portlet/blogs/view.jsp";
    }

    return getPath();
  }
  @Override
  public ActionForward render(
      ActionMapping actionMapping,
      ActionForm actionForm,
      PortletConfig portletConfig,
      RenderRequest renderRequest,
      RenderResponse renderResponse)
      throws Exception {

    try {
      ActionUtil.getCategory(renderRequest);
    } catch (Exception e) {
      if (e instanceof PrincipalException) {
        SessionErrors.add(renderRequest, e.getClass());

        return actionMapping.findForward("portlet.message_boards.error");
      } else {
        throw e;
      }
    }

    return actionMapping.findForward(
        getForward(renderRequest, "portlet.message_boards.move_category"));
  }
  @Override
  public ActionForward render(
      ActionMapping actionMapping,
      ActionForm actionForm,
      PortletConfig portletConfig,
      RenderRequest renderRequest,
      RenderResponse renderResponse)
      throws Exception {

    try {
      ActionUtil.getWorkflowDefinition(renderRequest);
    } catch (Exception e) {
      if (e instanceof WorkflowException) {
        SessionErrors.add(renderRequest, e.getClass());

        return actionMapping.findForward("portlet.workflow_definitions.error");
      } else {
        throw e;
      }
    }

    return actionMapping.findForward(
        getForward(renderRequest, "portlet.workflow_definitions.edit_workflow_definition"));
  }