Manohar
Manohar

Reputation: 39

How to recover deleted data in alfresco share through java?

I am new to alfresco community and i am using alfresco community for Document Management System.

Now my problem is i have deleted one document like as shown below and now i want to recover that data into same in which folder that exist before deletion

Document document = (Document) session.getObjectByPath(filePath);
document.delete();

Please any body help me...

Upvotes: 1

Views: 926

Answers (3)

Arjun
Arjun

Reputation: 634

You can use the java api VersionService(restore), if you know the deleted node.

http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/deleted-nodes/{id}/restore

restore @Auditable(parameters={ "nodeRef", "parentNodeRef", "assocTypeQName", "assocQName" }) NodeRef restore(NodeRef nodeRef, NodeRef parentNodeRef, QName assocTypeQName, QName assocQName) By default a deep restore is performed. Parameters: nodeRef - the node reference to a node that no longer exists in the store parentNodeRef - the new parent of the restored node assocTypeQName - the assoc type qname assocQName - the assoc qname Returns: the newly restored node reference

Upvotes: 1

Lista
Lista

Reputation: 2246

Also, if your node had "sys:temporary" aspect applied, then you are out of luck, that's the equivalent of "shift + delete" in Windows. You could still get it's content from the deleted store on disk, though.

Take a look at this blog post to understand the complete process: https://blyx.com/2014/08/18/understanding-alfresco-content-deletion/

Upvotes: 0

prignony
prignony

Reputation: 121

You can use this:

nodeArchiveService.restoreArchivedNode(NodeRef archivedNodeRef)

To get the archivedNodeRef you can either search it in alfresco database (bad) find it using one of it property under the archive://SpacesStore

new NodeRef(archiveRoot.getStoreRef(),(String)node.get("UUID"))

http://dev.alfresco.com/resource/docs/java/org/alfresco/repo/node/archive/NodeArchiveService.html

If you have the trashcanCleaner up and running, your trashcan is protected 14d by default after that, the node is removed.

An sql query to get node from archive store:

String sql = "SELECT n.id, n.UUID "
            + "FROM alf_node n, alf_store s "
            + "WHERE n.store_id = s.id "
            + "AND s.protocol = 'archive' "
            + "AND n.AUDIT_MODIFIED is not null "
            + "ORDER BY n.id asc ";

Add a few criteria in the where clause on the ALF_NODE_PROPERTIES table and you are set.

Upvotes: 1

Related Questions