Document Deleting¶
Document Deleting¶
1ot = impact.gui.output_toolbox
2db = impact.active_database
3
4
5_STATUS_AS_STRING_MAP = {
6 ipDocumentStatus.dsNormal: "Normal",
7 ipDocumentStatus.dsDeleted: "Deleted",
8 ipDocumentStatus.dsDataPurged: "DataPurged",
9}
10
11def status_as_string(status):
12 return _STATUS_AS_STRING_MAP.get(status, "Unknown")
13
14
15ot.clear()
16
17
18# WARNING: This script will permanently delete the document specified below
19
20# You can search for a document ID or document series ID
21# When seaching for a document series ID the latest document version is returned
22# document_id = "e1b1ad95-f9de-40c0-9d08-0fee87e8a011"
23document_id = "c3752e5a-6d50-4cfa-8508-58922e2dd212"
24
25document = db.find_document_by_id(document_id)
26
27if not document.isNone():
28 ot.add("Found document with status: " + str(status_as_string(document.status)))
29
30 # can delete a document with normal status
31 if document.can_delete:
32 if document.delete():
33 ot.add("Successfully deleted the document")
34 else:
35 ot.add("Failed to delete the document")
36
37 ot.add("New document status: " + str(status_as_string(document.status)))
38
39 # can undelete a document that was previously deleted (but not yet purged)
40 if document.can_undelete:
41 if document.undelete():
42 ot.add("Successfully undeleted the document")
43 else:
44 ot.add("Failed to undelete the document")
45
46 ot.add("New document status: " + str(status_as_string(document.status)))
47
48 # delete the document again (after undelete)
49 if document.can_delete:
50 if document.delete():
51 ot.add("Successfully deleted the document")
52 else:
53 ot.add("Failed to delete the document")
54
55 ot.add("New document status: " + str(status_as_string(document.status)))
56
57 # data purge the document
58 if document.can_purge:
59 if document.purge():
60 ot.add("Successfully purged the document file data")
61 else:
62 ot.add("Failed to purge the document file data")
63
64 ot.add("New document status: " + str(status_as_string(document.status)))
65
66 # finally obliterate the document
67 if document.can_obliterate:
68 if document.obliterate():
69 ot.add("Successfully obliterated the document")
70 else:
71 ot.add("Failed to obliterate the document")
72
73 # the IDocument interface is no longer valid at this point
74
75else:
76 ot.add("Unable to find the document with ID '" + str(document_id) + "'")