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

Tip: SQL client for Apache Ignite cache

A new SQL client configuration described in  The Apache Ignite book . If it got you interested, check out the rest of the book for more helpful information. Apache Ignite provides SQL queries execution on the caches, SQL syntax is an ANSI-99 compliant. Therefore, you can execute SQL queries against any caches from any SQL client which supports JDBC thin client. This section is for those, who feels comfortable with SQL rather than execute a bunch of code to retrieve data from the cache. Apache Ignite out of the box shipped with JDBC driver that allows you to connect to Ignite caches and retrieve distributed data from the cache using standard SQL queries. Rest of the section of this chapter will describe how to connect SQL IDE (Integrated Development Environment) to Ignite cache and executes some SQL queries to play with the data. SQL IDE or SQL editor can simplify the development process and allow you to get productive much quicker. Most database vendors have their own fron...

8 things every developer should know about the Apache Ignite caching

Any technology, no matter how advanced it is, will not be able to solve your problems if you implement it improperly. Caching, precisely when it comes to the use of a distributed caching, can only accelerate your application with the proper use and configurations of it. From this point of view, Apache Ignite is no different, and there are a few steps to consider before using it in the production environment. In this article, we describe various technics that can help you to plan and adequately use of Apache Ignite as cutting-edge caching technology. Do proper capacity planning before using Ignite cluster. Do paperwork for understanding the size of the cache, number of CPUs or how many JVMs will be required. Let’s assume that you are using Hibernate as an ORM in 10 application servers and wish to use Ignite as an L2 cache. Calculate the total memory usages and the number of Ignite nodes you have to need for maintaining your SLA. An incorrect number of the Ignite nodes can become a b...

Load balancing and fail over with scheduler

Every programmer at least develop one Scheduler or Job in their life time of programming. Nowadays writing or developing scheduler to get you job done is very simple, but when you are thinking about high availability or load balancing your scheduler or job it getting some tricky. Even more when you have a few instance of your scheduler but only one can be run at a time also need some tricks to done. A long time ago i used some data base table lock to achieved such a functionality as leader election. Around 2010 when Zookeeper comes into play, i always preferred to use Zookeeper to bring high availability and scalability. For using Zookeeper you have to need Zookeeper cluster with minimum 3 nodes and maintain the cluster. Our new customer denied to use such a open source product in their environment and i was definitely need to find something alternative. Definitely Quartz was the next choose. Quartz makes developing scheduler easy and simple. Quartz clustering feature brings the HA and...