@Override public int getTrashContainerModelsCount(long classPK) throws PortalException, SystemException { JournalFolder folder = JournalFolderLocalServiceUtil.getFolder(classPK); return JournalFolderLocalServiceUtil.getFoldersCount( folder.getGroupId(), classPK, WorkflowConstants.STATUS_IN_TRASH); }
@Override public void deleteStagedModel(String uuid, long groupId, String className, String extraData) throws PortalException, SystemException { JournalFolder folder = JournalFolderLocalServiceUtil.fetchJournalFolderByUuidAndGroupId(uuid, groupId); if (folder != null) { JournalFolderLocalServiceUtil.deleteFolder(folder); } }
@Override public int getContainerModelsCount(long classPK, long parentContainerModelId) throws PortalException, SystemException { return JournalFolderLocalServiceUtil.getFoldersCount( getGroupId(classPK), parentContainerModelId); }
public AssetRenderer getAssetRenderer(long classPK, int type) throws PortalException, SystemException { JournalFolder folder = JournalFolderLocalServiceUtil.getFolder(classPK); return new JournalFolderAssetRenderer(folder); }
protected void verifyTree() throws Exception { long[] companyIds = PortalInstances.getCompanyIdsBySQL(); for (long companyId : companyIds) { JournalFolderLocalServiceUtil.rebuildTree(companyId); } }
@Test public void testJournalFolderTreePathWithJournalFolderInTrash() throws Exception { JournalFolder parentFolder = JournalTestUtil.addFolder(_group.getGroupId(), RandomTestUtil.randomString()); JournalFolder folder = JournalTestUtil.addFolder( _group.getGroupId(), parentFolder.getFolderId(), RandomTestUtil.randomString()); JournalFolderLocalServiceUtil.moveFolderToTrash( TestPropsValues.getUserId(), folder.getFolderId()); JournalFolderLocalServiceUtil.deleteFolder(parentFolder.getFolderId(), false); doVerify(); }
@Override public boolean hasPermission(PermissionChecker permissionChecker, long classPK, String actionId) throws Exception { JournalFolder folder = JournalFolderLocalServiceUtil.getFolder(classPK); return JournalFolderPermission.contains(permissionChecker, folder, actionId); }
@Override public JournalFolder getParentFolder() throws PortalException { if (getParentFolderId() == JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) { return null; } return JournalFolderLocalServiceUtil.getFolder(getParentFolderId()); }
@Override protected StagedModel getStagedModel(String uuid, Group group) { try { return JournalFolderLocalServiceUtil.getJournalFolderByUuidAndGroupId( uuid, group.getGroupId()); } catch (Exception e) { return null; } }
@Test public void testJournalArticleTreePathWithParentJournalFolderInTrash() throws Exception { JournalFolder grandparentFolder = JournalTestUtil.addFolder(_group.getGroupId(), RandomTestUtil.randomString()); JournalFolder parentFolder = JournalTestUtil.addFolder( _group.getGroupId(), grandparentFolder.getFolderId(), RandomTestUtil.randomString()); JournalTestUtil.addArticle(_group.getGroupId(), parentFolder.getFolderId(), "title", "content"); JournalFolderLocalServiceUtil.moveFolderToTrash( TestPropsValues.getUserId(), parentFolder.getFolderId()); JournalFolderLocalServiceUtil.deleteFolder(grandparentFolder.getFolderId(), false); doVerify(); }
@Override public boolean hasPermission( PermissionChecker permissionChecker, String entryClassName, long entryClassPK, String actionId) throws Exception { JournalFolder folder = JournalFolderLocalServiceUtil.getFolder(entryClassPK); return JournalFolderPermission.contains(permissionChecker, folder, ActionKeys.VIEW); }
protected void updateFolderAssets() throws Exception { List<JournalFolder> folders = JournalFolderLocalServiceUtil.getNoAssetFolders(); if (_log.isDebugEnabled()) { _log.debug("Processing " + folders.size() + " folders with no asset"); } for (JournalFolder folder : folders) { try { JournalFolderLocalServiceUtil.updateAsset(folder.getUserId(), folder, null, null, null); } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn( "Unable to update asset for folder " + folder.getFolderId() + ": " + e.getMessage()); } } } if (_log.isDebugEnabled()) { _log.debug("Assets verified for folders"); } }
@Override public List<TrashRenderer> getTrashContainerModelTrashRenderers(long classPK, int start, int end) throws PortalException, SystemException { List<TrashRenderer> trashRenderers = new ArrayList<TrashRenderer>(); JournalFolder folder = JournalFolderLocalServiceUtil.getFolder(classPK); List<JournalFolder> folders = JournalFolderLocalServiceUtil.getFolders( folder.getGroupId(), classPK, WorkflowConstants.STATUS_IN_TRASH, start, end); for (JournalFolder curFolder : folders) { TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(JournalFolder.class.getName()); TrashRenderer trashRenderer = trashHandler.getTrashRenderer(curFolder.getPrimaryKey()); trashRenderers.add(trashRenderer); } return trashRenderers; }
@Override protected void validateImport( Map<String, List<StagedModel>> dependentStagedModelsMap, Group group) throws Exception { List<StagedModel> dependentStagedModels = dependentStagedModelsMap.get(JournalFolder.class.getSimpleName()); Assert.assertEquals(1, dependentStagedModels.size()); JournalFolder folder = (JournalFolder) dependentStagedModels.get(0); JournalFolderLocalServiceUtil.getJournalFolderByUuidAndGroupId( folder.getUuid(), group.getGroupId()); }
@Override public List<ContainerModel> getContainerModels( long classPK, long parentContainerModelId, int start, int end) throws PortalException, SystemException { List<JournalFolder> folders = JournalFolderLocalServiceUtil.getFolders( getGroupId(classPK), parentContainerModelId, start, end); List<ContainerModel> containerModels = new ArrayList<ContainerModel>(folders.size()); for (JournalFolder curFolder : folders) { containerModels.add(curFolder); } return containerModels; }
@Override protected void doRestoreStagedModel(PortletDataContext portletDataContext, JournalFolder folder) throws Exception { long userId = portletDataContext.getUserId(folder.getUserUuid()); JournalFolder existingFolder = JournalFolderLocalServiceUtil.fetchJournalFolderByUuidAndGroupId( folder.getUuid(), portletDataContext.getScopeGroupId()); if ((existingFolder == null) || !existingFolder.isInTrash()) { return; } TrashHandler trashHandler = existingFolder.getTrashHandler(); if (trashHandler.isRestorable(existingFolder.getFolderId())) { trashHandler.restoreTrashEntry(userId, existingFolder.getFolderId()); } }
@Override protected void doImportStagedModel(PortletDataContext portletDataContext, JournalFolder folder) throws Exception { long userId = portletDataContext.getUserId(folder.getUserUuid()); if (folder.getParentFolderId() != JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) { StagedModelDataHandlerUtil.importReferenceStagedModel( portletDataContext, folder, JournalFolder.class, folder.getParentFolderId()); } Map<Long, Long> folderIds = (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(JournalFolder.class); long parentFolderId = MapUtil.getLong(folderIds, folder.getParentFolderId(), folder.getParentFolderId()); ServiceContext serviceContext = portletDataContext.createServiceContext(folder); JournalFolder importedFolder = null; long groupId = portletDataContext.getScopeGroupId(); if (portletDataContext.isDataStrategyMirror()) { JournalFolder existingFolder = JournalFolderLocalServiceUtil.fetchJournalFolderByUuidAndGroupId( folder.getUuid(), groupId); if (existingFolder == null) { serviceContext.setUuid(folder.getUuid()); importedFolder = JournalFolderLocalServiceUtil.addFolder( userId, groupId, parentFolderId, folder.getName(), folder.getDescription(), serviceContext); } else { importedFolder = JournalFolderLocalServiceUtil.updateFolder( userId, existingFolder.getFolderId(), parentFolderId, folder.getName(), folder.getDescription(), false, serviceContext); } } else { importedFolder = JournalFolderLocalServiceUtil.addFolder( userId, groupId, parentFolderId, folder.getName(), folder.getDescription(), serviceContext); } portletDataContext.importClassedModel(folder, importedFolder); }
@Override public ContainerModel getContainerModel(long containerModelId) throws PortalException, SystemException { return JournalFolderLocalServiceUtil.getFolder(containerModelId); }
@Override protected void doReindex(String className, long classPK) throws Exception { JournalFolder folder = JournalFolderLocalServiceUtil.getFolder(classPK); doReindex(folder); }