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(); } } }

Tuesday, March 16, 2021

Creating ROOT Folder and Sub Folders in FileNet Repository using CE JAVA API (IBM FileNet)

Creating Root Folder and Sub Folders


package fnp8api.ceoperations;

public class CreatingFolders{

public static void main(String args[]){

try {
   Connection connection = //Get CE 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() );
   
   Folder newFolder= Factory.Folder.createInstance(objectStore,null);
   Folder rootFolder= objectStore.get_RootFolder(); 
   newFolder.set_Parent(rootFolder);
   newFolder.set_FolderName("NewFolder");
   newFolder.save(RefreshMode.REFRESH);
       
   //Creating Sub folder  
   Folder subFolder1= newFolder.createSubFolder("SubFolder1");
   subFolder1.save(RefreshMode.REFRESH);
	
   Folder subFolder2 = newFolder.createSubFolder("SubFolder2");
   subFolder2.save(RefreshMode.REFRESH);

  } catch (Exception exe) {
  	System.out.println(exe.getMessage());
  	exe.printStackTrace();
  }

}
}

Sunday, March 14, 2021

Deleting Folders from FileNet Repository using CE java API

 Deleting Folders from FileNet

 public void deletingFolders() {  
 
 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 here", null);
  
   String folder= "QSpace/Commercial/2018";
     
   Folder folder= Factory.Folder.fetchInstance(objectStore,folder, null);
   
  //Check for Subfolders
   FolderSet subFolders= folder.get_SubFolders();
   Iterator childFolders = subFolders.iterator();
   while(childFolders.hasNext()){
    
    Folder subFolder = (com.filenet.api.core.Folder) childFolders.next();
    
    String childName = subFolder.get_FolderName();
    S.O.P("Check the subfolder name :"+childName);
    //First delete the subfolders and next delete the root folder
    subFolder.delete();
    subFolder.save(RefreshMode.NO_REFRESH);
    }
   
   folder.delete();
   folder.save(RefreshMode.REFRESH);
   
  } catch (Exception exe) {
	System.out.println(exe.getMessage());
  	exe.printStackTrace();
  }
 }

Saturday, March 13, 2021

FileNet - Setting user Preferences using Process Engine API

 

Setting User Preference


package com.fnp8api.userPreferences;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import javax.security.auth.Subject;
import com.filenet.api.core.Connection;
import com.filenet.api.core.Domain;
import com.filenet.api.core.Factory;
import com.filenet.api.util.UserContext;
import filenet.vw.api.VWSecurityList;
import filenet.vw.api.VWSession;
import filenet.vw.api.VWUserInfo;


public class SettingUserPreferences{

public static void main(String args[])
{
try
{

Connection con= // get the Connecton code from here

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

// Connect to ProcessEngine and get vwSession object 
 VWSession vwSession = new VWSession();

 vwSession.setBootstrapCEURI("your content engine url");
  
 vwSession.logon( "UserName", "password", "Connection Point Name");

 VWSecurityList userList = vwSession.fetchUsers(1000,false);

 while(list.hasNext())
 {
    
	VWUserInfo userInfo = vwSession.fetchUserInfo(userList.next().toString());
    
	userInfo.setEMailAddress(userInfo +"@"+"email domain suffix");
    
 	int notification = VWUserInfo.NOTIFICATION_STEP_EXPIRED_DEADLINE |
 	VWUserInfo.NOTIFICATION_STEP_REMINDERS |
	VWUserInfo.NOTIFICATION_TRACKER_EXPIRED_DEADLINE |
 	VWUserInfo.NOTIFICATION_TRACKER_NEW_ASSIGNMENT |
 	VWUserInfo.NOTIFICATION_STEP_NEW_ASSIGNMENT |
 	VWUserInfo.NOTIFICATION_TRACKER_WORKFLOW_EXCEPTION;

 	userInfo.setNotificationFlags(notification);

 	userInfo.save();
 
 }

}
    
catch(Exception e)
{
    e.printStackTrace();

}
}
}