Friday, July 14, 2023

How to get folder Name from doc id in filenet?

 

            public static void main(String[] args) {

                        String uri = <MTOM Url>

                        String username = user id;

                        String password = password;

                        String objectStoreName = osSymbolicName

 

                      String docId = "{1233-213-214-324-4-32423424}";

 

                        Connection conn = Factory.Connection.getConnection(uri);

                        Subject subject = UserContext.createSubject(conn, username, password, <jazzname>);

                        UserContext.get().pushSubject(subject);

                        Domain domain = Factory.Domain.fetchInstance(conn, null, null);

                UserContext.get().pushSubject(UserContext.createSubject(conn, username, password, null));

                ObjectStore objectStore = Factory.ObjectStore.fetchInstance(domain, objectStoreName, null);

 

                                                // Fetch the source document

Document doc= Factory.Document.fetchInstance(objectStore, docId ,null);

                                                FolderSet folders = doc.get_FoldersFiledIn();

                                                Properties props= doc.getProperties();

                                                if (folders != null & !folders.isEmpty()) {

                                                            Folder folder = (Folder) folders.iterator().next();

                                                            System.out.println("Folder Name " + folder.get_FolderName());

}