public void setContentStream(CallContext context, String repositoryId, Holder<String> objectId,
Boolean overwriteFlag, Holder<String> changeToken, ContentStream contentStream, ExtensionsData extension) {
LOG.debug("start setContentStream()");
Content content;
if ( null == overwriteFlag ) {
overwriteFlag = Boolean.TRUE;
}
StoredObject so = validator.setContentStream(context, repositoryId, objectId, overwriteFlag, extension);
if (changeToken != null && changeToken.getValue() != null
&& Long.valueOf(so.getChangeToken()) > Long.valueOf(changeToken.getValue())) {
throw new CmisUpdateConflictException("updateProperties failed: changeToken does not match");
}
if (!(so instanceof Document || so instanceof VersionedDocument || so instanceof DocumentVersion)) {
throw new CmisObjectNotFoundException("Id" + objectId
+ " does not refer to a document, but only documents can have content");
}
// validate content allowed
TypeDefinition typeDef = getTypeDefinition(repositoryId, so);
if (!(typeDef instanceof DocumentTypeDefinition))
throw new CmisInvalidArgumentException("Object does not refer to a document, can't set content");
TypeValidator.validateContentAllowed((DocumentTypeDefinition) typeDef , null != contentStream);
if (so instanceof Document) {
content = ((Document) so);
} else if (so instanceof DocumentVersion) {
// something that is versionable check the proper status of the
// object
String user = context.getUsername();
testHasProperCheckedOutStatus(so, user);
content = (DocumentVersion) so;
} else {
throw new IllegalArgumentException("Content cannot be set on this object (must be document or version)");
}
if (!overwriteFlag && content.getContent(0, -1) != null) {
throw new CmisContentAlreadyExistsException("cannot overwrite existing content if overwrite flag is not set");
}
content.setContent(contentStream, true);
LOG.debug("stop setContentStream()");
}