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
- BAW / WFPS
- FileNet
- Java editor
PREREQUISITE
- BAW is installed
- FileNet is installed
- BAW can access FileNet system via external service
- Java editor and JDK 8 or higher
- Maven is installed to create jar file (We can use different setup as well to create jar file)
STEPS
- Create java maven project
- 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;
}
}
}
- 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) {
}
}
- Go to root directory and run below maven command to create jar
mvn clean;
mvn install;
- Open workflow process in BA Studio
- Go to Files Server Files
7. Select Jar file and upload the jar
- Create External Service
- Select First option to create service using java
- Create java service using server file
- Create a service flow and connect external service we just created
- 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
- Run and verify
JARS USED
REFERENCES
- https://www.ibm.com/docs/en/filenet-p8-platform/5.5.x?topic=extensions-tag-class
- https://www.ibm.com/docs/en/baw/20.x?topic=systems-working-document-content