* Authentication and transactions are the client's responsibility. * * @return Returns an existing folder reference or null */ public NodeRef getFolderPath( NamespaceService namespaceService, NodeService nodeService, SearchService searchService, FileFolderService fileFolderService) { NodeRef pathStartNodeRef = super.resolveNodePath(namespaceService, nodeService, searchService); if (pathStartNodeRef == null) { throw new AlfrescoRuntimeException( "Folder path resolution requires an existing base path. \n" + " Base path: " + getRootPath()); } // Just choose the root path if the folder path is empty if (folderPath.size() == 0) { return pathStartNodeRef; } else { try { FileInfo folderInfo = fileFolderService.resolveNamePath(pathStartNodeRef, folderPath); if (!folderInfo.isFolder()) { throw new AlfrescoRuntimeException("Not a folder: " + this); } return folderInfo.getNodeRef(); } catch (FileNotFoundException e) { throw new AlfrescoRuntimeException("Folder not found: " + this); } } // Done } /** * Helper method to find or create the folder path referenced by this bean. * The {@link #getPath() path} to the start of the {@link #getFolderNames() folder path} * must exist. The folder path will be created, if required. *
* Authentication and transactions are the client's responsibility. * * @return Returns an existing or new folder reference */ public NodeRef getOrCreateFolderPath( NamespaceService namespaceService, NodeService nodeService, SearchService searchService, FileFolderService fileFolderService) { NodeRef pathStartNodeRef = super.resolveNodePath(namespaceService, nodeService, searchService); if (pathStartNodeRef == null) { throw new AlfrescoRuntimeException( "Folder path resolution requires an existing base path. \n" + " Base path: " + getRootPath()); } // Just choose the root path if the folder path is empty if (folderPath.size() == 0) { return pathStartNodeRef; } else { FileInfo folderInfo = FileFolderServiceImpl.makeFolders( fileFolderService, pathStartNodeRef, folderPath, ContentModel.TYPE_FOLDER); return folderInfo.getNodeRef(); } // Done } }