cancel
Showing results for 
Search instead for 
Did you mean: 

Node deletion issue

bensonfungjava
Champ in-the-making
Champ in-the-making
Hi,

I would like to delete a space under 'Company Home' via Alfresco Web Service(WS) API.   I know the following link described how to delete a node, but I don't know how to create a Reference object and then get passed to the deleteSpace method.  Please help and give me an example.

http://wiki.alfresco.com/wiki/IngresTutorial_Alfresco_Web_Service_API_for_Java#Delete_a_node

Thanks
1 REPLY 1

jpotts
World-Class Innovator
World-Class Innovator
Look at SomeCoDataCleaner.java from the Alfresco Developer Guide (and/or the ecmarchitect.com tutorials). That class does a query for objects of a certain type in a certain folder and then deletes them.

Review the entire class, but the parts you'll be interested in are:
Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
….SNIP….
CMLDelete[] deleteCMLArray = new CMLDelete[rows.length];
for (int index = 0; index < rows.length; index++) {
    ResultSetRow row = rows[index];
    deleteCMLArray[index] = new CMLDelete(new Predicate(new Reference[] {new Reference(storeRef, row.getNode().getId(), null)}, null, null));
}
               
// Construct CML Block
CML cml = new CML();
cml.setDelete(deleteCMLArray);
That should be enough to get you going with CML and the Web Services API. But for stuff like deleting spaces, you might want to consider using OpenCMIS. OpenCMIS is a Java API that can use either a SOAP Web Services binding or a RESTful Atom Pub binding. The nice thing is that you can learn how to do it once and then you'll know how to do it for all CMIS-compliant repositories.

Jeff