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

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


    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


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

    // CMIS 1.1
    public void appendContentStream(CallContext context, String repositoryId, Holder<String> objectId, Holder<String> changeToken,
            ContentStream contentStream, ExtensionsData extension) {

        Content content;
       
        LOG.debug("start appendContentStream()");
        StoredObject so = validator.appendContentStream(context, repositoryId, objectId, 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)");
        }

        content.appendContent(contentStream);
    }
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

            }
            return res;
        }
       
        private boolean findText(String nodeText) {
            Content cont = (Content)so;
            String pattern = StringUtil.unescape(nodeText, "\\'-");
            if (null == pattern)
              throw new CmisInvalidArgumentException("Illegal Escape sequence in text search expression " + nodeText);
           
            if (so instanceof Content && cont.hasContent()) {
                ContentStreamDataImpl cdi = (ContentStreamDataImpl) cont.getContent(0, -1);
                if (cdi.getMimeType().startsWith("text/")) {
                  byte[] ba = cdi.getBytes();
                  String text = new String(ba);
                  int match = text.indexOf(pattern);
                  return match >= 0;
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.