Sunday, 23 November 2014

Design Entry Template in FileNet (FileNet Content Engine)

Users can easily add documents, folders, and custom objects to an object store using entry templates. Entry templates also make it easy to define approval workflows for these objects. For example, a manufacturing company’s template designer can create a set of entry templates for the various types of engineering specifications that are managed in the object store. The entry templates in this example predefine the document class, all property values except the document title, the access rights, and an approval workflow. When using the entry template to add a document to the object store, a user interacts with a wizard, which decreases the chance of invalid data entry by limiting the number of steps required and providing a more controlled entry process. Entry templates are created in Workplace, typically by a relatively small set of users, and are used by a much larger number of users. Some of the key capabilities of entry templates and advantages to using them are as follows:
Documents, folders, form data, and custom objects can be created with entry templates.
  • Users who are not administrators can create entry templates. For example, a project manager can create the entry templates used by her project team.
  • Entry templates support FileNet P8 records management by providing a simplified and customizable method of declaring a document as a record.
  • Entry templates can specify the folder in which the object will be filed, can either prevent or allow the user to change the folder, and can restrict the user to selecting a particular folder or its subfolders.
  • Default property values can be specified in an entry template, and the template designer can elect to show or hide each property to users of the template.
  • Entry templates can specify whether a document should be added as a major or minor version and can specify whether a user can change this setting.
  • Entry templates can be set up to automatically classify the document based on its content.
  • Entry templates can specify the access rights for the object, and the designer can elect to hide or show the access rights for the user to modify.
  • Entry templates can serve as placeholders for documents that a user provides while processing a workflow step. When the user clicks on the entry template in the Workplace step processor, the entry template wizard prompts the user to add a document and the new document replaces the entry template attachment.
  • Entry templates support specifying a workflow that will be launched when the user creates an object with the template, whether the workflow is a simple approval workflow that is defined in the entry template wizard or any other workflow created using Process Designer. For workflows created using the entry template wizard, the user can choose from a workflow with three steps—review, approve, and publish—or one with multiple, sequential approval steps. The template designer can specify the participants in advance, or let the user do so when using the template.  

Entry templates make it easy for users to add documents, folders and custom objects to an object store. Entry templates also make it easy to define approval workflows for these objects.
Below are the steps to create a Entry Template.
 
Steps :

1. Go to Workplace XT --> Advanced Tools --> Entry Templates --> Add

2. Select Document Entry Template or Folder Entry Template



3. Select Object Store and Folder (define the destination path where the new object is added )


4. (Optional)

Select the display option for the Select Folder step in the add wizard. 
  • To permit users to change the location when adding an object, select Show Select Folder step. This option is selected by default.
  • To prevent users from changing the location, select Hide Select Folder step.

5. Click on Next 
 
6. Select Class
 
 
 

7. Optional: Click Order Class properties to change the order in which the properties are displayed in the entry template.




8. Select the Required check box next to the property name if the user must enter a value for a property.

9. In the Default Value field, type any preset value.
 
10. Select the Access Level for each property. The access level determines what the end user can do with a property when adding an object

Editable  Allows the user to edit the property value
Read Only  Displays the property and value, but the value cannot be changed.
Hide  Does not display the property
Hide/Editable  Does not display the property, but the value can be changed pro-grammatically



11. Specify whether to add the object a compound document.
 
12. Specify whether to add the object as a major version.
 
13. Specify whether to allow users to add documents with the same file name. The Allow duplicate names setting is only supported on Workplace XT
 
14. Specify whether users see the properties when adding a new object.  
 
To permit users to view or change the preset property values, select Show Set Properties step. This option is selected by default 
 
To hide all the property names and values, select Hide Set Properties step. Do not choose this option if you marked any properties as required and didn't set a default value





15. Click on Next.

16. Add Users and Groups(Who can access Entry Template).



17. Click on Next and Select Work flow, properties. 

18. Click on Next.

19. Select Folder (Where you store the Entry Template) and Click on NEXT
 
 

