use of org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl in project structr by structr.
the class CMISObjectService method createDocumentFromSource.
@Override
public String createDocumentFromSource(String repositoryId, String sourceId, Properties properties, String folderId, VersioningState versioningState, List<String> policies, Acl addAces, Acl removeAces, ExtensionsData extension) {
// copy existing document
final App app = StructrApp.getInstance(securityContext);
String uuid = null;
try (final Tx tx = app.tx()) {
final File existingDocument = app.get(File.class, sourceId);
if (existingDocument != null) {
try (final InputStream inputStream = existingDocument.getInputStream()) {
final ContentStreamImpl copyContentStream = new ContentStreamImpl();
copyContentStream.setFileName(existingDocument.getName());
copyContentStream.setMimeType(existingDocument.getContentType());
copyContentStream.setLength(BigInteger.valueOf(existingDocument.getSize()));
copyContentStream.setStream(inputStream);
uuid = createDocument(repositoryId, properties, folderId, copyContentStream, versioningState, policies, addAces, removeAces, extension);
}
} else {
throw new CmisObjectNotFoundException("Document with ID " + sourceId + " does not exist");
}
tx.success();
} catch (Throwable t) {
throw new CmisRuntimeException("New document could not be created: " + t.getMessage());
}
return uuid;
}
Aggregations