public static void openNodes(HttpServletRequest request, String treeId, String[] nodeIds) {

    while (true) {
      try {
        PortalPreferences portalPreferences =
            PortletPreferencesFactoryUtil.getPortalPreferences(request);

        String openNodesString =
            portalPreferences.getValue(SessionTreeJSClicks.class.getName(), treeId);

        for (String nodeId : nodeIds) {
          openNodesString = StringUtil.add(openNodesString, nodeId);
        }

        portalPreferences.setValue(SessionTreeJSClicks.class.getName(), treeId, openNodesString);

        return;
      } catch (ConcurrentModificationException cme) {
        continue;
      } catch (Exception e) {
        _log.error(e, e);

        return;
      }
    }
  }
  protected String getDisplayStyle(HttpServletRequest request, String[] displayViews) {

    PortalPreferences portalPreferences =
        PortletPreferencesFactoryUtil.getPortalPreferences(request);

    String displayStyle = ParamUtil.getString(request, "displayStyle");

    if (Validator.isNull(displayStyle)) {
      JournalWebConfiguration journalWebConfiguration =
          (JournalWebConfiguration) _request.getAttribute(JournalWebConfiguration.class.getName());

      displayStyle =
          portalPreferences.getValue(
              JournalPortletKeys.JOURNAL,
              "display-style",
              journalWebConfiguration.defaultDisplayView());
    } else {
      if (ArrayUtil.contains(displayViews, displayStyle)) {
        portalPreferences.setValue(JournalPortletKeys.JOURNAL, "display-style", displayStyle);

        request.setAttribute(WebKeys.SINGLE_PAGE_APPLICATION_CLEAR_CACHE, Boolean.TRUE);
      }
    }

    if (!ArrayUtil.contains(displayViews, displayStyle)) {
      displayStyle = displayViews[0];
    }

    return displayStyle;
  }
  public OrganizationSearch(
      PortletRequest portletRequest, String curParam, PortletURL iteratorURL) {

    super(
        portletRequest,
        new OrganizationDisplayTerms(portletRequest),
        new OrganizationSearchTerms(portletRequest),
        curParam,
        DEFAULT_DELTA,
        iteratorURL,
        headerNames,
        EMPTY_RESULTS_MESSAGE);

    OrganizationDisplayTerms displayTerms = (OrganizationDisplayTerms) getDisplayTerms();

    iteratorURL.setParameter(OrganizationDisplayTerms.CITY, displayTerms.getCity());
    iteratorURL.setParameter(
        OrganizationDisplayTerms.COUNTRY_ID, String.valueOf(displayTerms.getCountryId()));
    iteratorURL.setParameter(OrganizationDisplayTerms.NAME, displayTerms.getName());
    iteratorURL.setParameter(
        OrganizationDisplayTerms.PARENT_ORGANIZATION_ID,
        String.valueOf(displayTerms.getParentOrganizationId()));
    iteratorURL.setParameter(
        OrganizationDisplayTerms.REGION_ID, String.valueOf(displayTerms.getRegionId()));
    iteratorURL.setParameter(OrganizationDisplayTerms.STREET, displayTerms.getStreet());
    iteratorURL.setParameter(OrganizationDisplayTerms.ZIP, displayTerms.getZip());

    try {
      PortalPreferences preferences =
          PortletPreferencesFactoryUtil.getPortalPreferences(portletRequest);

      String orderByCol = ParamUtil.getString(portletRequest, "orderByCol");
      String orderByType = ParamUtil.getString(portletRequest, "orderByType");

      if (Validator.isNotNull(orderByCol) && Validator.isNotNull(orderByType)) {

        preferences.setValue(PortletKeys.USERS_ADMIN, "organizations-order-by-col", orderByCol);
        preferences.setValue(PortletKeys.USERS_ADMIN, "organizations-order-by-type", orderByType);
      } else {
        orderByCol =
            preferences.getValue(PortletKeys.USERS_ADMIN, "organizations-order-by-col", "name");
        orderByType =
            preferences.getValue(PortletKeys.USERS_ADMIN, "organizations-order-by-type", "asc");
      }

      OrderByComparator orderByComparator =
          UsersAdminUtil.getOrganizationOrderByComparator(orderByCol, orderByType);

      setOrderableHeaders(orderableHeaders);
      setOrderByCol(orderByCol);
      setOrderByType(orderByType);
      setOrderByComparator(orderByComparator);
    } catch (Exception e) {
      _log.error(e);
    }
  }
  public static String getOpenNodes(HttpServletRequest request, String treeId) {

    try {
      PortalPreferences portalPreferences =
          PortletPreferencesFactoryUtil.getPortalPreferences(request);

      return portalPreferences.getValue(SessionTreeJSClicks.class.getName(), treeId);
    } catch (Exception e) {
      _log.error(e, e);

      return null;
    }
  }
  public PasswordPolicySearch(PortletRequest portletRequest, PortletURL iteratorURL) {

    super(
        portletRequest,
        new PasswordPolicyDisplayTerms(portletRequest),
        new PasswordPolicyDisplayTerms(portletRequest),
        DEFAULT_CUR_PARAM,
        DEFAULT_DELTA,
        iteratorURL,
        headerNames,
        EMPTY_RESULTS_MESSAGE);

    PasswordPolicyDisplayTerms displayTerms = (PasswordPolicyDisplayTerms) getDisplayTerms();

    iteratorURL.setParameter(PasswordPolicyDisplayTerms.NAME, displayTerms.getName());

    try {
      PortalPreferences preferences =
          PortletPreferencesFactoryUtil.getPortalPreferences(portletRequest);

      String orderByCol = ParamUtil.getString(portletRequest, "orderByCol");
      String orderByType = ParamUtil.getString(portletRequest, "orderByType");

      if (Validator.isNotNull(orderByCol) && Validator.isNotNull(orderByType)) {

        preferences.setValue(
            PortletKeys.PASSWORD_POLICIES_ADMIN, "password-policies-order-by-col", orderByCol);
        preferences.setValue(
            PortletKeys.PASSWORD_POLICIES_ADMIN, "password-policies-order-by-type", orderByType);
      } else {
        orderByCol =
            preferences.getValue(
                PortletKeys.PASSWORD_POLICIES_ADMIN, "password-policies-order-by-col", "name");
        orderByType =
            preferences.getValue(
                PortletKeys.PASSWORD_POLICIES_ADMIN, "password-policies-order-by-type", "asc");
      }

      OrderByComparator orderByComparator =
          PasswordPoliciesAdminUtil.getPasswordPolicyOrderByComparator(orderByCol, orderByType);

      setOrderableHeaders(orderableHeaders);
      setOrderByCol(orderByCol);
      setOrderByType(orderByType);
      setOrderByComparator(orderByComparator);
    } catch (Exception e) {
      _log.error(e);
    }
  }
  public static void closeNodes(HttpServletRequest request, String treeId) {
    while (true) {
      try {
        PortalPreferences portalPreferences =
            PortletPreferencesFactoryUtil.getPortalPreferences(request);

        portalPreferences.setValue(SessionTreeJSClicks.class.getName(), treeId, StringPool.BLANK);

        return;
      } catch (ConcurrentModificationException cme) {
        continue;
      } catch (Exception e) {
        _log.error(e, e);

        return;
      }
    }
  }
