Showing posts with label IBM Content Navigator. Show all posts
Showing posts with label IBM Content Navigator. Show all posts

Sunday, May 2, 2021

Updating Bullk Documents properties using Event Action Handler

Document Operations - Updating Document Properties with Folder Properties using EventActionHandler 


public class UpdateDocumentProperties implements EventActionHandler

{

@Override

public void onEvent(ObjectChangeEvent event, Id arg1) throws EngineRuntimeException 

{

try{  

ObjectStore os = event.getObjectStore();  

Id id = event.get_SourceObjectId(); System.out.println(" *Your Event Action Call Started *");  

Folder folder = Factory.Folder.fetchInstance(os, id, null);  

DocumentSet docList =  folder.get_ContainedDocuments();  

Iterator docItr = docList.iterator();  

while (docItr.hasNext() )

{  

Document doc = (Document) docItr.next(); doc.getProperties().putValue("Your_SymbolicName", folder.getProperties().get("Your_SymbolicName").getInteger32Value()); doc.getProperties().putValue("Your_SymbolicName", folder.getProperties().get("Your_SymbolicName").getStringValue()); doc.getProperties().putValue("Your_SymbolicName", folder.getProperties().get("Your_SymbolicName").getDateTimeValue()); doc.save(RefreshMode.NO_REFRESH); 
}catch(Exception e){
  e.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();
  }

}
}

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

}
}
}

Monday, February 15, 2021

IBM FileNet custom logger -Configuring Fnlog4j.properties

IBM FileNet : Configuring fnlog4j.properties for logger


Copy the sample fnlog4j.properties.sample file form \IBM\FileNet\ContentEngine\tools\PE\samples

And Place the bellow code in the fnlog4j.properties file



log4j.appender.MYAPPLICATION=org.apache.log4j.DailyRollingFileAppender

log4j.appender.MYAPPLICATION.layout=org.apache.log4j.PatternLayout

log4j.appender.MYAPPLICATION.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss,SSS} %5p %c: %L - %m%n

log4j.appender.MYAPPLICATION.File=mydrive/IBM/WebSphere/AppServer/profiles/AppServer/myserverabc/ComponentLogs/javacomplog.txt

log4j.appender.MYAPPLICATION.Append=true


log4j.logger.myapplogger=ALL, MYAPPLICATION


Copy the fnlog4j.properties file to :    - \IBM\WebSphere\AppServer\java\jre\lib

And use the bellow code in java project 


import filenet.vw.base.logging.Logger;

this.logger=Logger.getLogger("myapplogger");

Wednesday, January 27, 2021

ICN Plug-in Filter for Retrieving Users from LDAP and displaying in Property as a Choice List Object (IBM Content Navigator Plugins and Filters)


IBM Filenet Request and Response Filters


public class OpenContentClassFilter extends PluginResponseFilter {

public String[] getFilteredServices() {

return new String[] { "/p8/openContentClass" };

}

public void filter(String serverType, PluginServiceCallbacks callbacks,

HttpServletRequest request, JSONObject jsonResponse) throws Exception {

JSONArray jsonprops = (JSONArray) jsonResponse.get("criterias");

for(int i =0; i<jsonprops.size();i++){

JSONObject jobject = (JSONObject) jsonprops.get(i);

String str  = (String) jobject.get("name");

if(str.equals("CmAcmRuleType")){

JSONObject newchlist = new JSONObject();

newchlist.put("displayName", "listofadusers");

JSONArray jarry = new JSONArray();

ArrayList list = getListValues();

for(int j = 0; j<list.size();j++){

JSONObject item = new JSONObject();

item.put("value", list.get(j));

jarry.add(item);

}

newchlist.put("choices", jarry);

jobject.put("choiceList", newchlist);

}

}

}

ArrayList getListValues(){

String rootDN = "CN=xyz,CN=xyz,DC=xyz,DC=xyz";

        String rootPWD = "*****";

        Hashtable<String, String> environment = new Hashtable<String, String>();

        environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");

        environment.put(Context.PROVIDER_URL, "<ldapurl>");

        environment.put(Context.SECURITY_AUTHENTICATION, "authentications type");

        environment.put(Context.SECURITY_PRINCIPAL, rootDN);

        environment.put(Context.SECURITY_CREDENTIALS, rootPWD);

        DirContext dirContext = null;

        NamingEnumeration<?> results = null;

        ArrayList list = new ArrayList();

        try{

        dirContext = new InitialDirContext(environment);

        SearchControls searchctrl = new SearchControls();

        searchctrl.setSearchScope(SearchControls.SUBTREE_SCOPE);

        searchctrl.setReturningAttributes(new String[]{"name or id"}); \\ attributes which we are retriving from AD

        results = dirContext.search("", "(objectclass=user)", searchctrl);

        while(results.hasMore()){

        SearchResult res = (SearchResult) results.next();

        Attributes attributes = res.getAttributes();

        Enumeration attribute = attributes.getAll();

        while(attribute.hasMoreElements()){

        Attribute attr = (Attribute) attribute.nextElement();

        if(!attr.toString().equals("") && !attr.toString().equals(null)){

        list.add(attr.toString());

        }

        }       

          }       

        }catch(Exception exe){

        System.out.println("Exception occured : "+exe.getLocalizedMessage());

        }                

return list;

}

}

FileNet ACCE Script to set Retention period on CE objects (Documents or Folders) - Packages.com.filenet.api.property.Properties

IBM FileNet ACCE Script to set Retention period on CE objects


importClass(Packages.com.filenet.api.property.Properties); 

importClass(Packages.com.filenet.api.constants.RefreshMode); 

function OnCustomProcess (CEObject) 

CEObject.refresh(); 

CEObject.set_CmRetentionDate(new Date(new Date().getTime()-4)); 

CEObject.save(RefreshMode.REFRESH); 

}