Hello
I'm trying to update file description when make a new version of file in the Alfresco Repository. The update is OK, but the lastest description doesn't shows in the alfresco web ui.
here is the code:
public String updateFile (String fileName, String filePath, String username,
String fileDescription, String folderPath, String mimeType) throws Exception {
AuthenticationUtils.startSession(USERNAME, PASSWORD);
try
{
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
AuthoringServiceSoapBindingStub authoringService = WebServiceFactory.getAuthoringService();
Reference reference = this.obtenerArchivoRepositorio(fileName,folderPath);
if (reference != null){
makeVersionable(repositoryService, reference);
// Checkout the newly created content, placing the working document in the same folder
Predicate itemsToCheckOut = new Predicate(new Reference[]{reference}, null, null);
CheckoutResult checkOutResult = authoringService.checkout(itemsToCheckOut, null);
// Get a reference to the working copy
Reference workingCopyReference = checkOutResult.getWorkingCopies()[0];
// Update the content of the working copy
ContentFormat format = new ContentFormat(mimeType, "UTF-8");
//loads the file from remote or local machine
InputStream in;
if (filePath.indexOf("http") >= 0 || filePath.indexOf("ftp") >= 0){
in = new URL(filePath).openStream();
try {
contentService.write(workingCopyReference, Constants.PROP_CONTENT,
IOUtils.toByteArray(in), format);
} finally {
IOUtils.closeQuietly(in);
}
}else{
File archivoOrigen = new File (filePath);
contentService.write(workingCopyReference, Constants.PROP_CONTENT,
FileUtils.readFileToByteArray(archivoOrigen), format);
}
// Now check the working copy in with a description of the change made that will be recorded in the version history
Predicate predicate = new Predicate(new Reference[]{workingCopyReference}, null, null);
NamedValue [] propiedades = new NamedValue[5];
propiedades[0] = Utils.createNamedValue(Constants.PROP_DESCRIPTION,fileDescription);
propiedades[1] = Utils.createNamedValue(Constants.OWNER_AUTHORITY,username);
propiedades[2] = Utils.createNamedValue(Constants.PROP_NAME,fileName);
propiedades[3] = Utils.createNamedValue(Constants.PROP_TITLE,fileName);
propiedades[4] = Utils.createNamedValue(Constants.PROP_USERNAME,username);
authoringService.checkin(predicate, propiedades, false);
return "TRUE";
}else{
return "FALSE";
}
}finally{
// End the session
AuthenticationUtils.endSession();
}
}
I will apreciate the help
Vladimir