Showing posts with label ICN Filters. Show all posts
Showing posts with label ICN Filters. Show all posts

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;

}

}