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

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


            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)) {
                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: "
                        + 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


        if (link == null) {
            link = loadLink(repositoryId, objectId, AtomPubParser.LINK_REL_CONTENT, null);
        }

        if (link == null) {
            throw new CmisConstraintException("No content stream");
        }

        UrlBuilder url = new UrlBuilder(link);
        // using the content URL and adding a streamId param
        // is not spec-compliant
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 and type id from version series.
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 check-out flag
View Full Code Here

                if (jsonMessage != null) {
                    message = jsonMessage.toString();
                }

                if (CmisConstraintException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
                    return new CmisConstraintException(message, errorContent, t);
                } else if (CmisContentAlreadyExistsException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
                    return new CmisContentAlreadyExistsException(message, errorContent, t);
                } else if (CmisFilterNotValidException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
                    return new CmisFilterNotValidException(message, errorContent, t);
                } else if (CmisInvalidArgumentException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
                    return new CmisInvalidArgumentException(message, errorContent, t);
                } else if (CmisNameConstraintViolationException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
                    return new CmisNameConstraintViolationException(message, errorContent, t);
                } else if (CmisNotSupportedException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
                    return new CmisNotSupportedException(message, errorContent, t);
                } else if (CmisObjectNotFoundException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
                    return new CmisObjectNotFoundException(message, errorContent, t);
                } else if (CmisPermissionDeniedException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
                    return new CmisPermissionDeniedException(message, errorContent, t);
                } else if (CmisStorageException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
                    return new CmisStorageException(message, errorContent, t);
                } else if (CmisStreamNotSupportedException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
                    return new CmisStreamNotSupportedException(message, errorContent, t);
                } else if (CmisUpdateConflictException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
                    return new CmisUpdateConflictException(message, errorContent, t);
                } else if (CmisVersioningException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
                    return new CmisVersioningException(message, errorContent, t);
                }
            }
        }

        // fall back to status code
        switch (code) {
        case 400:
            return new CmisInvalidArgumentException(message, errorContent, t);
        case 401:
            return new CmisUnauthorizedException(message, errorContent, t);
        case 403:
            return new CmisPermissionDeniedException(message, errorContent, t);
        case 404:
            return new CmisObjectNotFoundException(message, errorContent, t);
        case 405:
            return new CmisNotSupportedException(message, errorContent, t);
        case 407:
            return new CmisProxyAuthenticationException(message, errorContent, t);
        case 409:
            return new CmisConstraintException(message, errorContent, t);
        default:
            return new CmisRuntimeException(message, errorContent, t);
        }
    }
View Full Code Here

            } else if (CmisUpdateConflictException.EXCEPTION_NAME.equals(exception)) {
                return new CmisUpdateConflictException(message, errorContent, t);
            } else if (CmisNameConstraintViolationException.EXCEPTION_NAME.equals(exception)) {
                return new CmisNameConstraintViolationException(message, errorContent, t);
            }
            return new CmisConstraintException(message, errorContent, t);
        default:
            if (CmisStorageException.EXCEPTION_NAME.equals(exception)) {
                return new CmisStorageException(message, errorContent, t);
            }
            return new CmisRuntimeException(message, errorContent, t);
View Full Code Here

        }

        // check if children exist
        List<StoredObject> children = ((Folder) folder).getChildren(-1, -1, user);
        if (children != null && !children.isEmpty()) {
            throw new CmisConstraintException("Cannot delete folder with id:  " + folderId + ". Folder is not empty.");
        }

        fStoredObjectMap.remove(folderId);
    }
View Full Code Here

            for (TypeDefinitionContainer tdc : tdl) {
                TypeDefinition td = tdc.getTypeDefinition();
                for (PropertyDefinition<?> pd1 : td.getPropertyDefinitions().values()) {
                    // check if id is used
                    if (pd1.getId().equals(pd2.getId()))
                        throw new CmisConstraintException("Property id " + pd2.getId() + " already in use in type "
                                + td.getId());
                    // check if query name is used
                    if (pd1.getQueryName().equals(pd2.getQueryName()))
                        throw new CmisConstraintException("Property query name " + pd2.getQueryName() + " already in use in type "
                                + td.getQueryName());
                    // check if local name is used
                    if (pd1.getLocalName().equals(pd2.getLocalName()))
                        throw new CmisConstraintException("Property local name " + pd2.getLocalName() + " already in use in type "
                                + td.getId());
                }
            }
        }       
    }
View Full Code Here

            throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
        }
       
        for (TypeDefinitionContainer tdc : tm.getTypeDefinitionList()) {
            if (tdc.getTypeDefinition().getLocalName().equals(localName))
                throw new CmisConstraintException("You cannot add type with local name " + localName
                        + " because it already exists.");                      
        }
    }
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.