List of usage examples for com.liferay.portal.kernel.repository Repository getFileEntries
public List<FileEntry> getFileEntries(long folderId, int start, int end, OrderByComparator<FileEntry> 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 file entries in the folder. * * <p>//w w w .jav a 2s . c om * 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 file entry's repository * @param folderId the primary key of the file entry's 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 file entries (optionally * <code>null</code>) * @return the range of file entries in the folder ordered by comparator * <code>obc</code> * @throws PortalException if the folder could not be found * @throws SystemException if a system exception occurred */ public List<FileEntry> getFileEntries(long repositoryId, long folderId, int start, int end, OrderByComparator obc) throws PortalException, SystemException { Repository repository = getRepository(repositoryId); return repository.getFileEntries(folderId, 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 ww . j av a2s .c om*/ 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; } }); }