private PropertyUpdater() { }
public static PropertyUpdater create(JcrTypeManager typeManager, String typeId, Properties properties) {
if (properties == null) {
throw new CmisConstraintException("No properties!");
}
// get the property definitions
TypeDefinition type = typeManager.getType(typeId);
if (type == null) {
throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!");
}
PropertyUpdater propertyUpdater = new PropertyUpdater();
// update properties
for (PropertyData<?> prop : properties.getProperties().values()) {
PropertyDefinition<?> propDef = type.getPropertyDefinitions().get(prop.getId());
// do we know that property?
if (propDef == null) {
throw new CmisInvalidArgumentException("Property '" + prop.getId() + "' is unknown!");
}
// skip content stream file name
if (propDef.getId().equals(PropertyIds.CONTENT_STREAM_FILE_NAME)) {
log.warn("Cannot set " + PropertyIds.CONTENT_STREAM_FILE_NAME + ". Ignoring");
continue;
}
// silently skip name
if (propDef.getId().equals(PropertyIds.NAME)) {
continue;
}
// can it be set?
if (propDef.getUpdatability() == Updatability.READONLY) {
throw new CmisConstraintException("Property '" + prop.getId() + "' is readonly!");
}
if (propDef.getUpdatability() == Updatability.ONCREATE) {
throw new CmisConstraintException("Property '" + prop.getId() + "' can only be set on create!");
}
// default or value
PropertyData<?> newProp;
newProp = PropertyHelper.isPropertyEmpty(prop)