The new Java Project is created as AUD_CIOps.
The Package and Class outlines used are as follows.
Package: com.ibm.filenet.ps.ciops
Class AUDOperations (void)
==========================
Variables:
JMSsession: Session
JMSconnection: Connection
connFactory:ConnectionFactory
messageString: String
dLookup: String
logger: Logger
session: Session
connection: Connection
Methods
=======
AUDOperations() (Constructor)
getConnection():Connection
getVWSession():VWSession
getDatabaseConnection(): Connection
getFolderFromAttachment(VMAttachment):Folder (Private)
getDocumentFromAttachment(VWAttachment): VWAttachment[]:Document (Private)
getObjectStore(String):ObjectStore (Private)
getFolderDocuments(VWAttachment):VWAttachment[] (Public)
getContainedDocuments(Folder):DocumentSet (Private)
getContainedDocumentsPropertyFilter():PropertyFilter (Private)
getAsVWAttachment(Document):VWAttachment (Private)
sendJMSMessage(VWAttachment,String):void (Public)
putMsg(Destination,String):void (Private)
Listing 3-3The specification for the AUDOperations Component Integrator code module
The code for the CELoginModule Class, working at FileNet P8 5.5.x, is listed at the following link:
www.ibm.com/docs/fr/filenet-p8-platform/5.5.x?topic=performers-celoginmodule-class
A Jar file is created to test the base compilation and functionality.
The Java code created is as follows.
package com.ibm.filenet.ps.ciops;
import java.security.AccessController;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Set;
//JMS packages
import javax.jms.*;
import javax.naming.*;
import javax.naming.directory.*;
import java.util.Hashtable;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.TextMessage;
import javax.jms.Topic;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.naming.Context;
import javax.naming.directory.InitialDirContext;
import javax.naming.ldap.InitialLdapContext;
import javax.security.auth.Subject;
import com.filenet.api.collection.DocumentSet;
import com.filenet.api.constants.PropertyNames;
import com.filenet.api.core.Connection;
import com.filenet.api.core.Document;
import com.filenet.api.core.Domain;
import com.filenet.api.core.EntireNetwork;
import com.filenet.api.core.Factory;
import com.filenet.api.core.Folder;
import com.filenet.api.core.ObjectStore;
import com.filenet.api.property.FilterElement;
import com.filenet.api.property.PropertyFilter;
import com.ibm.filenet.ps.ciops.database.DatabasePrincipal;
import com.ibm.mq.MQC;
import com.ibm.mq.MQEnvironment;
import com.ibm.mq.MQMessage;
import com.ibm.mq.MQPutMessageOptions;
import com.ibm.mq.MQQueueManager;
import com.ibm.mq.constants.CMQC;
import com.ibm.mq.constants.MQConstants;
import com.ibm.mq.jms.MQConnectionFactory;
import com.ibm.mq.jms.MQQueue;
import filenet.vw.api.VWAttachment;
import filenet.vw.api.VWAttachmentType;
import filenet.vw.api.VWException;
import filenet.vw.api.VWLibraryType;
import filenet.vw.api.VWSession;
import filenet.vw.base.logging.Logger;
//Import JMS related packages
/**
* Alan S. Bluck – 26th June 2022
* AUD JMS Message sender Component Integrator code for AUDOperations
*
*
*/
public class AUDOperations {
javax.jms.Session JMSsession = null;
javax.jms.Connection JMSconnection = null;
javax.jms.ConnectionFactory connFactory = null;
String messageString = null;
String dLookup = “cn=AUDQAR”; // Generic JMS Destination
private static Logger logger = Logger.getLogger( AUDOperations.class );
//JMS Variables
static Session session = null; // JMS Session
static Connection connection = null; // JMS Connection
public AUDOperations() {
//java.sql.Connection databaseConnection = getDatabaseConnection();
//if ( databaseConnection != null ) {
// logger.debug( databaseConnection.toString() );
//} else {
logger.debug( “No database connection” );
//}
}
protected Connection getConnection() {
String uri = System.getProperty(“filenet.pe.bootstrap.ceuri”);
return Factory.Connection.getConnection(uri);
}
protected VWSession getVWSession() throws VWException {
String connectionPoint = System.getProperty(“filenet.pe.cm.connectionPoint”);
return new VWSession(connectionPoint);
}
protected java.sql.Connection getDatabaseConnection() {
Subject subject = Subject.getSubject( AccessController.getContext() );
Set<DatabasePrincipal> principals = subject.getPrincipals( DatabasePrincipal.class );
if ( principals != null && ! principals.isEmpty() ) {
DatabasePrincipal principal = principals.iterator().next();
return principal.getConnection();
}
return null;
}
private Folder getFolderFromAttachment(VWAttachment folderAttachment) {
ObjectStore objectStore = getObjectStore( folderAttachment.getLibraryName() );
Folder folder = (Folder) objectStore.getObject(“Folder”, folderAttachment.getId() );
return folder;
}
private Document getDocumentFromAttachment(VWAttachment documentAttachment) {
ObjectStore objectStore = getObjectStore( documentAttachment.getLibraryName() );
Document folder = (Document) objectStore.getObject(“Document”, documentAttachment.getId() );
return folder;
}
private ObjectStore getObjectStore( String objectStoreName ) {
Connection connection = getConnection();
EntireNetwork entireNetwork = Factory.EntireNetwork.fetchInstance(connection, null);
Domain domain = entireNetwork.get_LocalDomain();
return Factory.ObjectStore.getInstance( domain, objectStoreName );
}
/**
* Returns the documents filed in the folder.
*
* @param folderAttachment the input folder.
* @return an array of documents filed in the folder.
* @throws Exception
*/
public VWAttachment[] getFolderDocuments(VWAttachment folderAttachment ) throws Exception {
Folder folder = getFolderFromAttachment(folderAttachment);
DocumentSet containedDocuments = getContainedDocuments(folder);
Iterator<?> iterator = containedDocuments.iterator();
ArrayList<VWAttachment> containedDocumentList = new ArrayList<VWAttachment>();
while ( iterator.hasNext() ) {
Document document = (Document) iterator.next();
VWAttachment documentAttachment = getAsVWAttachment(document);
containedDocumentList.add( documentAttachment );
}
return containedDocumentList.toArray( new VWAttachment[0] );
}