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

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

Introduction

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

Prototype

public void checkInFileEntry(long userId, long fileEntryId, String lockUuid, ServiceContext serviceContext)
            throws PortalException;

Source Link

Usage

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

License:Open Source License

/**
 * Checks in the file entry. If a user has not checked out the specified
 * file entry, invoking this method will result in no changes.
 *
 * <p>/*from w  w w  .j av  a 2s .  c o  m*/
 * When a file entry is checked out, a PWC (private working copy) is created
 * and the original file entry is locked. A client can make as many changes
 * to the PWC as he desires without those changes being visible to other
 * users. If the user is satisfied with the changes, he may elect to check
 * in his changes, resulting in a new file version based on the PWC; the PWC
 * will be removed and the file entry will be unlocked. If the user is not
 * satisfied with the changes, he may elect to cancel his check out; this
 * results in the deletion of the PWC and unlocking of the file entry.
 * </p>
 *
 * @param  fileEntryId the primary key of the file entry to check in
 * @param  majorVersion whether the new file version is a major version
 * @param  changeLog the file's version change log
 * @param  serviceContext the service context to be applied
 * @throws PortalException if the file entry could not be found
 * @throws SystemException if a system exception occurred
 * @see    #cancelCheckOut(long)
 * @see    #checkOutFileEntry(long)
 */
public void checkInFileEntry(long fileEntryId, boolean majorVersion, String changeLog,
        ServiceContext serviceContext) throws PortalException, SystemException {

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

    repository.checkInFileEntry(fileEntryId, majorVersion, changeLog, serviceContext);

    FileEntry fileEntry = getFileEntry(fileEntryId);

    FileVersion fileVersion = fileEntry.getLatestFileVersion();

    dlAppHelperLocalService.updateFileEntry(getUserId(), fileEntry, fileVersion,
            fileVersion.getFileVersionId());
}

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

License:Open Source License

public FileEntry updateFileEntryAndCheckIn(long fileEntryId, String sourceFileName, String mimeType,
        String title, String description, String changeLog, boolean majorVersion, File file,
        ServiceContext serviceContext) throws PortalException, SystemException {

    if ((file == null) || !file.exists() || (file.length() == 0)) {
        return updateFileEntryAndCheckIn(fileEntryId, sourceFileName, mimeType, title, description, changeLog,
                majorVersion, null, 0, serviceContext);
    }/*  w  w w . j  a va2 s. c om*/

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

    FileEntry fileEntry = repository.updateFileEntry(fileEntryId, sourceFileName, mimeType, title, description,
            changeLog, majorVersion, file, serviceContext);

    DLProcessorRegistryUtil.cleanUp(fileEntry.getLatestFileVersion());

    repository.checkInFileEntry(fileEntryId, majorVersion, changeLog, serviceContext);

    dlAppHelperLocalService.updateFileEntry(getUserId(), fileEntry, fileEntry.getFileVersion(), serviceContext);

    return fileEntry;
}

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

License:Open Source License

public FileEntry updateFileEntryAndCheckIn(long fileEntryId, String sourceFileName, String mimeType,
        String title, String description, String changeLog, boolean majorVersion, InputStream is, long size,
        ServiceContext serviceContext) throws PortalException, SystemException {

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

    FileEntry fileEntry = repository.updateFileEntry(fileEntryId, sourceFileName, mimeType, title, description,
            changeLog, majorVersion, is, size, serviceContext);

    if (is != null) {
        DLProcessorRegistryUtil.cleanUp(fileEntry.getLatestFileVersion());
    }//from www .  j a v a  2 s  .co  m

    repository.checkInFileEntry(fileEntryId, majorVersion, changeLog, serviceContext);

    dlAppHelperLocalService.updateFileEntry(getUserId(), fileEntry, fileEntry.getFileVersion(), serviceContext);

    return fileEntry;
}