Update Content

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2009 03:26 AM
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,…
Labels:
- Labels:
-
Archive
7 REPLIES 7
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2009 05:25 AM
buenas Pablo,
Claro que se puede hacer, si buscas el nodo a actualizar y acontinuacion le asignas propiedades deberia funcionar, algo como:
Y luego un save por supuesto
Es mas mirando en el ejemplo de webservices del SDK, viene esto:
El objeto cml tiene tambien un metodo update
Saludos
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

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2009 06:01 AM
Si he visto lo del CMLUpdate sino le pongo el aspect no falla pero cuando se lo pongo me da
debo estar configurando mal el aspect
{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);
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2009 06:05 AM
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
Saludos

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2009 06:08 AM
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
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
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");

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2009 06:12 AM
Acabo de probar el cmlDelete y ese si que me funciona, asi q el problema va estar al cargar el aspect para el cmlUpdate
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2009 06:17 AM

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2009 06:43 AM
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..
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..
