Search in sources :

Example 1 with CMISContentStream

use of org.structr.files.cmis.wrapper.CMISContentStream in project structr by structr.

the class CMISObjectService method getContentStream.

@Override
public ContentStream getContentStream(final String repositoryId, final String objectId, final String streamId, final BigInteger offset, final BigInteger length, final ExtensionsData extension) {
    final App app = StructrApp.getInstance();
    ContentStreamImpl result = null;
    try (final Tx tx = app.tx()) {
        final File file = app.get(File.class, objectId);
        if (file != null) {
            return new CMISContentStream(file, offset, length);
        }
        tx.success();
    } catch (Throwable t) {
        logger.warn("", t);
    }
    if (result != null) {
        return result;
    }
    throw new CmisObjectNotFoundException("Object with ID " + objectId + " does not exist");
}
Also used : App(org.structr.core.app.App) StructrApp(org.structr.core.app.StructrApp) ContentStreamImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl) Tx(org.structr.core.graph.Tx) CmisObjectNotFoundException(org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException) AbstractFile(org.structr.web.entity.AbstractFile) File(org.structr.web.entity.File) CMISContentStream(org.structr.files.cmis.wrapper.CMISContentStream)

Aggregations

CmisObjectNotFoundException (org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException)1 ContentStreamImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl)1 App (org.structr.core.app.App)1 StructrApp (org.structr.core.app.StructrApp)1 Tx (org.structr.core.graph.Tx)1 CMISContentStream (org.structr.files.cmis.wrapper.CMISContentStream)1 AbstractFile (org.structr.web.entity.AbstractFile)1 File (org.structr.web.entity.File)1