Monday, March 22, 2021

Document Operations - Deleting a Document from FileNet Repository using Java CE API

Deleting a Document

The below code will delete the document. Deleting the document deletes the document object itself, internal content and all its corresponding annotations and other
dependent objects. This may give exception in case if the user dont have requisite permissions to delete the document or dependent objects.

package fnp8api.ceoperations; public class DeleteDocument{ public static void main(String args[]){ try { Connection connection = // Get the Connection code from here Domain domain = Factory.Domain.fetchInstance(connection, null, null); ObjectStore objectStore = Factory.ObjectStore.fetchInstance(domain,"your os name", null); System.out.println("Object Store : "+ objectStore.get_DisplayName() ); Document document = Factory.Document.getInstance(objectStore, ClassNames.DOCUMENT, new Id("{A03A3EF2-6Y42-1L91-7IAD-A21DA1D5DB85}") ); document.delete(); document.save(RefreshMode.NO_REFRESH); } catch (Exception exe) { System.out.println(exe.getMessage()); exe.printStackTrace(); } } }

No comments:

Post a Comment