Cloud Pak for Business Automation

 View Only

Tagging Documents in FileNet system using BAW flow

By SHWETKETU RAI posted Tue September 20, 2022 10:11 AM

  

OBJECTIVE

BAW content toolkit does not provide the capability to tag a document stored in FileNet system.

Objective of this technical recipe is to help developer to achieve document tagging using BAW service flow

TECHNICAL COMPONENT

  1. BAW / WFPS
  2. FileNet
  3. Java editor

PREREQUISITE

  1. BAW is installed
  2. FileNet is installed
  3. BAW can access FileNet system via external service
  4. Java editor and JDK 8 or higher
  5. Maven is installed to create jar file (We can use different setup as well to create jar file) 

STEPS

  1. Create java maven project
  2. Create ConnectionECM.java

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;
public class ConnectionECM {
private ConnectionECM(){}
private static Connection conn;
public static Connection getConnection(String uri,String username,String password){
if(conn == null){
conn = Factory.Connection.getConnection(uri);
Subject subject = UserContext.createSubject(conn, username, password, null);
UserContext.get().pushSubject(subject);
Domain domain = Factory.Domain.getInstance(conn, null);
return conn;
}else{
return conn;
}
}
}

 

  1. Create ‘Tag.java’
import com.filenet.api.core.Domain;
import com.filenet.api.core.Factory;
import com.filenet.api.core.ObjectStore;
import com.filenet.api.util.Id;
import com.filenet.api.constants.ClassNames;
import com.filenet.api.constants.RefreshMode;
import com.filenet.api.core.CmAbstractPersistable;
import com.filenet.api.core.Connection;
import com.filenet.api.core.Document;
public class Tag {
public void tagDocuemnt(String uri, String username, String password, String docID, StringtagValueString, String objectStore) {
Connection conn = ConnectionECM.getConnection(uri, username, password);
Domain domain = Factory.Domain.getInstance(conn, null);
ObjectStore os = Factory.ObjectStore.fetchInstance(domain, objectStore, null);
CmAbstractPersistable tag = Factory.CmAbstractPersistable.createInstance(os, "ClbTag");
Document documentObj = Factory.Document.getInstance(os, ClassNames.DOCUMENT, new Id(docID));
tag.getProperties().putValue("ClbTagValue", tagValueString);
tag.getProperties().putObjectValue("ClbTaggedDocument", documentObj);
tag.save(RefreshMode.REFRESH);
}
public static void main(String[] args) {
}
}

 

  1. Go to root directory and run below maven command to create jar
mvn clean;
mvn install;
  1. Open workflow process in BA Studio

 

  1. Go to Files Server Files

7. Select Jar file and upload the jar


  1. Create External Service

  1. Select First option to create service using java

 

  1. Create java service using server file

  1. Create a service flow and connect external service we just created

  1. Select the operation and do the Data Mapping

 Operation: tagDocument

Data Mapping:
tw.local.Parameter1 – uri
tw.local.Parameter2 – username
tw.local.Parameter3 – password
tw.local.Parameter4 -  docID
tw.local.Parameter5 -  tagValueString
tw.local.Parameter6 -  objectStore

 

  1. Run and verify

 

JARS USED

REFERENCES

  1. https://www.ibm.com/docs/en/filenet-p8-platform/5.5.x?topic=extensions-tag-class
  2. https://www.ibm.com/docs/en/baw/20.x?topic=systems-working-document-content
1 comment
48 views

Permalink

Comments

Fri February 16, 2024 06:12 AM

How to achieve the BAW access to FileNet system. I am getting the following error 

Details: "Access to the Content Engine was not allowed because the Content Engine API library or the Web Service Interface (WSI) Listener could not find the required security context information. Expected credentials were not found in the security context.".