Wednesday 21 December 2011

Adding and removing files To and from MDS in SOA 11g

In this post we will see how can we add and remove files to MDS through ant script files.
First we have to create folder structure in ${wn.bea.home}\jdeveloper\integration\seed\soa [Ex: apps\Saileshan1\Saileshan2\ABC.wsdl]

${wn.bea.home}\jdeveloper\integration\seed\soa folder is the home folder for MDS repository.
By default we will see configuration and shared folder here.

Now create a folder with name (any location our wish) Saileshan1 and place properties file, build.xml and .cmd file in this folder.

Now we have to give mds.applications value as Saileshan1

build.properties file:

# global
wn.bea.home=D:\Jdeveloper1113
oracle.home=${wn.bea.home}/jdeveloper
java.passed.home=${wn.bea.home}/jdk160_18
wl_home=${wn.bea.home}/wlserver_10.3
# temp
tmp.output.dir=c:/temp
mds.reposistory=D:/Jdeveloper1113/jdeveloper/integration/seed/soa/apps/
mds.applications=Saileshan1
mds.undeploy=true
deployment.plan.environment=dev
# dev deployment server weblogic
dev.serverURL=http://localhost:8001
dev.overwrite=true
dev.user=weblogic
dev.password=welcome1
dev.forceDefault=true
# acceptance deployment server weblogic
acc.serverURL=http://localhost:8001
acc.overwrite=true
acc.user=weblogic
acc.password=welcome1
acc.forceDefault=true

build.xml file:

<?xml version="1.0" encoding="iso-8859-1"?>
<project name="soaDeployAll" default="deployMDS">
    <echo>basedir ${basedir}</echo>
    <property environment="env"/>
    <echo>current folder ${env.CURRENT_FOLDER}</echo>
    <property file="${env.CURRENT_FOLDER}/build.properties"/> 
    <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
    <target name="unDeployMDS">
        <echo>undeploy MDS</echo>
        <foreach list="${mds.applications}" param="mds.application" target="undeployMDSApplication" inheritall="true" inheritrefs="false"/>
    </target>
    <target name="deployMDS">
        <echo>undeploy and deploy MDS</echo>
        <if>
          <equals arg1="${mds.undeploy}" arg2="true"/>
          <then>
            <foreach list="${mds.applications}" param="mds.application" target="undeployMDSApplication" inheritall="true" inheritrefs="false"/>
          </then>
        </if>
        <foreach list="${mds.applications}" param="mds.application" target="deployMDSApplication" inheritall="true" inheritrefs="false"/>
    </target>
    <target name="deployMDSApplication">
        <echo>deploy MDS application ${mds.application}</echo>
        <echo>Directory ${mds.reposistory}</echo>
        <echo>remove and create local MDS temp</echo>
        <property name="mds.deploy.dir" value="${tmp.output.dir}/${mds.application}"/>
   
        <delete dir="${mds.deploy.dir}"/>
        <mkdir dir="${mds.deploy.dir}"/>
        <echo>create zip from file MDS store </echo>
      <zip destfile="${mds.deploy.dir}/${mds.application}_mds.jar" compress="false">
        <fileset dir="${mds.reposistory}" includes="**"/>
      </zip>
        <echo>create zip with MDS jar</echo>
      <zip destfile="${mds.deploy.dir}/${mds.application}_mds.zip" compress="false">
        <fileset dir="${mds.deploy.dir}" includes="*.jar"/>
      </zip>
        <propertycopy name="deploy.serverURL"    from="${deployment.plan.environment}.serverURL"/>
        <propertycopy name="deploy.overwrite"    from="${deployment.plan.environment}.overwrite"/>
        <propertycopy name="deploy.user"         from="${deployment.plan.environment}.user"/>
        <propertycopy name="deploy.password"     from="${deployment.plan.environment}.password"/>
        <propertycopy name="deploy.forceDefault" from="${deployment.plan.environment}.forceDefault"/>
        <echo>deploy MDS app</echo>
        <echo>deploy on ${deploy.serverURL} with user ${deploy.user}</echo>
        <echo>deploy sarFile ${mds.deploy.dir}/${mds.application}_mds.zip</echo>
        <echo>Oracle Home: ${oracle.home}</echo>
        <ant antfile="D:/Jdeveloper1113/jdeveloper/bin/ant-sca-deploy.xml" inheritAll="false" target="deploy">
             <property name="wl_home" value="${wl_home}"/>
           <!--  <property name="oracle.home" value="${oracle.home}"/>-->
             <property name="serverURL" value="${deploy.serverURL}"/>
             <property name="user" value="${deploy.user}"/>
             <property name="password" value="${deploy.password}"/>
             <property name="overwrite" value="${deploy.overwrite}"/>
             <property name="forceDefault" value="${deploy.forceDefault}"/>
             <property name="sarLocation" value="${mds.deploy.dir}/${mds.application}_mds.zip"/>
        </ant>
    </target>
    <target name="undeployMDSApplication">
        <echo>undeploy MDS application ${mds.application}</echo>
       <propertycopy name="deploy.serverURL"    from="${deployment.plan.environment}.serverURL"/>
        <propertycopy name="deploy.overwrite"    from="${deployment.plan.environment}.overwrite"/>
        <propertycopy name="deploy.user"         from="${deployment.plan.environment}.user"/>
        <propertycopy name="deploy.password"     from="${deployment.plan.environment}.password"/>
        <propertycopy name="deploy.forceDefault" from="${deployment.plan.environment}.forceDefault"/>
         <echo>undeploy MDS app folder apps/${mds.application} </echo>
         <ant antfile="D:/Jdeveloper1113/jdeveloper/bin/ant-sca-deploy.xml" inheritAll="false" target="removeSharedData">
              <property name="wl_home" value="${wl_home}"/>
           <!--   <property name="oracle.home" value="${oracle.home}"/>-->
              <property name="serverURL" value="${deploy.serverURL}"/>
              <property name="user" value="${deploy.user}"/>
              <property name="password" value="${deploy.password}"/>
              <property name="folderName" value="${mds.application}"/>
         </ant>
    </target>
</project>

deployMDS.cmd:

set ORACLE_HOME=D:\Jdeveloper1113
set ANT_HOME=%ORACLE_HOME%\jdeveloper\ant
set PATH=%ANT_HOME%\bin;%PATH%
set JAVA_HOME=%ORACLE_HOME%\jdk160_18
set CURRENT_FOLDER=%CD%
ant -f build.xml deployMDS


Now run this deployMDS.cmd.

Create a MDS connection in Jdev and now we can see apps folder along with configuration and shared folders, and the structure we have created in apps folder.

We can access the files we have placed in MDS in BPEL. We will see this in coming posts.

No comments:

Post a Comment

xslt padding with characters call template for left pad and right pad

  Could a call-template be written that took two parameters ?   a string, and a   number) return the string with empty spaces appended t...