protected void deleteFolders(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);
    }

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

    for (long deleteFolderId : deleteFolderIds) {
      if (moveToTrash) {
        BookmarksFolder folder = _bookmarksFolderService.moveFolderToTrash(deleteFolderId);

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

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

      hideDefaultSuccessMessage(actionRequest);
    }
  }
  protected void deleteCategories(ActionRequest actionRequest, boolean moveToTrash)
      throws Exception {

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

    long[] deleteCategoryIds = null;

    long categoryId = ParamUtil.getLong(actionRequest, "mbCategoryId");

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

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

    for (long deleteCategoryId : deleteCategoryIds) {
      if (moveToTrash) {
        MBCategory category = _mbCategoryService.moveCategoryToTrash(deleteCategoryId);

        trashedModels.add(category);
      } else {
        _mbCategoryService.deleteCategory(themeDisplay.getScopeGroupId(), deleteCategoryId);
      }
    }

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

      hideDefaultSuccessMessage(actionRequest);
    }
  }
  protected void deleteEntries(ActionRequest actionRequest, boolean moveToTrash) throws Exception {

    long[] deleteFolderIds = ParamUtil.getLongValues(actionRequest, "rowIdsFolder");

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

    for (int i = 0; i < deleteFolderIds.length; i++) {
      long deleteFolderId = deleteFolderIds[i];

      if (moveToTrash) {
        Folder folder = _dlTrashService.moveFolderToTrash(deleteFolderId);

        if (folder.getModel() instanceof TrashedModel) {
          trashedModels.add((TrashedModel) folder.getModel());
        }
      } else {
        _dlAppService.deleteFolder(deleteFolderId);
      }
    }

    // Delete file shortcuts before file entries. See LPS-21348.

    long[] deleteFileShortcutIds = ParamUtil.getLongValues(actionRequest, "rowIdsDLFileShortcut");

    for (int i = 0; i < deleteFileShortcutIds.length; i++) {
      long deleteFileShortcutId = deleteFileShortcutIds[i];

      if (moveToTrash) {
        FileShortcut fileShortcut = _dlTrashService.moveFileShortcutToTrash(deleteFileShortcutId);

        if (fileShortcut.getModel() instanceof TrashedModel) {
          trashedModels.add((TrashedModel) fileShortcut.getModel());
        }
      } else {
        _dlAppService.deleteFileShortcut(deleteFileShortcutId);
      }
    }

    long[] deleteFileEntryIds = ParamUtil.getLongValues(actionRequest, "rowIdsFileEntry");

    for (long deleteFileEntryId : deleteFileEntryIds) {
      if (moveToTrash) {
        FileEntry fileEntry = _dlTrashService.moveFileEntryToTrash(deleteFileEntryId);

        if (fileEntry.getModel() instanceof TrashedModel) {
          trashedModels.add((TrashedModel) fileEntry.getModel());
        }
      } else {
        _dlAppService.deleteFileEntry(deleteFileEntryId);
      }
    }

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

      hideDefaultSuccessMessage(actionRequest);
    }
  }
Ejemplo n.º 4
0
  @Override
  public void deleteEntriesAttachments(
      long companyId, long repositoryId, Date date, String[] attachmentFileNames) {

    for (String attachmentFileName : attachmentFileNames) {
      String trashTime = TrashUtil.getTrashTime(attachmentFileName, TRASH_TIME_SEPARATOR);

      long timestamp = GetterUtil.getLong(trashTime);

      if (timestamp < date.getTime()) {
        DLStoreUtil.deleteDirectory(companyId, repositoryId, attachmentFileName);
      }
    }
  }
