/** * @see org.opencms.cmis.I_CmsCmisRepository#deleteContentStream(org.opencms.cmis.CmsCmisCallContext, org.apache.chemistry.opencmis.commons.spi.Holder, org.apache.chemistry.opencmis.commons.spi.Holder) */ public synchronized void deleteContentStream( CmsCmisCallContext context, Holder<String> objectId, Holder<String> changeToken) { throw new CmisConstraintException("Content streams may not be deleted."); }
/** * @return this instance as a <code>RegistryDocument</code> * @throws CmisConstraintException if <code>this.isDocument() == false</code> */ public RegistryDocument asDocument() { if (isDocument()) { return (RegistryDocument) this; } else { throw new CmisConstraintException("Not a document: " + this); } }
public static void validateContentAllowed(DocumentTypeDefinition typeDef, boolean hasContent) { ContentStreamAllowed contentAllowed = typeDef.getContentStreamAllowed(); if (ContentStreamAllowed.REQUIRED == contentAllowed && !hasContent) { throw new CmisConstraintException("Type " + typeDef.getId() + " requires content but document has no content."); } else if (ContentStreamAllowed.NOTALLOWED == contentAllowed && hasContent) { throw new CmisConstraintException("Type " + typeDef.getId() + " does not allow content but document has content."); } }
public void applyPolicies(NodeRef nodeRef, TypeDefinitionWrapper type, List<String> policies) { if ((policies == null) || (policies.isEmpty())) { return; } if (!type.getTypeDefinition(false).isControllablePolicy()) { throw new CmisConstraintException("Object is not policy controllable!"); } // nothing else to do... }
public void applyPolicies(NodeRef nodeRef, TypeDefinitionWrapper type, List<String> policies) { if ((policies == null) || (policies.isEmpty())) { return; } if (!type.getTypeDefinition(false).isControllablePolicy()) { throw new CmisConstraintException("Object is not policy controllable!"); } // nothing else to do... }
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"); } }
protected static void validateAllowedTypes(TypeDefinition typeDef, List<String> allowedTypes, String description) { if (isNullOrEmpty(allowedTypes)) { return; // all types are allowed } for (String allowedType : allowedTypes) { if (allowedType.equals(typeDef.getId())) { return; } } throw new CmisConstraintException("The requested type " + typeDef.getId() + " is not allowed " + description); }
@Override public void validate(PropertyDefinition<BigInteger> propDef, PropertyData<BigInteger> property) { super.validate(propDef, property); BigInteger propVal = property.getFirstValue(); 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); } } }
@Override public void validate(PropertyDefinition<BigDecimal> propDef, PropertyData<BigDecimal> property) { super.validate(propDef, property); BigDecimal propVal = property.getFirstValue(); 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); } } }
@Override public void validate(PropertyDefinition<String> propDef, PropertyData<String> property) { super.validate(propDef, property); long maxLen = ((PropertyStringDefinition) propDef).getMaxLength() == null ? -1 : ((PropertyStringDefinition) propDef).getMaxLength().longValue(); long len = property.getFirstValue() == null ? -1 : property.getFirstValue().length(); // check max length if (maxLen >= 0 && len >= 0 && maxLen < len) { throw new CmisConstraintException("For property with id " + propDef.getId() + " the length of " + len + " is bigger than the maximum allowed length " + maxLen); } } }
public static void validateVersionStateForCreate(DocumentTypeDefinition typeDef, VersioningState verState) { 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."); } }
@Override public void removePolicy(String repositoryId, String policyId, String objectId, ExtensionsData extension) { checkRepositoryId(repositoryId); // what kind of object is it? CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object"); TypeDefinitionWrapper type = info.getType(); if (type == null) { throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?"); } throw new CmisConstraintException("Object is not policy controllable!"); }
@Override public void removePolicy(String repositoryId, String policyId, String objectId, ExtensionsData extension) { checkRepositoryId(repositoryId); // what kind of object is it? CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object"); TypeDefinitionWrapper type = info.getType(); if (type == null) { throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?"); } throw new CmisConstraintException("Object is not policy controllable!"); }
private void checkDocumentTypeForContent(TypeDefinitionWrapper type) { if (type == null) { throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?"); } if (!(type instanceof DocumentTypeDefinitionWrapper)) { throw new CmisStreamNotSupportedException("Object is not a document!"); } if (((DocumentTypeDefinition) type.getTypeDefinition(false)).getContentStreamAllowed() == ContentStreamAllowed.NOTALLOWED) { throw new CmisConstraintException("Document cannot have content!"); } }
private void checkDocumentTypeForContent(TypeDefinitionWrapper type) { if (type == null) { throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?"); } if (!(type instanceof DocumentTypeDefinitionWrapper)) { throw new CmisStreamNotSupportedException("Object is not a document!"); } if (((DocumentTypeDefinition) type.getTypeDefinition(false)).getContentStreamAllowed() == ContentStreamAllowed.NOTALLOWED) { throw new CmisConstraintException("Document cannot have content!"); } }
public void validate(PropertyDefinition<T> propDef, PropertyData<T> prop) { // check general constraints for all property types if (propDef.getCardinality() == Cardinality.SINGLE) { if (prop.getValues() != null && prop.getValues().size() > 1) { throw new CmisConstraintException("The property with id " + propDef.getId() + " is single valued, but multiple values are passed " + prop.getValues()); } } if (isNotEmpty(propDef.getChoices())) { validateChoices(propDef, prop); } }
/** * See CMIS 1.0 section 2.2.7.1 checkOut * * @throws CmisRuntimeException */ public RegistryPrivateWorkingCopy checkout() { Resource node = getNode(); try { if (isCheckedOut(node)) { throw new CmisConstraintException("Document is already checked out " + node.getId()); } return getPwc(checkout(getRepository(), node)); } catch (RegistryException e) { String msg = "Failed checkout the node with path " + node.getPath(); log.error(msg, e); throw new CmisRuntimeException(msg, e); } }
@Override public Acl applyAcl(String repositoryId, String objectId, final Acl aces, AclPropagation aclPropagation) { checkRepositoryId(repositoryId); // We are spec compliant if we just let it through and the tck will not fail CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object"); // relationships don't have ACLs if (info.isVariant(CMISObjectVariant.ASSOC)) { throw new CmisConstraintException("Relationships are not ACL controllable!"); } final NodeRef nodeRef = info.getCurrentNodeNodeRef(); final TypeDefinitionWrapper type = info.getType(); connector.applyACL(nodeRef, type, aces); return connector.getACL(nodeRef, false); }
@Override public Acl applyAcl(String repositoryId, String objectId, final Acl aces, AclPropagation aclPropagation) { checkRepositoryId(repositoryId); // We are spec compliant if we just let it through and the tck will not fail CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object"); // relationships don't have ACLs if (info.isVariant(CMISObjectVariant.ASSOC)) { throw new CmisConstraintException("Relationships are not ACL controllable!"); } final NodeRef nodeRef = info.getCurrentNodeNodeRef(); final TypeDefinitionWrapper type = info.getType(); connector.applyACL(nodeRef, type, aces); return connector.getACL(nodeRef, false); }
@Override public Acl applyAcl( String repositoryId, String objectId, final Acl addAces, final Acl removeAces, AclPropagation aclPropagation, ExtensionsData extension) { checkRepositoryId(repositoryId); // We are spec compliant if we just let it through and the tck will not fail CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object"); // relationships don't have ACLs if (info.isVariant(CMISObjectVariant.ASSOC)) { throw new CmisConstraintException("Relationships are not ACL controllable!"); } final NodeRef nodeRef = info.getCurrentNodeNodeRef(); final TypeDefinitionWrapper type = info.getType(); connector.applyACL(nodeRef, type, addAces, removeAces); return connector.getACL(nodeRef, false); }