Friday, December 31, 2021
Read the content of a PDF file using Java API
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() )
{
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
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(); } } }
dependent objects. This may give exception in case if the user dont have requisite permissions to delete the document or dependent objects.
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();
}
}
}
Saturday, February 27, 2021
FileNet API - Getting an ObjectStore Object
Getting ObjectStore
You can use static methods on the Factory inner classes to create instances of ObjectStore.
Use createInstance to create a new instance of an ObjectStore object.
The pattern for getting an ObjectStore is as follows -
ObjectStore
- Get a Connection object.
- Get a Domain object.
- Get an ObjectStore object.
- Connection Object : Get to the Connection code
- Get the Domain Object as shown in 3 rd step.
- The Below code is to Create Object for Object Store,
The difference between these two methods is that getInstance does not verify the existence of the requested object on the server; it returns a local reference to the object, which is not affiliated with a server object until you perform a function on the object.
The fetchInstance method, however, immediately makes a round trip to the server to retrieve the property values of the ObjectStore object.
Friday, February 26, 2021
FileNet API - Creating a new Document Class using Java CE API
Creating a new Class
This code will create a Document sub Class in a Class, The class which we give in fetchInstance will become a super class for the newly created class
Connection connection = // get the connection object from here
Subject subject = UserContext.createSubject(connection, "******", "******", null);
UserContext.get().pushSubject(subject);
Domain domain = Factory.Domain.fetchInstance(connection, null, null);
ObjectStore os = Factory.ObjectStore.fetchInstance(domain, "your domain name", null);
String className = "your new class name";
ClassDefinition cd = Factory.ClassDefinition.fetchInstance(os, "your main class name",null);
//com.filenet.api.admin.ClassDefinition
System.out.println(cd.get_DisplayName());
ClassDefinition subClassDef = cd.createSubclass();
LocalizedString localstr = Factory.LocalizedString.createInstance();
localstr.set_LocalizedText(className);
localstr.set_LocaleName(os.get_LocaleName());
subClassDef.set_DisplayNames(Factory.LocalizedString.createList());
subClassDef.get_DisplayNames().add(localstr);
subClassDef.set_SymbolicName("symbolicname_"+ className.replace(" ", ""));
subClassDef.set_DescriptiveTexts(Factory.LocalizedString.createList());
subClassDef.get_DescriptiveTexts().add(localstr);
subClassDef.save(RefreshMode.REFRESH);
Tuesday, February 23, 2021
Working with Documents : Create a Document in FileNet using Java CE API
Creating a Document
This code creates a document in object store with Document class and file in a folder using Referential Containment Relationship
// Write the connection code here or click here to get the connection code
Domain domain = Factory.Domain.fetchInstance(connection, null, null);
ObjectStore os = Factory.ObjectStore.fetchInstance(domain, "your object store name", null);
Document doc = Factory.Document.createInstance(os, ClassNames.DOCUMENT);
doc.getProperties().putValue("DocumentTitle", "Your Document Title");
doc.set_MimeType("text/plain");
StorageArea sa = Factory.StorageArea.getInstance(os, new Id("{********-****-****-****-************}"));
doc.set_StorageArea(sa);
doc.save(RefreshMode.NO_REFRESH);
doc.checkin(AutoClassify.DO_NOT_AUTO_CLASSIFY,
CheckinType.MAJOR_VERSION);
doc.save(RefreshMode.NO_REFRESH);
get the folder object where you want to place the newly created document
Folder folder = Factory.Folder.getInstance(os, ClassNames.FOLDER,new Id("{********-****-****-****-************}") );
The below code will place the document in the folder
ReferentialContainmentRelationship rcr = folder.file(doc,
AutoUniqueName.AUTO_UNIQUE, "Adding New Document with Java Code",
DefineSecurityParentage.DO_NOT_DEFINE_SECURITY_PARENTAGE);
rcr.save(RefreshMode.NO_REFRESH);
Tuesday, February 16, 2021
Lotus domino's script to move mails form one folder to another based on conditions
Lotus domino's script to move mails from one folder to another based on conditions
//Below LotusScript agent move mails to specified
folder
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim document As NotesDocument
Set db = session.CurrentDatabase
Set view = db.GetView( "($Sent)" )
Messagebox "The view is set to sent items"
Dim folder As String
folder = "ICCArchive/Sent Items"
Set document = view.GetFirstDocument
If document.HasItem("Subject") Then
While Not(document Is Nothing)
Forall subject In document.GetItemValue("Subject")
If subject Like "financial*" Then
Messagebox subject
Call document.PutInFolder(folder)
End If
End Forall
Set document = view.GetNextDocument(doc)
End While
End If
End Sub
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, February 3, 2021
FileNet- PE API - Java code to Connect Process Engine(Creating vw session object )
FileNet Process Engine API
\\Connecting to Process Engine using PE API
public VWSession getVWSession(){
try{
vwSession=new VWSession(); \\Creating VWSession Object
vwSession.setBootstrapCEURI("<your content engine url>");
vwSession.logon("userName", "password", connectionPointObject);
return vwSession;
}
catch(Exception e){
e.printStackTrace();
}
return null;
}
Tuesday, February 2, 2021
Java - Send email using java program ( javax.mail API)
Java Mail API
public static sendMail() {
//sending email using java code using javax.mail api
Properties props = new Properties();
props.put("mail.smtp.host", "MailHost");
props.put("mail.smtp.port", "MailHostPort");
props.put("mail.smtp.auth", "true");
final String user = "EmailUsername";
final String password = "Password";
String to = "EmailToAddress";
String from = "EmailFromAddress";
Session session = Session.getInstance(props,
new javax.mail.Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user, password);
}
});
try {
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(user));
message.addRecipient(Message.RecipientType.TO,to);
message.setSubject("Mail Subject any text");
MimeBodyPart messageBodyPart1 = new MimeBodyPart();
messageBodyPart1.setContent("mail content in html fromat or text", "text/html");
MimeBodyPart messageBodyPart2 = new MimeBodyPart();
DataSource source1= new FileDataSource(new File("attachment path if required"));
messageBodyPart2.setDataHandler(new DataHandler(source1));
messageBodyPart2.setFileName(doctitle);
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart2);
multipart.addBodyPart(messageBodyPart1);
message.setContent(multipart);
Transport.send(message);
} catch (MessagingException ex) {
ex.printStackTrace();
}
}
Wednesday, January 27, 2021
FileNet and Ldap connectivity - java code to get Active Directory Connection
//Connecting to LDAP using java code
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;
dirContext = new InitialDirContext(environment);
FileNet - Fetch the users and all attributes from Active Directory and AD Connection and setting all environment variables for AD
Connecting to Active Directory
ArrayList getListValues(){
// Connect to the Active Directory here or click here for Connection code
ArrayList list = new ArrayList();
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());
}
}
}
return list;
}
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;
}
}
IBM Case Manager script - Select User Dialog box on Filed Focus event - to select user from the list of LDAP Users (ecm.widget.dialog.SelectUserGroupDialog)
if(payload.eventName === "icm.FieldFocused"){
if(payload.id === "PRX_Name")
{
callback = function(users){
this.propController.set("value", users[0].shortName);
};
var selectUserDialog = new ecm.widget.dialog.SelectUserGroupDialog({
queryMode: "users",
selectionMode :"single",
callback: dojo.hitch(this,callback)
});
selectUserDialog.show(solution.getTargetOS());
}
}
FileNet Dojo Script in ACCE -Set List values to String List object (multi cardinality object values) - com.filenet.api.collection.StringList
importClass(Packages.com.filenet.api.property.Properties);
importClass(Packages.com.filenet.api.constants.RefreshMode);
importClass(Packages.com.filenet.api.collection.StringList);
function OnCustomProcess (CEObject)
{
CEObject.refresh();
var list =new Packages.com.filenet.api.core.Factory.StringList.createList();
var values = CEObject.getProperties().getStringValue("City").split(";");
for (var l = 0; l < values.length; l++) {
list.add(values[l]);
}
CEObject.getProperties().putObjectValue("StatesList",list);
CEObject.save(RefreshMode.REFRESH);
}
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);
}
-
Creating a Document This code creates a document in object store with Document class and file in a folder using ...
-
FileNet Content Engine Connection A Connection is a fairly lightweight class. It tells the API how to connect to the Content Eng...
-
IBM Filenet Request and Response Filters public class OpenContentClassFilter extends PluginResponseFilter { public String[] getFilteredSer...