Esempio n. 7
0
  public PmlFileStatusSearch(RenderRequest renderRequest, PortletURL iteratorURL) {
    super(
        renderRequest,
        new PmlFileStatusDisplayTerms(renderRequest),
        new PmlFileStatusSearchTerms(renderRequest),
        DEFAULT_CUR_PARAM,
        DEFAULT_DELTA,
        iteratorURL,
        headernames,
        EMPTY_RESULTS_MESSAGE);

    PmlFileStatusDisplayTerms displayTerms = (PmlFileStatusDisplayTerms) getDisplayTerms();
    iteratorURL.setParameter(
        PmlFileStatusDisplayTerms.FILESTATUS_CODE, displayTerms.getFilestatuscode());
    iteratorURL.setParameter(
        PmlFileStatusDisplayTerms.FILESTATUS_NAME, displayTerms.getFilestatusname());

    try {
      PortalPreferences preferences =
          PortletPreferencesFactoryUtil.getPortalPreferences(renderRequest);

      String orderByCol = ParamUtil.getString(renderRequest, "orderByCol");
      String orderByType = ParamUtil.getString(renderRequest, "orderByType");

      if (Validator.isNotNull(orderByCol) && Validator.isNotNull(orderByType)) {

        preferences.setValue("SGS_PMLEDM_FILESTATUS", "pmlFilestatus-order-by-type", orderByCol);
        preferences.setValue("SGS_PMLEDM_FILESTATUS", "pmlFilestatus-order-by-type", orderByType);
      } else {
        preferences.setValue(
            "SGS_PMLEDM_FILESTATUS", "pmlFilestatus-order-by-column", "orderFilestatuscode");
        preferences.setValue("SGS_PMLEDM_FILESTATUS", "pmlFilestatus-order-by-type", "asc");
      }
      OrderByComparator orderByComparator =
          PmlFileStatusUtil.getPmlFileStatusOrderByComparator(orderByCol, orderByType);
      setOrderableHeaders(orderableHeaders);
      setOrderByCol(orderByCol);
      setOrderByType(orderByType);
      setOrderByComparator(orderByComparator);

    } catch (Exception e) {
      _log.error(e);
    }
  }
  public void updateRootKBFolderId(ActionRequest actionRequest, ActionResponse actionResponse)
      throws PortalException {

    long kbFolderId = ParamUtil.getLong(actionRequest, "rootKBFolderId");

    if (kbFolderId == KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
      return;
    }

    KBFolder kbFolder = KBFolderServiceUtil.getKBFolder(kbFolderId);

    PortalPreferences portalPreferences =
        PortletPreferencesFactoryUtil.getPortalPreferences(
            PortalUtil.getLiferayPortletRequest(actionRequest));

    portalPreferences.setValue(
        PortletKeys.KNOWLEDGE_BASE_DISPLAY, "preferredKBFolderURLTitle", kbFolder.getUrlTitle());

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

    if (Validator.isNull(urlTitle)) {
      return;
    }

    KBArticle kbArticle =
        KBArticleLocalServiceUtil.fetchKBArticleByUrlTitle(
            kbFolder.getGroupId(), kbFolder.getUrlTitle(), urlTitle);

    if (kbArticle == null) {
      return;
    }

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

    if (!KBArticlePermission.contains(
        themeDisplay.getPermissionChecker(), kbArticle, ActionKeys.VIEW)) {

      return;
    }

    actionResponse.setRenderParameter("kbFolderUrlTitle", kbFolder.getUrlTitle());
    actionResponse.setRenderParameter("urlTitle", urlTitle);
  }
