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!
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.
Thanks for your reply.
As I understand it, CMIS does not contain functionality for renaming files with the same name?
Right, if you want renaming, you have to implement it in your code that is using CMIS.
Thank you for help.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.