}
// get parent File
File parent = getFile(folderId);
if (!parent.isDirectory()) {
throw new CmisObjectNotFoundException("Parent is not a folder!");
}
// get source File
File source = getFile(sourceId);
if (!source.isFile()) {
throw new CmisObjectNotFoundException("Source is not a document!");
}
// file name
String name = source.getName();
// get properties
PropertiesImpl sourceProperties = new PropertiesImpl();
readCustomProperties(source, sourceProperties, null, new ObjectInfoImpl());
// get the type id
String typeId = getIdProperty(sourceProperties, PropertyIds.OBJECT_TYPE_ID);
if (typeId == null) {
typeId = TypeManager.DOCUMENT_TYPE_ID;
}
// copy properties
PropertiesImpl newProperties = new PropertiesImpl();
for (PropertyData<?> prop : sourceProperties.getProperties().values()) {
if ((prop.getId().equals(PropertyIds.OBJECT_TYPE_ID)) || (prop.getId().equals(PropertyIds.CREATED_BY))
|| (prop.getId().equals(PropertyIds.CREATION_DATE))
|| (prop.getId().equals(PropertyIds.LAST_MODIFIED_BY))) {
continue;
}
newProperties.addProperty(prop);
}
// replace properties
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());