Esempio n. 9
0
  public PmlFieldSearch(RenderRequest renderRequest, PortletURL iteratorURL) {
    super(
        renderRequest,
        new PmlFieldDisplayTerms(renderRequest),
        new PmlFieldSearchTerms(renderRequest),
        DEFAULT_CUR_PARAM,
        DEFAULT_DELTA,
        iteratorURL,
        headernames,
        EMPTY_RESULTS_MESSAGE);

    PmlFieldDisplayTerms displayTerms = (PmlFieldDisplayTerms) getDisplayTerms();
    iteratorURL.setParameter(PmlFieldDisplayTerms.MA_PHAN_LOAI, displayTerms.getMaPhanLoai());
    iteratorURL.setParameter(PmlFieldDisplayTerms.TEN_PHAN_LOAI, displayTerms.getTenPhanLoai());

    try {
      PortalPreferences preferences =
          PortletPreferencesFactoryUtil.getPortalPreferences(renderRequest);

      String orderByCol = ParamUtil.getString(renderRequest, "orderByCol");
      String orderByType = ParamUtil.getString(renderRequest, "orderByType");

      if (Validator.isNotNull(orderByCol) && Validator.isNotNull(orderByType)) {

        preferences.setValue("SGS_DOCUMENTFIELD", "pmlfield-order-by-column", orderByCol);
        preferences.setValue("SGS_DOCUMENTFIELD", "pmlfield-order-by-type", orderByType);
      } else {
        preferences.setValue("SGS_DOCUMENTFIELD", "pmlfield-order-by-column", "field.code");
        preferences.setValue("SGS_DOCUMENTFIELD", "pmlfield-order-by-type", "asc");
      }

      OrderByComparator orderByComparator =
          PmlFieldUtil.getPmlFieldOrderByComparator(orderByCol, orderByType);
      setOrderableHeaders(orderableHeaders);
      setOrderByCol(orderByCol);
      setOrderByType(orderByType);
      setOrderByComparator(orderByComparator);

    } catch (Exception e) {
      _log.error(e);
    }
  }
  public static String getDDLRecordSetDisplayStyle(
      PortletRequest portletRequest, String[] displayViews) {

    PortalPreferences portalPreferences =
        PortletPreferencesFactoryUtil.getPortalPreferences(portletRequest);

    String displayStyle = ParamUtil.getString(portletRequest, "displayStyle");

    if (Validator.isNull(displayStyle)) {
      displayStyle =
          portalPreferences.getValue(
              DDLPortletKeys.DYNAMIC_DATA_LISTS,
              "display-style",
              DDLWebConfigurationValues.DEFAULT_DISPLAY_VIEW);
    } else if (ArrayUtil.contains(displayViews, displayStyle)) {
      portalPreferences.setValue(DDLPortletKeys.DYNAMIC_DATA_LISTS, "display-style", displayStyle);
    }

    if (!ArrayUtil.contains(displayViews, displayStyle)) {
      displayStyle = displayViews[0];
    }

    return displayStyle;
  }
  public KBArticleSearch(PortletRequest portletRequest, PortletURL iteratorURL) {

    super(
        portletRequest,
        new KBArticleDisplayTerms(portletRequest),
        new KBArticleSearchTerms(portletRequest),
        DEFAULT_CUR_PARAM,
        DEFAULT_DELTA,
        iteratorURL,
        null,
        EMPTY_RESULTS_MESSAGE);

    KBArticleDisplayTerms displayTerms = (KBArticleDisplayTerms) getDisplayTerms();

    iteratorURL.setParameter(
        KBArticleDisplayTerms.ANYTIME, String.valueOf(displayTerms.isAnytime()));
    iteratorURL.setParameter(KBArticleDisplayTerms.CONTENT, displayTerms.getContent());
    iteratorURL.setParameter(
        KBArticleDisplayTerms.END_DATE_DAY, String.valueOf(displayTerms.getEndDateDay()));
    iteratorURL.setParameter(
        KBArticleDisplayTerms.END_DATE_MONTH, String.valueOf(displayTerms.getEndDateMonth()));
    iteratorURL.setParameter(
        KBArticleDisplayTerms.END_DATE_YEAR, String.valueOf(displayTerms.getEndDateYear()));
    iteratorURL.setParameter(
        KBArticleDisplayTerms.START_DATE_DAY, String.valueOf(displayTerms.getStartDateDay()));
    iteratorURL.setParameter(
        KBArticleDisplayTerms.START_DATE_MONTH, String.valueOf(displayTerms.getStartDateMonth()));
    iteratorURL.setParameter(
        KBArticleDisplayTerms.START_DATE_YEAR, String.valueOf(displayTerms.getStartDateYear()));
    iteratorURL.setParameter(
        KBArticleDisplayTerms.STATUS, String.valueOf(displayTerms.getStatus()));
    iteratorURL.setParameter(KBArticleDisplayTerms.TITLE, displayTerms.getTitle());

    try {
      PortalPreferences preferences =
          PortletPreferencesFactoryUtil.getPortalPreferences(portletRequest);

      PortletPreferences portletPreferences =
          PortletPreferencesFactoryUtil.getPortletSetup(portletRequest);

      String portletOrderByCol =
          portletPreferences.getValue("kbArticlesOrderByCol", StringPool.BLANK);
      String portletOrderByType =
          portletPreferences.getValue("kbArticlesOrderByType", StringPool.BLANK);

      String oldOrderByCol =
          preferences.getValue(
              PortletKeys.KNOWLEDGE_BASE_ADMIN, "kb-articles-order-by-col", portletOrderByCol);
      String oldOrderByType =
          preferences.getValue(
              PortletKeys.KNOWLEDGE_BASE_ADMIN, "kb-articles-order-by-type", portletOrderByType);

      String orderByCol = ParamUtil.getString(portletRequest, "orderByCol", oldOrderByCol);
      String orderByType = ParamUtil.getString(portletRequest, "orderByType", oldOrderByType);

      if (!Validator.equals(orderByCol, oldOrderByCol)
          || !Validator.equals(orderByType, oldOrderByType)) {

        preferences.setValue(
            PortletKeys.KNOWLEDGE_BASE_ADMIN, "kb-articles-order-by-col", orderByCol);
        preferences.setValue(
            PortletKeys.KNOWLEDGE_BASE_ADMIN, "kb-articles-order-by-type", orderByType);

        KBArticleSearchTerms searchTerms = (KBArticleSearchTerms) getSearchTerms();

        searchTerms.setCurStartValues(new int[0]);
      }

      OrderByComparator orderByComparator =
          KnowledgeBaseUtil.getKBArticleOrderByComparator(orderByCol, orderByType);

      setOrderByCol(orderByCol);
      setOrderByType(orderByType);
      setOrderByComparator(orderByComparator);
    } catch (Exception e) {
      _log.error(e);
    }
  }
Esempio n. 12
0
  public DocumentDetailSearch(RenderRequest renderRequest, PortletURL iteratorURL) {
    super(
        renderRequest,
        new DocumentDetailDisplayTerms(renderRequest),
        new DocumentDetailSearchTerms(renderRequest),
        DEFAULT_CUR_PARAM,
        DEFAULT_DELTA,
        iteratorURL,
        headerNames,
        EMPTY_RESULTS_MESSAGE);

    DocumentDetailDisplayTerms displayTerms = (DocumentDetailDisplayTerms) getDisplayTerms();

    iteratorURL.setParameter(
        DocumentDetailDisplayTerms.DEPARTMENTID, String.valueOf(displayTerms.getDepartmentId()));
    iteratorURL.setParameter(
        DocumentDetailDisplayTerms.USERID, String.valueOf(displayTerms.getUserId()));
    iteratorURL.setParameter(
        DocumentDetailDisplayTerms.NHOMCONGVAN, String.valueOf(displayTerms.getNhomCongVan()));
    iteratorURL.setParameter(
        DocumentDetailDisplayTerms.LOAICONGVAN, String.valueOf(displayTerms.getLoaiCongVan()));
    iteratorURL.setParameter(
        DocumentDetailDisplayTerms.DOMAT, String.valueOf(displayTerms.getDoMat()));
    iteratorURL.setParameter(
        DocumentDetailDisplayTerms.FROMDATE, String.valueOf(displayTerms.getFromDate()));
    iteratorURL.setParameter(
        DocumentDetailDisplayTerms.TODATE, String.valueOf(displayTerms.getToDate()));
    iteratorURL.setParameter(
        DocumentDetailDisplayTerms.CAPGUI, String.valueOf(displayTerms.getCapgui()));
    iteratorURL.setParameter(
        DocumentDetailDisplayTerms.LOAISOCONGVAN, String.valueOf(displayTerms.getLoaisocongvan()));

    try {
      PortalPreferences preferences =
          PortletPreferencesFactoryUtil.getPortalPreferences(renderRequest);

      String orderByCol = ParamUtil.getString(renderRequest, "orderByCol", "pccc-cvdtn-domat");
      String orderByType = ParamUtil.getString(renderRequest, "orderByType", "asc");

      String portletName = "SGS_PCCCDOCUMENTRECEIPTREPORT";

      if (Validator.isNotNull(orderByCol) && Validator.isNotNull(orderByType)) {

        preferences.setValue(portletName, "documentdetail-order-by-col", orderByCol);
        preferences.setValue(portletName, "documentdetail-order-by-type", orderByType);
      } else {
        orderByCol =
            preferences.getValue(portletName, "documentdetail-order-by-col", "pccc-cvdtn-domat");
        orderByType = preferences.getValue(portletName, "documentdetail-order-by-type", "asc");
      }

      OrderByComparator orderByComparator =
          DocumentDetailUtil.getDocumentDetailOrderByComparator(orderByCol, orderByType);

      setOrderableHeaders(orderableHeaders);

      setOrderByCol(orderByCol);
      setOrderByType(orderByType);
      setOrderByComparator(orderByComparator);
    } catch (Exception e) {
      _log.error(e);
    }
  }
  @Override
  public void render(RenderRequest renderRequest, RenderResponse renderResponse)
      throws IOException, PortletException {

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

      int status = getStatus(renderRequest);

      renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_STATUS, status);

      KBArticle kbArticle = null;

      Tuple resourceTuple = getResourceTuple(renderRequest);

      long resourcePrimKey = (Long) resourceTuple.getObject(1);

      if (resourcePrimKey != KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
        long resourceClassNameId = (Long) resourceTuple.getObject(0);

        long kbFolderClassNameId = PortalUtil.getClassNameId(KBFolderConstants.getClassName());

        if (resourceClassNameId == kbFolderClassNameId) {
          PortalPreferences portalPreferences =
              PortletPreferencesFactoryUtil.getPortalPreferences(renderRequest);

          String preferredKBFolderURLTitle =
              portalPreferences.getValue(
                  PortletKeys.KNOWLEDGE_BASE_DISPLAY, "preferredKBFolderURLTitle");

          kbArticle =
              getKBFolderKBArticle(
                  themeDisplay.getScopeGroupId(), resourcePrimKey, preferredKBFolderURLTitle);
        } else {
          kbArticle = KBArticleServiceUtil.fetchLatestKBArticle(resourcePrimKey, status);
        }
      } else {
        long parentResourcePrimKey =
            ParamUtil.getLong(
                renderRequest, "parentResourcePrimKey", KBFolderConstants.DEFAULT_PARENT_FOLDER_ID);

        if (parentResourcePrimKey == KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

          List<KBArticle> kbArticles =
              KBArticleLocalServiceUtil.getGroupKBArticles(
                  themeDisplay.getScopeGroupId(),
                  status,
                  0,
                  1,
                  new KBArticlePriorityComparator(true));

          if (!kbArticles.isEmpty()) {
            kbArticle = kbArticles.get(0);
          }
        }
      }

      renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_KB_ARTICLE, kbArticle);
    } catch (Exception e) {
      if (e instanceof NoSuchArticleException || e instanceof PrincipalException) {

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

        SessionMessages.add(
            renderRequest,
            PortalUtil.getPortletId(renderRequest)
                + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
      } else {
        throw new PortletException(e);
      }
    }

    super.render(renderRequest, renderResponse);
  }