Example usage for com.liferay.portal.kernel.repository LocalRepository getFileEntryByUuid

List of usage examples for com.liferay.portal.kernel.repository LocalRepository getFileEntryByUuid

Introduction

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

Prototype

public FileEntry getFileEntryByUuid(String uuid) throws PortalException;

Source Link

Usage

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

License:Open Source License

/**
 * Returns the file entry with the UUID and group.
 *
 * @param  uuid the file entry's universally unique identifier
 * @param  groupId the primary key of the file entry's group
 * @return the file entry with the UUID and group
 * @throws PortalException if the file entry could not be found
 * @throws SystemException if a system exception occurred
 *///from   www  .ja  v a2s  . c  o  m
public FileEntry getFileEntryByUuidAndGroupId(String uuid, long groupId)
        throws PortalException, SystemException {

    try {
        LocalRepository localRepository = getLocalRepository(groupId);

        return localRepository.getFileEntryByUuid(uuid);
    } catch (NoSuchFileEntryException nsfee) {
        List<com.liferay.portal.model.Repository> repositories = repositoryPersistence.findByGroupId(groupId);

        for (int i = 0; i < repositories.size(); i++) {
            try {
                long repositoryId = repositories.get(i).getRepositoryId();

                LocalRepository localRepository = getLocalRepository(repositoryId);

                return localRepository.getFileEntryByUuid(uuid);
            } catch (NoSuchFileEntryException nsfee2) {
            }
        }
    }

    StringBundler msg = new StringBundler(6);

    msg.append("No DLFileEntry exists with the key {");
    msg.append("uuid=");
    msg.append(uuid);
    msg.append(", groupId=");
    msg.append(groupId);
    msg.append(StringPool.CLOSE_CURLY_BRACE);

    throw new NoSuchFileEntryException(msg.toString());
}