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

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

Introduction

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

Prototype

public void deleteFileEntry(long fileEntryId) throws PortalException;

Source Link

Usage

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

License:Open Source License

/**
 * Deletes the file entry with the primary key.
 *
 * @param  fileEntryId the primary key of the file entry
 * @throws PortalException if the file entry could not be found
 * @throws SystemException if a system exception occurred
 *//*from  w  w  w.j a v a 2s.co  m*/
public void deleteFileEntry(long fileEntryId) throws PortalException, SystemException {

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

    FileEntry fileEntry = repository.getFileEntry(fileEntryId);

    dlAppHelperLocalService.deleteFileEntry(fileEntry);

    repository.deleteFileEntry(fileEntryId);
}

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

License:Open Source License

protected FileEntry copyFileEntry(Repository toRepository, FileEntry fileEntry, long newFolderId,
        ServiceContext serviceContext) throws PortalException, SystemException {

    List<FileVersion> fileVersions = fileEntry.getFileVersions(WorkflowConstants.STATUS_ANY);

    FileVersion latestFileVersion = fileVersions.get(fileVersions.size() - 1);

    FileEntry destinationFileEntry = toRepository.addFileEntry(newFolderId, fileEntry.getTitle(),
            latestFileVersion.getMimeType(), latestFileVersion.getTitle(), latestFileVersion.getDescription(),
            StringPool.BLANK, latestFileVersion.getContentStream(false), latestFileVersion.getSize(),
            serviceContext);//  w ww . java 2  s  .  c  o  m

    for (int i = fileVersions.size() - 2; i >= 0; i--) {
        FileVersion fileVersion = fileVersions.get(i);

        FileVersion previousFileVersion = fileVersions.get(i + 1);

        try {
            destinationFileEntry = toRepository.updateFileEntry(destinationFileEntry.getFileEntryId(),
                    fileEntry.getTitle(), destinationFileEntry.getMimeType(), destinationFileEntry.getTitle(),
                    destinationFileEntry.getDescription(), StringPool.BLANK,
                    isMajorVersion(previousFileVersion, fileVersion), fileVersion.getContentStream(false),
                    fileVersion.getSize(), serviceContext);
        } catch (PortalException pe) {
            toRepository.deleteFileEntry(destinationFileEntry.getFileEntryId());

            throw pe;
        }
    }

    dlAppHelperLocalService.addFileEntry(getUserId(), destinationFileEntry,
            destinationFileEntry.getFileVersion(), serviceContext);

    return destinationFileEntry;
}

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

License:Open Source License

protected void deleteFileEntry(long oldFileEntryId, long newFileEntryId, Repository fromRepository,
        Repository toRepository) throws PortalException, SystemException {

    try {//from  w ww.ja va  2 s.com
        FileEntry fileEntry = fromRepository.getFileEntry(oldFileEntryId);

        dlAppHelperLocalService.deleteFileEntry(fileEntry);

        fromRepository.deleteFileEntry(oldFileEntryId);
    } catch (PortalException pe) {
        FileEntry fileEntry = toRepository.getFileEntry(newFileEntryId);

        toRepository.deleteFileEntry(newFileEntryId);

        dlAppHelperLocalService.deleteFileEntry(fileEntry);

        throw pe;
    }
}