Skip to main content

Manipulation Oracle Bpm directory with FDI api

The BPM Directory is an information repository. It stores configuration information about a BPM Environment. This repository is a fundamental component of the BPM Environment; a BPM Environment cannot exist without a BPM Directory. All the users information and organizational unit information maintains on BPM directory. Oracle BPM also provides API named FDI to CRUD operations on these information. For more additional information see here. In this current post, i will provide sample java code which will help to quick start with FDI.
Fdi Api is not public api to use, for these reason only a few reference found on the web. Oracle BPM Standard Components Reference provides most of the information to working with FDI. For example purpose, i will use Bpm Standalone Enterprise server directory.xml. To run standalone client we have to need following libraries on class path:
  • fuegopapi-client.jar
  • b1oracle.jar
  • b1base.jar
  • b1util.jar
  • b1resource.jar

Here is my maven pom.xml file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ru.fors.nsi.bpm.proxy</groupId>
<artifactId>bpmproxy</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>bpmproxy</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>fuego</groupId>
<artifactId>fuegopapi-client</artifactId>
<version>6.5.0</version>
<!--<scope>provided</scope>-->  
</dependency>
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>ejb</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>albpm.jdbc.oracle</groupId>
<artifactId>b1oracle</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>albpm.jdbc.base</groupId>
<artifactId>b1base</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>albpm.util</groupId>
<artifactId>b1util</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
<version>1.1</version>
</dependency>
<!--<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>1.6.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<skip>true</skip>
</configuration>
</plugin>          
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>      
</build>
</project>

Here is my directory.xml, which must be on classpath.
<?xml version="1.0" encoding="UTF-8"?>
<?fuego version="6.5.1" build="94375"?>
<DirectoryConfiguration>
<id>default</id>
<description>Default Directory Configuration</description>
<admin>admin</admin>
<adminPass><encrypted>uPgrjqI482A=</adminPass>
<presets>
<preset name="engine">
<property name="participant" value="admin"/>
<property name="participant_password" value="<encrypted>uPgrjqI482A="/>
</preset>
<preset name="xobjects">
<property name="participant" value="admin"/>
<property name="participant_password" value="<encrypted>uPgrjqI482A="/>
</preset>
<preset name="portal-anonymous">
<property name="participant" value="admin"/>
<property name="participant_password" value="<encrypted>uPgrjqI482A="/>
</preset>
<preset name="datawarehouse">
<property name="participant" value="admin"/>
<property name="participant_password" value="<encrypted>uPgrjqI482A="/>
</preset>
<preset name="papiws-anonymous">
<property name="participant" value="admin"/>
<property name="participant_password" value="<encrypted>uPgrjqI482A="/>
</preset>
</presets>
<set>
<configuration name="fuego" type="SQL" subtype="DDORACLE">
<property name="jdbc.pool.idle_timeout" value="5"/>
<property name="jdbc.pool.entry.max" value="10"/>
<property name="oracle.dateEqualsTimestamp" value="false"/>
<property name="jdbc.host" value="xyz"/>
<property name="user" value="OBPMDirLocal"/>
<property name="jdbc.port" value="1521"/>
<property name="jdbc.pool.min" value="0"/>
<property name="jdbc.pool.maxopencursors" value="100"/>
<property name="oracle.sid" value="ftsdb"/>
<property name="password" value="<encrypted>ko8PrHu2UJLLicio"/>
<property name="jdbc.xa" value="false"/>
<property name="jdbc.pool.max" value="10"/>
</configuration>
</set>
</DirectoryConfiguration>



Next, it's time for java coding
package ru.fors.bpm.client;

import fuego.directory.*;
import fuego.directory.exception.ProtocolNotSupportedException;


import java.util.Properties;

