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

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


        private PropertyUpdater() { }

        public static PropertyUpdater create(JcrTypeManager typeManager, String typeId, Properties properties) {
            if (properties == null) {
                throw new CmisConstraintException("No properties!");
            }

            // get the property definitions
            TypeDefinition type = typeManager.getType(typeId);
            if (type == null) {
                throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!");
            }

            PropertyUpdater propertyUpdater = new PropertyUpdater();
            // update properties
            for (PropertyData<?> prop : properties.getProperties().values()) {
                PropertyDefinition<?> propDef = type.getPropertyDefinitions().get(prop.getId());

                // do we know that property?
                if (propDef == null) {
                    throw new CmisInvalidArgumentException("Property '" + prop.getId() + "' is unknown!");
                }

                // skip content stream file name
                if (propDef.getId().equals(PropertyIds.CONTENT_STREAM_FILE_NAME)) {
                    log.warn("Cannot set " + PropertyIds.CONTENT_STREAM_FILE_NAME + ". Ignoring");
                    continue;
                }

                // silently skip name
                if (propDef.getId().equals(PropertyIds.NAME)) {
                    continue;
                }

                // can it be set?
                if (propDef.getUpdatability() == Updatability.READONLY) {
                    throw new CmisConstraintException("Property '" + prop.getId() + "' is readonly!");
                }

                if (propDef.getUpdatability() == Updatability.ONCREATE) {
                    throw new CmisConstraintException("Property '" + prop.getId() + "' can only be set on create!");
                }

                // default or value
                PropertyData<?> newProp;
                newProp = PropertyHelper.isPropertyEmpty(prop)
View Full Code Here


            throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!");
        }

        boolean isVersionable = JcrTypeManager.isVersionable(type);
        if (!isVersionable && versioningState != VersioningState.NONE) {
            throw new CmisConstraintException("Versioning not supported for " + typeId);
        }

        if (isVersionable && versioningState == VersioningState.NONE) {
            throw new CmisConstraintException("Versioning required for " + typeId);
        }

        // check the name
        String name = PropertyHelper.getStringProperty(properties, PropertyIds.NAME);
        if (!JcrConverter.isValidJcrName(name)) {
View Full Code Here

        // get source document Node
        JcrDocument source = getJcrNode(session, sourceId).asDocument();

        boolean isVersionable = source.isVersionable();
        if (!isVersionable && versioningState != VersioningState.NONE) {
            throw new CmisConstraintException("Versioning not supported for " + sourceId);
        }

        if (isVersionable && versioningState == VersioningState.NONE) {
            throw new CmisConstraintException("Versioning required for " + sourceId);
        }

        // create child from source
        JcrNode jcrNode = parent.addNodeFromSource(source, properties);
        return jcrNode.getId();
View Full Code Here

        if (isMarkedForDeleteTree) {
            FailedToDeleteData ftd = getBinding().getObjectService().deleteTree(getRepositoryId(), getId(),
                    deleteTreeAllVersions, deleteTreeUnfile, deleteTreeContinueOnFailure, null);

            if ((ftd != null) && (!ftd.getIds().isEmpty())) {
                throw new CmisConstraintException("deleteTree could not delete all folder children: " + ftd.getIds());
            }

            return null;
        }
View Full Code Here

     */
    public JcrPrivateWorkingCopy checkout() {
        Node node = getNode();
        try {
            if (node.isCheckedOut()) {
                throw new CmisConstraintException("Document is already checked out " + getId());
            }

            checkout(node);
            return getPwc();
        }
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

        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

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.