AnsweredAssumed Answered

CMIS: save files with the same name

Question asked by viktoriyamoskovkina on Feb 19, 2019
Latest reply on Mar 1, 2019 by viktoriyamoskovkina

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!

Outcomes