cancel
Showing results for 
Search instead for 
Did you mean: 

Deletion In Alfresco

mike_smith30100
Champ in-the-making
Champ in-the-making
Hi Guys,
          we are developing our own application in which we have upload, search, delete functionality. we are using Jsf, alfresco api till now we have done upload as well as search through Alfresco webservices, but I am facing difficulties doing delete functionality(in this delete functionality we are just deleting selected files , Back end is of alfresco.from our side we are writing Jsp pages and writing java code). So guys if you have any idea please assist in this regard, if you have any code/sample code, please do send me on mike_smith301001@yahoo.co.in, or please reply ASAP.
          With Regards
               Mike
6 REPLIES 6

pitt1
Champ in-the-making
Champ in-the-making
It sounds like you want to use the repository service update method and pass in a CMLDelete statement.  Here is an example:


Reference nodeRef = new Reference(storeRef, nodeId, nodePath);
Predicate predicate = new Predicate(new Reference[]{nodeRef}, null, null);       
CMLDelete delete = new CMLDelete(predicate);
CML cml = new CML();
cml.setDelete(new CMLDelete[]{delete});
repositoryService.update(cml);    

Note: you will not be able to use the Alfresco foundation (native java) API outside the JVM that the alfresco webapp is running in.  That is why you're seeing the ContextLoader error you messaged me about.

mike_smith30100
Champ in-the-making
Champ in-the-making
Hi Pitt,
          Thanks for your code, now deletion is working for me, thanks a ton.

klwalker
Champ in-the-making
Champ in-the-making
When using the webservice CMLDelete method you described to delete nodes, it will just do a soft delete, meaning you could recover that deleted item from the "Manage Deleted Items" section of the web client, correct?  If so, is there a way to mark a document for permanent deletion via the webservice API?

pitt1
Champ in-the-making
Champ in-the-making
I'm not familiar with the "Manage Deleted Items" section of the web client, but I'm guessing it goes against the archive://SpacesStore, which contains deleted items for some period of time.  My guess is that if you want to be able to permanently delete an item, delete it first from workspace://SpacesStore, then from archive://SpacesStore.

klwalker
Champ in-the-making
Champ in-the-making
You were right, after deleting from the workspace store it goes to the archive store and I was able to use the same CMLDelete method to delete from that store afterwards.  Thanks!

klwalker
Champ in-the-making
Champ in-the-making
One question though…once things are deleted from the workspace store, will they ever be automatically deleted from the archive store by the contentStoreCleaner (after protectDays is reached), or does the contentStoreCleaner only delete things that have been deleted from the archive store?  Maybe I don't actually have to bother deleting from the archive store in order for the documents to actually be removed from disk (eventually).