12. Add Entry Template Name


13. Add (Set Security)  Users and Groups (Who can Modify the Entry Template)


14. Click on Finish 

******Entry Template Created*********

Configure Work Queue in FileNet (FileNet Process Engine)

---Configure Work Queue in FileNet (FileNet Process Engine)

A work queue holds work items that can be processed by one of a number of users or by an automated process.

In Process Configuration Console, you create and configure work queues as appropriate for your applications. For each queue, you can specify security for the queue, which determines who can see and process items in the queue, and you can expose data fields and create indexes to facilitate searching for items in the queue.


--Steps to Configure

Steps

//Process Configuration Console
1. Goto Workplace XT --> Tools --> Administration --> Process Configuration Console

2. Select on Connection Point and Click on Connect
 



3. Right Click on Work Queue and click on New..


 4. Enter Queue Name and click on Create




 5. Click on Commit (Save Queue) and Work Queue created Successfully


 
 6. If you want to add users and groups in work Queue, Right click on work queue and go to Properties..
 
 
 
 7. Go to Security tab and add users and groups (add users and groups to Right Side Layout)
 


 8. Commit Changes

 
 

Friday, 21 November 2014

Configure Component Queue in FileNet (FileNet Process Engine)

---Configure Component Queue in FileNet (FileNet Process Engine)

Component queues make it possible to process a workflow step by using an external entity, such as a Java object or Java Message Service (JMS).

By using Process Configuration Console, you configure a component queue with an adapter, either Java or JMS. The Java adapter allows you to expose public methods from a Java class as operations on a queue. The JMS adapter enables you to publish workflow data to a JMS queue, also by using operations. By using Process Designer, the workflow author adds a component step to a map and selects operations for that step from the list of component queues. The workflow author also specifies the appropriate expression for each operation parameter.


--Steps to Configure

Required Tools  

1. Process Configuration Console (PCC) Configuartion
2. Application Engine Process Task Manager (AE PTM) Configuration

Steps

//Process Configuration Console

1. Goto Workplace XT --> Tools --> Administration --> Process Configuration Console

2. Select on Connection Point and Click on Connect  


3.Right Click on Component Queue. and Click on New




4.Enter Queue Name


5. Click on Next


6.  Click on Configure..


7. Select JAR File 
8. Select Main Class File and Click on OK



9. Fill the JAAS Credentials as shown below and Click on OK


10. Right Click on Component, you created and go to Operation


11. Select Required Methods (Functions) and Click on OK






12. Commit Changes 






//Application Engine Process Task Manager (AE PTM)


13. Go to Installed-Path/FileNet/WebClient/Router

Open routercmd (PTM)



 14. Disconnect (Stop) Connection Point (Same as you installed Component Queue)




 15. Go to Required Libraries  tab and add Component JAR and Support JAR and Support file paths.
