Package org.apache.chemistry.opencmis.commons.exceptions

Examples of org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException


        if (so == null) {
            throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
        }

        if ( so.getChangeToken() != null && ( changeToken == null || !so.getChangeToken().equals( changeToken.getValue() ) ) )
            throw new CmisUpdateConflictException( "deleteContentStream failed, ChangeToken does not match." );
            
        if (!(so instanceof Content)) {
            throw new CmisObjectNotFoundException("Id" + objectId
                    + " does not refer to a document, but only documents can have content");
        }
View Full Code Here


        }

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

        // check properties for validity
        TypeValidator.validateProperties(typeDef, properties, false);

        if (changeToken != null && changeToken.getValue() != null
                && Long.valueOf(so.getChangeToken()) > Long.valueOf(changeToken.getValue())) {
            throw new CmisUpdateConflictException("updateProperties failed: changeToken does not match");
        }

        // update properties
        boolean hasUpdatedName = false;
        boolean hasUpdatedOtherProps = false;

        if(properties != null) {
          for (String key : properties.getProperties().keySet()) {
            if (key.equals(PropertyIds.NAME))
            {
              continue; // ignore here
            }

            PropertyData<?> value = properties.getProperties().get(key);
            PropertyDefinition<?> propDef = typeDef.getPropertyDefinitions().get(key);
            if (value.getValues() == null || value.getFirstValue() == null) {
              // delete property
              // check if a required a property
              if (propDef.isRequired()) {
                throw new CmisConstraintException(
                    "updateProperties failed, following property can't be deleted, because it is required: "
                        + key);
              }
              oldProperties.remove(key);
              hasUpdatedOtherProps = true;
            } else {
              if (propDef.getUpdatability().equals(Updatability.WHENCHECKEDOUT)) {
                if (!isCheckedOut)
                  throw new CmisUpdateConflictException(
                      "updateProperties failed, following property can't be updated, because it is not checked-out: "
                          + key);
              } else if (!propDef.getUpdatability().equals(Updatability.READWRITE)) {
                throw new CmisConstraintException(
                    "updateProperties failed, following property can't be updated, because it is not writable: "
View Full Code Here

        } else {
            content = ((VersionedDocument) so).getLatestVersion(false).getContent(0, -1);
        }

        if (verDoc.isCheckedOut()) {
            throw new CmisUpdateConflictException("Document " + objectId.getValue() + " is already checked out.");
        }

        String user = context.getUsername();
        checkHasUser(user);
View Full Code Here

            if (CmisContentAlreadyExistsException.EXCEPTION_NAME.equals(exception)) {
                return new CmisContentAlreadyExistsException(message, errorContent, t);
            } else if (CmisVersioningException.EXCEPTION_NAME.equals(exception)) {
                return new CmisVersioningException(message, errorContent, t);
            } else if (CmisUpdateConflictException.EXCEPTION_NAME.equals(exception)) {
                return new CmisUpdateConflictException(message, errorContent, t);
            } else if (CmisNameConstraintViolationException.EXCEPTION_NAME.equals(exception)) {
                return new CmisNameConstraintViolationException(message, errorContent, t);
            }
            return new CmisConstraintException(message, errorContent, t);
        default:
View Full Code Here

                } else if (CmisStorageException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
                    return new CmisStorageException(message, errorContent, t);
                } else if (CmisStreamNotSupportedException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
                    return new CmisStreamNotSupportedException(message, errorContent, t);
                } else if (CmisUpdateConflictException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
                    return new CmisUpdateConflictException(message, errorContent, t);
                } else if (CmisVersioningException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
                    return new CmisVersioningException(message, errorContent, t);
                }
            }
        }
View Full Code Here

        boolean rename = newName != null && !getName().equals(newName);
        if (rename && !JcrConverter.isValidJcrName(newName)) {
            throw new CmisNameConstraintViolationException("Name is not valid: " + newName);
        }
        if (rename && isRoot()) {
            throw new CmisUpdateConflictException("Cannot rename root node");
        }

        try {
            // rename file or folder if necessary
            Session session = getNode().getSession();
View Full Code Here

        }

        // get the node
        JcrNode jcrNode = getJcrNode(session, objectId.getValue());
        if (!jcrNode.isVersionable()) {
            throw new CmisUpdateConflictException("Not a version: " + jcrNode);
        }

        // checkout
        JcrPrivateWorkingCopy pwc = jcrNode.asVersion().checkout();
        objectId.setValue(pwc.getId());
View Full Code Here

        }

        // get the node
        JcrNode jcrNode = getJcrNode(session, objectId);
        if (!jcrNode.isVersionable()) {
            throw new CmisUpdateConflictException("Not a version: " + jcrNode);
        }

        // cancelCheckout
        jcrNode.asVersion().cancelCheckout();
    }
View Full Code Here

        JcrNode jcrNode;
        try {
            jcrNode = getJcrNode(session, objectId.getValue());
        }
        catch (CmisObjectNotFoundException e) {
            throw new CmisUpdateConflictException(e.getCause().getMessage(), e.getCause());
        }
       
        if (!jcrNode.isVersionable()) {
            throw new CmisUpdateConflictException("Not a version: " + jcrNode);
        }

        // checkin
        JcrVersion checkedIn = jcrNode.asVersion().checkin(properties, contentStream, checkinComment);
        objectId.setValue(checkedIn.getId());
View Full Code Here

TOP

Related Classes of org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException

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.