Search in sources :

Example 1 with CMLUpdate

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;
}
Also used : CML(org.alfresco.webservice.types.CML) RepositoryFault(org.alfresco.webservice.repository.RepositoryFault) ParentReference(org.alfresco.webservice.types.ParentReference) Reference(org.alfresco.webservice.types.Reference) CMLUpdate(org.alfresco.webservice.types.CMLUpdate) NamedValue(org.alfresco.webservice.types.NamedValue) AuthenticationFault(org.alfresco.webservice.authentication.AuthenticationFault) RemoteException(java.rmi.RemoteException) Predicate(org.alfresco.webservice.types.Predicate)

Aggregations

RemoteException (java.rmi.RemoteException)1 AuthenticationFault (org.alfresco.webservice.authentication.AuthenticationFault)1 RepositoryFault (org.alfresco.webservice.repository.RepositoryFault)1 CML (org.alfresco.webservice.types.CML)1 CMLUpdate (org.alfresco.webservice.types.CMLUpdate)1 NamedValue (org.alfresco.webservice.types.NamedValue)1 ParentReference (org.alfresco.webservice.types.ParentReference)1 Predicate (org.alfresco.webservice.types.Predicate)1 Reference (org.alfresco.webservice.types.Reference)1