Ejemplo n.º 5
0
  protected void addBreadcrumbEntries(
      HttpServletRequest request,
      LiferayPortletResponse liferayPortletResponse,
      String className,
      long classPK,
      String paramName,
      PortletURL containerModelURL,
      boolean checkInTrashContainers)
      throws PortalException, PortletException {

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

    PortletURL portletURL = PortletURLUtil.clone(containerModelURL, liferayPortletResponse);

    TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className);

    List<ContainerModel> containerModels = trashHandler.getParentContainerModels(classPK);

    Collections.reverse(containerModels);

    for (ContainerModel containerModel : containerModels) {
      TrashHandler containerModelTrashHandler =
          TrashHandlerRegistryUtil.getTrashHandler(containerModel.getModelClassName());

      if (checkInTrashContainers
          && !containerModelTrashHandler.isInTrash(containerModel.getContainerModelId())) {

        continue;
      }

      portletURL.setParameter(paramName, String.valueOf(containerModel.getContainerModelId()));

      String name = containerModel.getContainerModelName();

      if (containerModelTrashHandler.isInTrash(containerModel.getContainerModelId())) {

        name = TrashUtil.getOriginalTitle(name);
      }

      PortalUtil.addPortletBreadcrumbEntry(request, name, portletURL.toString());
    }

    TrashRenderer trashRenderer = trashHandler.getTrashRenderer(classPK);

    PortalUtil.addPortletBreadcrumbEntry(
        request, trashRenderer.getTitle(themeDisplay.getLocale()), null);
  }
  @Override
  protected Document doGetDocument(JournalArticle journalArticle) throws Exception {

    Document document = getBaseModelDocument(CLASS_NAME, journalArticle);

    long classPK = journalArticle.getId();

    if (!isIndexAllArticleVersions()) {
      classPK = journalArticle.getResourcePrimKey();
    }

    document.addUID(CLASS_NAME, classPK);

    String articleDefaultLanguageId =
        LocalizationUtil.getDefaultLanguageId(journalArticle.getDocument());

    String[] languageIds = LocalizationUtil.getAvailableLanguageIds(journalArticle.getDocument());

    for (String languageId : languageIds) {
      String content = extractDDMContent(journalArticle, languageId);

      String description = journalArticle.getDescription(languageId);

      String title = journalArticle.getTitle(languageId);

      if (languageId.equals(articleDefaultLanguageId)) {
        document.addText(Field.CONTENT, content);
        document.addText(Field.DESCRIPTION, description);
        document.addText("defaultLanguageId", languageId);
      }

      document.addText(LocalizationUtil.getLocalizedName(Field.CONTENT, languageId), content);
      document.addText(
          LocalizationUtil.getLocalizedName(Field.DESCRIPTION, languageId), description);
      document.addText(LocalizationUtil.getLocalizedName(Field.TITLE, languageId), title);
    }

    document.addKeyword(Field.FOLDER_ID, journalArticle.getFolderId());

    String articleId = journalArticle.getArticleId();

    if (journalArticle.isInTrash()) {
      articleId = TrashUtil.getOriginalTitle(articleId);
    }

    document.addKeyword(Field.ARTICLE_ID, articleId);

    document.addKeyword(Field.LAYOUT_UUID, journalArticle.getLayoutUuid());
    document.addKeyword(
        Field.TREE_PATH, StringUtil.split(journalArticle.getTreePath(), CharPool.SLASH));
    document.addKeyword(Field.VERSION, journalArticle.getVersion());

    document.addKeyword("ddmStructureKey", journalArticle.getDDMStructureKey());
    document.addKeyword("ddmTemplateKey", journalArticle.getDDMTemplateKey());
    document.addDate("displayDate", journalArticle.getDisplayDate());
    document.addKeyword("head", JournalUtil.isHead(journalArticle));

    boolean headListable = JournalUtil.isHeadListable(journalArticle);

    document.addKeyword("headListable", headListable);

    // Scheduled listable articles should be visible in asset browser

    if (journalArticle.isScheduled() && headListable) {
      boolean visible = GetterUtil.getBoolean(document.get("visible"));

      if (!visible) {
        document.addKeyword("visible", true);
      }
    }

    addDDMStructureAttributes(document, journalArticle);

    return document;
  }