Katerina
Katerina

Reputation: 11

upload and update with same name to Alfresco

i want to update files to Alfresco. i upload it and when i want to update (with same name) i have errors "duplicate child name". i want to keep both of files with the same name on Alfresco and to change only the "file versions" (the name to Alfresco will be one but have file versions 1.0 , 1.1, 1.2). Below is my java code that i have the problem.

protected void executeFunction(AlfrescoRestClient alfrescoClient, AlfrescoSOAPClient alfrescoSOAPClient) throws Exception {
    String lastFileId = "";  
    for (int i=0; i < files.size(); i++) {          
        String filename = files.get(i).substring(files.get(i).lastIndexOf("name=")+5);
        String contentType = files.get(i).substring(0, files.get(i).indexOf(";"));

        lastFileId = alfrescoSOAPClient.uploadFileWithProperties(this.sourcePath + filename, filename, 
                 this.destinationFolder, contentType, "utf8", false, null, null, null, null, null, false, null, 
                 null, null, null, null, false, null, null, null);                

        AlfrescoResponse resp = alfrescoClient.updateCheckedOutFile(this.sourcePath + filename, this.description, contentType, checkOutId);

        Document<Element> doc = resp.getDocument();
        Entry responseEntry = (Entry)doc.getRoot();
        LOGGER.severe("ID: " + responseEntry.getId().toString());
        lastFileId = responseEntry.getId().toString();
        this.fileId = lastFileId;  
     }     
}

Upvotes: 0

Views: 1155

Answers (1)

Dhaval Soni
Dhaval Soni

Reputation: 85

You can not Update the document with same name in alfresco but you can change the content and update the version of Document.

Upvotes: 3

Related Questions