Tuesday, May 13, 2014

ADF page for creating MDS Deployment Utility for Oracle SOA


The base for this post is following post in Oracle.

This document points out how exactly you can deploy the artifacts in to MDS using ant script.

In this exercise we will see how we can use the idea in this to create a web page for deploying artifacts to MDS.

Looking in to the ant code you can figure out that the only parameter which are required at run time are following

Username,password,host,port and URL.

The idea behind this post is to pass all these details dynamically at run time from the ADF page and rest all of the things are a one time set activity.

So you can develop a page to get these details



As soon as you will click on deploy button the bean at the back end will create a property file and write all these data to a property file.

public String to_deploy() {

String result = System.out.toString();
//transformer.
File file = new File("Buildconfig.properties");
RichInputText userText = getUserName();
RichInputText pwdText = getPassword();
RichInputText HostText = getHostName();
RichInputText PortText = getPortNumber();
RichInputText ServerURL = getServerURL();
String user = userText.getValue().toString();
String pwd = pwdText.getValue().toString();
String host = HostText.getValue().toString();
String port = PortText.getValue().toString();
String serverurl= ServerURL.getValue().toString();
//System.out.println(workingDir + "/Buildconfig.properties");
/////////////

Properties prop = new Properties();
OutputStream output = null;


try {
if (!file.exists()) {
file.createNewFile();
}
output = new FileOutputStream(file);
prop.setProperty("dev.user", user);
prop.setProperty("dev.password", pwd);
prop.setProperty("dev.server", host);
prop.setProperty("dev.port", port);
prop.setProperty("dev.serverURL",serverurl);
prop.store(output, null);
userText.resetValue();
PortText.resetValue();
HostText.resetValue();
pwdText.resetValue();

} catch (IOException e) {
e.printStackTrace();
}
display.setValue(result.toString());
AntDeploy dep = new AntDeploy();
System.out.println("Executed"+dep.executeAntTask("build.xml", "myTarget"));

return null;
}

You can use the following post to call the ant script from JAVA

Now once the file is written to the location the ant script is called which again read and overwrite the existing properties with the user values passed.Include the new property file thus created in your build.xml so that it can now refer to the new values.

<available file="build.properties" property="file.exists" value="true"/>

The problem with this code is that you will have to copy the build.properties file in the server domain.

So you need to create and batch file to first copy the properties and build.xml file in to the domain.

this works fine in a single node but for a cluster node it may need to fine tune as managed servers will have different domain home.

No comments: