cancel
Showing results for 
Search instead for 
Did you mean: 

Update Content

pablo_zapico
Champ in-the-making
Champ in-the-making
Desde el webService se puede actualizar un contenido? me dice error de duplicado.. Realmente lo que kiero actualizar son las propiedades de un contenido, descripcion, nombre,…
7 REPLIES 7

pjcaracuel_2349
Confirmed Champ
Confirmed Champ
buenas Pablo,

Claro que se puede hacer, si buscas el nodo a actualizar y acontinuacion le asignas propiedades deberia funcionar, algo como:

Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>();
        titledProps.put(ContentModel.PROP_TITLE, name);
        titledProps.put(ContentModel.PROP_DESCRIPTION, name);

Y luego un save por supuesto

Es mas mirando en el ejemplo de webservices del SDK, viene esto:

 // Assign name            String name = "Web Services sample (" + System.currentTimeMillis() + ")";            companyHomeParent.setChildName("cm:" + name);                        // Construct CML statement to create content node            // Note: Assign "1" as a local id, so we can refer to it in subsequent            //       CML statements within the same CML block            NamedValue[] contentProps = new NamedValue[1];             contentProps[0] = Utils.createNamedValue(Constants.PROP_NAME, name);             CMLCreate create = new CMLCreate("1", companyHomeParent, null, null, null, Constants.TYPE_CONTENT, contentProps);                        // Construct CML statement to add titled aspect            NamedValue[] titledProps = new NamedValue[2];            titledProps[0] = Utils.createNamedValue(Constants.PROP_TITLE, name);            titledProps[1] = Utils.createNamedValue(Constants.PROP_DESCRIPTION, name);            CMLAddAspect addAspect = new CMLAddAspect(Constants.ASPECT_TITLED, titledProps, null, "1");                        // Construct CML Block            CML cml = new CML();            cml.setCreate(new CMLCreate[] {create});            cml.setAddAspect(new CMLAddAspect[] {addAspect});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

El objeto cml tiene tambien un metodo update
Saludos

pablo_zapico
Champ in-the-making
Champ in-the-making
Si he visto lo del CMLUpdate sino le pongo el aspect no falla pero cuando se lo pongo me da

{http://www.alfresco.org/ws/service/repository/1.0}RepositoryFault:<ns1:errorCode>0</ns1:errorCode><ns1:message>java.lang.NullPointerException</ns1:message>‍‍‍

debo estar configurando mal el aspect

             RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();                                ParentReference parentReference = new ParentReference(STORE, null, "/app:company_home/cm:sample_folder", Constants.ASSOC_CONTAINS, Constants.ASSOC_CONTAINS);                        NamedValue[] properties = new NamedValue[]{Utils.createNamedValue(Constants.PROP_NAME, System.currentTimeMillis() + "_WebServiceSample4.txt")};            CMLCreate create = new CMLCreate("id1", parentReference, null, null, null, Constants.TYPE_CONTENT, properties);            CMLUpdate update = new CMLUpdate();            ParentReference parentReference2 = new ParentReference(STORE, null, "/app:company_home/cm:sample_folder/cm:hola.txt", Constants.ASSOC_CONTAINS,                     "{" + Constants.NAMESPACE_CONTENT_MODEL + "}" + "hola.txt");                        String aspectString = Constants.createQNameString("modelo.regasoc", "aspectRegasoc");                        NamedValue[] titledProps = new NamedValue[3];                      titledProps[0] = Utils.createNamedValue(Constants.PROP_TITLE, "pablo");          titledProps[1] = Utils.createNamedValue(Constants.PROP_DESCRIPTION, "descripción");          titledProps[2] = Utils.createNamedValue(Constants.createQNameString("modelo.regasoc", "nexpediente"), "10");          CMLAddAspect addAspect = new CMLAddAspect(aspectString, titledProps, null, null);                        Predicate predicate = new Predicate(new Reference[]{parentReference2}, null, null);            update.setWhere(predicate);                       CML cml = new CML();                       cml.setUpdate(new CMLUpdate[]{update});            cml.setAddAspect(new CMLAddAspect[] {addAspect});                        UpdateResult[] updateResults = repositoryService.update(cml);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

pjcaracuel_2349
Confirmed Champ
Confirmed Champ
Es que quizas el aspect que tu estes utilizando no lo tienes tu definido o no lo tratas correctamente. Son las propiedades de un aspecto lo que tu quieres actualizar?

Saludos

pablo_zapico
Champ in-the-making
Champ in-the-making
Si exacto, pero el aspect me esta funcionando bien, xq tngo picada una carga de contenido con ese aspect y funciona, lo q pasa q un parametro me llega mas tarde y tngo q hacer una actualizacion, de todas formas ahora estoy intentando actualizar el title y me da el mismo error

               titledProps[0] = Utils.createNamedValue(Constants.PROP_TITLE, "pablo");                   CMLAddAspect addAspect = new CMLAddAspect(Constants.ASPECT_TITLED, titledProps, null, "1");‍‍‍‍

el ultimo parametro que se le pasa al new CMLAddAspect, en este caso un 1, a q se corresponde?

no se si quizas hago mal en el pathreference

 ParentReference parentReference2 = new ParentReference(STORE, null, "/app:company_home/cm:sample_folder/cm:hola.txt", Constants.ASSOC_CONTAINS,                     "{" + Constants.NAMESPACE_CONTENT_MODEL + "}" + "hola.txt");‍‍‍‍

pablo_zapico
Champ in-the-making
Champ in-the-making
Acabo de probar el cmlDelete y ese si que me funciona, asi q el problema va estar al cargar el aspect para el cmlUpdate

pjcaracuel_2349
Confirmed Champ
Confirmed Champ

pablo_zapico
Champ in-the-making
Champ in-the-making
Vale, si ya ta

No entendia muy bien xq no se usa el CMLUpdate, pero lo que he visto es q me faltaba configurar bien el aspect

no se cuanto te pagan en tu empresa, pero seguro q es menos de loq vales….

muchas gracias, por la ayuda..