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

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

Introduction

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

Prototype

public long getRepositoryId();

Source Link

Usage

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 ww  .java  2  s. com*/

    Folder folder = repository.getFolder(classPK);

    return (DLFolder) folder.getModel();
}

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

License:Open Source License

protected DLFileEntry getDLFileEntry(long classPK) throws PortalException {
    Repository repository = RepositoryProviderUtil.getFileEntryRepository(classPK);

    if (!repository.isCapabilityProvided(TrashCapability.class)) {
        throw new UnsupportedCapabilityException(TrashCapability.class,
                "Repository " + repository.getRepositoryId());
    }/*  ww w .j  av a2 s .  c o  m*/

    FileEntry fileEntry = repository.getFileEntry(classPK);

    return (DLFileEntry) fileEntry.getModel();
}

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

License:Open Source License

protected DLFileShortcut getDLFileShortcut(long classPK) throws PortalException {

    Repository repository = RepositoryProviderUtil.getFileShortcutRepository(classPK);

    if (!repository.isCapabilityProvided(TrashCapability.class)) {
        throw new UnsupportedCapabilityException(TrashCapability.class,
                "Repository " + repository.getRepositoryId());
    }/*from  w w  w.j  a  va2s  . co  m*/

    FileShortcut fileShortcut = repository.getFileShortcut(classPK);

    return (DLFileShortcut) fileShortcut.getModel();
}

From source file:com.liferay.document.library.jaxrs.FolderRepr.java

License:Open Source License

public static FolderRepr fromRepository(long groupId, Repository repository,
        List<RepositoryContentObject> repositoryContentObjects, UriBuilder uriBuilder) {

    String url = uriBuilder.build(Long.toString(groupId), Long.toString(repository.getRepositoryId()))
            .toString();// w ww.  jav  a2s .com

    return new FolderRepr(repository.getRepositoryId(), 0, "", new Date(), "", repositoryContentObjects, url);
}

From source file:com.liferay.document.library.jaxrs.FolderResource.java

License:Open Source License

public FolderResource(DLAppService dlAppService, final long groupId, final Repository repository,
        UriBuilder repositoryUriBuilder, UriBuilder folderUriBuilder, UriBuilder fileUriBuilder) {

    _dlAppService = dlAppService;//from  ww  w .  j  a v a  2 s . co m
    _folderUriBuilder = folderUriBuilder;
    _fileUriBuilder = fileUriBuilder;

    _repositoryId = repository.getRepositoryId();
    _folderId = 0;
    _folderReprFunction = contents -> FolderRepr.fromRepository(groupId, repository, contents,
            repositoryUriBuilder);
}

From source file:com.liferay.document.library.jaxrs.RepositoryRepr.java

License:Open Source License

public static RepositoryRepr fromRepository(Repository repository, UriBuilder uriBuilder) {

    return new RepositoryRepr(repository.getRepositoryId(), new Date(), "repository", "repository",
            uriBuilder.build(repository.getRepositoryId()).toString());
}

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

License:Open Source License

/**
 * Moves the file entry to the new folder.
 *
 * @param  fileEntryId the primary key of the file entry
 * @param  newFolderId the primary key of the new folder
 * @param  serviceContext the service context to be applied
 * @return the file entry/*from   w ww.  j  a  va2 s.co  m*/
 * @throws PortalException if the file entry or the new folder could not be
 *         found
 * @throws SystemException if a system exception occurred
 */
public FileEntry moveFileEntry(long fileEntryId, long newFolderId, ServiceContext serviceContext)
        throws PortalException, SystemException {

    Repository fromRepository = getRepository(0, fileEntryId, 0);
    Repository toRepository = getRepository(newFolderId, serviceContext);

    if (fromRepository.getRepositoryId() == toRepository.getRepositoryId()) {

        // Move file entries within repository

        FileEntry fileEntry = fromRepository.moveFileEntry(fileEntryId, newFolderId, serviceContext);

        return fileEntry;
    }

    // Move file entries between repositories

    return moveFileEntries(fileEntryId, newFolderId, fromRepository, toRepository, serviceContext);
}

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

License:Open Source License

/**
 * Moves the folder to the new parent folder with the primary key.
 *
 * @param  folderId the primary key of the folder
 * @param  parentFolderId the primary key of the new parent folder
 * @param  serviceContext the service context to be applied
 * @return the file entry/*from w w  w .java2  s.co m*/
 * @throws PortalException if the folder could not be found
 * @throws SystemException if a system exception occurred
 */
public Folder moveFolder(long folderId, long parentFolderId, ServiceContext serviceContext)
        throws PortalException, SystemException {

    Repository fromRepository = getRepository(folderId, 0, 0);
    Repository toRepository = getRepository(parentFolderId, serviceContext);

    if (fromRepository.getRepositoryId() == toRepository.getRepositoryId()) {

        // Move file entries within repository

        Folder folder = fromRepository.moveFolder(folderId, parentFolderId, serviceContext);

        return folder;
    }

    // Move file entries between repositories

    return moveFolders(folderId, parentFolderId, fromRepository, toRepository, serviceContext);
}

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);/*from ww  w  .  j a  v a 2  s  .c  o m*/

    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;
}