02-19-2019 01:57 PM
Good day.
I create a document in Alfresco using CMIS. Code:
Session session = ...
Folder parent = session.getRootFolder ();
String textFileName = "test.txt"; // prepare content - a simple text file
String content = "Hello World!";
String filename = textFileName;
String mimetype = "text / plain; charset = UTF-8";
byte [] contentBytes = content.getBytes ("UTF-8");
ByteArrayInputStream stream = new ByteArrayInputStream (contentBytes);
ContentStream contentStream = session.getObjectFactory (). CreateContentStream (filename, contentBytes.length, mimetype, stream); // prepare properties
Map <String, Object> properties = new HashMap <String, Object> ();
properties.put (PropertyIds.NAME, textFileName);
properties.put (PropertyIds.OBJECT_TYPE_ID, "cmis: document"); // create the document
Document newDoc = parent.createDocument (properties, contentStream, VersioningState.MAJOR);
However, when I save a file with the same name twice, I get a CmisContentAlreadyExistsException.
When I add files with the same name through Alfresco, suffixes are added to the file names (as file_name-1, file_name-2 ...). Is it possible to save files with the same name via CMIS?
Thanks!
02-21-2019 10:36 AM
My recollection is that the renaming is done by the UI by catching the exception, and updating the name until that exception is not thrown.
02-25-2019 11:46 PM
Thanks for your reply.
As I understand it, CMIS does not contain functionality for renaming files with the same name?
02-28-2019 11:18 AM
Right, if you want renaming, you have to implement it in your code that is using CMIS.
03-01-2019 12:51 PM
Thank you for help.
Explore our Alfresco products with the links below. Use labels to filter content by product module.