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

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


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

        if (!(so instanceof Content)) {
            throw new CmisConstraintException("Id" + objectId
                    + " does not refer to a document or version, but only those can have content");
        }

        ContentStream csd = getContentStream(so, streamId, offset, length);

        if (null == csd) {
            throw new CmisConstraintException("Object " + so.getId() + " does not have content.");
        }

        LOG.debug("stop getContentStream()");
        return csd;
    }
View Full Code Here


            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) && !isCheckedOut) {
                    throw new CmisConstraintException(
                            "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: "
                                    + key);
                }
                oldProperties.put(key, value);
                hasUpdatedOtherProps = true;
            }
        }

        // get name from properties and perform special rename to check if
        // path already exists
        PropertyData<?> pd = properties.getProperties().get(PropertyIds.NAME);
        if (pd != null && so instanceof Filing) {
            String newName = (String) pd.getFirstValue();
            List<Folder> parents = ((Filing) so).getParents(user);
            if (so instanceof Folder && parents.isEmpty()) {
                throw new CmisConstraintException("updateProperties failed, you cannot rename the root folder");
            }
            if (newName == null || newName.equals("")) {
                throw new CmisConstraintException("updateProperties failed, name must not be empty.");
            }

            so.rename((String) pd.getFirstValue()); // note: this does persist
            hasUpdatedName = true;
        }
View Full Code Here

                continue; // ignore system properties for validation
            }

            // Check if all properties are known in the type
            if (!typeContainsProperty(typeDef, propertyId)) {
                throw new CmisConstraintException("Unknown property " + propertyId + " in type " + typeDef.getId());
            }

            // check all type specific constraints:
            PropertyDefinition<T> propDef = getPropertyDefinition(typeDef, propertyId);
            PropertyValidator<T> validator = createPropertyValidator(propDef);
            validator.validate(propDef, (PropertyData<T>) prop);
        }

        if (checkMandatory && !propDefsRequired.isEmpty()) {
            throw new CmisConstraintException("The following mandatory properties are missing: " + propDefsRequired);
        }
    }
View Full Code Here

        if (null == verState) {
            return;
        }
        if (typeDef.isVersionable() && verState.equals(VersioningState.NONE) || !typeDef.isVersionable()
                && !verState.equals(VersioningState.NONE)) {
            throw new CmisConstraintException("The versioning state flag is imcompatible to the type definition.");
        }

    }
View Full Code Here

         for (String allowedType : allowedTypes) {
             if (allowedType.equals(typeDef.getId()))
                 return;
         }
         throw new CmisConstraintException("The requested type " + typeDef.getId() + " is not allowed " + description);
     }
View Full Code Here

      
    public static void  validateAcl(TypeDefinition typeDef, Acl addACEs, Acl removeACEs)
    {
      if (!typeDef.isControllableAcl() && (addACEs != null || removeACEs != null))
      {
        throw new CmisConstraintException("acl set for type: " + typeDef.getDisplayName() + " that is not controllableACL");
      }
      }
View Full Code Here

        public void validate(PropertyDefinition<T> propDef, PropertyData<T> prop) {

            // check general constraints for all property types
            if (propDef.getCardinality() == Cardinality.SINGLE && prop.getValues().size() > 1) {
                throw new CmisConstraintException("The property with id " + propDef.getId()
                        + " is single valued, but multiple values are passed " + prop.getValues());
            }

            if (propDef.getChoices() != null && propDef.getChoices().size() > 0) {
                validateChoices(propDef, prop);
View Full Code Here

                    }
                }
            }

            if (!isAllowedValue) {
                throw new CmisConstraintException("The property with id " + propDef.getId()
                        + " has a fixed set of values. Value(s) " + prop.getValues() + " are not listed.");
            }
        }
View Full Code Here

            BigInteger minVal = ((PropertyIntegerDefinition) propDef).getMinValue();
            BigInteger maxVal = ((PropertyIntegerDefinition) propDef).getMaxValue();

            // check min and max
            if (minVal != null && propVal != null && propVal.compareTo(minVal) == -1) {
                throw new CmisConstraintException("For property with id " + propDef.getId() + " the value " + propVal
                        + " is less than the minimum value " + minVal);
            }
            if (maxVal != null && propVal != null && propVal.compareTo(maxVal) == 1) {
                throw new CmisConstraintException("For property with id " + propDef.getId() + " the value " + propVal
                        + " is bigger than the maximum value " + maxVal);
            }
        }
View Full Code Here

            BigDecimal minVal = ((PropertyDecimalDefinition) propDef).getMinValue();
            BigDecimal maxVal = ((PropertyDecimalDefinition) propDef).getMaxValue();

            // check min and max
            if (minVal != null && propVal != null && propVal.compareTo(minVal) == -1) {
                throw new CmisConstraintException("For property with id " + propDef.getId() + " the value " + propVal
                        + " is less than the minimum value " + minVal);
            }
            if (maxVal != null && propVal != null && propVal.compareTo(maxVal) == 1) {
                throw new CmisConstraintException("For property with id " + propDef.getId() + " the value " + propVal
                        + " is bigger than the maximum value " + maxVal);
            }
        }
View Full Code Here

TOP

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

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.