/** * @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."); }
fail(e.toString());
assertTrue(e.getMessage().startsWith("Value is out of range for property"));
fail(e.toString());
/** * @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); } }
fail(e.toString());
/** * Returns the definition after it has checked if the type can be used for * object creation. */ public TypeDefinitionWrapper getTypeForCreate(String cmisTypeId, BaseTypeId baseTypeId) { TypeDefinitionWrapper type = getType(cmisTypeId); if ((type == null) || (type.getBaseTypeId() != baseTypeId)) { switch (baseTypeId) { case CMIS_DOCUMENT: throw new CmisConstraintException("Type is not a document type!"); case CMIS_FOLDER: throw new CmisConstraintException("Type is not a folder type!"); case CMIS_RELATIONSHIP: throw new CmisConstraintException("Type is not a relationship type!"); case CMIS_POLICY: throw new CmisConstraintException("Type is not a policy type!"); case CMIS_ITEM: throw new CmisConstraintException("Type is not an item type!"); } } if (!type.getTypeDefinition(false).isCreatable()) { throw new CmisConstraintException("Type is not creatable!"); } return type; }
/** * Returns the definition after it has checked if the type can be used for * object creation. */ public TypeDefinitionWrapper getTypeForCreate(String cmisTypeId, BaseTypeId baseTypeId) { TypeDefinitionWrapper type = getType(cmisTypeId); if ((type == null) || (type.getBaseTypeId() != baseTypeId)) { switch (baseTypeId) { case CMIS_DOCUMENT: throw new CmisConstraintException("Type is not a document type!"); case CMIS_FOLDER: throw new CmisConstraintException("Type is not a folder type!"); case CMIS_RELATIONSHIP: throw new CmisConstraintException("Type is not a relationship type!"); case CMIS_POLICY: throw new CmisConstraintException("Type is not a policy type!"); case CMIS_ITEM: throw new CmisConstraintException("Type is not an item type!"); } } if (!type.getTypeDefinition(false).isCreatable()) { throw new CmisConstraintException("Type is not creatable!"); } return type; }
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"); } }
throw new CmisConstraintException("Invalid null permission!");
throw new CmisConstraintException("Invalid null permission!");
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 write(byte[] buffer, int offset, int len) throws IOException { try { if (len == 0) { return; } if (maxContentSize > -1 && length + len > maxContentSize) { destroy(null); throw new CmisConstraintException("Content too big!"); } expand(len); System.arraycopy(buffer, offset, buf, bufSize, len); bufSize += len; length += len; } catch (IOException ioe) { destroy(ioe); if (LOG.isErrorEnabled()) { if (tempFile != null) { LOG.error("Writing to temp file {} failed: {}", tempFile.getAbsolutePath(), ioe.toString(), ioe); } else { LOG.error("Writing to temp buffer failed: {}", ioe.toString(), ioe); } } throw ioe; } }
@Override public void write(int oneByte) throws IOException { try { if (maxContentSize > -1 && length + 1 > maxContentSize) { destroy(null); throw new CmisConstraintException("Content too big!"); } if (bufSize == buf.length) { expand(1); } buf[bufSize++] = (byte) oneByte; length++; } catch (IOException ioe) { destroy(ioe); if (LOG.isErrorEnabled()) { if (tempFile != null) { LOG.error("Writing to temp file {} failed: {}", tempFile.getAbsolutePath(), ioe.toString(), ioe); } else { LOG.error("Writing to temp buffer failed: {}", ioe.toString(), ioe); } } throw ioe; } }
@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); } } }
/** * Checks if a child of a given type can be added to a given folder. */ @SuppressWarnings("unchecked") public void checkChildObjectType(CMISNodeInfo folderInfo, String childType) { TypeDefinitionWrapper targetType = folderInfo.getType(); PropertyDefinitionWrapper allowableChildObjectTypeProperty = targetType .getPropertyById(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS); List<String> childTypes = (List<String>) allowableChildObjectTypeProperty.getPropertyAccessor().getValue( folderInfo); if ((childTypes == null) || childTypes.isEmpty()) { return; } if (!childTypes.contains(childType)) { throw new CmisConstraintException("Objects of type '" + childType + "' cannot be added to this folder!"); } }