//Deleting Sub Folders and Root Folder in CE
public void deleteCEFolder(Connection conn) { //FileNet CE Connection
try {
Domain domain = Factory.Domain.fetchInstance(conn, null, null);
ObjectStore objStore = Factory.ObjectStore.fetchInstance(domain,"OSNAME", null);
System.out.println("Object Store ="+ objStore.get_DisplayName() );
String folder= "/NewFolder";
com.filenet.api.core.Folder folderOj= Factory.Folder.fetchInstance(objStore,folder, null);
System.out.println("del"+folderOj.get_Name());
FolderSet subFolders= folderOj.get_SubFolders();
Iterator it = subFolders.iterator();
while(it.hasNext()){
com.filenet.api.core.Folder subFolder= (com.filenet.api.core.Folder) it.next();
String name = ((com.filenet.api.core.Folder) subFolder).get_FolderName();
System.out.println("Subfolder = "+name);
//1. First Delete sub folders
subFolder.delete();
subFolder.save(RefreshMode.NO_REFRESH);
System.out.println("Subfolder = "+name+" is Deleted");
}
//2. Delete Root folder
folderOj.delete();
folderOj.save(RefreshMode.REFRESH);
System.out.println("Root Folder "+folderOj + "is Deleted");
} catch (Exception e) {
e.printStackTrace();
}
}
public void deleteCEFolder(Connection conn) { //FileNet CE Connection
try {
Domain domain = Factory.Domain.fetchInstance(conn, null, null);
ObjectStore objStore = Factory.ObjectStore.fetchInstance(domain,"OSNAME", null);
System.out.println("Object Store ="+ objStore.get_DisplayName() );
String folder= "/NewFolder";
com.filenet.api.core.Folder folderOj= Factory.Folder.fetchInstance(objStore,folder, null);
System.out.println("del"+folderOj.get_Name());
FolderSet subFolders= folderOj.get_SubFolders();
Iterator it = subFolders.iterator();
while(it.hasNext()){
com.filenet.api.core.Folder subFolder= (com.filenet.api.core.Folder) it.next();
String name = ((com.filenet.api.core.Folder) subFolder).get_FolderName();
System.out.println("Subfolder = "+name);
//1. First Delete sub folders
subFolder.delete();
subFolder.save(RefreshMode.NO_REFRESH);
System.out.println("Subfolder = "+name+" is Deleted");
}
//2. Delete Root folder
folderOj.delete();
folderOj.save(RefreshMode.REFRESH);
System.out.println("Root Folder "+folderOj + "is Deleted");
} catch (Exception e) {
e.printStackTrace();
}
}
No comments:
Post a Comment