Created
June 14, 2012 08:42
-
-
Save farukonder/2929100 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="iso-8859-1"?> | |
<project name="soaDeployAll" default="goOverTheDatamodel"> | |
<echo>basedir ${basedir}</echo> | |
<property environment="env" /> | |
<property name="library.dir" value="lib" /> | |
<property name="system.library.dir" value="/usr/share/java" /> | |
<path id="libraries"> | |
<fileset dir="${library.dir}"> | |
<include name="*.jar" /> | |
</fileset> | |
</path> | |
<property file="replace.properties" /> | |
<taskdef resource="net/sf/antcontrib/antlib.xml" classpathref="libraries" /> | |
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask" classpathref="libraries" /> | |
<target name="goOverTheDatamodel"> | |
<for param="file"> | |
<path> | |
<fileset dir="${basedir}/Repository" includes="**/*" /> | |
</path> | |
<sequential> | |
<echo>Replacing "oramds" in @{file}</echo> | |
<antcall target="replaceORAMDSWithSuitableLevelSlashInFile" inheritall="true" inheritrefs="false"> | |
<param name="file" value="@{file}" /> | |
</antcall> | |
</sequential> | |
</for> | |
<for param="file"> | |
<path> | |
<fileset dir="${basedir}/Repository" includes="**/ApplicationConnectorServiceLibrary/**/*.wsdl" excludes="**/*_Properties.wsdl"/> | |
<fileset dir="${basedir}/Repository" includes="**/EnterpriseBusinessFlowLibrary/**/*.wsdl" excludes="**/*_Properties.wsdl"/> | |
<fileset dir="${basedir}/Repository" includes="**/EnterpriseBusinessServiceLibrary/**/*.wsdl" excludes="**/*_Properties.wsdl"/> | |
</path> | |
<sequential> | |
<echo>Adding binding parts to file @{file}</echo> | |
<antcall target="findPortTypesGenerateAddBindingPartToWsdl" inheritall="true" inheritrefs="false"> | |
<param name="file" value="@{file}" /> | |
</antcall> | |
</sequential> | |
</for> | |
<antcall target="letItRockMakeJarAndDeploy" /> | |
</target> | |
<target name="replaceORAMDSWithSuitableLevelSlashInFile"> | |
<property name="pathOnFileSystem" value="${file}" /> | |
<script language="beanshell"> | |
<classpath> | |
<fileset dir="${library.dir}"> | |
<include name="*.jar" /> | |
</fileset> | |
</classpath> | |
<![CDATA[ | |
print("pathOnFileSystem : " + pathOnFileSystem); | |
String newPath = pathOnFileSystem.substring(pathOnFileSystem.indexOf("/datamodel")+10); | |
print("newPath : " + newPath); | |
int count = 0; | |
for (int i=0; i < newPath.length(); i++) | |
{ | |
if (newPath.charAt(i) == '/') | |
{ | |
count++; | |
} | |
} | |
print("in-level : " + count); | |
--count; | |
String newPrefix = ""; | |
for (int i = 0; i < count; i++) { | |
newPrefix+="../"; | |
} | |
print("newPrefix : " + newPrefix); | |
project.setProperty("countedSlashString",newPrefix); | |
project.setUserProperty("countedSlashString",newPrefix); | |
]]> | |
</script> | |
<echo>countedSlashString = ${countedSlashString}</echo> | |
<replace file="${pathOnFileSystem}"> | |
<replacefilter token="oramds:/apps/datamodel/" value="${countedSlashString}" /> | |
</replace> | |
</target> | |
<target name="letItRockMakeJarAndDeploy"> | |
<delete file="Repository.jar" /> | |
<jar destfile="Repository.jar"> | |
<fileset dir="."> | |
<include name="**/*.xsd" /> | |
<include name="**/*.wsdl" /> | |
</fileset> | |
</jar> | |
<!--deploy--> | |
<!-- onu da siz gönderin :)--> | |
</target> | |
<target name="test"> | |
<antcall target="replaceORAMDSWithSuitableLevelSlashInFile"> | |
<param name="file" value="Repository/datamodel/ApplicationObjectLibrary/XXX/wsdl/YYY.wsdl" /> | |
</antcall> | |
<antcall target="removeHttpBindingPartAndItsServicePort" inheritall="true" inheritrefs="false"> | |
<param name="file" value="Repository/datamodel/ApplicationObjectLibrary/XXX/wsdl/YYY.wsdl" /> | |
</antcall> | |
<antcall target="findPortTypesGenerateAddBindingPartToWsdl" inheritall="true" inheritrefs="false"> | |
<param name="file" value="Repository/datamodel/EnterpriseBusinessServiceLibrary/YYY.wsdl" /> | |
</antcall> | |
<antcall target="findPortTypesGenerateAddBindingPartToWsdl" inheritall="true" inheritrefs="false"> | |
<param name="file" value="Repository/datamodel/EnterpriseBusinessServiceLibrary/XXX/wsdl/YYY.wsdl" /> | |
</antcall> | |
</target> | |
<target name="findPortTypesGenerateAddBindingPartToWsdl"> | |
<property name="file" value="${file}" /> | |
<echo> file : ${file}</echo> | |
<script language="beanshell"> | |
<classpath> | |
<fileset dir="${library.dir}"> | |
<include name="*.jar" /> | |
</fileset> | |
</classpath> | |
<![CDATA[ | |
String path = file; | |
String xmlNamespace = "xmlns:"; | |
String targetNamespace = "targetNamespace"; | |
String targetNs = null; | |
String targetNsPrefix = null; | |
javax.xml.parsers.DocumentBuilderFactory domFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance(); | |
javax.xml.parsers.DocumentBuilder domBuilder; | |
try { | |
domBuilder = domFactory.newDocumentBuilder(); | |
org.w3c.dom.Document doc = domBuilder.parse(path); | |
org.w3c.dom.Element root = doc.getDocumentElement(); | |
org.w3c.dom.NamedNodeMap atts = root.getAttributes(); | |
for (int i = 0; i < atts.getLength(); i++) { | |
org.w3c.dom.Node node = atts.item(i); | |
String name = node.getNodeName(); | |
if (name.equals(targetNamespace)) | |
targetNs = node.getNodeValue(); | |
} | |
print("targetNs " + targetNs); | |
for (int i = 0; i < atts.getLength(); i++) { | |
org.w3c.dom.Node node = atts.item(i); | |
String value = node.getNodeValue(); | |
if (value.equals(targetNs) && !node.getNodeName().equals(targetNamespace)) | |
targetNsPrefix = node.getNodeName().replace(xmlNamespace, ""); | |
} | |
print("targetNsPrefix " + targetNsPrefix); | |
project.setProperty("targetNsPrefix",targetNsPrefix); | |
project.setUserProperty("targetNsPrefix",targetNsPrefix); | |
} catch (Exception e) { | |
print("error " + e.printStackTrace()); | |
} | |
]]> | |
</script> | |
<xmltask source="${file}" dest="${file}"> | |
<copy path="/*[local-name()='definitions']/@targetNamespace" property="targetNS"/> | |
</xmltask> | |
<echo> targetNS : ${targetNS}</echo> | |
<xmltask source="${file}" dest="${file}"> | |
<copy path="count(/*[local-name()='definitions']/*[local-name()='portType'])" property="portTypeCount"/> | |
<copy path="/*[local-name()='definitions']/*[local-name()='portType'][1]/@name" property="portTypeCountFirst"/> | |
<copy path="/*[local-name()='definitions']/*[local-name()='portType'][2]/@name" property="portTypeCountSecond"/> | |
</xmltask> | |
<echo> portTypeCount : ${portTypeCount}</echo> | |
<if> | |
<or> | |
<equals arg1="${portTypeCount}" arg2="1" /> | |
<equals arg1="${portTypeCount}" arg2="2" /> | |
</or> | |
<then> | |
<echo> portTypeCountFirst : ${portTypeCountFirst}</echo> | |
<antcall target="generateAddBindingPartToWsdl2" inheritall="true" inheritrefs="false"> | |
<param name="file" value="${file}" /> | |
<param name="whichPortBindingName" value="${portTypeCountFirst}" /> | |
</antcall> | |
</then> | |
</if> | |
<if> | |
<equals arg1="${portTypeCount}" arg2="2"/> | |
<then> | |
<echo> portTypeCountSecond : ${portTypeCountSecond}</echo> | |
<antcall target="generateAddBindingPartToWsdl2" inheritall="true" inheritrefs="false"> | |
<param name="file" value="${file}" /> | |
<param name="whichPortBindingName" value="${portTypeCountSecond}" /> | |
</antcall> | |
</then> | |
</if> | |
</target> | |
<target name="generateAddBindingPartToWsdl2"> | |
<property name="whichPortBindingName" value="${whichPortBindingName}" /> | |
<xmltask source="${file}" dest="${file}"> | |
<insert path="/*[local-name()='definitions']" > | |
<![CDATA[ | |
<wsdl:binding name="${whichPortBindingName}Binding" type="${targetNsPrefix}:${whichPortBindingName}" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> | |
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" /> | |
</wsdl:binding> | |
]]> | |
</insert> | |
</xmltask> | |
<property name="countScriptString" value="count(/*[local-name()='definitions']/*[local-name()='portType'][@name='${whichPortBindingName}']/*[local-name()='operation'])"></property> | |
<xmltask source="${file}" dest="${file}"> | |
<copy path="${countScriptString}" property="countNumber"/> | |
</xmltask> | |
<script language="beanshell"> | |
<classpath> | |
<fileset dir="${library.dir}"> | |
<include name="*.jar" /> | |
</fileset> | |
</classpath> | |
<![CDATA[ | |
print("countNumber : " + countNumber); | |
int count = new Integer(countNumber).intValue(); | |
String forLoopString = ""; | |
for (int i=0; i < count; i++) | |
{ | |
forLoopString+=(i+1)+","; | |
} | |
print("forLoopString : " + forLoopString); | |
project.setProperty("forLoopString",forLoopString); | |
project.setUserProperty("forLoopString",forLoopString); | |
]]> | |
</script> | |
<for param="operationInstance" list="${forLoopString}" > | |
<sequential> | |
<antcall target="generateAddOperationUnderBindingToWsdl"> | |
<param name="file" value="${file}" /> | |
<param name="operationInstance" value="@{operationInstance} " /> | |
<param name="targetNS" value="${targetNS}" /> | |
</antcall> | |
</sequential> | |
</for> | |
</target> | |
<target name="generateAddOperationUnderBindingToWsdl"> | |
<property name="file" value="${file}" /> | |
<property name="operationInstance" value="${operationInstance}" /> | |
<property name="targetNS" value="${targetNS}" /> | |
<echo> whichPortBindingName : ${whichPortBindingName}</echo> | |
<echo> operationInstance : ${operationInstance}</echo> | |
<property name="operationNameScriptString" value="/*[local-name()='definitions']/*[local-name()='portType'][@name='${whichPortBindingName}']/*[local-name()='operation'][${operationInstance}]/@name"></property> | |
<xmltask source="${file}" dest="${file}"> | |
<copy path="${operationNameScriptString}" property="operationName" /> | |
</xmltask> | |
<echo> operationName : ${operationName} </echo> | |
<property name="hasOutputScriptString" value="count(/*[local-name()='definitions']/*[local-name()='portType'][@name='${whichPortBindingName}']/*[local-name()='operation'][${operationInstance}]/*[local-name()='output'])"></property> | |
<xmltask source="${file}" dest="${file}"> | |
<copy path="${hasOutputScriptString}" property="hasOutput" /> | |
</xmltask> | |
<echo> hasOutput : ${hasOutput} </echo> | |
<property name="addingPlaceFinderScriptString" value="/*[local-name()='definitions']/*[local-name()='binding'][@name='${whichPortBindingName}Binding']"></property> | |
<if> | |
<equals arg1="${hasOutput}" arg2="0"/> | |
<then> | |
<xmltask source="${file}" dest="${file}"> | |
<insert path="${addingPlaceFinderScriptString}" > | |
<![CDATA[ | |
<wsdl:operation name="${operationName}" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> | |
<soap:operation style="document" soapAction="${operationName}" /> | |
<wsdl:input> | |
<soap:body use="literal" namespace="${targetNS}" /> | |
</wsdl:input> | |
</wsdl:operation> | |
]]> | |
</insert> | |
</xmltask> | |
</then> | |
<else> | |
<xmltask source="${file}" dest="${file}"> | |
<insert path="${addingPlaceFinderScriptString}" > | |
<![CDATA[ | |
<wsdl:operation name="${operationName}" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> | |
<soap:operation style="document" soapAction="${operationName}" /> | |
<wsdl:input> | |
<soap:body use="literal" namespace="${targetNS}" /> | |
</wsdl:input> | |
<wsdl:output> | |
<soap:body use="literal" namespace="${targetNS}" /> | |
</wsdl:output> | |
</wsdl:operation> | |
]]> | |
</insert> | |
</xmltask> | |
</else> | |
</if> | |
</target> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment