public void deleteLayout(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

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

    String redirect = ParamUtil.getString(actionRequest, "redirect");

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

    if (selPlid <= 0) {
      long groupId = ParamUtil.getLong(actionRequest, "groupId");
      boolean privateLayout = ParamUtil.getBoolean(actionRequest, "privateLayout");
      long layoutId = ParamUtil.getLong(actionRequest, "layoutId");

      Layout layout = layoutLocalService.getLayout(groupId, privateLayout, layoutId);

      selPlid = layout.getPlid();
    }

    Object[] returnValue = SitesUtil.deleteLayout(actionRequest, actionResponse);

    if (selPlid == themeDisplay.getRefererPlid()) {
      long newRefererPlid = (Long) returnValue[2];

      redirect = HttpUtil.setParameter(redirect, "refererPlid", newRefererPlid);
      redirect = HttpUtil.setParameter(redirect, actionResponse.getNamespace() + "selPlid", 0);
    }

    actionRequest.setAttribute(WebKeys.REDIRECT, redirect);
  }
Exemplo n.º 2
0
  public void updateAttachments(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    String portletId = PortalUtil.getPortletId(actionRequest);

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

    String dirName = ParamUtil.getString(actionRequest, "dirName");

    ServiceContext serviceContext =
        ServiceContextFactory.getInstance(KBArticle.class.getName(), actionRequest);

    dirName =
        KBArticleServiceUtil.updateAttachments(portletId, resourcePrimKey, dirName, serviceContext);

    String redirect = ParamUtil.getString(actionRequest, "redirect");

    redirect = HttpUtil.setParameter(redirect, actionResponse.getNamespace() + "dirName", dirName);

    actionRequest.setAttribute(WebKeys.REDIRECT, redirect);
  }
Exemplo n.º 3
0
  public void updateKBArticle(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

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

    String portletId = PortalUtil.getPortletId(actionRequest);

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

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

    long parentResourcePrimKey = ParamUtil.getLong(actionRequest, "parentResourcePrimKey");
    String title = ParamUtil.getString(actionRequest, "title");
    String content = ParamUtil.getString(actionRequest, "content");
    String description = ParamUtil.getString(actionRequest, "description");
    String[] sections = actionRequest.getParameterValues("sections");
    String dirName = ParamUtil.getString(actionRequest, "dirName");
    int workflowAction = ParamUtil.getInteger(actionRequest, "workflowAction");

    KBArticle kbArticle = null;

    ServiceContext serviceContext =
        ServiceContextFactory.getInstance(KBArticle.class.getName(), actionRequest);

    if (cmd.equals(Constants.ADD)) {
      kbArticle =
          KBArticleServiceUtil.addKBArticle(
              portletId,
              parentResourcePrimKey,
              title,
              content,
              description,
              sections,
              dirName,
              serviceContext);
    } else if (cmd.equals(Constants.UPDATE)) {
      kbArticle =
          KBArticleServiceUtil.updateKBArticle(
              resourcePrimKey, title, content, description, sections, dirName, serviceContext);
    }

    if (!cmd.equals(Constants.ADD) && !cmd.equals(Constants.UPDATE)) {
      return;
    }

    if (workflowAction == WorkflowConstants.ACTION_SAVE_DRAFT) {
      String namespace = actionResponse.getNamespace();
      String redirect = getRedirect(actionRequest, actionResponse);

      String editURL = PortalUtil.getLayoutFullURL(themeDisplay);

      editURL = HttpUtil.setParameter(editURL, "p_p_id", PortletKeys.KNOWLEDGE_BASE_ADMIN);
      editURL =
          HttpUtil.setParameter(editURL, namespace + "mvcPath", templatePath + "edit_article.jsp");
      editURL = HttpUtil.setParameter(editURL, namespace + "redirect", redirect);
      editURL =
          HttpUtil.setParameter(
              editURL, namespace + "resourcePrimKey", kbArticle.getResourcePrimKey());

      actionRequest.setAttribute(WebKeys.REDIRECT, editURL);
    }
  }
  @Override
  public void processAction(
      ActionMapping actionMapping,
      ActionForm actionForm,
      PortletConfig portletConfig,
      ActionRequest actionRequest,
      ActionResponse actionResponse)
      throws Exception {

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    try {
      Organization organization = null;

      if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
        organization = updateOrganization(actionRequest);
      } else if (cmd.equals(Constants.DELETE)) {
        deleteOrganizations(actionRequest);
      }

      String redirect = ParamUtil.getString(actionRequest, "redirect");

      if (organization != null) {
        redirect =
            HttpUtil.setParameter(
                redirect,
                actionResponse.getNamespace() + "organizationId",
                organization.getOrganizationId());
      }

      sendRedirect(actionRequest, actionResponse, redirect);
    } catch (Exception e) {
      if (e instanceof NoSuchOrganizationException || e instanceof PrincipalException) {

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

        setForward(actionRequest, "portlet.users_admin.error");
      } else if (e instanceof AddressCityException
          || e instanceof AddressStreetException
          || e instanceof AddressZipException
          || e instanceof DuplicateOrganizationException
          || e instanceof EmailAddressException
          || e instanceof NoSuchCountryException
          || e instanceof NoSuchListTypeException
          || e instanceof NoSuchRegionException
          || e instanceof OrganizationNameException
          || e instanceof OrganizationParentException
          || e instanceof PhoneNumberException
          || e instanceof RequiredOrganizationException
          || e instanceof WebsiteURLException) {

        if (e instanceof NoSuchListTypeException) {
          NoSuchListTypeException nslte = (NoSuchListTypeException) e;

          SessionErrors.add(actionRequest, e.getClass().getName() + nslte.getType());
        } else {
          SessionErrors.add(actionRequest, e.getClass());
        }

        if (e instanceof RequiredOrganizationException) {
          String redirect =
              PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect"));

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

          if (organizationId > 0) {
            redirect =
                HttpUtil.setParameter(
                    redirect, actionResponse.getNamespace() + "organizationId", organizationId);
          }

          if (Validator.isNotNull(redirect)) {
            actionResponse.sendRedirect(redirect);
          }
        }
      } else {
        throw e;
      }
    }
  }