if (properties != null) {
// find new name
String newName = getStringProperty(properties, PropertyIds.NAME);
if (newName != null) {
if (!isValidName(newName)) {
throw new CmisNameConstraintViolationException("Name is not valid!");
}
name = newName;
}
// get the property definitions
TypeDefinition type = types.getType(typeId);
if (type == null) {
throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!");
}
// replace with new values
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.READWRITE)) {
throw new CmisConstraintException("Property '" + prop.getId() + "' cannot be updated!");
}
// empty properties are invalid
if (isEmptyProperty(prop)) {
throw new CmisConstraintException("Property '" + prop.getId() + "' must not be empty!");
}
newProperties.addProperty(prop);
}
}
addPropertyId(newProperties, typeId, null, PropertyIds.OBJECT_TYPE_ID, typeId);
addPropertyString(newProperties, typeId, null, PropertyIds.CREATED_BY, context.getUsername());
addPropertyDateTime(newProperties, typeId, null, PropertyIds.CREATION_DATE,
millisToCalendar(System.currentTimeMillis()));
addPropertyString(newProperties, typeId, null, PropertyIds.LAST_MODIFIED_BY, context.getUsername());
// check the file
File newFile = new File(parent, name);
if (newFile.exists()) {
throw new CmisNameConstraintViolationException("Document already exists.");
}
// create the file
try {
newFile.createNewFile();