List of usage examples for com.liferay.portal.kernel.repository Repository getFolders
public List<Folder> getFolders(long parentFolderId, boolean includeMountFolders, int start, int end, OrderByComparator<Folder> obc) throws PortalException;
From source file:com.liferay.portlet.documentlibrary.service.impl.DLAppServiceImpl.java
License:Open Source License
/** * Returns an ordered range of all the immediate subfolders of the parent * folder.//from w ww. java 2 s . c o m * * <p> * Useful when paginating results. Returns a maximum of <code>end - * start</code> instances. <code>start</code> and <code>end</code> are not * primary keys, they are indexes in the result set. Thus, <code>0</code> * refers to the first result in the set. Setting both <code>start</code> * and <code>end</code> to {@link * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full * result set. * </p> * * @param repositoryId the primary key of the folder's repository * @param parentFolderId the primary key of the folder's parent folder * @param includeMountFolders whether to include mount folders for * third-party repositories * @param start the lower bound of the range of results * @param end the upper bound of the range of results (not inclusive) * @param obc the comparator to order the folders (optionally * <code>null</code>) * @return the range of immediate subfolders of the parent folder ordered by * comparator <code>obc</code> * @throws PortalException if the parent folder could not be found * @throws SystemException if a system exception occurred */ public List<Folder> getFolders(long repositoryId, long parentFolderId, boolean includeMountFolders, int start, int end, OrderByComparator obc) throws PortalException, SystemException { Repository repository = getRepository(repositoryId); return repository.getFolders(parentFolderId, includeMountFolders, start, end, obc); }
From source file:com.liferay.portlet.documentlibrary.service.impl.DLAppServiceImpl.java
License:Open Source License
/** * Returns an ordered range of all the immediate subfolders of the parent * folder.//from ww w .j a v a2 s .c o m * * <p> * Useful when paginating results. Returns a maximum of <code>end - * start</code> instances. <code>start</code> and <code>end</code> are not * primary keys, they are indexes in the result set. Thus, <code>0</code> * refers to the first result in the set. Setting both <code>start</code> * and <code>end</code> to {@link * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full * result set. * </p> * * @param repositoryId the primary key of the folder's repository * @param parentFolderId the primary key of the folder's parent folder * @param start the lower bound of the range of results * @param end the upper bound of the range of results (not inclusive) * @param obc the comparator to order the folders (optionally * <code>null</code>) * @return the range of immediate subfolders of the parent folder ordered by * comparator <code>obc</code> * @throws PortalException if the parent folder could not be found * @throws SystemException if a system exception occurred */ public List<Folder> getFolders(long repositoryId, long parentFolderId, int start, int end, OrderByComparator obc) throws PortalException, SystemException { Repository repository = getRepository(repositoryId); return repository.getFolders(parentFolderId, true, start, end, obc); }
From source file:com.liferay.portlet.documentlibrary.service.impl.DLAppServiceImpl.java
License:Open Source License
protected void copyFolder(Repository repository, Folder srcFolder, Folder destFolder, ServiceContext serviceContext) throws PortalException, SystemException { Queue<Folder[]> folders = new LinkedList<Folder[]>(); final List<FileEntry> fileEntries = new ArrayList<FileEntry>(); Folder curSrcFolder = srcFolder;//from w w w.j a v a2 s . c o m Folder curDestFolder = destFolder; while (true) { List<FileEntry> srcFileEntries = repository.getFileEntries(curSrcFolder.getFolderId(), QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); for (FileEntry srcFileEntry : srcFileEntries) { try { FileEntry fileEntry = repository.copyFileEntry(curDestFolder.getGroupId(), srcFileEntry.getFileEntryId(), curDestFolder.getFolderId(), serviceContext); dlAppHelperLocalService.addFileEntry(getUserId(), fileEntry, fileEntry.getFileVersion(), serviceContext); fileEntries.add(fileEntry); } catch (Exception e) { _log.error(e, e); continue; } } List<Folder> srcSubfolders = repository.getFolders(curSrcFolder.getFolderId(), false, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); for (Folder srcSubfolder : srcSubfolders) { Folder destSubfolder = repository.addFolder(curDestFolder.getFolderId(), srcSubfolder.getName(), srcSubfolder.getDescription(), serviceContext); folders.offer(new Folder[] { srcSubfolder, destSubfolder }); } Folder[] next = folders.poll(); if (next == null) { break; } else { curSrcFolder = next[0]; curDestFolder = next[1]; } } TransactionCommitCallbackUtil.registerCallback(new Callable<Void>() { public Void call() throws Exception { for (FileEntry fileEntry : fileEntries) { DLProcessorRegistryUtil.trigger(fileEntry); } return null; } }); }