use of org.alfresco.webservice.types.CMLUpdate in project trainning by fernandotomasio.
the class AlfrescoContentDAO method updateDocument.
@Override
public String updateDocument(ContentDTO document) {
try {
AuthenticationUtils.startSession(USERNAME, PASSWORD);
WebServiceFactory.getRepositoryService();
Reference node = new Reference();
node.setStore(STORE);
if (document.getUid() == null || document.getUid().equals("")) {
return null;
}
node.setUuid(document.getUid());
Predicate predicate = new Predicate(new Reference[] { node }, STORE, null);
// update content
CMLUpdate update = new CMLUpdate();
NamedValue[] properties = new NamedValue[3];
properties[0] = Utils.createNamedValue(Constants.PROP_NAME, document.getName());
properties[1] = Utils.createNamedValue(Constants.PROP_TITLE, document.getTitle());
properties[2] = Utils.createNamedValue(Constants.PROP_DESCRIPTION, document.getDescription());
update.setProperty(properties);
update.setWhere(predicate);
CML cmlUpdate = new CML();
cmlUpdate.setUpdate(new CMLUpdate[] { update });
WebServiceFactory.getRepositoryService().update(cmlUpdate);
return document.getUid();
} catch (AuthenticationFault e) {
Logger.getLogger(AlfrescoContentDAO.class.getName()).log(Level.SEVERE, "Erro de Autenticação");
} catch (RepositoryFault e) {
Logger.getLogger(AlfrescoContentDAO.class.getName()).log(Level.INFO, "Conteúdo não disponível");
} catch (RemoteException e) {
Logger.getLogger(AlfrescoContentDAO.class.getName()).log(Level.SEVERE, "Erro de Acesso a Serviço Web");
} finally {
// End the session
AuthenticationUtils.endSession();
}
return null;
}
Aggregations