(Note : It allows JAR files and Folder Path only. If you have *.properties files, add it's parent folder only).





  



16. Click on Apply and Start Connection point


**********Component Queue configured Successfully*****************

Thursday, 20 November 2014

Add Case Comments in Case Client (IBM Case Manager API)

//Add Case Comments in Case Client (IBM Case Manager API)

public void addCaseCommentInHistory() throws Exception {
            String caseFolderGUID = //GUID of Case Folder
            String comment = "Hi"
            CaseMgmtContext oldCmc = null;
            log.info("Inside [WorkFlowHoldUnholdServices]addCaseComment():.............");
            ICMManager icmManager=new ICMManager();
            Connection conn=null;
            DomainReference domainRef=null;
            ObjectStoreReference osRef=null;
            Folder folder=null;
            try{
                conn=// Establish Connection

                if(conn!=null){
                    domainRef=ICMManager.getDomainReference(conn);
                    if(domainRef!=null){
                        osRef=ICMManager.getTargetOSReference(domainRef, fnObjectStoreName);
                        if(osRef!=null){
                            // retrieve case folder
                            folder = Factory.Folder.fetchInstance(osRef.getFetchlessCEObject(), caseFolderGUID, null);
                            // retrieve case using GUID
                            Id folderGUID = folder.get_Id();
                            Case cs = Case.getFetchlessInstance(osRef, folderGUID);
                            cs.addCaseComment(CommentContext.CASE, comment);
                            cs.save(RefreshMode.REFRESH, null, ModificationIntent.MODIFY);
                            log.info("History updated in Case");
                           
                        }else{
                            log.info("History Not updated As Target OS Ref is NULL");
                        }
                    }   
                }       
            }catch (Exception e) {
                log.error("addCaseCommentInHistory(String, String) - exception:"+ e,e); //$NON-NLS-1$
                e.printStackTrace();               

            }                    
        }               
             




//for connection please click on below link

IBM Case Manager API (fetch P8Connection, Domain, Target Obbject Store)


  

Dispatch Work Item in FileNet Process Engine (Process Engine API)

   
    //Fetch the Work Item
    VWWorkObject vwWorkObj=null;
      try{
          VWRoster roster=peSession.getRoster(rosterName);
          int queryFlags=VWRoster.QUERY_NO_OPTIONS;
          String Name = "abcd";
          String filter="Doc_Name="+Name;//Change Accrordigly (Based on Process Administaration tool fields)
             
          VWRosterQuery query=roster.createQuery(null, null, null, queryFlags, filter, null, VWFetchType.FETCH_TYPE_WORKOBJECT);
          log.info("Total records for Work ITem: "+query.fetchCount());
         
          while(query.hasNext()){
              vwWorkObj=(VWWorkObject) query.next(); 
          }
         
      }catch(VWException vwe){
          log.error("Exception found at PEManager.getVWWorkObject():"+vwe,vwe);
          vwe.printStackTrace();
      }catch(Exception vwe){
          log.error("Exception found at PEManager.getVWWorkObject():"+vwe,vwe);
          vwe.printStackTrace();
      }
     
//Terminate(Dispatch) work Item
try{

if(vwWorkObj!=null){

String Response = "Cancel";
VWStepElement vwStepObj=vwWorkObj.fetchStepElement();
vwStepObj.doLock(true);
vwStepObj.setSelectedResponse(Response);

vwStepObj.doDispatch();
}else{
                           
log.info("VWWorkObject is NULL");
                       
}
                       
}catch(Exception ex){
                           
ex.printStackTrace();
                       
}   

Tuesday, 18 November 2014

Build URL of Document in FileNet (Content Engine API)

//Build URL of Document in FileNet (Content Engine API)



//The below code generates the URL of Document. The URL works on same Browser where you run the code else it asks Credentials

public void opendoc() throws IOException
    {
        String baseP8URL = "http://localhost:9080/WorkplaceXT/";
        String user = //User Name
        String password = //Password
        //String objectStore = //Object Store Name
        String docID = //GUID of Document
        //Get Connection
        //Get Domain
        objectStore = //Get Object Store
        com.filenet.api.core.Document doc=com.filenet.api.core.Factory.Document.fetchInstance(objectStore, docID, null);
        String vsId = doc.get_VersionSeries().get_Id().toString();
       
        // Call WorkplaceXT’s setCredentials servlet to obtain user token
        try {
       
        URL url = new URL(baseP8URL +
        "setCredentials?op=getUserToken&userId="
        + user + "&password=" + password + "&verify=true");
        HttpURLConnection p8con =
        (HttpURLConnection) url.openConnection();
        p8con.setRequestMethod("POST");
        p8con.connect();
        InputStream in = p8con.getInputStream();
        int c = -1;
        String tempUserToken = "";
        while ( (c=in.read()) >= 0) tempUserToken +=
        new Character((char)c).toString();
                String userToken = URLEncoder.encode(tempUserToken, "UTF-8");
                System.out.println("the user token "+userToken);
                String strURL = baseP8URL + "getContent?objectStoreName="
                + "Target" + "&vsId=" + vsId + "&objectType=document&ut=" //
                + userToken + "&impersonate=true";
        System.out.println("ssss"+ strURL);
        }
        catch (Exception e )
        {
            e.printStackTrace();
        }
               
    }

View Content (Attachment) in FileNet Document (Content Engine API)

//View Content (Attachment) in FileNet Document (Content Engine API)


        ceConnection = //Get Connection
        domain = //Get Domain
        objectStore = //Get Object Store
       
        InputStream inputStream=null;
        try
        {
        FileInputStream is=null;
       
        System.out.println("inside fetchdoc Filenet----------------------------");
        ArrayList[] ars=new ArrayList[2];
        SearchScope search=new SearchScope(objectStore);
       
        String sql1= "Select * from [DocClass_Test] where ([DocumentTitle]= '"+DocTitle+"')";
        SearchSQL searchSQL=new SearchSQL(sql1);
        DocumentSet documents=(DocumentSet)search.fetchObjects(searchSQL, Integer.getInteger("50"), null, Boolean.valueOf(true));
        Document doc;
        Iterator it=documents.iterator();
       
        System.out.println("calling FileInputStream");
        while(it.hasNext())
        {
            doc=(Document)it.next();
            ContentElementList contents = doc.get_ContentElements();
              ContentTransfer ct;
              Iterator itContent = contents.iterator();
              while(itContent.hasNext()) {
                  ct = (ContentTransfer)itContent.next();
              inputStream = ct.accessContentStream();
              int bufferLength = 64*1024; // buffer size (64KB)
                byte[] buffer = new byte[bufferLength];
                int read=0;
              
                DataOutputStream out = new DataOutputStream(response.getOutputStream());
                System.out.println("calling while-- check");
                while((read=inputStream.read(buffer))!=-1)
                {
                    out.write(buffer,0,read);                 
                }
               
                out.close();
   
        }     
        }
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

Monday, 17 November 2014

Send Mail with multiple TO address and with Rich HTML Text

//Send Mail with multiple TO address and with Rich HTML Text

                    String from = abc@abcc.com
                  logger.debug("From Address :" +from);
                 
                  String[] to = "abcd@gmail.com,bcda@yahoo.com, xyzaa@gmail.com,vbgjg@hotmail.com";
                  String[] temp_to;
                  String delimeter = ",";
                  temp_to = to.split(delimeter);
                  for(int i =0; i < temp_to.length ; i++){
                      System.out.println(temp_to[i]);
                      System.out.println("");
                      }
                  logger.debug("To Address :"+to);
                  String host = "localhost";
                  logger.debug("SMTP Server IP Address :"+host);

                 
                  try{
                  //Session
                  Properties properties = System.getProperties(); 
                  properties.setProperty("mail.smtp.host", host); 
                  Session session = Session.getDefaultInstance(properties);
                              
                  //logger.info("Session ="+session);
                  logger.debug("Session object is created :"+session);
                 
                 
                  //Mail Part
                  MimeMessage message = new MimeMessage(session);
                  Multipart multipart = new MimeMultipart();
                  message.setFrom(new InternetAddress(from));
                  InternetAddress[] recipientAddress = new InternetAddress[temp_to.length];
                  int counter = 0;
                  for (String recipient : temp_to) {
                      recipientAddress[counter] = new InternetAddress(recipient.trim());
                      counter++;
                  }
                 // message.setRecipients(message.RecipientType.TO, recipientAddress);
                  message.setRecipients(javax.mail.Message.RecipientType.TO, recipientAddress);
                  message.setSubject("Document Uploaded:Need Approval");
                  logger.debug("Subject is created");
                 
                  BodyPart messageBodyPart = new MimeBodyPart();
         
                  String body = "<i>Dear Sir/Madam,</i><br>";
                  body += "<br><br><b>**********************ABCD**********************</b><br>";
                  body += "<br><font color=black>Sample Mail from p8programmer.</font><br>";
                  body += "<br><br><b><font color=red>Details:</font></b><br>";
                  body += "<br><table border=1><tbody>";
                  body += "<tr><td width=150 valign=top class=emailcontent style=padding:8px;>From</td><td width=200 valign=top class=emailcontent style=padding:8px;><b>"+from+"</b></td></tr>";
                  body += "<tr><td width=150 valign=top class=emailcontent style=padding:8px;>To</td><td width=200 valign=top class=emailcontent style=padding:8px;><b>"+to+"</b></td></tr>";
                  body += "</tbody></table><br><br><br>";
                  body += "<tr><td bgcolor=black height=5></td></tr>";
                  body += "<tr> <td style=padding:10px; class=emailcontent><br>Thanks &amp;Regards <br/>";
                  body += "<strong><i><font color=blue>p8programmer</font></i></strong></td>";
                  body += "<br><br></tr>";
                  body += "<td style=padding:10px; class=emailcontent>***************************************************************************************************************<br>";
                
               
                 
                  messageBodyPart.setContent(body,"text/html");
                  multipart.addBodyPart(messageBodyPart);
                 
                                  
                  logger.debug("...Body Part Created...");
                  message.setContent(multipart);
                  Transport.send(message);
                 
                  //logger.info("message sent successfully....");
                  logger.info("......Message sent successfully.....");
                  }
                  catch (MessagingException mex) {
                      mex.printStackTrace();
                      logger.error("Exception occured while sending mail :"+mex);
                  }

Send EMail reminder from Excel spreadsheet (Read TO Address from Excel sheet)

Description:  
Sending automatic mail from java code based on Date of births

1. Read Data from Excel sheet

2. Compare Date of Birth and Current Date
3. Fetch Name and mail Address  based on Date of birth and Current date (If equal)
4. Send mail to particular person (Send Mail with random images) with help of above deatils


Note :

Excel sheet content : (Date Format US English (mm/dd) )




 //Read Excel sheet compare Date of Birth and Current Date

package sample;

import java.io.File;
import java.io.IOException;

import jxl.Cell;
import jxl.CellType;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

import java.util.Calendar;
import java.util.GregorianCalendar;

import java.util.*;


public class ReadExcel {

 
  private String inputFile;
  public ArrayList<String> items = new ArrayList();

 
  public void setInputFile(String inputFile) {
    this.inputFile = inputFile;
  }

  public void read() throws IOException  {
    File inputWorkbook = new File(inputFile);
    Workbook w;
    try {
      w = Workbook.getWorkbook(inputWorkbook);
      // Get the first sheet
      Sheet sheet = w.getSheet(0);
      // Loop over first 10 column and lines

      for (int j = 0; j < sheet.getColumns(); j++) {
        for (int i = 0; i < sheet.getRows(); i++) {
          Cell cell = sheet.getCell(j, i);
          CellType type = cell.getType();
          
               
          if (type == CellType.DATE) {
              if( GetDate().equals(cell.getContents()))
                 
                      {
                 
                  System.out.println("Date Matched");
                 
                  System.out.println("Current Date "+GetDate());
                 
                  Cell a2 = sheet.getCell(j-1,i);
                //  name = a2.getContents();
                  items.add(a2.getContents());
                 
                 
                  Cell a1 = sheet.getCell(j+1,i);
                 // email = a1.getContents();
                  items.add(a1.getContents());
                    
                  System.out.println("Name  :" + a2);
                  System.out.println("Email  :"+ a1);
                     System.out.println("I got a Date " + cell.getContents());                
                 
            }else
            {
                System.out.println("Date not matched with current date");
            }
          }
         
           

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

 String GetDate(){
     int day, month;
     String CurrentDate;
     GregorianCalendar date = new GregorianCalendar();

     day = date.get(Calendar.DAY_OF_MONTH);
     month = date.get(Calendar.MONTH);
     CurrentDate = (month+1)+"/"+day;
 
     System.out.println("Current date is  " +CurrentDate);

    return CurrentDate;
     
  }
  public static void main(String[] args) throws IOException {
    ReadExcel test = new ReadExcel();
   // test.setInputFile("C:/Users/IBM_ADMIN/Documents/sample.xls");
    //test.GetDate();
    test.read();
    Iterator itr= test.items.iterator();
    while(itr.hasNext())
    {
        System.out.println("Name :" + itr.next() + "\n Email :" + itr.next());
 
    }
   
  }

}



//Sending Mail with Random Images 

package sample;

import java.io.IOException;
import java.util.*; 

import javax.mail.*; 
import javax.mail.internet.*; 
import javax.activation.*; 

import sample.ReadExcel;
 
public class SendEmail extends ReadExcel  

 public static void main(String [] args) throws IOException {
   
     
   
      String from = "abcde@gmail.com";//change accordingly
   
      String host = "127.0.0.1";//or IP address 
     
     
 
     //Get the session object 
      Properties properties = System.getProperties(); 
      properties.setProperty("mail.smtp.host", host); 
      Session session = Session.getDefaultInstance(properties); 
   
      String charsetNum = "123456789";
      StringBuffer image=new StringBuffer("images");
      ReadExcel test = new ReadExcel();
      test.setInputFile("C:/Users/IBM_ADMIN/Documents/sample.xls");
      test.GetDate();
      test.read();
      for(Iterator itr = test.items.iterator(); itr.hasNext();)
      {
          String name = (String)itr.next();
          String mail = (String)itr.next();
          String cc= (String) itr.next();
          System.out.println((new StringBuilder("Name :")).append(name).append("\n Email :").append(mail).append("\n CC :").append(cc).toString());
          try
          {
              java.util.Random rand = new java.util.Random(System.currentTimeMillis());

              for (int n = 1; n <2; n++) {
                  int pos = rand.nextInt(charsetNum.length());
                  image.append(charsetNum.charAt(pos));
              }
             
              String randomImageName = image.toString();
              System.out.println("randomImageName- "+randomImageName);
             
             
           
              MimeMessage message = new MimeMessage(session);
              message.setFrom(new InternetAddress(from));
              message.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(mail));
              message.addRecipient(javax.mail.Message.RecipientType.CC, new InternetAddress(cc));
              message.setSubject("Wishing you a Very Happy Birthday -"+name);
             
              MimeMultipart multipart = new MimeMultipart();
              BodyPart messageBodyPart = new MimeBodyPart();
                                        
              String htmlText = "<H2 style=\"font-family:Calibri;color:red;\">Wishing you a Very Happy Birthday.. !!**.."+name+"..**!!</H2>";
              messageBodyPart.setContent(htmlText, "text/html");               
             
              multipart.addBodyPart(messageBodyPart);
            
             
              messageBodyPart = new MimeBodyPart();
              String cntent1 = "<H3 style=\"font-family:Calibri;color:green;\"><br><br>Wishes you for Healthy Long Life...</H3>";
              messageBodyPart.setContent(cntent1,"text/html");
              multipart.addBodyPart(messageBodyPart);
             
              messageBodyPart = new MimeBodyPart();
              String cntent2 = "<H4 style=\"font-family:Calibri;color:red;\"><br><br>From ABC.</H4><br><img src=\"cid:image\"><br><br>" +
                      "PLEASE DO NOT REPLY TO ALL!!!!<br><br><b>AA PMO TEAM</b>";
              messageBodyPart.setContent(cntent2, "text/html");               
              multipart.addBodyPart(messageBodyPart);               
             
              messageBodyPart = new MimeBodyPart();
              javax.activation.DataSource fds1 = new FileDataSource("C:/Users/IBM_ADMIN/Pictures/"+randomImageName+".jpg");
              messageBodyPart.setDataHandler(new DataHandler(fds1));
              messageBodyPart.addHeader("Content-ID", "<image>");
              multipart.addBodyPart(messageBodyPart);
             
             
              message.setContent(multipart);
              Transport.send(message);
              System.out.println("message sent successfully....");
          }   

        catch (MessagingException mex) {mex.printStackTrace();} 
         
   
      }
     
 
     //compose the message 
     
   }