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 ( so.getChangeToken() != null && ( changeToken == null || !so.getChangeToken().equals( changeToken.getValue() ) ) )
throw new CmisUpdateConflictException( "setContentStream 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");
}
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()");
}