public synchronized void setContentStream(
        CmsCmisCallContext context,
        Holder<String> objectId,
        boolean overwriteFlag,
        Holder<String> changeToken,
        ContentStream contentStream) {

        checkWriteAccess();

        try {
            CmsObject cms = getCmsObject(context);
            CmsUUID structureId = new CmsUUID(objectId.getValue());
            if (!overwriteFlag) {
                throw new CmisContentAlreadyExistsException();
            }
            CmsResource resource = cms.readResource(structureId);
            if (resource.isFolder()) {
                throw new CmisStreamNotSupportedException("Folders may not have content streams.");
            }
            CmsFile file = cms.readFile(resource);
            InputStream contentInput = contentStream.getStream();
            byte[] newContent = CmsFileUtil.readFully(contentInput);
            file.setContents(newContent);
            boolean wasLocked = ensureLock(cms, resource);
            CmsFile newFile = cms.writeFile(file);
            if (wasLocked) {
                cms.unlockResource(newFile);
            }
        } catch (CmsException e) {
            handleCmsException(e);
        } catch (IOException e) {
            throw new CmisRuntimeException(e.getLocalizedMessage(), e);
        }
    }
public synchronized void setContentStream ( CmsCmisCallContext context , Holder < String > objectId , boolean overwriteFlag , Holder < String > changeToken , ContentStream contentStream ) { checkWriteAccess ( ) ; try { CmsObject cms = getCmsObject ( context ) ; CmsUUID structureId = new CmsUUID ( objectId . getValue ( ) ) ; if ( ! overwriteFlag ) { throw new CmisContentAlreadyExistsException ( ) ; } CmsResource resource = cms . readResource ( structureId ) ; if ( resource . isFolder ( ) ) { throw new CmisStreamNotSupportedException ( "Folders may not have content streams." ) ; } CmsFile file = cms . readFile ( resource ) ; InputStream contentInput = contentStream . getStream ( ) ; byte [ ] newContent = CmsFileUtil . readFully ( contentInput ) ; file . setContents ( newContent ) ; boolean wasLocked = ensureLock ( cms , resource ) ; CmsFile newFile = cms . writeFile ( file ) ; if ( wasLocked ) { cms . unlockResource ( newFile ) ; } } catch ( CmsException e ) { handleCmsException ( e ) ; } catch ( IOException e ) { throw new CmisRuntimeException ( e . getLocalizedMessage ( ) , e ) ; } }
@see org.opencms.cmis.I_CmsCmisRepository#setContentStream(org.opencms.cmis.CmsCmisCallContext, org.apache.chemistry.opencmis.commons.spi.Holder, boolean, org.apache.chemistry.opencmis.commons.spi.Holder, org.apache.chemistry.opencmis.commons.data.ContentStream)