public class FdiClient {
public FdiClient(){}
private static DirectorySession directorySession;
static{
Properties configuration = new Properties();
/*Configuration for Standalone*/
configuration.setProperty( "fuego.custom.replication.config.directoryId", "default");
configuration.setProperty("fuego.custom.replication.config.directoryFile", "directory.xml");
configuration.setProperty("fuego.custom.replication.config.preset", "engine");
try {
DirectoryConfigurationManager.getRuntime("default").setPropertiesFileName(configuration.getProperty("fuego.custom.replication.config.directoryFile").trim());
DirectoryPassport directoryPassport = DirectoryPassport.createWithIDAndPreset(configuration.getProperty("fuego.custom.replication.config.directoryId").trim(), configuration.getProperty("fuego.custom.replication.config.preset").trim());

directoryPassport.fillPassport();

directorySession = Directory.startAdminSession(directoryPassport);

}catch (ProtocolNotSupportedException e) {
e.printStackTrace();
}catch (AuthenticationException e) {
e.printStackTrace();
}catch(DirectoryException e){
e.printStackTrace();
}
}
private void disconnect () throws DirectoryException{
if(directorySession.isConnected()){
directorySession.disconnect();
}
}
private void createParticipant (final String participantName, final String participantDisplayName, final String password) throws Exception{
if(!directorySession.isConnected()){
throw new Exception ("session already closed..");
}
// fetch Role
DirOrganizationalRole nsiRoles = DirOrganizationalRole.fetch(directorySession, "Controller");

fuego.directory.DirHumanParticipant.RoleAssignment role = new DirHumanParticipant.RoleAssignment(nsiRoles.getId(), 255, nsiRoles.getIn());

DirHumanParticipant participant = DirHumanParticipant.create(directorySession,
participantName,
participantDisplayName,
participantName,
participantDisplayName,
"fts@mydomain.com", "", "",
password, DirOrganizationalUnit.fetchRoot(directorySession) , new DirHumanParticipant.RoleAssignment[]{ role } );

System.out.println("Participant create:"+ participant.getStatus());
}
private void changedPassword(final String oldPassWord, final String newPassword) throws Exception{
if(!directorySession.isConnected()){
throw new Exception ("session already closed..");
}
DirHumanParticipant part = DirHumanParticipant.fetch(directorySession, "test23");
part.changePassword(oldPassWord, newPassword);
System.out.println("Status:"+part.getStatus());

}
private DirHumanParticipant getParticipant(final String name) {
if(!directorySession.isConnected()){
throw new Exception ("session already closed..");
}
return DirHumanParticipant.fetch(directorySession, name);
}
public static void main(String[] args) throws Exception{
System.out.println("FDI - connect to Oracle BPM directory Service...");
FdiClient client = new FdiClient();
//client.createParticipant("test23", "test23","123456");
//client.changedPassword("123456","654321");
DirHumanParticipant part =  client.getParticipant("part2");
System.out.println("Status:"+ part.getPermissions());
client.disconnect();
}
}

On the above code permission 255 is a binary mask, from the api reference
Fuego.Fdi.DirHumanParticipant.getPermissionValue would be as follows:
"X" Execute 1
"R" Route 2
"S" Suspend 4
"A" Abort 8
"D" Delegate 16
"G" Grab (re-assign) 32
"E" Escalate 64
"P" Peer assign 128
For example, if you have XEP, then the integer value would be 1 + 64 + 128 = 193, and then all values are XRSADGEP = 255
Additional links:
1) Creating Oracle BPM PAPI Clients
2) Oracle forum thread

Comments

Popular posts from this blog

Apache Ignite deep dive, SQL engine

Apache Ignite  is an open source memory-centric distributed database, caching and comput- ing platform. From the beginning, it was designed as an in-memory data grid for developing a high-performance software system. So, it’s core architecture design is slightly different from the traditional NoSQL databases, which can simplify building modern applications with a flexible data model and simpler high availability, high scalability.     Moreover, to understand how to design application with any databases or framework properly, you must understand the architecture of the database or framework itself. By getting a better idea of the system, you can solve different problems in your enterprise architecture landscape, can select a comprehensive database or framework that is appropriate for your application and get the maximum benefits from the system. In this article we are going to explore the Apache Ignite SQL engine.      Under the hood...

Book review: High Performance in-memory computing with Apache Ignite by Sadruddin Md

A new title  The Apache Ignite book  has been released including Ignite 2.6 and above. Read the full book review by Sadruddin Md .

Quick start with In memory Data Grid, Apache Ignite

UP1: For complete quick start guide, see also the sample chapter of the book "High performance in-memory computing with Apache Ignite" here . Even you can find the sample examples from the GitHub repository . IMDG or In memory data grid is not an in-memory relational database, an NoSQL database or a relational database. It is a different breed of software datastore. The data model is distributed across many servers in a single location or across multiple locations. This distribution is known as a data fabric. This distributed model is known as a ‘shared nothing’ architecture. IMDG has following characteristics: All servers can be active in each site. All data is stored in the RAM of the servers. Servers can be added or removed non-disruptively, to increase the amount of RAM available. The data model is non-relational and is object-based.  Distributed applications written on the platform independent language. The data fabric is resilient, allowing non-disruptive au...