Example usage for com.liferay.portal.kernel.repository.capabilities TemporaryFileEntriesScope getUserId

List of usage examples for com.liferay.portal.kernel.repository.capabilities TemporaryFileEntriesScope getUserId

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.repository.capabilities TemporaryFileEntriesScope getUserId.

Prototype

public long getUserId() 

Source Link

Usage

From source file:com.liferay.document.library.internal.repository.capabilities.TemporaryFileEntriesCapabilityImpl.java

License:Open Source License

@Override
public FileEntry addTemporaryFileEntry(TemporaryFileEntriesScope temporaryFileEntriesScope, String fileName,
        String mimeType, InputStream inputStream) throws PortalException {

    Folder folder = addTempFolder(temporaryFileEntriesScope);

    File file = null;//ww w. ja v  a  2s . c om

    try {
        if (inputStream == null) {
            inputStream = new UnsyncByteArrayInputStream(new byte[0]);
        }

        file = FileUtil.createTempFile(inputStream);

        ServiceContext serviceContext = new ServiceContext();

        serviceContext.setAddGroupPermissions(true);
        serviceContext.setAddGuestPermissions(true);

        return _documentRepository.addFileEntry(temporaryFileEntriesScope.getUserId(), folder.getFolderId(),
                fileName, mimeType, fileName, StringPool.BLANK, StringPool.BLANK, file, serviceContext);
    } catch (IOException ioe) {
        throw new SystemException("Unable to write temporary file", ioe);
    } finally {
        FileUtil.delete(file);
    }
}

From source file:com.liferay.document.library.internal.repository.capabilities.TemporaryFileEntriesCapabilityImpl.java

License:Open Source License

@Override
public List<FileEntry> getTemporaryFileEntries(TemporaryFileEntriesScope temporaryFileEntriesScope)
        throws PortalException {

    try {//from   ww w .  ja v  a 2  s  . c o  m
        Folder folder = addTempFolder(temporaryFileEntriesScope);

        return _documentRepository.getRepositoryFileEntries(temporaryFileEntriesScope.getUserId(),
                folder.getFolderId(), QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
    } catch (NoSuchModelException nsme) {

        // LPS-52675

        if (_log.isDebugEnabled()) {
            _log.debug(nsme, nsme);
        }

        return Collections.emptyList();
    }
}

From source file:com.liferay.document.library.internal.repository.capabilities.TemporaryFileEntriesCapabilityImpl.java

License:Open Source License

protected Folder addTempFolder(TemporaryFileEntriesScope temporaryFileEntriesScope) throws PortalException {

    ServiceContext serviceContext = new ServiceContext();

    serviceContext.setAddGroupPermissions(true);
    serviceContext.setAddGuestPermissions(true);

    return addFolders(temporaryFileEntriesScope.getUserId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
            _getFolderPath(temporaryFileEntriesScope), serviceContext);
}

From source file:com.liferay.document.library.internal.repository.capabilities.TemporaryFileEntriesCapabilityImpl.java

License:Open Source License

private String _getFolderPath(TemporaryFileEntriesScope temporaryFileEntriesScope) {

    StringBundler sb = new StringBundler(7);

    sb.append(_FOLDER_NAME_TEMP);/*from ww  w . ja va  2  s  .  c  om*/
    sb.append(StringPool.SLASH);
    sb.append(temporaryFileEntriesScope.getCallerUuid());
    sb.append(StringPool.SLASH);
    sb.append(temporaryFileEntriesScope.getUserId());
    sb.append(StringPool.SLASH);
    sb.append(temporaryFileEntriesScope.getFolderPath());

    return sb.toString();
}