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

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


        if (properties != null) {
            // find new name
            String newName = getStringProperty(properties, PropertyIds.NAME);
            if (newName != null) {
                if (!isValidName(newName)) {
                    throw new CmisNameConstraintViolationException("Name is not valid!");
                }
                name = newName;
            }

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

            // replace with new values
            for (PropertyData<?> prop : properties.getProperties().values()) {
                PropertyDefinition<?> propType = type.getPropertyDefinitions().get(prop.getId());

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

                // can it be set?
                if ((propType.getUpdatability() != Updatability.READWRITE)) {
                    throw new CmisConstraintException("Property '" + prop.getId() + "' cannot be updated!");
                }

                // empty properties are invalid
                if (isEmptyProperty(prop)) {
                    throw new CmisConstraintException("Property '" + prop.getId() + "' must not be empty!");
                }

                newProperties.addProperty(prop);
            }
        }

        addPropertyId(newProperties, typeId, null, PropertyIds.OBJECT_TYPE_ID, typeId);
        addPropertyString(newProperties, typeId, null, PropertyIds.CREATED_BY, context.getUsername());
        addPropertyDateTime(newProperties, typeId, null, PropertyIds.CREATION_DATE,
                millisToCalendar(System.currentTimeMillis()));
        addPropertyString(newProperties, typeId, null, PropertyIds.LAST_MODIFIED_BY, context.getUsername());

        // check the file
        File newFile = new File(parent, name);
        if (newFile.exists()) {
            throw new CmisNameConstraintViolationException("Document already exists.");
        }

        // create the file
        try {
            newFile.createNewFile();
View Full Code Here


                millisToCalendar(System.currentTimeMillis()), context.getUsername(), properties);

        // check the name
        String name = getStringProperty(properties, PropertyIds.NAME);
        if (!isValidName(name)) {
            throw new CmisNameConstraintViolationException("Name is not valid.");
        }

        // get parent File
        File parent = getFile(folderId);
        if (!parent.isDirectory()) {
View Full Code Here

        // get and check the new name
        String newName = getStringProperty(properties, PropertyIds.NAME);
        boolean isRename = (newName != null) && (!file.getName().equals(newName));
        if (isRename && !isValidName(newName)) {
            throw new CmisNameConstraintViolationException("Name is not valid!");
        }

        // get old properties
        PropertiesImpl oldProperties = new PropertiesImpl();
        readCustomProperties(file, oldProperties, null, new ObjectInfoImpl());
View Full Code Here

        case FILTER_NOT_VALID:
            return new CmisFilterNotValidException(msg, code);
        case INVALID_ARGUMENT:
            return new CmisInvalidArgumentException(msg, code);
        case NAME_CONSTRAINT_VIOLATION:
            return new CmisNameConstraintViolationException(msg, code);
        case NOT_SUPPORTED:
            return new CmisNotSupportedException(msg, code);
        case OBJECT_NOT_FOUND:
            return new CmisObjectNotFoundException(msg, code);
        case PERMISSION_DENIED:
View Full Code Here

        }

        // check the name
        String name = PropertyHelper.getStringProperty(properties, PropertyIds.NAME);
        if (!JcrConverter.isValidJcrName(name)) {
            throw new CmisNameConstraintViolationException("Name is not valid: " + name);
        }

        // get parent Node and create child
        JcrFolder parent = getJcrNode(session, folderId).asFolder();
        JcrNode jcrNode = parent.addNode(name, typeId, properties, contentStream, versioningState);
View Full Code Here

        }

        // check the name
        String name = PropertyHelper.getStringProperty(properties, PropertyIds.NAME);
        if (!JcrConverter.isValidJcrName(name)) {
            throw new CmisNameConstraintViolationException("Name is not valid: " + name);
        }

        // get parent Node
        JcrFolder parent = getJcrNode(session, folderId).asFolder();
        JcrNode jcrNode = parent.addFolder(name, typeId, properties);
View Full Code Here

            fObjStore.lock();
            for (Folder folder : fParents) {
              if (folder == null)
                  throw new CmisInvalidArgumentException("Root folder cannot be renamed.");
              if (folder.hasChild(newName))
                  throw new CmisNameConstraintViolationException("Cannot rename object to " + newName
                          + ". This path already exists in parent " + folder.getPath() + ".");
            }
            setName(newName);
        } finally {
          fObjStore.unlock();
View Full Code Here

            fObjStore.lock();
            boolean hasChild;
            String name = folder.getName();
            hasChild = hasChild(name);
            if (hasChild)
                throw new CmisNameConstraintViolationException("Cannot create folder " + name + ". Name already exists in parent folder");
            folder.setParent(this);
            folder.persist();
        } finally {
            fObjStore.unlock();
        }
View Full Code Here

                throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);

            boolean hasChild;
            hasChild = hasChild(name);
            if (hasChild)
                throw new CmisNameConstraintViolationException("Cannot create object: " + name + ". Name already exists in parent folder");

            if (so instanceof SingleFiling)
                ((SingleFiling) so).setParent(this);
            else if (so instanceof MultiFiling)
                ((MultiFiling) so).addParent(this);
View Full Code Here

        try {
            fObjStore.lock();
            if (getParent() == null)
                throw new CmisInvalidArgumentException("Root folder cannot be renamed.");
            if (getParent().hasChild(newName))
                throw new CmisNameConstraintViolationException("Cannot rename object to " + newName
                        + ". This path already exists.");

            setName(newName);
        } finally {
          fObjStore.unlock();
View Full Code Here

TOP

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

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.