/**
* Checks and updates a property set that can be written to disc.
*/
private Properties updateProperties(String typeId, String creator, GregorianCalendar creationDate, String modifier,
Properties oldProperties, Properties properties) {
PropertiesImpl result = new PropertiesImpl();
if (properties == null) {
throw new CmisConstraintException("No properties!");
}
// get the property definitions
TypeDefinition type = fTypes.getType(typeId);
if (type == null) {
throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!");
}
// copy old properties
for (PropertyData<?> prop : oldProperties.getProperties().values()) {
PropertyDefinition<?> propType = type.getPropertyDefinitions().get(prop.getId());
// do we know that property?
if (propType == null) {
throw new CmisConstraintException("Property '" + prop.getId() + "' is unknown!");
}
// only add read/write properties
if ((propType.getUpdatability() != Updatability.READWRITE)) {
continue;
}
result.addProperty(prop);
}
// update properties
for (PropertyData<?> prop : properties.getProperties().values()) {
PropertyDefinition<?> propType = type.getPropertyDefinitions().get(prop.getId());
// do we know that property?
if (propType == null) {
throw new CmisConstraintException("Property '" + prop.getId() + "' is unknown!");
}
// can it be set?
if ((propType.getUpdatability() == Updatability.READONLY)) {
throw new CmisConstraintException("Property '" + prop.getId() + "' is readonly!");
}
if ((propType.getUpdatability() == Updatability.ONCREATE)) {
throw new CmisConstraintException("Property '" + prop.getId() + "' can only be set on create!");
}
// default or value
if (isEmptyProperty(prop)) {
addPropertyDefault(result, propType);
} else {
result.addProperty(prop);
}
}
addPropertyId(result, typeId, null, PropertyIds.OBJECT_TYPE_ID, typeId);
addPropertyString(result, typeId, null, PropertyIds.CREATED_BY, creator);