List of usage examples for com.liferay.portal.kernel.repository.model Folder getDescription
public String getDescription();
From source file:au.com.permeance.liferay.portlet.documentlibrary.action.FolderInfoAction.java
License:Open Source License
protected DLFolderInfo buildFolderInfo(RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); long groupId = ParamUtil.getLong(renderRequest, "groupId"); long scopeGroupId = themeDisplay.getScopeGroupId(); String scopeGroupName = themeDisplay.getScopeGroupName(); long repositoryId = ParamUtil.getLong(renderRequest, "repositoryId"); long folderId = ParamUtil.getLong(renderRequest, "folderId"); Folder folder = DLAppServiceUtil.getFolder(folderId); ServiceContext serviceContext = ServiceContextFactory.getInstance(Folder.class.getName(), renderRequest); if (s_log.isDebugEnabled()) { s_log.debug("building folder info ..."); ParamUtil.print(renderRequest);//from ww w . j a v a 2 s .c om s_log.debug("groupId: " + groupId); s_log.debug("scopeGroupId: " + scopeGroupId); s_log.debug("scopeGroupName: " + scopeGroupName); s_log.debug("repositoryId: " + repositoryId); s_log.debug("folderId: " + folderId); } PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker(); if (!folder.containsPermission(permissionChecker, ActionKeys.VIEW)) { throw new PrincipalException(); } DLFolderInfo folderInfo = new DLFolderInfo(); try { User user = UserServiceUtil.getUserById(folder.getUserId()); DLFolderUsage folderUsage = DLFolderUsageServiceUtil.calculateFolderUsage(repositoryId, folderId, serviceContext); folderInfo.setFolderId(folderId); folderInfo.setFolderName(folder.getName()); folderInfo.setFolderCreateDate(folder.getCreateDate()); folderInfo.setFolderDescription(folder.getDescription()); folderInfo.setFolderPath(buildPath(folder)); folderInfo.setFolderUsage(folderUsage); folderInfo.setFolderUserId(folder.getUserId()); if (user != null) { folderInfo.setFolderUserFullName(user.getFullName()); } folderInfo.setRepositoryId(repositoryId); Repository repository = null; if (repositoryId != scopeGroupId) { repository = RepositoryServiceUtil.getRepository(repositoryId); if (repository != null) { folderInfo.setRepositoryName(repository.getName()); folderInfo.setRepositoryClassName(repository.getClassName()); folderInfo.setRepositoryDescription(repository.getDescription()); } } } catch (Exception e) { String msg = "Error building information for folder " + folderId + " in repository " + repositoryId + " : " + e.getMessage(); s_log.error(msg, e); throw new PortalException(msg, e); } finally { // placeholder } return folderInfo; }
From source file:com.liferay.document.library.internal.atom.FolderAtomCollectionAdapter.java
License:Open Source License
@Override public String getEntrySummary(Folder folder) { return folder.getDescription(); }
From source file:com.liferay.document.library.internal.exportimport.data.handler.FolderStagedModelDataHandler.java
License:Open Source License
@Override protected void doImportStagedModel(PortletDataContext portletDataContext, Folder folder) throws Exception { Map<Long, Long> folderIdsAndRepositoryEntryIds = (Map<Long, Long>) portletDataContext .getNewPrimaryKeysMap(Folder.class + ".folderIdsAndRepositoryEntryIds"); if (!folder.isDefaultRepository()) { Map<Long, Long> repositoryEntryIds = (Map<Long, Long>) portletDataContext .getNewPrimaryKeysMap(RepositoryEntry.class); folderIdsAndRepositoryEntryIds.put(folder.getFolderId(), repositoryEntryIds.get(folder.getFolderId())); return;/*ww w . ja v a2s. c o m*/ } long userId = portletDataContext.getUserId(folder.getUserUuid()); Map<Long, Long> folderIds = (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(Folder.class); long parentFolderId = MapUtil.getLong(folderIds, folder.getParentFolderId(), folder.getParentFolderId()); ServiceContext serviceContext = portletDataContext.createServiceContext(folder, DLFolder.class); serviceContext.setUserId(userId); Folder importedFolder = null; if (portletDataContext.isDataStrategyMirror()) { Folder existingFolder = fetchStagedModelByUuidAndGroupId(folder.getUuid(), portletDataContext.getScopeGroupId()); if (existingFolder == null) { String name = getFolderName(null, portletDataContext.getScopeGroupId(), parentFolderId, folder.getName(), 2); serviceContext.setUuid(folder.getUuid()); importedFolder = _dlAppLocalService.addFolder(userId, portletDataContext.getScopeGroupId(), parentFolderId, name, folder.getDescription(), serviceContext); } else { String name = getFolderName(folder.getUuid(), portletDataContext.getScopeGroupId(), parentFolderId, folder.getName(), 2); importedFolder = _dlAppLocalService.updateFolder(existingFolder.getFolderId(), parentFolderId, name, folder.getDescription(), serviceContext); } } else { String name = getFolderName(null, portletDataContext.getScopeGroupId(), parentFolderId, folder.getName(), 2); importedFolder = _dlAppLocalService.addFolder(userId, portletDataContext.getScopeGroupId(), parentFolderId, name, folder.getDescription(), serviceContext); } Element folderElement = portletDataContext.getImportDataElement(folder); importFolderFileEntryTypes(portletDataContext, folderElement, folder, importedFolder, serviceContext); portletDataContext.importClassedModel(folder, importedFolder, DLFolder.class); folderIds.put(folder.getFolderId(), importedFolder.getFolderId()); folderIdsAndRepositoryEntryIds.put(folder.getFolderId(), importedFolder.getFolderId()); }
From source file:com.liferay.document.library.internal.exportimport.data.handler.test.FolderStagedModelDataHandlerTest.java
License:Open Source License
@Override protected void validateImportedStagedModel(StagedModel stagedModel, StagedModel importedStagedModel) throws Exception { Assert.assertTrue(stagedModel.getCreateDate() + " " + importedStagedModel.getCreateDate(), DateUtil.equals(stagedModel.getCreateDate(), importedStagedModel.getCreateDate())); Assert.assertEquals(stagedModel.getUuid(), importedStagedModel.getUuid()); Folder folder = (Folder) stagedModel; Folder importedFolder = (Folder) importedStagedModel; Assert.assertEquals(folder.getName(), importedFolder.getName()); Assert.assertEquals(folder.getDescription(), importedFolder.getDescription()); }
From source file:com.liferay.document.library.jaxrs.FolderRepr.java
License:Open Source License
public static FolderRepr fromFolder(Folder folder, List<RepositoryContentObject> repositoryContentObjects, UriBuilder uriBuilder) {// w w w .ja va 2s . c o m String url = uriBuilder.build(Long.toString(folder.getFolderId())).toString(); return new FolderRepr(folder.getRepositoryId(), folder.getFolderId(), folder.getDescription(), folder.getCreateDate(), folder.getName(), repositoryContentObjects, url); }
From source file:com.liferay.document.library.web.internal.webdav.DLWebDAVStorageImpl.java
License:Open Source License
@Override public int copyCollectionResource(WebDAVRequest webDAVRequest, Resource resource, String destination, boolean overwrite, long depth) throws WebDAVException { try {// w w w .j a v a 2 s . com String[] destinationArray = WebDAVUtil.getPathArray(destination, true); long companyId = webDAVRequest.getCompanyId(); long parentFolderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID; try { parentFolderId = getParentFolderId(companyId, destinationArray); } catch (NoSuchFolderException nsfe) { if (_log.isDebugEnabled()) { _log.debug(nsfe, nsfe); } return HttpServletResponse.SC_CONFLICT; } Folder folder = (Folder) resource.getModel(); long groupId = WebDAVUtil.getGroupId(companyId, destination); String name = WebDAVUtil.getResourceName(destinationArray); String description = folder.getDescription(); ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(isAddGroupPermissions(groupId)); serviceContext.setAddGuestPermissions(true); int status = HttpServletResponse.SC_CREATED; if (overwrite) { if (deleteResource(groupId, parentFolderId, name, webDAVRequest.getLockUuid())) { status = HttpServletResponse.SC_NO_CONTENT; } } if (depth == 0) { _dlAppService.addFolder(groupId, parentFolderId, name, description, serviceContext); } else { _dlAppService.copyFolder(groupId, folder.getFolderId(), parentFolderId, name, description, serviceContext); } return status; } catch (DuplicateFolderNameException dfne) { if (_log.isDebugEnabled()) { _log.debug(dfne, dfne); } return HttpServletResponse.SC_PRECONDITION_FAILED; } catch (PrincipalException pe) { if (_log.isDebugEnabled()) { _log.debug(pe, pe); } return HttpServletResponse.SC_FORBIDDEN; } catch (Exception e) { throw new WebDAVException(e); } }
From source file:com.liferay.document.library.web.internal.webdav.DLWebDAVStorageImpl.java
License:Open Source License
@Override public int moveCollectionResource(WebDAVRequest webDAVRequest, Resource resource, String destination, boolean overwrite) throws WebDAVException { try {//from ww w .j a v a2 s .com String[] destinationArray = WebDAVUtil.getPathArray(destination, true); Folder folder = (Folder) resource.getModel(); long companyId = webDAVRequest.getCompanyId(); long groupId = WebDAVUtil.getGroupId(companyId, destinationArray); long folderId = folder.getFolderId(); long parentFolderId = getParentFolderId(companyId, destinationArray); String name = WebDAVUtil.getResourceName(destinationArray); String description = folder.getDescription(); ServiceContext serviceContext = new ServiceContext(); serviceContext.setUserId(webDAVRequest.getUserId()); int status = HttpServletResponse.SC_CREATED; if (overwrite) { if (deleteResource(groupId, parentFolderId, name, webDAVRequest.getLockUuid())) { status = HttpServletResponse.SC_NO_CONTENT; } } if (parentFolderId != folder.getParentFolderId()) { _dlAppService.moveFolder(folderId, parentFolderId, serviceContext); } if (!name.equals(folder.getName())) { _dlAppService.updateFolder(folderId, name, description, serviceContext); } return status; } catch (PrincipalException pe) { if (_log.isDebugEnabled()) { _log.debug(pe, pe); } return HttpServletResponse.SC_FORBIDDEN; } catch (DuplicateFolderNameException dfne) { if (_log.isDebugEnabled()) { _log.debug(dfne, dfne); } return HttpServletResponse.SC_PRECONDITION_FAILED; } catch (Exception e) { throw new WebDAVException(e); } }
From source file:com.liferay.opensocial.editor.portlet.EditorPortlet.java
License:Open Source License
protected void serveUpdateFolderName(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception { long folderId = ParamUtil.getLong(resourceRequest, "folderId"); Folder folder = DLAppServiceUtil.getFolder(folderId); String folderName = ParamUtil.getString(resourceRequest, "folderName"); ServiceContext serviceContext = ServiceContextFactory.getInstance(resourceRequest); DLAppServiceUtil.updateFolder(folderId, folderName, folder.getDescription(), serviceContext); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); writeJSON(resourceRequest, resourceResponse, jsonObject); }
From source file:com.liferay.opensocial.shindig.service.LiferayAlbumService.java
License:Open Source License
protected Album toAlbum(Folder folder, Set<String> fields, SecurityToken securityToken) throws JSONException { Album album = new AlbumImpl(); album.setDescription(folder.getDescription()); album.setId(String.valueOf(folder.getFolderId())); album.setOwnerId(String.valueOf(folder.getUserId())); album.setTitle(folder.getName());//from w w w . ja va2 s . co m SerializerUtil.copyProperties(folder.getAttributes(), album, _ALBUM_FIELDS); return album; }
From source file:com.liferay.portlet.documentlibrary.atom.FolderAtomCollectionAdapter.java
License:Open Source License
public String getEntrySummary(Folder folder) { return folder.getDescription(); }