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

        boolean cmis11 = context.getCmisVersion() != CmisVersion.CMIS_1_0;
        validateProperties(repositoryId, so, properties, false, cmis11);

        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 hasUpdatedProp = false;

        // Find secondary type definitions to consider for update
        List<String> existingSecondaryTypeIds = so.getSecondaryTypeIds();
        @SuppressWarnings("unchecked")
        PropertyData<String> pdSec = (PropertyData<String>) properties.getProperties().get(PropertyIds.SECONDARY_OBJECT_TYPE_IDS);
        List<String> newSecondaryTypeIds = pdSec == null ? null : pdSec.getValues();
        Set<String> secondaryTypeIds = new HashSet<String>();
        if (null != existingSecondaryTypeIds)
            secondaryTypeIds.addAll(existingSecondaryTypeIds);
        if (null != newSecondaryTypeIds)
            secondaryTypeIds.addAll(newSecondaryTypeIds);

        // Find secondary type definitions to delete (null means not set --> do not change, empty --> remove all secondary types)
        if (null != newSecondaryTypeIds) {
            List<String> propertiesIdToDelete = getListOfPropertiesToDeleteFromRemovedSecondaryTypes(repositoryId, so, newSecondaryTypeIds);
            for (String propIdToRemove : propertiesIdToDelete) {
                so.getProperties().remove(propIdToRemove);
            }
        }

        // update properties:
        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 (null == propDef && cmis11) {
                TypeDefinition typeDefSecondary= getSecondaryTypeDefinition(repositoryId, secondaryTypeIds, key);
                if (null == typeDefSecondary)
                    throw new CmisInvalidArgumentException("Cannot update property " + key + ": not contained in type");
                propDef = typeDefSecondary.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);
              hasUpdatedProp = 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

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

        }
    }

    protected void testCheckedOutByCurrentUser(String user, VersionedDocument verDoc) {
        if (!user.equals(verDoc.getCheckedOutBy())) {
            throw new CmisUpdateConflictException("User " + verDoc.getCheckedOutBy()
                    + " has checked out the document.");
        }
    }
View Full Code Here

        }
    }

    protected void testIsCheckedOut(VersionedDocument verDoc) {
        if (!verDoc.isCheckedOut()) {
            throw new CmisUpdateConflictException("Document " + verDoc.getId() + " is not checked out.");
        }
    }
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.