Example usage for com.liferay.portal.kernel.repository Repository getFolder

List of usage examples for com.liferay.portal.kernel.repository Repository getFolder

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.repository Repository getFolder.

Prototype

public Folder getFolder(long folderId) throws PortalException;

Source Link

Usage

From source file:com.liferay.document.library.internal.trash.DLBaseTrashHandler.java

License:Open Source License

protected DLFolder fetchDLFolder(long classPK) throws PortalException {
    Repository repository = RepositoryProviderUtil.getFolderRepository(classPK);

    if (!repository.isCapabilityProvided(TrashCapability.class)) {
        return null;
    }//from w  w w . ja  v a  2 s.  c o  m

    Folder folder = repository.getFolder(classPK);

    return (DLFolder) folder.getModel();
}

From source file:com.liferay.document.library.internal.trash.DLBaseTrashHandler.java

License:Open Source License

protected DLFolder getDLFolder(long classPK) throws PortalException {
    Repository repository = RepositoryProviderUtil.getFolderRepository(classPK);

    if (!repository.isCapabilityProvided(TrashCapability.class)) {
        throw new UnsupportedCapabilityException(TrashCapability.class,
                "Repository " + repository.getRepositoryId());
    }/*from w  w  w .  ja va 2s  .co m*/

    Folder folder = repository.getFolder(classPK);

    return (DLFolder) folder.getModel();
}

From source file:com.liferay.portlet.documentlibrary.service.impl.DLAppServiceImpl.java

License:Open Source License

/**
 * Performs a deep copy of the folder./*from   w w  w  . j av  a 2s .  c om*/
 *
 * @param  repositoryId the primary key of the repository
 * @param  sourceFolderId the primary key of the folder to copy
 * @param  parentFolderId the primary key of the new folder's parent folder
 * @param  name the new folder's name
 * @param  description the new folder's description
 * @param  serviceContext the service context to be applied
 * @return the folder
 * @throws PortalException if the source folder or the new parent folder
 *         could not be found or if the new folder's information was invalid
 * @throws SystemException if a system exception occurred
 */
public Folder copyFolder(long repositoryId, long sourceFolderId, long parentFolderId, String name,
        String description, ServiceContext serviceContext) throws PortalException, SystemException {

    Repository repository = getRepository(repositoryId);

    Folder srcFolder = repository.getFolder(sourceFolderId);

    Folder destFolder = repository.addFolder(parentFolderId, name, description, serviceContext);

    copyFolder(repository, srcFolder, destFolder, serviceContext);

    return destFolder;
}

From source file:com.liferay.portlet.documentlibrary.service.impl.DLAppServiceImpl.java

License:Open Source License

/**
 * Returns the folder with the primary key.
 *
 * @param  folderId the primary key of the folder
 * @return the folder with the primary key
 * @throws PortalException if the folder could not be found
 * @throws SystemException if a system exception occurred
 *///from  ww  w .  ja  v a2  s  .c  o m
public Folder getFolder(long folderId) throws PortalException, SystemException {

    Repository repository = getRepository(folderId, 0, 0);

    return repository.getFolder(folderId);
}

From source file:com.liferay.portlet.documentlibrary.service.impl.DLAppServiceImpl.java

License:Open Source License

protected Folder moveFolders(long folderId, long parentFolderId, Repository fromRepository,
        Repository toRepository, ServiceContext serviceContext) throws PortalException, SystemException {

    Folder folder = fromRepository.getFolder(folderId);

    Folder newFolder = toRepository.addFolder(parentFolderId, folder.getName(), folder.getDescription(),
            serviceContext);/* w w  w  .  j a  va 2  s. c  om*/

    List<Object> foldersAndFileEntriesAndFileShortcuts = getFoldersAndFileEntriesAndFileShortcuts(
            fromRepository.getRepositoryId(), folderId, WorkflowConstants.STATUS_ANY, true, QueryUtil.ALL_POS,
            QueryUtil.ALL_POS);

    try {
        for (Object folderAndFileEntryAndFileShortcut : foldersAndFileEntriesAndFileShortcuts) {

            if (folderAndFileEntryAndFileShortcut instanceof FileEntry) {
                FileEntry fileEntry = (FileEntry) folderAndFileEntryAndFileShortcut;

                copyFileEntry(toRepository, fileEntry, newFolder.getFolderId(), serviceContext);
            } else if (folderAndFileEntryAndFileShortcut instanceof Folder) {
                Folder currentFolder = (Folder) folderAndFileEntryAndFileShortcut;

                moveFolders(currentFolder.getFolderId(), newFolder.getFolderId(), fromRepository, toRepository,
                        serviceContext);

            } else if (folderAndFileEntryAndFileShortcut instanceof DLFileShortcut) {

                if (newFolder.isSupportsShortcuts()) {
                    DLFileShortcut dlFileShorcut = (DLFileShortcut) folderAndFileEntryAndFileShortcut;

                    dlFileShortcutService.addFileShortcut(dlFileShorcut.getGroupId(), newFolder.getFolderId(),
                            dlFileShorcut.getToFileEntryId(), serviceContext);
                }
            }
        }
    } catch (PortalException pe) {
        toRepository.deleteFolder(newFolder.getFolderId());

        throw pe;
    }

    try {
        fromRepository.deleteFolder(folderId);
    } catch (PortalException pe) {
        toRepository.deleteFolder(newFolder.getFolderId());

        throw pe;
    }

    return newFolder;
}