Skip to content

Instantly share code, notes, and snippets.

@farukonder
Created June 10, 2012 21:26
Show Gist options
  • Save farukonder/2907406 to your computer and use it in GitHub Desktop.
Save farukonder/2907406 to your computer and use it in GitHub Desktop.
datamodel importer
<?xml version="1.0" encoding="iso-8859-1"?>
<project name="soaDeployAll" default="replace">
<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="replace">
<for param="file">
<path>
<fileset dir="${basedir}/Repository" includes="**/*" />
</path>
<sequential>
<echo>Replacing "oramds" in @{file}</echo>
<antcall target="replaceFileWithSuitableLevelSlash" inheritall="true" inheritrefs="false">
<param name="file" value="@{file}" />
</antcall>
</sequential>
</for>
<for param="file">
<path>
<fileset dir="${basedir}/Repository" includes="**/ApplicationObjectLibrary/**/*.wsdl" />
</path>
<sequential>
<echo>Removing "http:binding" in @{file}</echo>
<antcall target="removeHttpBindingPartAndItsServicePort" inheritall="true" inheritrefs="false">
<param name="file" value="@{file}" />
</antcall>
</sequential>
</for>
<!-- this task will have to be removed, when wsdl files are corrected -->
<antcall target="tmpDelete" />
<antcall target="letItRockMakeJarAndDeploy" />
</target>
<target name="removeHttpBindingPartAndItsServicePort">
<property name="file" value="${file}" />
<xmltask source="${file}" dest="${file}">
<copy path="/*[local-name()='definitions']/*[local-name()='binding'][*[local-name()='binding'][@verb='POST']]/@name" property="httpBindingNameInWsdl" />
<remove path="/*[local-name()='definitions']/*[local-name()='binding'][*[local-name()='binding'][@verb='POST']]" if="httpBindingNameInWsdl"/>
</xmltask>
<if>
<isset property="httpBindingNameInWsdl" />
<then>
<echo>Removed "http:binding" in ${httpBindingNameInWsdl} in file ${file}</echo>
<xmltask source="${file}" dest="${file}">
<copy path="/*[local-name()='definitions']/*[local-name()='service']/*[local-name()='port']/self::node()[contains(@binding,'${httpBindingNameInWsdl}')]/@binding" property="httpServiceBindingNameInWsdl" />
</xmltask>
<if>
<isset property="httpServiceBindingNameInWsdl" />
<then>
<echo>Removing "http:binding" in ${httpServiceBindingNameInWsdl} in file ${file}</echo>
<property name="httpServiceBindingNameInWsdlCall" value="/*[local-name()='definitions']/*[local-name()='service']/*[local-name()='port'][@binding='${httpServiceBindingNameInWsdl}']" />
</then>
</if>
<xmltask source="${file}" dest="${file}">
<remove path="${httpServiceBindingNameInWsdlCall}" if="httpServiceBindingNameInWsdlCall" />
</xmltask>
</then>
<else>
<echo>Nothing to be removed in file ${file}</echo>
</else>
</if>
</target>
<target name="replaceFileWithSuitableLevelSlash">
<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}" />
<replacefilter token="${replace.empty.import}" value="${replace.empty.text}" />
</replace>
</target>
<target name="letItRockMakeJarAndDeploy">
<delete file="Repository.jar" />
<jar destfile="Repository.jar">
<fileset dir=".">
<include name="**/*.xsd" />
<include name="**/*.wsdl" />
<!-- below wsdls contains some errors that preventing to commit the session in OSB console,temporarily dont put them in jar, //TODO -->
<exclude name="**/SuspendResumeCancelDueToDebtTTOReqABCS.wsdl" />
<exclude name="**/BasvuruWsKontorlXDSLProvABCS.wsdl" />
<exclude name="**/SimplifiedCancelOrderMTSProvABCS.wsdl" />
<exclude name="**/SendTemplateEmailSMMProvABCS.wsdl" />
<exclude name="**/SendStandardEmailSMMProvABCS.wsdl" />
<exclude name="**/AdjustBillNTYZReqABCS.wsdl" />
<exclude name="**/SimplifiedResumeOrderMTSProvABCS.wsdl" />
<exclude name="**/ISSTransferOutCustomerCancelMTSProvABCS.wsdl" />
<exclude name="**/SimplifiedSuspendOrderMTSProvABCS.wsdl" />
<exclude name="**/InquireProductUpdatesMTSReqABCS.wsdl" />
</fileset>
</jar>
<!--deploy-->
<!-- onu da siz gönderin :)-->
</target>
<target name="tmpDelete">
<delete>
<fileset dir=".">
<!-- below wsdls contains some errors that preventing to commit the session in OSB console,temporarily dont put them in jar, //TODO -->
<include name="**/SuspendResumeCancelDueToDebtTTOReqABCS.wsdl" />
<include name="**/BasvuruWsKontorlXDSLProvABCS.wsdl" />
<include name="**/SimplifiedCancelOrderMTSProvABCS.wsdl" />
<include name="**/SendTemplateEmailSMMProvABCS.wsdl" />
<include name="**/SendStandardEmailSMMProvABCS.wsdl" />
<include name="**/AdjustBillNTYZReqABCS.wsdl" />
<include name="**/SimplifiedResumeOrderMTSProvABCS.wsdl" />
<include name="**/ISSTransferOutCustomerCancelMTSProvABCS.wsdl" />
<include name="**/SimplifiedSuspendOrderMTSProvABCS.wsdl" />
<include name="**/InquireProductUpdatesMTSReqABCS.wsdl" />
</fileset>
</delete>
</target>
<target name="test">
<antcall target="replaceFileWithSuitableLevelSlash">
<param name="file" value="Repository/datamodel/ApplicationObjectLibrary/ESA/wsdl/MobilAboneAcmaService.wsdl" />
</antcall>
<antcall target="removeHttpBindingPartAndItsServicePort" inheritall="true" inheritrefs="false">
<param name="file" value="Repository/datamodel/ApplicationObjectLibrary/ESA/wsdl/MobilAboneAcmaService.wsdl" />
</antcall>
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment