Ejemplo n.º 1
0
  @Override
  public void postProcessContextQuery(BooleanQuery contextQuery, SearchContext searchContext)
      throws Exception {

    Long classNameId = (Long) searchContext.getAttribute(Field.CLASS_NAME_ID);

    if (classNameId != null) {
      contextQuery.addRequiredTerm("classNameId", classNameId.toString());
    }

    int status =
        GetterUtil.getInteger(
            searchContext.getAttribute(Field.STATUS), WorkflowConstants.STATUS_APPROVED);

    if (status != WorkflowConstants.STATUS_ANY) {
      contextQuery.addRequiredTerm(Field.STATUS, status);
    }

    long[] folderIds = searchContext.getFolderIds();

    if ((folderIds != null) && (folderIds.length > 0)) {
      if (folderIds[0] == JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

        return;
      }

      BooleanQuery folderIdsQuery = BooleanQueryFactoryUtil.create(searchContext);

      for (long folderId : folderIds) {
        try {
          JournalFolderServiceUtil.getFolder(folderId);
        } catch (Exception e) {
          continue;
        }

        folderIdsQuery.addTerm(Field.FOLDER_ID, folderId);
      }

      contextQuery.add(folderIdsQuery, BooleanClauseOccur.MUST);
    }

    String articleType = (String) searchContext.getAttribute("articleType");

    if (Validator.isNotNull(articleType)) {
      contextQuery.addRequiredTerm(Field.TYPE, articleType);
    }

    String structureId = (String) searchContext.getAttribute("structureId");

    if (Validator.isNotNull(structureId)) {
      contextQuery.addRequiredTerm("structureId", structureId);
    }

    String templateId = (String) searchContext.getAttribute("templateId");

    if (Validator.isNotNull(templateId)) {
      contextQuery.addRequiredTerm("templateId", templateId);
    }
  }
Ejemplo n.º 2
0
  protected void restoreFolderFromTrash(ActionRequest actionRequest)
      throws PortalException, SystemException {

    long[] restoreEntryIds =
        StringUtil.split(ParamUtil.getString(actionRequest, "restoreFolderIds"), 0L);

    for (long restoreEntryId : restoreEntryIds) {
      JournalFolderServiceUtil.restoreFolderFromTrash(restoreEntryId);
    }
  }
Ejemplo n.º 3
0
  protected void moveFolder(ActionRequest actionRequest) throws Exception {
    long folderId = ParamUtil.getLong(actionRequest, "folderId");

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

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

    JournalFolderServiceUtil.moveFolder(folderId, parentFolderId, serviceContext);
  }
Ejemplo n.º 4
0
  protected void deleteFolders(
      LiferayPortletConfig liferayPortletConfig, ActionRequest actionRequest, boolean moveToTrash)
      throws Exception {

    long[] deleteFolderIds = null;

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

    if (folderId > 0) {
      deleteFolderIds = new long[] {folderId};
    } else {
      deleteFolderIds = StringUtil.split(ParamUtil.getString(actionRequest, "folderIds"), 0L);
    }

    for (long deleteFolderId : deleteFolderIds) {
      if (moveToTrash) {
        JournalFolderServiceUtil.moveFolderToTrash(deleteFolderId);
      } else {
        JournalFolderServiceUtil.deleteFolder(deleteFolderId);
      }

      AssetPublisherUtil.removeRecentFolderId(
          actionRequest, JournalArticle.class.getName(), deleteFolderId);
    }

    if (moveToTrash && (deleteFolderIds.length > 0)) {
      Map<String, String[]> data = new HashMap<String, String[]>();

      data.put("restoreFolderIds", ArrayUtil.toStringArray(deleteFolderIds));

      SessionMessages.add(
          actionRequest,
          liferayPortletConfig.getPortletId() + SessionMessages.KEY_SUFFIX_DELETE_SUCCESS_DATA,
          data);

      SessionMessages.add(
          actionRequest,
          liferayPortletConfig.getPortletId()
              + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_SUCCESS_MESSAGE);
    }
  }
Ejemplo n.º 5
0
  protected void deleteEntries(ActionRequest actionRequest, boolean moveToTrash) throws Exception {

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

    List<TrashedModel> trashedModels = new ArrayList<TrashedModel>();

    long[] deleteFolderIds = StringUtil.split(ParamUtil.getString(actionRequest, "folderIds"), 0L);

    for (long deleteFolderId : deleteFolderIds) {
      if (moveToTrash) {
        JournalFolder folder = JournalFolderServiceUtil.moveFolderToTrash(deleteFolderId);

        trashedModels.add(folder);
      } else {
        JournalFolderServiceUtil.deleteFolder(deleteFolderId);
      }
    }

    String[] deleteArticleIds = StringUtil.split(ParamUtil.getString(actionRequest, "articleIds"));

    for (String deleteArticleId : deleteArticleIds) {
      if (moveToTrash) {
        JournalArticle article =
            JournalArticleServiceUtil.moveArticleToTrash(
                themeDisplay.getScopeGroupId(), deleteArticleId);

        trashedModels.add(article);
      } else {
        ActionUtil.deleteArticle(actionRequest, deleteArticleId);
      }
    }

    if (moveToTrash && !trashedModels.isEmpty()) {
      TrashUtil.addTrashSessionMessages(actionRequest, trashedModels);

      hideDefaultSuccessMessage(actionRequest);
    }
  }
Ejemplo n.º 6
0
  protected void updateFolder(ActionRequest actionRequest) throws Exception {
    long folderId = ParamUtil.getLong(actionRequest, "folderId");

    long parentFolderId = ParamUtil.getLong(actionRequest, "parentFolderId");
    String name = ParamUtil.getString(actionRequest, "name");
    String description = ParamUtil.getString(actionRequest, "description");

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

    if (folderId <= 0) {

      // Add folder

      JournalFolderServiceUtil.addFolder(
          serviceContext.getScopeGroupId(), parentFolderId, name, description, serviceContext);
    } else {

      // Update folder

      JournalFolderServiceUtil.updateFolder(
          folderId, parentFolderId, name, description, false, serviceContext);
    }
  }
Ejemplo n.º 7
0
  protected void moveEntries(ActionRequest actionRequest) throws Exception {
    long newFolderId = ParamUtil.getLong(actionRequest, "newFolderId");

    long[] folderIds = StringUtil.split(ParamUtil.getString(actionRequest, "folderIds"), 0L);

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

    for (long folderId : folderIds) {
      JournalFolderServiceUtil.moveFolder(folderId, newFolderId, serviceContext);
    }

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

    String[] articleIds = StringUtil.split(ParamUtil.getString(actionRequest, "articleIds"));

    for (String articleId : articleIds) {
      JournalArticleServiceUtil.moveArticle(themeDisplay.getScopeGroupId(), articleId, newFolderId);
    }
  }
  @Override
  public String getRowCheckBox(
      HttpServletRequest request, boolean checked, boolean disabled, String primaryKey) {

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

    JournalArticle article = null;
    JournalFolder folder = null;

    String articleId = GetterUtil.getString(primaryKey);

    try {
      article = JournalArticleServiceUtil.getArticle(themeDisplay.getScopeGroupId(), articleId);
    } catch (Exception e1) {
      if (e1 instanceof NoSuchArticleException) {
        try {
          long folderId = GetterUtil.getLong(primaryKey);

          folder = JournalFolderServiceUtil.getFolder(folderId);
        } catch (Exception e2) {
          return StringPool.BLANK;
        }
      }
    }

    boolean showInput = false;

    String name = null;

    if (article != null) {
      name = JournalArticle.class.getSimpleName();

      try {
        if (JournalArticlePermission.contains(_permissionChecker, article, ActionKeys.DELETE)
            || JournalArticlePermission.contains(_permissionChecker, article, ActionKeys.EXPIRE)
            || JournalArticlePermission.contains(_permissionChecker, article, ActionKeys.UPDATE)) {

          showInput = true;
        }
      } catch (Exception e) {
      }
    } else if (folder != null) {
      name = JournalFolder.class.getSimpleName();

      try {
        if (JournalFolderPermission.contains(_permissionChecker, folder, ActionKeys.DELETE)) {

          showInput = true;
        }
      } catch (Exception e) {
      }
    }

    if (!showInput) {
      return StringPool.BLANK;
    }

    StringBundler sb = new StringBundler(9);

    sb.append("['");
    sb.append(_liferayPortletResponse.getNamespace());
    sb.append(RowChecker.ROW_IDS);
    sb.append(JournalFolder.class.getSimpleName());
    sb.append("Checkbox', '");
    sb.append(_liferayPortletResponse.getNamespace());
    sb.append(RowChecker.ROW_IDS);
    sb.append(JournalArticle.class.getSimpleName());
    sb.append("Checkbox']");

    String checkBoxRowIds = sb.toString();

    return getRowCheckBox(
        request,
        checked,
        disabled,
        _liferayPortletResponse.getNamespace() + RowChecker.ROW_IDS + name + "Checkbox",
        primaryKey,
        checkBoxRowIds,
        "'#" + getAllRowIds() + "Checkbox'",
        StringPool.BLANK);
  }