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

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...

Analyse with ANT - a sonar way

After the Javaone conference in Moscow, i have found some free hours to play with Sonar . Here is a quick steps to start analyzing with ANT projects. Sonar provides Analyze with ANT document to play around with ANT, i have just modify some parts. Here is it. 1) Download the Sonar Ant Task and put it in your ${ANT_HOME}/lib directory 2) Modify your ANT build.xml as follows: <?xml version = '1.0' encoding = 'windows-1251'?> <project name="abc" default="build" basedir="."> <!-- Define the Sonar task if this hasn't been done in a common script --> <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml"> <classpath path="E:\java\ant\1.8\apache-ant-1.8.0\lib" /> </taskdef> <!-- Out-of-the-box those parameters are optional --> <property name="sonar.jdbc.url" value="jdbc:oracle:thin:@xyz/sirius.xyz" /> <property na...

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...