Package org.apache.chemistry.opencmis.inmemory.storedobj.api

Examples of org.apache.chemistry.opencmis.inmemory.storedobj.api.Content


            }
            return res;
        }
       
        private boolean findText(String nodeText) {
            Content cont;
            String pattern = StringUtil.unescape(nodeText, null);
            if (so instanceof Content && (cont=(Content)so).hasContent()) {
                ContentStreamDataImpl cdi = (ContentStreamDataImpl) cont.getContent(0, -1);
                byte[] ba = cdi.getBytes();
                String text = new String(ba);
                int match = text.indexOf(pattern);
                return match >= 0;
            }
View Full Code Here


    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;

        StoredObject so = validator.setContentStream(context, repositoryId, objectId, overwriteFlag, extension);

        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()");
    }
View Full Code Here

    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 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()");
    }
View Full Code Here

            }
            return res;
        }
       
        private boolean findText(String nodeText) {
            Content cont;
            String pattern = StringUtil.unescape(nodeText, null);
            if (so instanceof Content && (cont=(Content)so).hasContent()) {
                ContentStreamDataImpl cdi = (ContentStreamDataImpl) cont.getContent(0, -1);
                byte[] ba = cdi.getBytes();
                String text = new String(ba);
                int match = text.indexOf(pattern);
                return match >= 0;
            }
View Full Code Here

            }
            return res;
        }
       
        private boolean findText(String nodeText) {
            Content cont;
            String pattern = StringUtil.unescape(nodeText, null);
            if (so instanceof Content && (cont=(Content)so).hasContent()) {
                ContentStreamDataImpl cdi = (ContentStreamDataImpl) cont.getContent(0, -1);
                byte[] ba = cdi.getBytes();
                String text = new String(ba);
                int match = text.indexOf(pattern);
                return match >= 0;
            }
View Full Code Here

    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()");
    }
View Full Code Here

        LOG.debug("start setContentStream()");
        checkStandardParameters(repositoryId, objectId.getValue());

        ObjectStore folderStore = fStoreManager.getObjectStore(repositoryId);
        StoredObject so = folderStore.getObjectById(objectId.getValue());
        Content content;

        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()");
    }
View Full Code Here

    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;

        StoredObject so = validator.setContentStream(context, repositoryId, objectId, overwriteFlag, extension);

        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()");
    }
View Full Code Here

            objInfo.setWorkingCopyId(null);
            objInfo.setWorkingCopyOriginalId(null);
        }

        if (so instanceof Content) {
            Content cont = ((Content) so);
            objInfo.setHasContent(cont.getContent(0, -1) != null);
            objInfo.setContentType(cont.getContent(0, -1) != null ? cont.getContent(0, -1).getMimeType() : null);
            objInfo.setFileName(cont.getContent(0, -1) != null ? cont.getContent(0, -1).getFileName() : null);
        } else {
            objInfo.setHasContent(false);
            objInfo.setContentType(null);
            objInfo.setFileName(null);
        }
View Full Code Here

            objInfo.setWorkingCopyId(null);
            objInfo.setWorkingCopyOriginalId(null);
        }

        if (so instanceof Content) {
            Content cont = ((Content) so);
            objInfo.setHasContent(cont.getContent(0, -1) != null);
            objInfo.setContentType(cont.getContent(0, -1) != null ? cont.getContent(0, -1).getMimeType() : null);
            objInfo.setFileName(cont.getContent(0, -1) != null ? cont.getContent(0, -1).getFileName() : null);
        } else {
            objInfo.setHasContent(false);
            objInfo.setContentType(null);
            objInfo.setFileName(null);
        }
View Full Code Here

TOP

Related Classes of org.apache.chemistry.opencmis.inmemory.storedobj.api.Content

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.