SyncHelloWorld=370001
SyncHelloWorld=370002
BPELInstance.java
package client;
import com.oracle.bpel.client.IBPELDomainHandle;
import com.oracle.bpel.client.IInstanceHandle;
import com.oracle.bpel.client.Locator;
import com.oracle.bpel.client.ServerException;
import com.oracle.bpel.client.util.WhereCondition;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.util.Properties;
import java.util.Scanner;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import oracle.xml.parser.v2.XMLDocument;
import org.w3c.dom.NodeList;
public class BPELInstance {
public static void main(String[] args) throws ServerException,
IOException {
try {
Properties props = new Properties();
WhereCondition whCnd;
String processName;
Locator locator;
int value;
props.setProperty("orabpel.platform", "ias_10g");
props.setProperty("java.naming.factory.initial",
"com.evermind.server.rmi.RMIInitialContextFactory");
props.setProperty("java.naming.provider.url",
"opmn:ormi://hostname:6003:oc4j_soa/orabpel");
props.setProperty("java.naming.security.principal", "oc4jadmin");
props.setProperty("java.naming.security.credentials", "password");
props.setProperty("dedicated.connection", "true");
locator = new Locator("default", "password", props); // Provide the domain name and password
System.out.println("Connected to the Server");
File fFile =
new File("C:\\Zia\\Automation\\Client\\instances.txt");
Scanner scanner = new Scanner(fFile);
IBPELDomainHandle domain = locator.lookupDomain();
while (scanner.hasNextLine()) {
Scanner scanner1 = new Scanner(scanner.nextLine());
scanner1.useDelimiter("=");
if (scanner1.hasNext()) {
processName = scanner1.next();
value = Integer.parseInt(scanner1.next());
//System.out.println("ProcessName = " + processName + " Instance = " + value);
WhereCondition whereProcessId =
new WhereCondition("process_id = ?");
whereProcessId.setString(1, processName);
whCnd = new WhereCondition("cikey = ?");
whCnd.setInt(1, value);
whereProcessId.append("and").append(whCnd);
IInstanceHandle instances[] =
locator.listInstances(whereProcessId);
if (instances != null && instances.length > 0) {
System.out.println("*** Recovering " + processName +
"[" + value + "] ***");
String auditTrail = instances[0].getAuditTrail();
//System.out.println("\n\n"+auditTrail);
XMLDocument xmlDoc =
Utility.getXMLDocumentFromString(auditTrail);
if (xmlDoc != null) {
NodeList nodeList =
xmlDoc.selectNodes("//details[@id]");
if (nodeList != null) {
System.out.println("@@@@@@@@@" +
nodeList.getLength() +
"@@@@@@@@@");
if (nodeList.getLength() > 0) {
System.out.println("### Getting the data from AuditDetails ###");
String auditDetails =
instances[0].getAuditDetails(0);
System.out.println(auditDetails);
} else {
System.out.println("### Getting the data from AuditTrail ###");
XMLDocument xmlDoc1 =
Utility.getXMLDocumentFromString(Utility.getNodeValueByXPath(xmlDoc,
"/audit-trail/event/details/text()"));
NodeList nl =
xmlDoc1.getDocumentElement().getElementsByTagName("part");
StringWriter sw = new StringWriter();
Transformer serializer =
TransformerFactory.newInstance().newTransformer();
serializer.transform(new DOMSource(nl.item(0).getFirstChild()),
new StreamResult(sw));
String result = sw.toString();
System.out.println(result);
}
}
//System.out.println("******************* End Recovery Steps ***********************");
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Output
Connected to the Server
*** Recovering SyncHelloWorld[370001] ***
@@@@@@@@@0@@@@@@@@@
### Getting the data from AuditTrail ###
<?xml version="1.0" encoding="UTF-8"?>
<ns1:SyncHelloWorldProcessRequest xmlns:ns1="http://xmlns.oracle.com/SyncHelloWorld">
<ns1:input>JavaTest</ns1:input>
</ns1:SyncHelloWorldProcessRequest>
*** Recovering SyncHelloWorld[370002] ***
@@@@@@@@@0@@@@@@@@@
### Getting the data from AuditTrail ###
<?xml version="1.0" encoding="UTF-8"?>
<ns1:SyncHelloWorldProcessRequest xmlns:ns1="http://xmlns.oracle.com/SyncHelloWorld">
<ns1:input>OracleSoaTest</ns1:input>
</ns1:SyncHelloWorldProcessRequest>