Friday, November 25, 2011

Some of the utilities used for the Oracle SOA Suite 10g to 11g Migration.

Some of the utilities used for the Oracle SOA Suite 10g to 11g Migration.

I thought of sharing the pre and post migration utilities, we had used in our project.
Hope this may help somebody looking for the migration utilities.


The below java program helps us to remove the space in the preference name(bpel file and bpel.xml) used in 10g code base before starting the migration, the migration will fails if there is any empty spaces in the preference name.
import java.util.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.xpath.*;
import org.w3c.dom.*;
public class MigrationTask {
public MigrationTask() { }
static FilenameFilter filterPreferences = new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.equals("bpel.xml");
static FilenameFilter bpelProcess = new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.matches(".*.bpel");

//Remove the empty spaces in the preference name in bpel.xml and
//chanage corresponding preference name in bpel file
public static void updatePreferences(String baseDir) throws Exception {
File[] fileList =
listFilesAsArray(new File(baseDir), filterPreferences, true);
for (int i = 0; i < fileList.length; i++) {
DocumentBuilderFactory docBuilderFactory =
File f = fileList[i];
String fileName = f.getAbsolutePath();
// System.out.println(fileName);
Document document =
String bpelFolder =
fileName.substring(0, fileName.lastIndexOf("\\"));
NodeList nodeList =
executeXPath(document, "//preferences/property");
File[] fileListBpel =
listFilesAsArray(new File(bpelFolder), bpelProcess, false);
for (int j = 0; j < nodeList.getLength(); j++) {
Node node =
String preferenceValue = node.getNodeValue();
if (isSpaceAvilable(preferenceValue) &&
fileListBpel.length > 0) {
String newpreferenceValue =
preferenceValue.replaceAll(" ", "");
replaceStringInFile(fileListBpel[0], preferenceValue,
newpreferenceValue, "Pre");
Source source = new DOMSource(document);
File file = new File(fileList[i].getAbsolutePath());
Result result = new StreamResult(file);
Transformer xformer =
xformer.setOutputProperty(OutputKeys.INDENT, "yes");
xformer.transform(source, result);
public static NodeList executeXPath(Document doc, String xpathStr) {
XPath xpath = null;
NodeList value = null;
try {
XPathFactory xpathFactory = XPathFactory.newInstance();
xpath = xpathFactory.newXPath();
XPathExpression expr = xpath.compile(xpathStr);
value = (NodeList)expr.evaluate(doc, XPathConstants.NODESET);
return value;
} catch (XPathExpressionException e) {
System.err.println("Exception while processing xpath ::" +
} catch (Exception e) {
System.err.println("Exception while processing xpath ::" +
return null;
public static boolean isSpaceAvilable(String preference) {
return preference.contains(" ");
public static void main(String[] args) throws Exception {
if (args[1].equals("updatePreferences")) {
public static File[] listFilesAsArray(File directory,
FilenameFilter filter,
boolean recurse) throws Exception {
Collection<File> files = listFiles(directory, filter, recurse);
File[] arr = new File[files.size()];
return files.toArray(arr);
public static Collection<File> listFiles(File directory,
FilenameFilter filter,
boolean recurse) throws Exception {
Vector<File> files = new Vector<File>();
File[] entries = directory.listFiles();
for (File entry : entries) {
if (filter == null || filter.accept(directory, entry.getName())) {
if (recurse && entry.isDirectory()) {
files.addAll(listFiles(entry, filter, recurse));
return files;
public static void replaceStringInFile(File file, String searchText,
String replaceText,
String replacementtype) {
try {
FileInputStream fstream = new FileInputStream(file);
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String fileName = file.getAbsolutePath();
String strLine;
StringBuffer sb = new StringBuffer();
while ((strLine = br.readLine()) != null) {
// if(strLine.contains(searchText)){
Pattern p = Pattern.compile(searchText);
Matcher m = p.matcher(strLine);
if (m.find()) {
strLine = strLine.replace(searchText, replaceText);
FileOutputStream fos = new FileOutputStream(fileName);
BufferedWriter out = new BufferedWriter(new FileWriter(fileName));
String outText = sb.toString();
} catch (Exception e) { //Catch exception if any
System.err.println("Error: " + e.getMessage());

java MigrationTask <10g codebase location > updatePreferences


The below ant script will help us to change the custom xpath package import, changing the Base64Decoder/Encoder class and changing the common schema reference to oramds.
The setTitle method used in 10g will be changed to setCompositeInstanceTitle - the title set by setTitle method in 11g can't be used in em console to track the instance.


<?xml version="1.0" encoding="iso-8859-1"?>
<project name="migrationTask" default="Migration" basedir=".">
<property environment="env"/>
<target name="Migration">
<replace dir="${CodeBaseDir}" token="" value="oracle.fabric.common.xml.xpath">
<include name="**/*.java"/>
<replace dir="${CodeBaseDir}" token="com.collaxa.common.util.Base64Decoder" value="oracle.soa.common.util.Base64Decoder">
<include name="**/*.bpel"/>
<replace dir="${CodeBaseDir}" token="http://host:port/orabpel/xmllib/Schemas/Common1.xsd" value="oramds:/apps/EAIMetaData/schemas/Common1.xsd">
<include name="**/*.xsd"/>
<include name="**/*.wsdl"/>
<replace dir="${CodeBaseDir}" token="http://host:port/orabpel/xmllib/Schemas/Common2.xsd" value="oramds:/apps/EAIMetaData/schemas/Common2.xsd">
<include name="**/*.xsd"/>
<include name="**/*.wsdl"/>
<replace dir="${CodeBaseDir}" token="setTitle" value="setCompositeInstanceTitle">
<include name="**/*.bpel"/>

Use the below comment to execute the script

ant -buildfile MigrationTaskes.xml –DcodeBaseDir <Migrated Codebase>

Ant script to migrate the DVM to 11g format:


<project name="Rename" basedir="." default="rename">
<target name="rename">
<move todir="D:\11g\DVM " includeemptydirs="false">
<fileset dir="D:\10g\DVM">
<include name="**/*.xml"/>
<mapper type="glob" from="*.xml" to="*.dvm"/>
<target name="to11G">
<fileset dir=" D:\11g\DVM " id="dvm">
<include name="**/*.dvm" />
<replaceregexp match="isNew=&quot;true&quot;" replace="xmlns=&quot;;">
<fileset refid="dvm" />

<replaceregexp match="isNew=&quot;null&quot;" replace="xmlns=&quot;;">
<fileset refid="dvm" />


Use the below comment to execute the script - Change the DVM path before executing the script.

ant -buildfile MigrateDVM.xml rename
ant -buildfile MigrateDVMxml to11G

No comments:

Post a Comment