+

Search Tips   |   Advanced Search

A complex example of a wladm Ant task

Here is an example of how to use several wladm invocations and XML processing to solve more complex tasks.

This example lists all access rules of all apps in all runtimes. The third-party XMLTask Ant task, from oopsconsultancy is used, which provides, in particular:

Here is an example of the code:

<?xml version="1.0" encoding="UTF-8"?>
<project default="main">
  <!-- Prerequisite for using the <wladm> Ant task. -->
  <taskdef resource="com/worklight/ant/deployers/antlib.xml">
    <classpath>
      <pathelement location="/opt/IBM/Worklight/WorklightServer/worklight-ant-deployer.jar"/>
    </classpath>
  </taskdef>
  <!-- Prerequisite for using the <xmltask> Ant task. -->
  <taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask">
    <classpath>
      <pathelement location="/opt/xmltask/xmltask.jar"/>
    </classpath>
  </taskdef>
  <!-- Parameters for every <wladm> invocation. -->
  <property name="url" value="https://localhost:8443/worklightadmin"/>
  <property name="user" value="demo"/>
  <property name="password" value="demo"/>
  <property name="secure" value="false"/>
  <target name="main">
    <wladm url="${url}" user="${user}" password="${password}" secure="${secure}">
      <list-runtimes output="/tmp/ListRuntimes.xml" inDatabase="true"/>
    </wladm>
    <xmltask source="/tmp/ListRuntimes.xml">
      <call path="/projectconfiguration/projects/project">
        <param name="runtime" path="@name"/>
        <actions>
          <echo message="runtime=@{runtime}"/>
          <sequential>
            <wladm url="${url}" user="${user}" password="${password}" secure="${secure}">
              <list-apps runtime="@{runtime}" output="/tmp/ListApps.xml"/>
            </wladm>
            <xmltask source="/tmp/ListApps.xml">
              <call path="/applications/items/item/appVersions/appVersion">
                <param name="name" path="@application"/>
                <param name="environment" path="@environment"/>
                <param name="version" path="@version"/>
                <actions>
                  <sequential>
                    <echo message="Access rules for app name=@{name}, environment=@{environment}, version=@{version}:"/>
                    <wladm url="${url}" user="${user}" password="${password}" secure="${secure}">
                      <app-version runtime="@{runtime}" name="@{name}" environment="@{environment}" version="@{version}">
                        <get-accessrule/>
                      </app-version>
                    </wladm>
                  </sequential>
                </actions>
              </call>
            </xmltask>
          </sequential>
        </actions>
      </call>
    </xmltask>
  </target>
</project>


Parent topic: wladm Ant task