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

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


        String msg = ex.getFaultInfo().getMessage();
        BigInteger code = ex.getFaultInfo().getCode();

        switch (ex.getFaultInfo().getType()) {
        case CONSTRAINT:
            return new CmisConstraintException(msg, code);
        case CONTENT_ALREADY_EXISTS:
            return new CmisContentAlreadyExistsException(msg, code);
        case FILTER_NOT_VALID:
            return new CmisFilterNotValidException(msg, code);
        case INVALID_ARGUMENT:
View Full Code Here


        case 403:
            return new CmisPermissionDeniedException(message, errorContent, t);
        case 405:
            return new CmisNotSupportedException(message, errorContent, t);
        case 409:
            return new CmisConstraintException(message, errorContent, t);
        default:
            return new CmisRuntimeException(message, errorContent, t);
        }
    }
View Full Code Here

        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();
            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

        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();
            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

    }

    public DocumentVersion addVersion(ContentStream content, VersioningState verState, String user) {

        if (isCheckedOut()) {
            throw new CmisConstraintException("Cannot add a version to document, document is checked out.");
        }

        DocumentVersionImpl ver = new DocumentVersionImpl(fRepositoryId, this, content, verState, fObjStore);
        ver.setSystemBasePropertiesWhenCreatedDirect(getName(), getTypeId(), user); // copy
        // name
View Full Code Here

        if (fIsCheckedOut) {
            if (fCheckedOutUser.equals(user)) {
                fIsCheckedOut = false;
                fCheckedOutUser = null;
            } else {
                throw new CmisConstraintException("Error: Can't checkin. Document " + getId() + " user " + user
                        + " has not checked out the document");
            }
        } else {
            throw new CmisConstraintException("Error: Can't cancel checkout, Document " + getId()
                    + " is not checked out.");
        }

        DocumentVersion pwc = getPwc();
       
View Full Code Here

        pwc.commit(isMajor);
    }

    public DocumentVersion checkOut(ContentStream content, String user) {
        if (fIsCheckedOut) {
            throw new CmisConstraintException("Error: Can't checkout, Document " + getId() + " is already checked out.");
        }

        // create PWC
        DocumentVersion pwc = addVersion(content, VersioningState.CHECKEDOUT, user); // will
        // set
View Full Code Here

        LOG.debug("End removeObjectFromFolder()");
    }

    private static void checkObjects(StoredObject so, StoredObject folder) {
        if (!(so instanceof MultiFiling)) {
            throw new CmisConstraintException("Cannot add object to folder, object id " + so.getId()
                    + " is not a multi-filed object.");
        }

        if ((so instanceof Folder)) {
            throw new CmisConstraintException("Cannot add object to folder, object id " + folder.getId()
                    + " is a folder and folders are not multi-filed.");
        }

        if (!(folder instanceof Folder)) {
            throw new CmisConstraintException("Cannot add object to folder, folder id " + folder.getId()
                    + " does not refer to a folder.");
        }
    }
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.