// validate ACL
TypeValidator.validateAcl(typeDef, addACEs, removeACEs);
Folder folder = null;
if (null != folderId) {
StoredObject so = objectStore.getObjectById(folderId);
if (null == so) {
throw new CmisInvalidArgumentException(" Cannot create document, folderId: " + folderId + " is invalid");
}
if (so instanceof Folder) {
folder = (Folder) so;
} else {
throw new CmisInvalidArgumentException("Can't creat document, folderId does not refer to a folder: "
+ folderId);
}
TypeValidator.validateAllowedChildObjectTypes(typeDef, folder.getAllowedChildObjectTypeIds());
}
// check if the given type is a document type
if (!typeDef.getBaseTypeId().equals(BaseTypeId.CMIS_DOCUMENT)) {
throw new CmisInvalidArgumentException("Cannot create a document, with a non-document type: " + typeDef.getId());
}
// check name syntax
if (!NameValidator.isValidId(name)) {
throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
}
TypeValidator.validateVersionStateForCreate((DocumentTypeDefinition) typeDef, versioningState);
// set properties that are not set but have a default:
Map<String, PropertyData<?>> propMapNew = setDefaultProperties(typeDef, propMap);
if (propMapNew != propMap) {
properties = new PropertiesImpl(propMapNew.values());
propMap = propMapNew;
}
TypeValidator.validateProperties(typeDef, properties, true);
// set user, creation date, etc.
if (user == null) {
user = "unknown";
}
StoredObject so = null;
// check if content stream parameters are set and if not set some defaults
if (null != contentStream && (contentStream.getFileName() == null || contentStream.getFileName().length() == 0 ||
contentStream.getMimeType() == null || contentStream.getMimeType().length() == 0)) {
ContentStreamImpl cs = new ContentStreamImpl();