Saturday, February 27, 2021

FileNet API - Getting an ObjectStore Object


Getting ObjectStore 


        An object store is represented by the ObjectStore class in the Content Engine API.
 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.
  1. Connection Object : Get to the Connection code
  2. Get the Domain Object as shown in 3 rd step.
  3. The Below code is to  Create Object for Object Store,
             Domain domain = Factory.Domain.fetchInstance(connection, null, null);
             ObjectStore objectStore = Factory.ObjectStore.fetchInstance(domain, "your domain name", null);


            Use getInstance or fetchInstance to retrieve an existing instance of an ObjectStore object.
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

ICC - IBM Content Collector -Task Route Email Archiving Task Properties for Microsoft Exchange Server or IBM Domino Server


IBM Content Collector Task Route(Email Archiving) MS Exchange Server

ICC Setting Mail Class Properties in Email Archiving Task

 

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

        }     

 }