cancel
Showing results for 
Search instead for 
Did you mean: 

Delete node through the WS API[SOLVED]

sisao
Champ in-the-making
Champ in-the-making
Hi,

i'm going to use the labs version of alfresco as a repository for my application….using various API to get this fully automated and transparent….i can import content to alfresco via my application forms…doing all the session and writing job using the WS API which i find really fast. I'm anyway not found methods that let me handle nodes after they're imported…such as renaming that i can still do with changing the CML fields or most important i cant find a delete method for nodes….i've only found a clear content thing which is not what i was expecting to use.
I am now trying this through the JCR API but the whole login session is more articulated than the simple session handshake provided with the WS API that does not require any explicit spring beans injection.
How can i solve this problem….maybe i've just not checked the whole WS API properly.

Regards,
sees.
11 REPLIES 11

shamabbas
Champ in-the-making
Champ in-the-making
Hi all,
I worked in Uploading and Downloading and Deleting files from Alfresco Repository..
Now problem is this that when i delete file by giving index, it deletes from DB and if try to search and download says can't find hence deleted but problem is that it stays in HDD. And never get to remove from HardDrive. I want it to b delete from their too, cuz cover space. What should I do? If any idea any query any function then please let me know?

Thanks for replies…

Sham

bannu
Champ in-the-making
Champ in-the-making
Hi,
Following is my code to delete a file/node.
String fileName = "Test.pdf";
Query query = new Query(Constants.QUERY_LANG_LUCENE, "PATH:\"/app:company_home/cm:"+fileName+"\"");
System.out.println(STORE.getAddress());
QueryResult queryResult = repositoryService.query(STORE, query, false);
ResultSet rs = queryResult.getResultSet();
ResultSetRow[] rows = rs.getRows();
if(rs.getTotalRowCount() > 0){
          ResultSetRow[] rsRows = rs.getRows();
          System.out.println("Removing file " + rsRows[0].getColumns(1).getValue());
          Reference reference = new Reference(STORE, rsRows[0].getNode().getId(), null);
          System.out.println("After instantiating Reference");
          Predicate predicate = new Predicate(new Reference[]{companyHome}, null, null);
          System.out.println("After instantiating Predicate and before instantiating CMLDelete");
          CMLDelete delete = new CMLDelete(predicate);
          CML cml = new CML();
          cml.setDelete(new CMLDelete[] {delete});
          repositoryService.update(cml);

I am getting the following error:
Exception in thread "main" AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode:
faultString:
faultActor:
faultNode:
faultDetail:
   {http://www.alfresco.org/ws/service/repository/1.0}RepositoryFault:<ns1:errorCode>0</ns1:errorCode><ns1:message>org.alfresco.service.cmr.repository.InvalidNodeRefException: Node does not exist: workspace://SpacesStore/null</ns1:message>
   {http://xml.apache.org/axis/}exceptionNameSmiley Surprisedrg.alfresco.repo.webservice.repository.RepositoryFault
   {http://xml.apache.org/axis/}stackTrace:
   at org.alfresco.repo.webservice.repository.RepositoryWebService.update(RepositoryWebService.java:335)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
   at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)

Please help me with the solution