public static String getAbsolutePath(PortletRequest portletRequest, long folderId) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); if (folderId == BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID) { return themeDisplay.translate("home"); } BookmarksFolder folder = BookmarksFolderLocalServiceUtil.fetchBookmarksFolder(folderId); List<BookmarksFolder> folders = folder.getAncestors(); StringBundler sb = new StringBundler((folders.size() * 3) + 5); sb.append(themeDisplay.translate("home")); sb.append(StringPool.SPACE); Collections.reverse(folders); for (BookmarksFolder curFolder : folders) { sb.append(StringPool.RAQUO_CHAR); sb.append(StringPool.SPACE); sb.append(curFolder.getName()); } sb.append(StringPool.RAQUO_CHAR); sb.append(StringPool.SPACE); sb.append(folder.getName()); return sb.toString(); }
@Override public int getTrashContainerModelsCount(long classPK) throws PortalException { BookmarksFolder folder = BookmarksFolderLocalServiceUtil.getFolder(classPK); return BookmarksFolderLocalServiceUtil.getFoldersCount( folder.getGroupId(), classPK, WorkflowConstants.STATUS_IN_TRASH); }
@Override protected long addContainerModel(long containerModelId) throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId()); BookmarksFolder folder = BookmarksTestUtil.addFolder( containerModelId, RandomTestUtil.randomString(), serviceContext); return folder.getFolderId(); }
/** * Adds the bookmarks folder to the database. Also notifies the appropriate model listeners. * * @param bookmarksFolder the bookmarks folder * @return the bookmarks folder that was added */ @Indexable(type = IndexableType.REINDEX) @Override public BookmarksFolder addBookmarksFolder(BookmarksFolder bookmarksFolder) { bookmarksFolder.setNew(true); return bookmarksFolderPersistence.update(bookmarksFolder); }
@Override public boolean isShow(PortletRequest portletRequest) { try { BookmarksFolder folder = ActionUtil.getFolder(portletRequest); if (folder.getFolderId() == BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID) { return false; } ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); if (BookmarksFolderPermissionChecker.contains( themeDisplay.getPermissionChecker(), folder, ActionKeys.UPDATE)) { return true; } } catch (Exception e) { } return false; }
@Override public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) { PortletURL portletURL = PortalUtil.getControlPanelPortletURL( portletRequest, BookmarksPortletKeys.BOOKMARKS_ADMIN, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "/bookmarks/move_entry"); portletURL.setParameter("redirect", PortalUtil.getCurrentURL(portletRequest)); BookmarksFolder folder = null; try { folder = ActionUtil.getFolder(portletRequest); } catch (Exception e) { return null; } portletURL.setParameter("rowIdsBookmarksFolder", String.valueOf(folder.getFolderId())); return portletURL.toString(); }
@Override public List<TrashRenderer> getTrashContainerModelTrashRenderers(long classPK, int start, int end) throws PortalException { List<TrashRenderer> trashRenderers = new ArrayList<TrashRenderer>(); BookmarksFolder folder = BookmarksFolderLocalServiceUtil.getFolder(classPK); List<BookmarksFolder> folders = BookmarksFolderLocalServiceUtil.getFolders( folder.getGroupId(), classPK, WorkflowConstants.STATUS_IN_TRASH, start, end); for (BookmarksFolder curFolder : folders) { TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(BookmarksFolder.class.getName()); TrashRenderer trashRenderer = trashHandler.getTrashRenderer(curFolder.getPrimaryKey()); trashRenderers.add(trashRenderer); } return trashRenderers; }