Displaying differences for changeset
 
display as  

nbproject/build-impl.xml

@@ -1,1467 +1,1467 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-        *** GENERATED FROM project.xml - DO NOT EDIT  ***
-        ***         EDIT ../build.xml INSTEAD         ***
-
-        For the purpose of easier reading the script
-        is divided into following sections:
-        - initialization
-        - compilation
-        - dist
-        - execution
-        - debugging
-        - javadoc
-        - test compilation
-        - test execution
-        - test debugging
-        - cleanup
-
-        -->
-<project xmlns:webproject1="http://www.netbeans.org/ns/web-project/1" xmlns:webproject2="http://www.netbeans.org/ns/web-project/2" xmlns:webproject3="http://www.netbeans.org/ns/web-project/3" basedir=".." default="default" name="csip-r2-impl">
-    <import file="rest-build.xml"/>
-    <import file="ant-deploy.xml"/>
-    <fail message="Please build using Ant 1.7.1 or higher.">
-        <condition>
-            <not>
-                <antversion atleast="1.7.1"/>
-            </not>
-        </condition>
-    </fail>
-    <target depends="dist,javadoc" description="Build whole project." name="default"/>
-    <!--
-                INITIALIZATION SECTION
-            -->
-    <target name="-pre-init">
-        <!-- Empty placeholder for easier customization. -->
-        <!-- You can override this target in the ../build.xml file. -->
-    </target>
-    <target depends="-pre-init" name="-init-private">
-        <property file="nbproject/private/private.properties"/>
-    </target>
-    <target depends="-pre-init,-init-private" name="-init-user">
-        <property file="${user.properties.file}"/>
-        <!-- The two properties below are usually overridden -->
-        <!-- by the active platform. Just a fallback. -->
-        <property name="default.javac.source" value="1.4"/>
-        <property name="default.javac.target" value="1.4"/>
-    </target>
-    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
-        <property file="nbproject/project.properties"/>
-    </target>
-    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" if="dist.ear.dir" name="-do-ear-init"/>
-    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
-        <condition property="have.tests">
-            <or>
-                <available file="${test.src.dir}"/>
-            </or>
-        </condition>
-        <condition property="have.sources">
-            <or>
-                <available file="${src.dir}"/>
-            </or>
-        </condition>
-        <condition property="netbeans.home+have.tests">
-            <and>
-                <isset property="netbeans.home"/>
-                <isset property="have.tests"/>
-            </and>
-        </condition>
-        <condition property="no.javadoc.preview">
-            <isfalse value="${javadoc.preview}"/>
-        </condition>
-        <property name="javac.compilerargs" value=""/>
-        <condition property="no.deps">
-            <and>
-                <istrue value="${no.dependencies}"/>
-            </and>
-        </condition>
-        <condition property="no.dist.ear.dir">
-            <not>
-                <isset property="dist.ear.dir"/>
-            </not>
-        </condition>
-        <property name="build.web.excludes" value="${build.classes.excludes}"/>
-        <condition property="do.compile.jsps">
-            <istrue value="${compile.jsps}"/>
-        </condition>
-        <condition property="do.debug.server">
-            <or>
-                <not>
-                    <isset property="debug.server"/>
-                </not>
-                <istrue value="${debug.server}"/>
-                <and>
-                    <not>
-                        <istrue value="${debug.server}"/>
-                    </not>
-                    <not>
-                        <istrue value="${debug.client}"/>
-                    </not>
-                </and>
-            </or>
-        </condition>
-        <condition property="do.debug.client">
-            <istrue value="${debug.client}"/>
-        </condition>
-        <condition property="do.display.browser">
-            <istrue value="${display.browser}"/>
-        </condition>
-        <condition property="do.display.browser.debug.old">
-            <and>
-                <isset property="do.display.browser"/>
-                <not>
-                    <isset property="do.debug.client"/>
-                </not>
-                <not>
-                    <isset property="browser.context"/>
-                </not>
-            </and>
-        </condition>
-        <condition property="do.display.browser.debug">
-            <and>
-                <isset property="do.display.browser"/>
-                <not>
-                    <isset property="do.debug.client"/>
-                </not>
-                <isset property="browser.context"/>
-            </and>
-        </condition>
-        <available file="${conf.dir}/MANIFEST.MF" property="has.custom.manifest"/>
-        <available file="${persistence.xml.dir}/persistence.xml" property="has.persistence.xml"/>
-        <condition property="do.war.package.with.custom.manifest">
-            <isset property="has.custom.manifest"/>
-        </condition>
-        <condition property="do.war.package.without.custom.manifest">
-            <not>
-                <isset property="has.custom.manifest"/>
-            </not>
-        </condition>
-        <condition property="do.tmp.war.package.with.custom.manifest">
-            <and>
-                <isset property="has.custom.manifest"/>
-                <or>
-                    <isfalse value="${directory.deployment.supported}"/>
-                    <isset property="dist.ear.dir"/>
-                </or>
-            </and>
-        </condition>
-        <condition property="do.tmp.war.package.without.custom.manifest">
-            <and>
-                <not>
-                    <isset property="has.custom.manifest"/>
-                </not>
-                <or>
-                    <isfalse value="${directory.deployment.supported}"/>
-                    <isset property="dist.ear.dir"/>
-                </or>
-            </and>
-        </condition>
-        <condition property="do.tmp.war.package">
-            <or>
-                <isfalse value="${directory.deployment.supported}"/>
-                <isset property="dist.ear.dir"/>
-            </or>
-        </condition>
-        <property name="build.meta.inf.dir" value="${build.web.dir}/META-INF"/>
-        <condition else="" property="application.args.param" value="${application.args}">
-            <and>
-                <isset property="application.args"/>
-                <not>
-                    <equals arg1="${application.args}" arg2="" trim="true"/>
-                </not>
-            </and>
-        </condition>
-        <property name="source.encoding" value="${file.encoding}"/>
-        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
-            <and>
-                <isset property="javadoc.encoding"/>
-                <not>
-                    <equals arg1="${javadoc.encoding}" arg2=""/>
-                </not>
-            </and>
-        </condition>
-        <property name="javadoc.encoding.used" value="${source.encoding}"/>
-        <property name="includes" value="**"/>
-        <property name="excludes" value=""/>
-        <property name="runmain.jvmargs" value=""/>
-        <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
-        <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">
-            <and>
-                <isset property="endorsed.classpath"/>
-                <length length="0" string="${endorsed.classpath}" when="greater"/>
-            </and>
-        </condition>
-        <condition else="false" property="jdkBug6558476">
-            <and>
-                <matches pattern="1\.[56]" string="${java.specification.version}"/>
-                <not>
-                    <os family="unix"/>
-                </not>
-            </and>
-        </condition>
-        <property name="javac.fork" value="${jdkBug6558476}"/>
-        <condition property="junit.available">
-            <or>
-                <available classname="org.junit.Test" classpath="${run.test.classpath}"/>
-                <available classname="junit.framework.Test" classpath="${run.test.classpath}"/>
-            </or>
-        </condition>
-        <condition property="testng.available">
-            <available classname="org.testng.annotations.Test" classpath="${run.test.classpath}"/>
-        </condition>
-        <condition property="junit+testng.available">
-            <and>
-                <istrue value="${junit.available}"/>
-                <istrue value="${testng.available}"/>
-            </and>
-        </condition>
-        <condition else="testng" property="testng.mode" value="mixed">
-            <istrue value="${junit+testng.available}"/>
-        </condition>
-        <condition else="" property="testng.debug.mode" value="-mixed">
-            <istrue value="${junit+testng.available}"/>
-        </condition>
-    </target>
-    <target depends="init" name="-init-cos" unless="deploy.on.save">
-        <condition property="deploy.on.save" value="true">
-            <or>
-                <istrue value="${j2ee.deploy.on.save}"/>
-                <istrue value="${j2ee.compile.on.save}"/>
-            </or>
-        </condition>
-    </target>
-    <target name="-post-init">
-        <!-- Empty placeholder for easier customization. -->
-        <!-- You can override this target in the ../build.xml file. -->
-    </target>
-    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
-        <fail unless="src.dir">Must set src.dir</fail>
-        <fail unless="test.src.dir">Must set test.src.dir</fail>
-        <fail unless="build.dir">Must set build.dir</fail>
-        <fail unless="build.web.dir">Must set build.web.dir</fail>
-        <fail unless="build.generated.dir">Must set build.generated.dir</fail>
-        <fail unless="dist.dir">Must set dist.dir</fail>
-        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
-        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
-        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
-        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
-        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
-        <fail unless="dist.war">Must set dist.war</fail>
-        <condition property="missing.j2ee.server.home">
-            <and>
-                <matches pattern="j2ee.server.home" string="${j2ee.platform.classpath}"/>
-                <not>
-                    <isset property="j2ee.server.home"/>
-                </not>
-            </and>
-        </condition>
-        <fail if="missing.j2ee.server.home">
-The Java EE server classpath is not correctly set up - server home directory is missing.
-Either open the project in the IDE and assign the server or setup the server classpath manually.
-For example like this:
-   ant -Dj2ee.server.home=&lt;app_server_installation_directory&gt;
-                </fail>
-        <fail unless="j2ee.platform.classpath">
-The Java EE server classpath is not correctly set up. Your active server type is ${j2ee.server.type}.
-Either open the project in the IDE and assign the server or setup the server classpath manually.
-For example like this:
-   ant -Duser.properties.file=&lt;path_to_property_file&gt; (where you put the property "j2ee.platform.classpath" in a .properties file)
-or ant -Dj2ee.platform.classpath=&lt;server_classpath&gt; (where no properties file is used)
-                </fail>
-    </target>
-    <target name="-init-macrodef-property">
-        <macrodef name="property" uri="http://www.netbeans.org/ns/web-project/1">
-            <attribute name="name"/>
-            <attribute name="value"/>
-            <sequential>
-                <property name="@{name}" value="${@{value}}"/>
-            </sequential>
-        </macrodef>
-    </target>
-    <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-macrodef-javac-with-processors">
-        <macrodef name="javac" uri="http://www.netbeans.org/ns/web-project/2">
-            <attribute default="${src.dir}" name="srcdir"/>
-            <attribute default="${build.classes.dir}" name="destdir"/>
-            <attribute default="${javac.classpath}:${j2ee.platform.classpath}" name="classpath"/>
-            <attribute default="${javac.processorpath}" name="processorpath"/>
-            <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
-            <attribute default="${includes}" name="includes"/>
-            <attribute default="${excludes}" name="excludes"/>
-            <attribute default="${javac.debug}" name="debug"/>
-            <attribute default="${empty.dir}" name="gensrcdir"/>
-            <element name="customize" optional="true"/>
-            <sequential>
-                <property location="${build.dir}/empty" name="empty.dir"/>
-                <mkdir dir="${empty.dir}"/>
-                <mkdir dir="@{apgeneratedsrcdir}"/>
-                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" srcdir="@{srcdir}" target="${javac.target}">
-                    <src>
-                        <dirset dir="@{gensrcdir}" erroronmissingdir="false">
-                            <include name="*"/>
-                        </dirset>
-                    </src>
-                    <classpath>
-                        <path path="@{classpath}"/>
-                    </classpath>
-                    <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
-                    <compilerarg line="${javac.compilerargs}"/>
-                    <compilerarg value="-processorpath"/>
-                    <compilerarg path="@{processorpath}:${empty.dir}"/>
-                    <compilerarg line="${ap.processors.internal}"/>
-                    <compilerarg value="-s"/>
-                    <compilerarg path="@{apgeneratedsrcdir}"/>
-                    <compilerarg line="${ap.proc.none.internal}"/>
-                    <customize/>
-                </javac>
-            </sequential>
-        </macrodef>
-    </target>
-    <target depends="-init-ap-cmdline-properties" name="-init-macrodef-javac-without-processors" unless="ap.supported.internal">
-        <macrodef name="javac" uri="http://www.netbeans.org/ns/web-project/2">
-            <attribute default="${src.dir}" name="srcdir"/>
-            <attribute default="${build.classes.dir}" name="destdir"/>
-            <attribute default="${javac.classpath}:${j2ee.platform.classpath}" name="classpath"/>
-            <attribute default="${javac.processorpath}" name="processorpath"/>
-            <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
-            <attribute default="${includes}" name="includes"/>
-            <attribute default="${excludes}" name="excludes"/>
-            <attribute default="${javac.debug}" name="debug"/>
-            <attribute default="${empty.dir}" name="gensrcdir"/>
-            <element name="customize" optional="true"/>
-            <sequential>
-                <property location="${build.dir}/empty" name="empty.dir"/>
-                <mkdir dir="${empty.dir}"/>
-                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeantruntime="false" includes="@{includes}" source="${javac.source}" srcdir="@{srcdir}" target="${javac.target}">
-                    <src>
-                        <dirset dir="@{gensrcdir}" erroronmissingdir="false">
-                            <include name="*"/>
-                        </dirset>
-                    </src>
-                    <classpath>
-                        <path path="@{classpath}"/>
-                    </classpath>
-                    <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
-                    <compilerarg line="${javac.compilerargs}"/>
-                    <customize/>
-                </javac>
-            </sequential>
-        </macrodef>
-    </target>
-    <target depends="-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors" name="-init-macrodef-javac">
-        <macrodef name="depend" uri="http://www.netbeans.org/ns/web-project/2">
-            <attribute default="${src.dir}" name="srcdir"/>
-            <attribute default="${build.classes.dir}" name="destdir"/>
-            <attribute default="${javac.classpath}:${j2ee.platform.classpath}" name="classpath"/>
-            <sequential>
-                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
-                    <classpath>
-                        <path path="@{classpath}"/>
-                    </classpath>
-                </depend>
-            </sequential>
-        </macrodef>
-        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/web-project/2">
-            <attribute default="${build.classes.dir}" name="destdir"/>
-            <sequential>
-                <fail unless="javac.includes">Must set javac.includes</fail>
-                <pathconvert pathsep="${line.separator}" property="javac.includes.binary">
-                    <path>
-                        <filelist dir="@{destdir}" files="${javac.includes}"/>
-                    </path>
-                    <globmapper from="*.java" to="*.class"/>
-                </pathconvert>
-                <tempfile deleteonexit="true" property="javac.includesfile.binary"/>
-                <echo file="${javac.includesfile.binary}" message="${javac.includes.binary}"/>
-                <delete>
-                    <files includesfile="${javac.includesfile.binary}"/>
-                </delete>
-                <delete file="${javac.includesfile.binary}"/>
-            </sequential>
-        </macrodef>
-    </target>
-    <target if="${junit.available}" name="-init-macrodef-junit-init">
-        <condition else="false" property="nb.junit.batch" value="true">
-            <and>
-                <istrue value="${junit.available}"/>
-                <not>
-                    <isset property="test.method"/>
-                </not>
-            </and>
-        </condition>
-        <condition else="false" property="nb.junit.single" value="true">
-            <and>
-                <istrue value="${junit.available}"/>
-                <isset property="test.method"/>
-            </and>
-        </condition>
-    </target>
-    <target name="-init-test-properties">
-        <property name="test.binaryincludes" value="&lt;nothing&gt;"/>
-        <property name="test.binarytestincludes" value=""/>
-        <property name="test.binaryexcludes" value=""/>
-    </target>
-    <target if="${nb.junit.single}" name="-init-macrodef-junit-single" unless="${nb.junit.batch}">
-        <macrodef name="junit" uri="http://www.netbeans.org/ns/web-project/2">
-            <attribute default="${includes}" name="includes"/>
-            <attribute default="${excludes}" name="excludes"/>
-            <attribute default="**" name="testincludes"/>
-            <attribute default="" name="testmethods"/>
-            <element name="customize" optional="true"/>
-            <sequential>
-                <junit dir="${basedir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${java.io.tmpdir}">
-                    <test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/>
-                    <syspropertyset>
-                        <propertyref prefix="test-sys-prop."/>
-                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
-                    </syspropertyset>
-                    <formatter type="brief" usefile="false"/>
-                    <formatter type="xml"/>
-                    <jvmarg value="-ea"/>
-                    <customize/>
-                </junit>
-            </sequential>
-        </macrodef>
-    </target>
-    <target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
-        <macrodef name="junit" uri="http://www.netbeans.org/ns/web-project/2">
-            <attribute default="${includes}" name="includes"/>
-            <attribute default="${excludes}" name="excludes"/>
-            <attribute default="**" name="testincludes"/>
-            <attribute default="" name="testmethods"/>
-            <element name="customize" optional="true"/>
-            <sequential>
-                <property name="run.jvmargs.ide" value=""/>
-                <junit dir="${basedir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${build.dir}">
-                    <batchtest todir="${build.test.results.dir}">
-                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
-                            <filename name="@{testincludes}"/>
-                        </fileset>
-                        <fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
-                            <filename name="${test.binarytestincludes}"/>
-                        </fileset>
-                    </batchtest>
-                    <syspropertyset>
-                        <propertyref prefix="test-sys-prop."/>
-                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
-                    </syspropertyset>
-                    <formatter type="brief" usefile="false"/>
-                    <formatter type="xml"/>
-                    <jvmarg value="-ea"/>
-                    <jvmarg line="${run.jvmargs.ide}"/>
-                    <customize/>
-                </junit>
-            </sequential>
-        </macrodef>
-    </target>
-    <target depends="-init-macrodef-junit-init,-init-macrodef-junit-single, -init-macrodef-junit-batch" if="${junit.available}" name="-init-macrodef-junit"/>
-    <target if="${testng.available}" name="-init-macrodef-testng">
-        <macrodef name="testng" uri="http://www.netbeans.org/ns/web-project/2">
-            <attribute default="${includes}" name="includes"/>
-            <attribute default="${excludes}" name="excludes"/>
-            <attribute default="**" name="testincludes"/>
-            <attribute default="" name="testmethods"/>
-            <element name="customize" optional="true"/>
-            <sequential>
-                <condition else="" property="testng.methods.arg" value="@{testincludes}.@{testmethods}">
-                    <isset property="test.method"/>
-                </condition>
-                <union id="test.set">
-                    <fileset dir="${test.src.dir}" excludes="@{excludes},**/*.xml,${excludes}" includes="@{includes}">
-                        <filename name="@{testincludes}"/>
-                    </fileset>
-                </union>
-                <taskdef classname="org.testng.TestNGAntTask" classpath="${run.test.classpath}" name="testng"/>
-                <testng classfilesetref="test.set" failureProperty="tests.failed" listeners="org.testng.reporters.VerboseReporter" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="csip-r2" testname="TestNG tests" workingDir="${basedir}">
-                    <xmlfileset dir="${build.test.classes.dir}" includes="@{testincludes}"/>
-                    <propertyset>
-                        <propertyref prefix="test-sys-prop."/>
-                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
-                    </propertyset>
-                    <customize/>
-                </testng>
-            </sequential>
-        </macrodef>
-    </target>
-    <target name="-init-macrodef-test-impl">
-        <macrodef name="test-impl" uri="http://www.netbeans.org/ns/web-project/2">
-            <attribute default="${includes}" name="includes"/>
-            <attribute default="${excludes}" name="excludes"/>
-            <attribute default="**" name="testincludes"/>
-            <attribute default="" name="testmethods"/>
-            <element implicit="true" name="customize" optional="true"/>
-            <sequential>
-                <echo>No tests executed.</echo>
-            </sequential>
-        </macrodef>
-    </target>
-    <target depends="-init-macrodef-junit" if="${junit.available}" name="-init-macrodef-junit-impl">
-        <macrodef name="test-impl" uri="http://www.netbeans.org/ns/web-project/2">
-            <attribute default="${includes}" name="includes"/>
-            <attribute default="${excludes}" name="excludes"/>
-            <attribute default="**" name="testincludes"/>
-            <attribute default="" name="testmethods"/>
-            <element implicit="true" name="customize" optional="true"/>
-            <sequential>
-                <webproject2:junit excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
-                    <customize/>
-                </webproject2:junit>
-            </sequential>
-        </macrodef>
-    </target>
-    <target depends="-init-macrodef-testng" if="${testng.available}" name="-init-macrodef-testng-impl">
-        <macrodef name="test-impl" uri="http://www.netbeans.org/ns/web-project/2">
-            <attribute default="${includes}" name="includes"/>
-            <attribute default="${excludes}" name="excludes"/>
-            <attribute default="**" name="testincludes"/>
-            <attribute default="" name="testmethods"/>
-            <element implicit="true" name="customize" optional="true"/>
-            <sequential>
-                <webproject2:testng excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
-                    <customize/>
-                </webproject2:testng>
-            </sequential>
-        </macrodef>
-    </target>
-    <target depends="-init-macrodef-test-impl,-init-macrodef-junit-impl,-init-macrodef-testng-impl" name="-init-macrodef-test">
-        <macrodef name="test" uri="http://www.netbeans.org/ns/web-project/2">
-            <attribute default="${includes}" name="includes"/>
-            <attribute default="${excludes}" name="excludes"/>
-            <attribute default="**" name="testincludes"/>
-            <attribute default="" name="testmethods"/>
-            <sequential>
-                <webproject2:test-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
-                    <customize>
-                        <classpath>
-                            <path path="${run.test.classpath}:${j2ee.platform.classpath}:${j2ee.platform.embeddableejb.classpath}"/>
-                        </classpath>
-                        <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
-                        <jvmarg line="${runmain.jvmargs}"/>
-                    </customize>
-                </webproject2:test-impl>
-            </sequential>
-        </macrodef>
-    </target>
-    <target if="${junit.available}" name="-init-macrodef-junit-debug" unless="${nb.junit.batch}">
-        <macrodef name="junit-debug" uri="http://www.netbeans.org/ns/web-project/2">
-            <attribute default="${includes}" name="includes"/>
-            <attribute default="${excludes}" name="excludes"/>
-            <attribute default="**" name="testincludes"/>
-            <attribute default="" name="testmethods"/>
-            <element name="customize" optional="true"/>
-            <sequential>
-                <junit dir="${basedir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${java.io.tmpdir}">
-                    <test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/>
-                    <syspropertyset>
-                        <propertyref prefix="test-sys-prop."/>
-                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
-                    </syspropertyset>
-                    <formatter type="brief" usefile="false"/>
-                    <formatter type="xml"/>
-                    <jvmarg value="-ea"/>
-                    <jvmarg line="${debug-args-line}"/>
-                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
-                    <customize/>
-                </junit>
-            </sequential>
-        </macrodef>
-    </target>
-    <target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
-        <macrodef name="junit-debug" uri="http://www.netbeans.org/ns/web-project/2">
-            <attribute default="${includes}" name="includes"/>
-            <attribute default="${excludes}" name="excludes"/>
-            <attribute default="**" name="testincludes"/>
-            <attribute default="" name="testmethods"/>
-            <element name="customize" optional="true"/>
-            <sequential>
-                <property name="run.jvmargs.ide" value=""/>
-                <junit dir="${basedir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${build.dir}">
-                    <batchtest todir="${build.test.results.dir}">
-                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
-                            <filename name="@{testincludes}"/>
-                        </fileset>
-                        <fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
-                            <filename name="${test.binarytestincludes}"/>
-                        </fileset>
-                    </batchtest>
-                    <syspropertyset>
-                        <propertyref prefix="test-sys-prop."/>
-                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
-                    </syspropertyset>
-                    <formatter type="brief" usefile="false"/>
-                    <formatter type="xml"/>
-                    <jvmarg value="-ea"/>
-                    <jvmarg line="${run.jvmargs.ide}"/>
-                    <jvmarg line="${debug-args-line}"/>
-                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
-                    <customize/>
-                </junit>
-            </sequential>
-        </macrodef>
-    </target>
-    <target depends="-init-macrodef-junit-debug,-init-macrodef-junit-debug-batch" if="${junit.available}" name="-init-macrodef-junit-debug-impl">
-        <macrodef name="test-debug-impl" uri="http://www.netbeans.org/ns/web-project/2">
-            <attribute default="${includes}" name="includes"/>
-            <attribute default="${excludes}" name="excludes"/>
-            <attribute default="**" name="testincludes"/>
-            <attribute default="" name="testmethods"/>
-            <element implicit="true" name="customize" optional="true"/>
-            <sequential>
-                <webproject2:junit-debug excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
-                    <customize/>
-                </webproject2:junit-debug>
-            </sequential>
-        </macrodef>
-    </target>
-    <target if="${testng.available}" name="-init-macrodef-testng-debug">
-        <macrodef name="testng-debug" uri="http://www.netbeans.org/ns/web-project/2">
-            <attribute default="${main.class}" name="testClass"/>
-            <attribute default="" name="testMethod"/>
-            <element name="customize2" optional="true"/>
-            <sequential>
-                <condition else="-testclass @{testClass}" property="test.class.or.method" value="-methods @{testClass}.@{testMethod}">
-                    <isset property="test.method"/>
-                </condition>
-                <condition else="-suitename csip-r2 -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}">
-                    <matches pattern=".*\.xml" string="@{testClass}"/>
-                </condition>
-                <delete dir="${build.test.results.dir}" quiet="true"/>
-                <mkdir dir="${build.test.results.dir}"/>
-                <webproject1:debug args="${testng.cmd.args}" classname="org.testng.TestNG" classpath="${debug.test.classpath}:${j2ee.platform.embeddableejb.classpath}">
-                    <customize>
-                        <customize2/>
-                        <jvmarg value="-ea"/>
-                        <arg line="${testng.debug.mode}"/>
-                        <arg line="-d ${build.test.results.dir}"/>
-                        <arg line="-listener org.testng.reporters.VerboseReporter"/>
-                    </customize>
-                </webproject1:debug>
-            </sequential>
-        </macrodef>
-    </target>
-    <target depends="-init-macrodef-testng-debug" if="${testng.available}" name="-init-macrodef-testng-debug-impl">
-        <macrodef name="testng-debug-impl" uri="http://www.netbeans.org/ns/web-project/2">
-            <attribute default="${main.class}" name="testClass"/>
-            <attribute default="" name="testMethod"/>
-            <element implicit="true" name="customize2" optional="true"/>
-            <sequential>
-                <webproject2:testng-debug testClass="@{testClass}" testMethod="@{testMethod}">
-                    <customize2/>
-                </webproject2:testng-debug>
-            </sequential>
-        </macrodef>
-    </target>
-    <target depends="-init-macrodef-junit-debug-impl" if="${junit.available}" name="-init-macrodef-test-debug-junit">
-        <macrodef name="test-debug" uri="http://www.netbeans.org/ns/web-project/2">
-            <attribute default="${includes}" name="includes"/>
-            <attribute default="${excludes}" name="excludes"/>
-            <attribute default="**" name="testincludes"/>
-            <attribute default="" name="testmethods"/>
-            <attribute default="${main.class}" name="testClass"/>
-            <attribute default="" name="testMethod"/>
-            <sequential>
-                <webproject2:test-debug-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
-                    <customize>
-                        <classpath>
-                            <path path="${run.test.classpath}:${j2ee.platform.classpath}:${j2ee.platform.embeddableejb.classpath}"/>
-                        </classpath>
-                        <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
-                        <jvmarg line="${runmain.jvmargs}"/>
-                    </customize>
-                </webproject2:test-debug-impl>
-            </sequential>
-        </macrodef>
-    </target>
-    <target depends="-init-macrodef-testng-debug-impl" if="${testng.available}" name="-init-macrodef-test-debug-testng">
-        <macrodef name="test-debug" uri="http://www.netbeans.org/ns/web-project/2">
-            <attribute default="${includes}" name="includes"/>
-            <attribute default="${excludes}" name="excludes"/>
-            <attribute default="**" name="testincludes"/>
-            <attribute default="" name="testmethods"/>
-            <attribute default="${main.class}" name="testClass"/>
-            <attribute default="" name="testMethod"/>
-            <sequential>
-                <webproject2:testng-debug-impl testClass="@{testClass}" testMethod="@{testMethod}">
-                    <customize2>
-                        <syspropertyset>
-                            <propertyref prefix="test-sys-prop."/>
-                            <mapper from="test-sys-prop.*" to="*" type="glob"/>
-                        </syspropertyset>
-                    </customize2>
-                </webproject2:testng-debug-impl>
-            </sequential>
-        </macrodef>
-    </target>
-    <target depends="-init-macrodef-test-debug-junit,-init-macrodef-test-debug-testng" name="-init-macrodef-test-debug"/>
-    <target name="-init-macrodef-java">
-        <macrodef name="java" uri="http://www.netbeans.org/ns/web-project/1">
-            <attribute default="${main.class}" name="classname"/>
-            <attribute default="${debug.classpath}" name="classpath"/>
-            <element name="customize" optional="true"/>
-            <sequential>
-                <java classname="@{classname}" fork="true">
-                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
-                    <jvmarg line="${runmain.jvmargs}"/>
-                    <classpath>
-                        <path path="@{classpath}:${j2ee.platform.classpath}"/>
-                    </classpath>
-                    <syspropertyset>
-                        <propertyref prefix="run-sys-prop."/>
-                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
-                    </syspropertyset>
-                    <customize/>
-                </java>
-            </sequential>
-        </macrodef>
-    </target>
-    <target name="-init-macrodef-nbjsdebug">
-        <macrodef name="nbjsdebugstart" uri="http://www.netbeans.org/ns/web-project/1">
-            <attribute default="${client.url}" name="webUrl"/>
-            <sequential>
-                <nbjsdebugstart urlPart="${client.urlPart}" webUrl="@{webUrl}"/>
-            </sequential>
-        </macrodef>
-    </target>
-    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
-        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/web-project/1">
-            <attribute default="${main.class}" name="name"/>
-            <attribute default="${debug.classpath}:${j2ee.platform.classpath}" name="classpath"/>
-            <sequential>
-                <nbjpdastart addressproperty="jpda.address" name="@{name}" transport="${debug-transport}">
-                    <classpath>
-                        <path path="@{classpath}"/>
-                    </classpath>
-                </nbjpdastart>
-            </sequential>
-        </macrodef>
-        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/web-project/1">
-            <attribute default="${build.classes.dir}" name="dir"/>
-            <sequential>
-                <nbjpdareload>
-                    <fileset dir="@{dir}" includes="${fix.classes}">
-                        <include name="${fix.includes}*.class"/>
-                    </fileset>
-                </nbjpdareload>
-            </sequential>
-        </macrodef>
-        <macrodef name="nbjpdaappreloaded" uri="http://www.netbeans.org/ns/web-project/1">
-            <sequential>
-                <nbjpdaappreloaded/>
-            </sequential>
-        </macrodef>
-    </target>
-    <target name="-init-debug-args">
-        <property name="version-output" value="java version &quot;${ant.java.version}"/>
-        <condition property="have-jdk-older-than-1.4">
-            <or>
-                <contains string="${version-output}" substring="java version &quot;1.0"/>
-                <contains string="${version-output}" substring="java version &quot;1.1"/>
-                <contains string="${version-output}" substring="java version &quot;1.2"/>
-                <contains string="${version-output}" substring="java version &quot;1.3"/>
-            </or>
-        </condition>
-        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
-            <istrue value="${have-jdk-older-than-1.4}"/>
-        </condition>
-        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
-            <os family="windows"/>
-        </condition>
-        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
-            <isset property="debug.transport"/>
-        </condition>
-    </target>
-    <target depends="-init-debug-args" name="-init-macrodef-debug">
-        <macrodef name="debug" uri="http://www.netbeans.org/ns/web-project/1">
-            <attribute default="${main.class}" name="classname"/>
-            <attribute default="${debug.classpath}:${j2ee.platform.classpath}" name="classpath"/>
-            <attribute default="${application.args.param}" name="args"/>
-            <element name="customize" optional="true"/>
-            <sequential>
-                <java classname="@{classname}" fork="true">
-                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
-                    <jvmarg line="${debug-args-line}"/>
-                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
-                    <jvmarg line="${runmain.jvmargs}"/>
-                    <classpath>
-                        <path path="@{classpath}"/>
-                    </classpath>
-                    <syspropertyset>
-                        <propertyref prefix="run-sys-prop."/>
-                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
-                    </syspropertyset>
-                    <arg line="@{args}"/>
-                    <customize/>
-                </java>
-            </sequential>
-        </macrodef>
-    </target>
-    <target name="-init-taskdefs">
-        <fail unless="libs.CopyLibs.classpath">
-The libs.CopyLibs.classpath property is not set up.
-This property must point to 
-org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part
-of NetBeans IDE installation and is usually located at 
-&lt;netbeans_installation&gt;/java&lt;version&gt;/ant/extra folder.
-Either open the project in the IDE and make sure CopyLibs library
-exists or setup the property manually. For example like this:
- ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar
-                </fail>
-        <taskdef classpath="${libs.CopyLibs.classpath}" resource="org/netbeans/modules/java/j2seproject/copylibstask/antlib.xml"/>
-    </target>
-    <target name="-init-ap-cmdline-properties">
-        <property name="annotation.processing.enabled" value="true"/>
-        <property name="annotation.processing.processors.list" value=""/>
-        <property name="annotation.processing.run.all.processors" value="true"/>
-        <property name="javac.processorpath" value="${javac.classpath}"/>
-        <property name="javac.test.processorpath" value="${javac.test.classpath}"/>
-        <condition property="ap.supported.internal" value="true">
-            <not>
-                <matches pattern="1\.[0-5](\..*)?" string="${javac.source}"/>
-            </not>
-        </condition>
-    </target>
-    <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-ap-cmdline-supported">
-        <condition else="" property="ap.processors.internal" value="-processor ${annotation.processing.processors.list}">
-            <isfalse value="${annotation.processing.run.all.processors}"/>
-        </condition>
-        <condition else="" property="ap.proc.none.internal" value="-proc:none">
-            <isfalse value="${annotation.processing.enabled}"/>
-        </condition>
-    </target>
-    <target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline">
-        <property name="ap.cmd.line.internal" value=""/>
-    </target>
-    <!--
-                pre NB7.2 profiling section; consider it deprecated
-            -->
-    <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-check" if="profiler.info.jvmargs.agent" name="profile-init"/>
-    <target if="profiler.info.jvmargs.agent" name="-profile-pre-init">
-        <!-- Empty placeholder for easier customization. -->
-        <!-- You can override this target in the ../build.xml file. -->
-    </target>
-    <target if="profiler.info.jvmargs.agent" name="-profile-post-init">
-        <!-- Empty placeholder for easier customization. -->
-        <!-- You can override this target in the ../build.xml file. -->
-    </target>
-    <target depends="-profile-pre-init, init, -profile-post-init" if="profiler.info.jvmargs.agent" name="-profile-init-check">
-        <fail unless="profiler.info.jvm">Must set JVM to use for profiling in profiler.info.jvm</fail>
-        <fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail>
-    </target>
-    <!--
-                end of pre NB7.2 profiling section
-            -->
-    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-test,-init-macrodef-test-debug,-init-macrodef-java,-init-macrodef-nbjpda,-init-macrodef-nbjsdebug,-init-macrodef-debug,-init-taskdefs,-init-ap-cmdline" name="init"/>
-    <!--
-                COMPILATION SECTION
-            -->
-    <target depends="init" if="no.dist.ear.dir" name="deps-module-jar" unless="no.deps">
-        <ant antfile="${project.csip-core}/build.xml" inheritall="false" target="jar">
-            <property name="deploy.on.save" value="false"/>
-        </ant>
-    </target>
-    <target depends="init" if="dist.ear.dir" name="deps-ear-jar" unless="no.deps">
-        <ant antfile="${project.csip-core}/build.xml" inheritall="false" target="jar">
-            <property name="deploy.on.save" value="false"/>
-        </ant>
-    </target>
-    <target depends="init, deps-module-jar, deps-ear-jar" name="deps-jar" unless="no.deps"/>
-    <target depends="init,deps-jar,generate-rest-config" name="-pre-pre-compile">
-        <mkdir dir="${build.classes.dir}"/>
-    </target>
-    <target name="-pre-compile">
-        <!-- Empty placeholder for easier customization. -->
-        <!-- You can override this target in the ../build.xml file. -->
-    </target>
-    <target name="-copy-webdir">
-        <copy todir="${build.web.dir}">
-            <fileset dir="${web.docbase.dir}" excludes="${build.web.excludes},${excludes}" includes="${includes}"/>
-        </copy>
-        <copy todir="${build.web.dir}/WEB-INF">
-            <fileset dir="${webinf.dir}" excludes="${build.web.excludes}"/>
-        </copy>
-    </target>
-    <target depends="init, deps-jar, -pre-pre-compile, -pre-compile, -copy-manifest, -copy-persistence-xml, -copy-webdir, library-inclusion-in-archive,library-inclusion-in-manifest" if="have.sources" name="-do-compile">
-        <webproject2:javac destdir="${build.classes.dir}" gensrcdir="${build.generated.sources.dir}"/>
-        <copy todir="${build.classes.dir}">
-            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
-        </copy>
-    </target>
-    <target if="has.custom.manifest" name="-copy-manifest">
-        <mkdir dir="${build.meta.inf.dir}"/>
-        <copy todir="${build.meta.inf.dir}">
-            <fileset dir="${conf.dir}" includes="MANIFEST.MF"/>
-        </copy>
-    </target>
-    <target if="has.persistence.xml" name="-copy-persistence-xml">
-        <mkdir dir="${build.web.dir}/WEB-INF/classes/META-INF"/>
-        <copy todir="${build.web.dir}/WEB-INF/classes/META-INF">
-            <fileset dir="${persistence.xml.dir}" includes="persistence.xml orm.xml"/>
-        </copy>
-    </target>
-    <target name="-post-compile">
-        <!-- Empty placeholder for easier customization. -->
-        <!-- You can override this target in the ../build.xml file. -->
-    </target>
-    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
-    <target name="-pre-compile-single">
-        <!-- Empty placeholder for easier customization. -->
-        <!-- You can override this target in the ../build.xml file. -->
-    </target>
-    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
-        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
-        <webproject2:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}"/>
-        <copy todir="${build.classes.dir}">
-            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
-        </copy>
-    </target>
-    <target name="-post-compile-single">
-        <!-- Empty placeholder for easier customization. -->
-        <!-- You can override this target in the ../build.xml file. -->
-    </target>
-    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
-    <property name="jspc.schemas" value="/resources/schemas/"/>
-    <property name="jspc.dtds" value="/resources/dtds/"/>
-    <target depends="compile" description="Test compile JSP pages to expose compilation errors." if="do.compile.jsps" name="compile-jsps">
-        <mkdir dir="${build.generated.dir}/src"/>
-        <java classname="org.netbeans.modules.web.project.ant.JspC" failonerror="true" fork="true">
-            <arg value="-uriroot"/>
-            <arg file="${basedir}/${build.web.dir}"/>
-            <arg value="-d"/>
-            <arg file="${basedir}/${build.generated.dir}/src"/>
-            <arg value="-die1"/>
-            <arg value="-schemas ${jspc.schemas}"/>
-            <arg value="-dtds ${jspc.dtds}"/>
-            <arg value="-compilerSourceVM ${javac.source}"/>
-            <arg value="-compilerTargetVM ${javac.target}"/>
-            <arg value="-javaEncoding ${source.encoding}"/>
-            <arg value="-sysClasspath ${libs.jsp-compilation-syscp.classpath}"/>
-            <classpath path="${java.home}/../lib/tools.jar:${libs.jsp-compiler.classpath}:${libs.jsp-compilation.classpath}"/>
-        </java>
-        <mkdir dir="${build.generated.dir}/classes"/>
-        <webproject2:javac classpath="${build.classes.dir}:${libs.jsp-compilation.classpath}:${javac.classpath}:${j2ee.platform.classpath}" destdir="${build.generated.dir}/classes" srcdir="${build.generated.dir}/src"/>
-    </target>
-    <target depends="compile" if="jsp.includes" name="-do-compile-single-jsp">
-        <fail unless="javac.jsp.includes">Must select some files in the IDE or set javac.jsp.includes</fail>
-        <mkdir dir="${build.generated.dir}/src"/>
-        <java classname="org.netbeans.modules.web.project.ant.JspCSingle" failonerror="true" fork="true">
-            <arg value="-uriroot"/>
-            <arg file="${basedir}/${build.web.dir}"/>
-            <arg value="-d"/>
-            <arg file="${basedir}/${build.generated.dir}/src"/>
-            <arg value="-die1"/>
-            <arg value="-schemas ${jspc.schemas}"/>
-            <arg value="-dtds ${jspc.dtds}"/>
-            <arg value="-sysClasspath ${libs.jsp-compilation-syscp.classpath}"/>
-            <arg value="-jspc.files"/>
-            <arg path="${jsp.includes}"/>
-            <arg value="-compilerSourceVM ${javac.source}"/>
-            <arg value="-compilerTargetVM ${javac.target}"/>
-            <arg value="-javaEncoding ${source.encoding}"/>
-            <classpath path="${java.home}/../lib/tools.jar:${libs.jsp-compiler.classpath}:${libs.jsp-compilation.classpath}"/>
-        </java>
-        <mkdir dir="${build.generated.dir}/classes"/>
-        <webproject2:javac classpath="${build.classes.dir}:${libs.jsp-compilation.classpath}:${javac.classpath}:${j2ee.platform.classpath}" destdir="${build.generated.dir}/classes" srcdir="${build.generated.dir}/src">
-            <customize>
-                <patternset includes="${javac.jsp.includes}"/>
-            </customize>
-        </webproject2:javac>
-    </target>
-    <target name="compile-single-jsp">
-        <fail unless="jsp.includes">Must select a file in the IDE or set jsp.includes</fail>
-        <antcall target="-do-compile-single-jsp"/>
-    </target>
-    <!--
-                DIST BUILDING SECTION
-            -->
-    <target name="-pre-dist">
-        <!-- Empty placeholder for easier customization. -->
-        <!-- You can override this target in the ../build.xml file. -->
-    </target>
-    <target depends="init,compile,compile-jsps,-pre-dist" if="do.war.package.without.custom.manifest" name="-do-dist-without-manifest">
-        <dirname file="${dist.war}" property="dist.jar.dir"/>
-        <mkdir dir="${dist.jar.dir}"/>
-        <jar compress="${jar.compress}" jarfile="${dist.war}">
-            <fileset dir="${build.web.dir}" excludes="WEB-INF/classes/.netbeans_*,${dist.archive.excludes}"/>
-        </jar>
-    </target>
-    <target depends="init,compile,compile-jsps,-pre-dist" if="do.war.package.with.custom.manifest" name="-do-dist-with-manifest">
-        <dirname file="${dist.war}" property="dist.jar.dir"/>
-        <mkdir dir="${dist.jar.dir}"/>
-        <jar compress="${jar.compress}" jarfile="${dist.war}" manifest="${build.meta.inf.dir}/MANIFEST.MF">
-            <fileset dir="${build.web.dir}" excludes="WEB-INF/classes/.netbeans_*,${dist.archive.excludes}"/>
-        </jar>
-    </target>
-    <target depends="init,compile,compile-jsps,-pre-dist" if="do.tmp.war.package.without.custom.manifest" name="-do-tmp-dist-without-manifest">
-        <dirname file="${dist.war}" property="dist.jar.dir"/>
-        <mkdir dir="${dist.jar.dir}"/>
-        <jar compress="${jar.compress}" jarfile="${dist.war}">
-            <fileset dir="${build.web.dir}" excludes="WEB-INF/classes/.netbeans_*,${dist.archive.excludes}"/>
-        </jar>
-    </target>
-    <target depends="init,compile,compile-jsps,-pre-dist" if="do.tmp.war.package.with.custom.manifest" name="-do-tmp-dist-with-manifest">
-        <dirname file="${dist.war}" property="dist.jar.dir"/>
-        <mkdir dir="${dist.jar.dir}"/>
-        <jar compress="${jar.compress}" jarfile="${dist.war}" manifest="${build.meta.inf.dir}/MANIFEST.MF">
-            <fileset dir="${build.web.dir}" excludes="WEB-INF/classes/.netbeans_*,${dist.archive.excludes}"/>
-        </jar>
-    </target>
-    <target depends="init,compile,compile-jsps,-pre-dist,-do-dist-with-manifest,-do-dist-without-manifest" name="do-dist"/>
-    <target depends="init" if="dist.ear.dir" name="library-inclusion-in-manifest">
-        <copyfiles files="${reference.csip-core.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
-        <copyfiles files="${libs.CSIP-Jersey-2.16.classpath}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
-        <copyfiles files="${file.reference.Lmod2Rusle2.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
-        <copyfiles files="${file.reference.csip-soilsdb-3.0.18.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
-        <copyfiles files="${file.reference.csip-gis-objects-2.0.17.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
-        <copyfiles files="${file.reference.calcmanstir.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
-        <copyfiles files="${file.reference.SDMDriver-1.0.4.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
-        <mkdir dir="${build.web.dir}/META-INF"/>
-        <manifest file="${build.web.dir}/META-INF/MANIFEST.MF" mode="update"/>
-    </target>
-    <target depends="init" name="library-inclusion-in-archive" unless="dist.ear.dir">
-        <copyfiles files="${reference.csip-core.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
-        <copyfiles files="${libs.CSIP-Jersey-2.16.classpath}" todir="${build.web.dir}/WEB-INF/lib"/>
-        <copyfiles files="${file.reference.Lmod2Rusle2.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
-        <copyfiles files="${file.reference.csip-soilsdb-3.0.18.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
-        <copyfiles files="${file.reference.csip-gis-objects-2.0.17.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
-        <copyfiles files="${file.reference.calcmanstir.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
-        <copyfiles files="${file.reference.SDMDriver-1.0.4.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
-    </target>
-    <target depends="init" if="dist.ear.dir" name="-clean-webinf-lib">
-        <delete dir="${build.web.dir}/WEB-INF/lib"/>
-    </target>
-    <target depends="init,-clean-webinf-lib,compile,compile-jsps,-pre-dist,library-inclusion-in-manifest" if="do.tmp.war.package" name="do-ear-dist">
-        <dirname file="${dist.ear.war}" property="dist.jar.dir"/>
-        <mkdir dir="${dist.jar.dir}"/>
-        <jar compress="${jar.compress}" jarfile="${dist.ear.war}" manifest="${build.web.dir}/META-INF/MANIFEST.MF">
-            <fileset dir="${build.web.dir}" excludes="WEB-INF/classes/.netbeans_*,${dist.archive.excludes}"/>
-        </jar>
-    </target>
-    <target name="-post-dist">
-        <!-- Empty placeholder for easier customization. -->
-        <!-- You can override this target in the ../build.xml file. -->
-    </target>
-    <target depends="init,compile,-pre-dist,do-dist,-post-dist" description="Build distribution (WAR)." name="dist"/>
-    <target depends="init,-clean-webinf-lib,-init-cos,compile,-pre-dist,do-ear-dist,-post-dist" description="Build distribution (WAR) to be packaged into an EAR." name="dist-ear"/>
-    <!--
-                EXECUTION SECTION
-            -->
-    <target depends="run-deploy,run-display-browser" description="Deploy to server and show in browser." name="run"/>
-    <target name="-pre-run-deploy">
-        <!-- Empty placeholder for easier customization. -->
-        <!-- You can override this target in the ../build.xml file. -->
-    </target>
-    <target name="-post-run-deploy">
-        <!-- Empty placeholder for easier customization. -->
-        <!-- You can override this target in the ../build.xml file. -->
-    </target>
-    <target name="-pre-nbmodule-run-deploy">
-        <!-- Empty placeholder for easier customization. -->
-        <!-- This target can be overriden by NetBeans modules. Don't override it directly, use -pre-run-deploy task instead. -->
-    </target>
-    <target name="-post-nbmodule-run-deploy">
-        <!-- Empty placeholder for easier customization. -->
-        <!-- This target can be overriden by NetBeans modules. Don't override it directly, use -post-run-deploy task instead. -->
-    </target>
-    <target name="-run-deploy-am">
-        <!-- Task to deploy to the Access Manager runtime. -->
-    </target>
-    <target depends="init,-init-cos,compile,compile-jsps,-do-compile-single-jsp,-pre-dist,-do-tmp-dist-with-manifest,-do-tmp-dist-without-manifest,-pre-run-deploy,-pre-nbmodule-run-deploy,-run-deploy-nb,-init-deploy-ant,-deploy-ant,-run-deploy-am,-post-nbmodule-run-deploy,-post-run-deploy,-do-update-breakpoints" name="run-deploy"/>
-    <target if="netbeans.home" name="-run-deploy-nb">
-        <nbdeploy clientUrlPart="${client.urlPart}" debugmode="false" forceRedeploy="${forceRedeploy}"/>
-    </target>
-    <target name="-init-deploy-ant" unless="netbeans.home">
-        <property name="deploy.ant.archive" value="${dist.war}"/>
-        <property name="deploy.ant.docbase.dir" value="${web.docbase.dir}"/>
-        <property name="deploy.ant.resource.dir" value="${resource.dir}"/>
-        <property name="deploy.ant.enabled" value="true"/>
-    </target>
-    <target depends="dist,-run-undeploy-nb,-init-deploy-ant,-undeploy-ant" name="run-undeploy"/>
-    <target if="netbeans.home" name="-run-undeploy-nb">
-        <fail message="Undeploy is not supported from within the IDE"/>
-    </target>
-    <target depends="init,-pre-dist,dist,-post-dist" name="verify">
-        <nbverify file="${dist.war}"/>
-    </target>
-    <target depends="run-deploy,-init-display-browser,-display-browser-nb-old,-display-browser-nb,-display-browser-cl" name="run-display-browser"/>
-    <target if="do.display.browser" name="-init-display-browser">
-        <condition property="do.display.browser.nb.old">
-            <and>
-                <isset property="netbeans.home"/>
-                <not>
-                    <isset property="browser.context"/>
-                </not>
-            </and>
-        </condition>
-        <condition property="do.display.browser.nb">
-            <and>
-                <isset property="netbeans.home"/>
-                <isset property="browser.context"/>
-            </and>
-        </condition>
-        <condition property="do.display.browser.cl">
-            <isset property="deploy.ant.enabled"/>
-        </condition>
-    </target>
-    <target if="do.display.browser.nb.old" name="-display-browser-nb-old">
-        <nbbrowse url="${client.url}"/>
-    </target>
-    <target if="do.display.browser.nb" name="-display-browser-nb">
-        <nbbrowse context="${browser.context}" url="${client.url}" urlPath="${client.urlPart}"/>
-    </target>
-    <target if="do.display.browser.cl" name="-get-browser" unless="browser">
-        <condition property="browser" value="rundll32">
-            <os family="windows"/>
-        </condition>
-        <condition else="" property="browser.args" value="url.dll,FileProtocolHandler">
-            <os family="windows"/>
-        </condition>
-        <condition property="browser" value="/usr/bin/open">
-            <os family="mac"/>
-        </condition>
-        <property environment="env"/>
-        <condition property="browser" value="${env.BROWSER}">
-            <isset property="env.BROWSER"/>
-        </condition>
-        <condition property="browser" value="/usr/bin/firefox">
-            <available file="/usr/bin/firefox"/>
-        </condition>
-        <condition property="browser" value="/usr/local/firefox/firefox">
-            <available file="/usr/local/firefox/firefox"/>
-        </condition>
-        <condition property="browser" value="/usr/bin/mozilla">
-            <available file="/usr/bin/mozilla"/>
-        </condition>
-        <condition property="browser" value="/usr/local/mozilla/mozilla">
-            <available file="/usr/local/mozilla/mozilla"/>
-        </condition>
-        <condition property="browser" value="/usr/sfw/lib/firefox/firefox">
-            <available file="/usr/sfw/lib/firefox/firefox"/>
-        </condition>
-        <condition property="browser" value="/opt/csw/bin/firefox">
-            <available file="/opt/csw/bin/firefox"/>
-        </condition>
-        <condition property="browser" value="/usr/sfw/lib/mozilla/mozilla">
-            <available file="/usr/sfw/lib/mozilla/mozilla"/>
-        </condition>
-        <condition property="browser" value="/opt/csw/bin/mozilla">
-            <available file="/opt/csw/bin/mozilla"/>
-        </condition>
-    </target>
-    <target depends="-get-browser" if="do.display.browser.cl" name="-display-browser-cl">
-        <fail unless="browser">
-                    Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable.
-                </fail>
-        <property name="browse.url" value="${deploy.ant.client.url}${client.urlPart}"/>
-        <echo>Launching ${browse.url}</echo>
-        <exec executable="${browser}" spawn="true">
-            <arg line="${browser.args} ${browse.url}"/>
-        </exec>
-    </target>
-    <target depends="init,-init-cos,compile-single" name="run-main">
-        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
-        <webproject1:java classname="${run.class}"/>
-    </target>
-    <target depends="init,compile-test-single,-pre-test-run-single" name="run-test-with-main">
-        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
-        <webproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
-    </target>
-    <target depends="init" if="netbeans.home" name="-do-update-breakpoints">
-        <webproject1:nbjpdaappreloaded/>
-    </target>
-    <!--
-                DEBUGGING SECTION
-            -->
-    <target depends="init,-init-cos,compile,compile-jsps,-do-compile-single-jsp,-pre-dist,-do-tmp-dist-with-manifest,-do-tmp-dist-without-manifest" description="Debug project in IDE." if="netbeans.home" name="debug">
-        <nbstartserver debugmode="true"/>
-        <antcall target="connect-debugger"/>
-        <nbdeploy clientUrlPart="${client.urlPart}" debugmode="true" forceRedeploy="true"/>
-        <antcall target="debug-display-browser-old"/>
-        <antcall target="debug-display-browser"/>
-        <antcall target="connect-client-debugger"/>
-    </target>
-    <target if="do.debug.server" name="connect-debugger" unless="is.debugged">
-        <condition property="listeningcp" value="sourcepath">
-            <istrue value="${j2ee.compile.on.save}"/>
-        </condition>
-        <nbjpdaconnect address="${jpda.address}" host="${jpda.host}" listeningcp="${listeningcp}" name="${name}" transport="${jpda.transport}">
-            <classpath>
-                <path path="${debug.classpath}:${j2ee.platform.classpath}"/>
-            </classpath>
-            <sourcepath>
-                <path path="${web.docbase.dir}"/>
-            </sourcepath>
-        </nbjpdaconnect>
-    </target>
-    <target if="do.display.browser.debug.old" name="debug-display-browser-old">
-        <nbbrowse url="${client.url}"/>
-    </target>
-    <target if="do.display.browser.debug" name="debug-display-browser">
-        <nbbrowse context="${browser.context}" url="${client.url}" urlPath="${client.urlPart}"/>
-    </target>
-    <target if="do.debug.client" name="connect-client-debugger">
-        <webproject1:nbjsdebugstart webUrl="${client.url}"/>
-    </target>
-    <target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test">
-        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
-        <webproject1:debug classname="${debug.class}" classpath="${debug.test.classpath}"/>
-    </target>
-    <target depends="init,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>
-    <target depends="init,compile,compile-jsps,-do-compile-single-jsp,debug" if="netbeans.home" name="debug-single"/>
-    <target depends="init" if="netbeans.home" name="-debug-start-debugger-main-test">
-        <webproject1:nbjpdastart classpath="${debug.test.classpath}" name="${debug.class}"/>
-    </target>
-    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
-        <webproject1:nbjpdastart name="${debug.class}"/>
-    </target>
-    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
-        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
-        <webproject1:debug classname="${debug.class}"/>
-    </target>
-    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single-main"/>
-    <target depends="init" name="-pre-debug-fix">
-        <fail unless="fix.includes">Must set fix.includes</fail>
-        <property name="javac.includes" value="${fix.includes}.java"/>
-    </target>
-    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
-        <webproject1:nbjpdareload/>
-    </target>
-    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
-    <!--
-            =================
-            PROFILING SECTION
-            =================
-            -->
-    <!--
-                pre NB7.2 profiling section; consider it deprecated
-            -->
-    <target description="Profile a J2EE project in the IDE." if="profiler.info.jvmargs.agent" name="-profile-pre72">
-        <condition else="start-profiled-server" property="profiler.startserver.target" value="start-profiled-server-extraargs">
-            <isset property="profiler.info.jvmargs.extra"/>
-        </condition>
-        <antcall target="${profiler.startserver.target}"/>
-        <antcall target="run"/>
-        <antcall target="-profile-start-loadgen"/>
-    </target>
-    <target if="profiler.info.jvmargs.agent" name="start-profiled-server">
-        <nbstartprofiledserver forceRestart="${profiler.j2ee.serverForceRestart}" javaPlatform="${profiler.info.javaPlatform}" startupTimeout="${profiler.j2ee.serverStartupTimeout}">
-            <jvmarg value="${profiler.info.jvmargs.agent}"/>
-            <jvmarg value="${profiler.j2ee.agentID}"/>
-        </nbstartprofiledserver>
-    </target>
-    <target if="profiler.info.jvmargs.agent" name="start-profiled-server-extraargs">
-        <nbstartprofiledserver forceRestart="${profiler.j2ee.serverForceRestart}" javaPlatform="${profiler.info.javaPlatform}" startupTimeout="${profiler.j2ee.serverStartupTimeout}">
-            <jvmarg value="${profiler.info.jvmargs.extra}"/>
-            <jvmarg value="${profiler.info.jvmargs.agent}"/>
-            <jvmarg value="${profiler.j2ee.agentID}"/>
-        </nbstartprofiledserver>
-    </target>
-    <target depends="profile-init,compile-test-single" if="profiler.info.jvmargs.agent" name="-profile-test-single-pre72">
-        <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
-        <nbprofiledirect>
-            <classpath>
-                <path path="${run.test.classpath}"/>
-                <path path="${j2ee.platform.classpath}"/>
-            </classpath>
-        </nbprofiledirect>
-        <junit dir="${profiler.info.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" jvm="${profiler.info.jvm}" showoutput="true">
-            <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
-            <jvmarg value="${profiler.info.jvmargs.agent}"/>
-            <jvmarg line="${profiler.info.jvmargs}"/>
-            <test name="${profile.class}"/>
-            <classpath>
-                <path path="${run.test.classpath}"/>
-                <path path="${j2ee.platform.classpath}"/>
-            </classpath>
-            <syspropertyset>
-                <propertyref prefix="test-sys-prop."/>
-                <mapper from="test-sys-prop.*" to="*" type="glob"/>
-            </syspropertyset>
-            <formatter type="brief" usefile="false"/>
-            <formatter type="xml"/>
-        </junit>
-    </target>
-    <target if="netbeans.home" name="-profile-check">
-        <condition property="profiler.configured">
-            <or>
-                <contains casesensitive="true" string="${run.jvmargs.ide}" substring="-agentpath:"/>
-                <contains casesensitive="true" string="${run.jvmargs.ide}" substring="-javaagent:"/>
-            </or>
-        </condition>
-    </target>
-    <target depends="init,-init-cos,compile,compile-jsps,-do-compile-single-jsp,-pre-dist,-do-tmp-dist-with-manifest,-do-tmp-dist-without-manifest" name="-do-profile">
-        <startprofiler/>
-        <nbstartserver profilemode="true"/>
-        <nbdeploy clientUrlPart="${client.urlPart}" forceRedeploy="true" profilemode="true"/>
-        <antcall target="debug-display-browser-old"/>
-        <antcall target="debug-display-browser"/>
-        <antcall target="-profile-start-loadgen"/>
-    </target>
-    <target depends="-profile-check,-profile-pre72" description="Profile a J2EE project in the IDE." if="profiler.configured" name="profile" unless="profiler.info.jvmargs.agent">
-        <antcall target="-do-profile"/>
-    </target>
-    <target depends="-profile-test-single-pre72" name="profile-test-single"/>
-    <target depends="-profile-check" if="profiler.configured" name="profile-test" unless="profiler.info.jvmargs.agent">
-        <startprofiler/>
-        <antcall target="test-single"/>
-    </target>
-    <target if="profiler.loadgen.path" name="-profile-start-loadgen">
-        <loadgenstart path="${profiler.loadgen.path}"/>
-    </target>
-    <!--
-                JAVADOC SECTION
-            -->
-    <target depends="init" if="have.sources" name="javadoc-build">
-        <mkdir dir="${dist.javadoc.dir}"/>
-        <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
-            <classpath>
-                <path path="${javac.classpath}:${j2ee.platform.classpath}"/>
-            </classpath>
-            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
-                <filename name="**/*.java"/>
-            </fileset>
-            <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
-                <include name="**/*.java"/>
-            </fileset>
-        </javadoc>
-        <copy todir="${dist.javadoc.dir}">
-            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
-                <filename name="**/doc-files/**"/>
-            </fileset>
-            <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
-                <include name="**/doc-files/**"/>
-            </fileset>
-        </copy>
-    </target>
-    <target depends="init,javadoc-build" if="netbeans.home" name="javadoc-browse" unless="no.javadoc.preview">
-        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
-    </target>
-    <target depends="init,javadoc-build,javadoc-browse" description="Build Javadoc." name="javadoc"/>
-    <!--
-                
-                TEST COMPILATION SECTION
-            -->
-    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
-        <mkdir dir="${build.test.classes.dir}"/>
-        <property name="j2ee.platform.embeddableejb.classpath" value=""/>
-    </target>
-    <target name="-pre-compile-test">
-        <!-- Empty placeholder for easier customization. -->
-        <!-- You can override this target in the ../build.xml file. -->
-    </target>
-    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test" if="have.tests" name="-do-compile-test">
-        <webproject2:javac classpath="${javac.test.classpath}:${j2ee.platform.classpath}:${j2ee.platform.embeddableejb.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
-        <copy todir="${build.test.classes.dir}">
-            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
-        </copy>
-    </target>
-    <target name="-post-compile-test">
-        <!-- Empty placeholder for easier customization. -->
-        <!-- You can override this target in the ../build.xml file. -->
-    </target>
-    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
-    <target name="-pre-compile-test-single">
-        <!-- Empty placeholder for easier customization. -->
-        <!-- You can override this target in the ../build.xml file. -->
-    </target>
-    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
-        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
-        <webproject2:javac classpath="${javac.test.classpath}:${j2ee.platform.classpath}:${j2ee.platform.embeddableejb.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" srcdir="${test.src.dir}"/>
-        <copy todir="${build.test.classes.dir}">
-            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
-        </copy>
-    </target>
-    <target name="-post-compile-test-single">
-        <!-- Empty placeholder for easier customization. -->
-        <!-- You can override this target in the ../build.xml file. -->
-    </target>
-    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
-    <!--
-                
-                TEST EXECUTION SECTION
-            -->
-    <target depends="init" if="have.tests" name="-pre-test-run">
-        <mkdir dir="${build.test.results.dir}"/>
-    </target>
-    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
-        <webproject2:test includes="${includes}" testincludes="**/*Test.java"/>
-    </target>
-    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
-        <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
-    </target>
-    <target depends="init" if="have.tests" name="test-report"/>
-    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
-    <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
-    <target depends="init" if="have.tests" name="-pre-test-run-single">
-        <mkdir dir="${build.test.results.dir}"/>
-    </target>
-    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
-        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
-        <webproject2:test excludes="" includes="${test.includes}" testincludes="${test.includes}"/>
-    </target>
-    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
-        <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
-    </target>
-    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
-    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single-method">
-        <fail unless="test.class">Must select some files in the IDE or set test.class</fail>
-        <fail unless="test.method">Must select some method in the IDE or set test.method</fail>
-        <webproject2:test excludes="" includes="${javac.includes}" testincludes="${test.class}" testmethods="${test.method}"/>
-    </target>
-    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single-method" if="have.tests" name="-post-test-run-single-method">
-        <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
-    </target>
-    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single-method,-post-test-run-single-method" description="Run single unit test." name="test-single-method"/>
-    <!--
-                
-                TEST DEBUGGING SECTION
-            -->
-    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test">
-        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
-        <webproject2:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testincludes="${javac.includes}"/>
-    </target>
-    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test-method">
-        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
-        <fail unless="test.method">Must select some method in the IDE or set test.method</fail>
-        <webproject2:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testMethod="${test.method}" testincludes="${test.class}" testmethods="${test.method}"/>
-    </target>
-    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
-        <webproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
-    </target>
-    <target depends="init,compile-test,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
-    <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test-method" name="debug-test-method"/>
-    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
-        <webproject1:nbjpdareload dir="${build.test.classes.dir}"/>
-    </target>
-    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
-    <!--
-                
-                CLEANUP SECTION
-            -->
-    <target depends="init" name="deps-clean" unless="no.deps">
-        <ant antfile="${project.csip-core}/build.xml" inheritall="false" target="clean"/>
-    </target>
-    <target depends="init" name="do-clean">
-        <condition property="build.dir.to.clean" value="${build.web.dir}">
-            <isset property="dist.ear.dir"/>
-        </condition>
-        <property name="build.dir.to.clean" value="${build.web.dir}"/>
-        <delete includeEmptyDirs="true" quiet="true">
-            <fileset dir="${build.dir.to.clean}/WEB-INF/lib"/>
-        </delete>
-        <delete dir="${build.dir}"/>
-        <available file="${build.dir.to.clean}/WEB-INF/lib" property="status.clean-failed" type="dir"/>
-        <delete dir="${dist.dir}"/>
-    </target>
-    <target depends="do-clean" if="status.clean-failed" name="check-clean">
-        <echo message="Warning: unable to delete some files in ${build.web.dir}/WEB-INF/lib - they are probably locked by the J2EE server. "/>
-        <echo level="info" message="To delete all files undeploy the module from Server Registry in Runtime tab and then use Clean again."/>
-    </target>
-    <target depends="init" if="netbeans.home" name="undeploy-clean">
-        <nbundeploy failOnError="false" startServer="false"/>
-    </target>
-    <target name="-post-clean">
-        <!-- Empty placeholder for easier customization. -->
-        <!-- You can override this target in the ../build.xml file. -->
-    </target>
-    <target depends="init,undeploy-clean,deps-clean,do-clean,check-clean,-post-clean" description="Clean build products." name="clean"/>
-    <target depends="clean" description="Clean build products." name="clean-ear"/>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+        *** GENERATED FROM project.xml - DO NOT EDIT  ***
+        ***         EDIT ../build.xml INSTEAD         ***
+
+        For the purpose of easier reading the script
+        is divided into following sections:
+        - initialization
+        - compilation
+        - dist
+        - execution
+        - debugging
+        - javadoc
+        - test compilation
+        - test execution
+        - test debugging
+        - cleanup
+
+        -->
+<project xmlns:webproject1="http://www.netbeans.org/ns/web-project/1" xmlns:webproject2="http://www.netbeans.org/ns/web-project/2" xmlns:webproject3="http://www.netbeans.org/ns/web-project/3" basedir=".." default="default" name="csip-r2-impl">
+    <import file="rest-build.xml"/>
+    <import file="ant-deploy.xml"/>
+    <fail message="Please build using Ant 1.7.1 or higher.">
+        <condition>
+            <not>
+                <antversion atleast="1.7.1"/>
+            </not>
+        </condition>
+    </fail>
+    <target depends="dist,javadoc" description="Build whole project." name="default"/>
+    <!--
+                INITIALIZATION SECTION
+            -->
+    <target name="-pre-init">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="-pre-init" name="-init-private">
+        <property file="nbproject/private/private.properties"/>
+    </target>
+    <target depends="-pre-init,-init-private" name="-init-user">
+        <property file="${user.properties.file}"/>
+        <!-- The two properties below are usually overridden -->
+        <!-- by the active platform. Just a fallback. -->
+        <property name="default.javac.source" value="1.4"/>
+        <property name="default.javac.target" value="1.4"/>
+    </target>
+    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
+        <property file="nbproject/project.properties"/>
+    </target>
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" if="dist.ear.dir" name="-do-ear-init"/>
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
+        <condition property="have.tests">
+            <or>
+                <available file="${test.src.dir}"/>
+            </or>
+        </condition>
+        <condition property="have.sources">
+            <or>
+                <available file="${src.dir}"/>
+            </or>
+        </condition>
+        <condition property="netbeans.home+have.tests">
+            <and>
+                <isset property="netbeans.home"/>
+                <isset property="have.tests"/>
+            </and>
+        </condition>
+        <condition property="no.javadoc.preview">
+            <isfalse value="${javadoc.preview}"/>
+        </condition>
+        <property name="javac.compilerargs" value=""/>
+        <condition property="no.deps">
+            <and>
+                <istrue value="${no.dependencies}"/>
+            </and>
+        </condition>
+        <condition property="no.dist.ear.dir">
+            <not>
+                <isset property="dist.ear.dir"/>
+            </not>
+        </condition>
+        <property name="build.web.excludes" value="${build.classes.excludes}"/>
+        <condition property="do.compile.jsps">
+            <istrue value="${compile.jsps}"/>
+        </condition>
+        <condition property="do.debug.server">
+            <or>
+                <not>
+                    <isset property="debug.server"/>
+                </not>
+                <istrue value="${debug.server}"/>
+                <and>
+                    <not>
+                        <istrue value="${debug.server}"/>
+                    </not>
+                    <not>
+                        <istrue value="${debug.client}"/>
+                    </not>
+                </and>
+            </or>
+        </condition>
+        <condition property="do.debug.client">
+            <istrue value="${debug.client}"/>
+        </condition>
+        <condition property="do.display.browser">
+            <istrue value="${display.browser}"/>
+        </condition>
+        <condition property="do.display.browser.debug.old">
+            <and>
+                <isset property="do.display.browser"/>
+                <not>
+                    <isset property="do.debug.client"/>
+                </not>
+                <not>
+                    <isset property="browser.context"/>
+                </not>
+            </and>
+        </condition>
+        <condition property="do.display.browser.debug">
+            <and>
+                <isset property="do.display.browser"/>
+                <not>
+                    <isset property="do.debug.client"/>
+                </not>
+                <isset property="browser.context"/>
+            </and>
+        </condition>
+        <available file="${conf.dir}/MANIFEST.MF" property="has.custom.manifest"/>
+        <available file="${persistence.xml.dir}/persistence.xml" property="has.persistence.xml"/>
+        <condition property="do.war.package.with.custom.manifest">
+            <isset property="has.custom.manifest"/>
+        </condition>
+        <condition property="do.war.package.without.custom.manifest">
+            <not>
+                <isset property="has.custom.manifest"/>
+            </not>
+        </condition>
+        <condition property="do.tmp.war.package.with.custom.manifest">
+            <and>
+                <isset property="has.custom.manifest"/>
+                <or>
+                    <isfalse value="${directory.deployment.supported}"/>
+                    <isset property="dist.ear.dir"/>
+                </or>
+            </and>
+        </condition>
+        <condition property="do.tmp.war.package.without.custom.manifest">
+            <and>
+                <not>
+                    <isset property="has.custom.manifest"/>
+                </not>
+                <or>
+                    <isfalse value="${directory.deployment.supported}"/>
+                    <isset property="dist.ear.dir"/>
+                </or>
+            </and>
+        </condition>
+        <condition property="do.tmp.war.package">
+            <or>
+                <isfalse value="${directory.deployment.supported}"/>
+                <isset property="dist.ear.dir"/>
+            </or>
+        </condition>
+        <property name="build.meta.inf.dir" value="${build.web.dir}/META-INF"/>
+        <condition else="" property="application.args.param" value="${application.args}">
+            <and>
+                <isset property="application.args"/>
+                <not>
+                    <equals arg1="${application.args}" arg2="" trim="true"/>
+                </not>
+            </and>
+        </condition>
+        <property name="source.encoding" value="${file.encoding}"/>
+        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
+            <and>
+                <isset property="javadoc.encoding"/>
+                <not>
+                    <equals arg1="${javadoc.encoding}" arg2=""/>
+                </not>
+            </and>
+        </condition>
+        <property name="javadoc.encoding.used" value="${source.encoding}"/>
+        <property name="includes" value="**"/>
+        <property name="excludes" value=""/>
+        <property name="runmain.jvmargs" value=""/>
+        <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
+        <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">
+            <and>
+                <isset property="endorsed.classpath"/>
+                <length length="0" string="${endorsed.classpath}" when="greater"/>
+            </and>
+        </condition>
+        <condition else="false" property="jdkBug6558476">
+            <and>
+                <matches pattern="1\.[56]" string="${java.specification.version}"/>
+                <not>
+                    <os family="unix"/>
+                </not>
+            </and>
+        </condition>
+        <property name="javac.fork" value="${jdkBug6558476}"/>
+        <condition property="junit.available">
+            <or>
+                <available classname="org.junit.Test" classpath="${run.test.classpath}"/>
+                <available classname="junit.framework.Test" classpath="${run.test.classpath}"/>
+            </or>
+        </condition>
+        <condition property="testng.available">
+            <available classname="org.testng.annotations.Test" classpath="${run.test.classpath}"/>
+        </condition>
+        <condition property="junit+testng.available">
+            <and>
+                <istrue value="${junit.available}"/>
+                <istrue value="${testng.available}"/>
+            </and>
+        </condition>
+        <condition else="testng" property="testng.mode" value="mixed">
+            <istrue value="${junit+testng.available}"/>
+        </condition>
+        <condition else="" property="testng.debug.mode" value="-mixed">
+            <istrue value="${junit+testng.available}"/>
+        </condition>
+    </target>
+    <target depends="init" name="-init-cos" unless="deploy.on.save">
+        <condition property="deploy.on.save" value="true">
+            <or>
+                <istrue value="${j2ee.deploy.on.save}"/>
+                <istrue value="${j2ee.compile.on.save}"/>
+            </or>
+        </condition>
+    </target>
+    <target name="-post-init">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
+        <fail unless="src.dir">Must set src.dir</fail>
+        <fail unless="test.src.dir">Must set test.src.dir</fail>
+        <fail unless="build.dir">Must set build.dir</fail>
+        <fail unless="build.web.dir">Must set build.web.dir</fail>
+        <fail unless="build.generated.dir">Must set build.generated.dir</fail>
+        <fail unless="dist.dir">Must set dist.dir</fail>
+        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
+        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
+        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
+        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
+        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
+        <fail unless="dist.war">Must set dist.war</fail>
+        <condition property="missing.j2ee.server.home">
+            <and>
+                <matches pattern="j2ee.server.home" string="${j2ee.platform.classpath}"/>
+                <not>
+                    <isset property="j2ee.server.home"/>
+                </not>
+            </and>
+        </condition>
+        <fail if="missing.j2ee.server.home">
+The Java EE server classpath is not correctly set up - server home directory is missing.
+Either open the project in the IDE and assign the server or setup the server classpath manually.
+For example like this:
+   ant -Dj2ee.server.home=&lt;app_server_installation_directory&gt;
+                </fail>
+        <fail unless="j2ee.platform.classpath">
+The Java EE server classpath is not correctly set up. Your active server type is ${j2ee.server.type}.
+Either open the project in the IDE and assign the server or setup the server classpath manually.
+For example like this:
+   ant -Duser.properties.file=&lt;path_to_property_file&gt; (where you put the property "j2ee.platform.classpath" in a .properties file)
+or ant -Dj2ee.platform.classpath=&lt;server_classpath&gt; (where no properties file is used)
+                </fail>
+    </target>
+    <target name="-init-macrodef-property">
+        <macrodef name="property" uri="http://www.netbeans.org/ns/web-project/1">
+            <attribute name="name"/>
+            <attribute name="value"/>
+            <sequential>
+                <property name="@{name}" value="${@{value}}"/>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-macrodef-javac-with-processors">
+        <macrodef name="javac" uri="http://www.netbeans.org/ns/web-project/2">
+            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${build.classes.dir}" name="destdir"/>
+            <attribute default="${javac.classpath}:${j2ee.platform.classpath}" name="classpath"/>
+            <attribute default="${javac.processorpath}" name="processorpath"/>
+            <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="${javac.debug}" name="debug"/>
+            <attribute default="${empty.dir}" name="gensrcdir"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property location="${build.dir}/empty" name="empty.dir"/>
+                <mkdir dir="${empty.dir}"/>
+                <mkdir dir="@{apgeneratedsrcdir}"/>
+                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" srcdir="@{srcdir}" target="${javac.target}">
+                    <src>
+                        <dirset dir="@{gensrcdir}" erroronmissingdir="false">
+                            <include name="*"/>
+                        </dirset>
+                    </src>
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                    <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <compilerarg line="${javac.compilerargs}"/>
+                    <compilerarg value="-processorpath"/>
+                    <compilerarg path="@{processorpath}:${empty.dir}"/>
+                    <compilerarg line="${ap.processors.internal}"/>
+                    <compilerarg value="-s"/>
+                    <compilerarg path="@{apgeneratedsrcdir}"/>
+                    <compilerarg line="${ap.proc.none.internal}"/>
+                    <customize/>
+                </javac>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-ap-cmdline-properties" name="-init-macrodef-javac-without-processors" unless="ap.supported.internal">
+        <macrodef name="javac" uri="http://www.netbeans.org/ns/web-project/2">
+            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${build.classes.dir}" name="destdir"/>
+            <attribute default="${javac.classpath}:${j2ee.platform.classpath}" name="classpath"/>
+            <attribute default="${javac.processorpath}" name="processorpath"/>
+            <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="${javac.debug}" name="debug"/>
+            <attribute default="${empty.dir}" name="gensrcdir"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property location="${build.dir}/empty" name="empty.dir"/>
+                <mkdir dir="${empty.dir}"/>
+                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeantruntime="false" includes="@{includes}" source="${javac.source}" srcdir="@{srcdir}" target="${javac.target}">
+                    <src>
+                        <dirset dir="@{gensrcdir}" erroronmissingdir="false">
+                            <include name="*"/>
+                        </dirset>
+                    </src>
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                    <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <compilerarg line="${javac.compilerargs}"/>
+                    <customize/>
+                </javac>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors" name="-init-macrodef-javac">
+        <macrodef name="depend" uri="http://www.netbeans.org/ns/web-project/2">
+            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${build.classes.dir}" name="destdir"/>
+            <attribute default="${javac.classpath}:${j2ee.platform.classpath}" name="classpath"/>
+            <sequential>
+                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                </depend>
+            </sequential>
+        </macrodef>
+        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/web-project/2">
+            <attribute default="${build.classes.dir}" name="destdir"/>
+            <sequential>
+                <fail unless="javac.includes">Must set javac.includes</fail>
+                <pathconvert pathsep="${line.separator}" property="javac.includes.binary">
+                    <path>
+                        <filelist dir="@{destdir}" files="${javac.includes}"/>
+                    </path>
+                    <globmapper from="*.java" to="*.class"/>
+                </pathconvert>
+                <tempfile deleteonexit="true" property="javac.includesfile.binary"/>
+                <echo file="${javac.includesfile.binary}" message="${javac.includes.binary}"/>
+                <delete>
+                    <files includesfile="${javac.includesfile.binary}"/>
+                </delete>
+                <delete file="${javac.includesfile.binary}"/>
+            </sequential>
+        </macrodef>
+    </target>
+    <target if="${junit.available}" name="-init-macrodef-junit-init">
+        <condition else="false" property="nb.junit.batch" value="true">
+            <and>
+                <istrue value="${junit.available}"/>
+                <not>
+                    <isset property="test.method"/>
+                </not>
+            </and>
+        </condition>
+        <condition else="false" property="nb.junit.single" value="true">
+            <and>
+                <istrue value="${junit.available}"/>
+                <isset property="test.method"/>
+            </and>
+        </condition>
+    </target>
+    <target name="-init-test-properties">
+        <property name="test.binaryincludes" value="&lt;nothing&gt;"/>
+        <property name="test.binarytestincludes" value=""/>
+        <property name="test.binaryexcludes" value=""/>
+    </target>
+    <target if="${nb.junit.single}" name="-init-macrodef-junit-single" unless="${nb.junit.batch}">
+        <macrodef name="junit" uri="http://www.netbeans.org/ns/web-project/2">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <junit dir="${basedir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${java.io.tmpdir}">
+                    <test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/>
+                    <syspropertyset>
+                        <propertyref prefix="test-sys-prop."/>
+                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <formatter type="brief" usefile="false"/>
+                    <formatter type="xml"/>
+                    <jvmarg value="-ea"/>
+                    <customize/>
+                </junit>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
+        <macrodef name="junit" uri="http://www.netbeans.org/ns/web-project/2">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property name="run.jvmargs.ide" value=""/>
+                <junit dir="${basedir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${build.dir}">
+                    <batchtest todir="${build.test.results.dir}">
+                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
+                            <filename name="@{testincludes}"/>
+                        </fileset>
+                        <fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
+                            <filename name="${test.binarytestincludes}"/>
+                        </fileset>
+                    </batchtest>
+                    <syspropertyset>
+                        <propertyref prefix="test-sys-prop."/>
+                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <formatter type="brief" usefile="false"/>
+                    <formatter type="xml"/>
+                    <jvmarg value="-ea"/>
+                    <jvmarg line="${run.jvmargs.ide}"/>
+                    <customize/>
+                </junit>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-junit-init,-init-macrodef-junit-single, -init-macrodef-junit-batch" if="${junit.available}" name="-init-macrodef-junit"/>
+    <target if="${testng.available}" name="-init-macrodef-testng">
+        <macrodef name="testng" uri="http://www.netbeans.org/ns/web-project/2">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <condition else="" property="testng.methods.arg" value="@{testincludes}.@{testmethods}">
+                    <isset property="test.method"/>
+                </condition>
+                <union id="test.set">
+                    <fileset dir="${test.src.dir}" excludes="@{excludes},**/*.xml,${excludes}" includes="@{includes}">
+                        <filename name="@{testincludes}"/>
+                    </fileset>
+                </union>
+                <taskdef classname="org.testng.TestNGAntTask" classpath="${run.test.classpath}" name="testng"/>
+                <testng classfilesetref="test.set" failureProperty="tests.failed" listeners="org.testng.reporters.VerboseReporter" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="csip-r2" testname="TestNG tests" workingDir="${basedir}">
+                    <xmlfileset dir="${build.test.classes.dir}" includes="@{testincludes}"/>
+                    <propertyset>
+                        <propertyref prefix="test-sys-prop."/>
+                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                    </propertyset>
+                    <customize/>
+                </testng>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-macrodef-test-impl">
+        <macrodef name="test-impl" uri="http://www.netbeans.org/ns/web-project/2">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element implicit="true" name="customize" optional="true"/>
+            <sequential>
+                <echo>No tests executed.</echo>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-junit" if="${junit.available}" name="-init-macrodef-junit-impl">
+        <macrodef name="test-impl" uri="http://www.netbeans.org/ns/web-project/2">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element implicit="true" name="customize" optional="true"/>
+            <sequential>
+                <webproject2:junit excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
+                    <customize/>
+                </webproject2:junit>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-testng" if="${testng.available}" name="-init-macrodef-testng-impl">
+        <macrodef name="test-impl" uri="http://www.netbeans.org/ns/web-project/2">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element implicit="true" name="customize" optional="true"/>
+            <sequential>
+                <webproject2:testng excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
+                    <customize/>
+                </webproject2:testng>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-test-impl,-init-macrodef-junit-impl,-init-macrodef-testng-impl" name="-init-macrodef-test">
+        <macrodef name="test" uri="http://www.netbeans.org/ns/web-project/2">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <sequential>
+                <webproject2:test-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
+                    <customize>
+                        <classpath>
+                            <path path="${run.test.classpath}:${j2ee.platform.classpath}:${j2ee.platform.embeddableejb.classpath}"/>
+                        </classpath>
+                        <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                        <jvmarg line="${runmain.jvmargs}"/>
+                    </customize>
+                </webproject2:test-impl>
+            </sequential>
+        </macrodef>
+    </target>
+    <target if="${junit.available}" name="-init-macrodef-junit-debug" unless="${nb.junit.batch}">
+        <macrodef name="junit-debug" uri="http://www.netbeans.org/ns/web-project/2">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <junit dir="${basedir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${java.io.tmpdir}">
+                    <test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/>
+                    <syspropertyset>
+                        <propertyref prefix="test-sys-prop."/>
+                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <formatter type="brief" usefile="false"/>
+                    <formatter type="xml"/>
+                    <jvmarg value="-ea"/>
+                    <jvmarg line="${debug-args-line}"/>
+                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
+                    <customize/>
+                </junit>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
+        <macrodef name="junit-debug" uri="http://www.netbeans.org/ns/web-project/2">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property name="run.jvmargs.ide" value=""/>
+                <junit dir="${basedir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${build.dir}">
+                    <batchtest todir="${build.test.results.dir}">
+                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
+                            <filename name="@{testincludes}"/>
+                        </fileset>
+                        <fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
+                            <filename name="${test.binarytestincludes}"/>
+                        </fileset>
+                    </batchtest>
+                    <syspropertyset>
+                        <propertyref prefix="test-sys-prop."/>
+                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <formatter type="brief" usefile="false"/>
+                    <formatter type="xml"/>
+                    <jvmarg value="-ea"/>
+                    <jvmarg line="${run.jvmargs.ide}"/>
+                    <jvmarg line="${debug-args-line}"/>
+                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
+                    <customize/>
+                </junit>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-junit-debug,-init-macrodef-junit-debug-batch" if="${junit.available}" name="-init-macrodef-junit-debug-impl">
+        <macrodef name="test-debug-impl" uri="http://www.netbeans.org/ns/web-project/2">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element implicit="true" name="customize" optional="true"/>
+            <sequential>
+                <webproject2:junit-debug excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
+                    <customize/>
+                </webproject2:junit-debug>
+            </sequential>
+        </macrodef>
+    </target>
+    <target if="${testng.available}" name="-init-macrodef-testng-debug">
+        <macrodef name="testng-debug" uri="http://www.netbeans.org/ns/web-project/2">
+            <attribute default="${main.class}" name="testClass"/>
+            <attribute default="" name="testMethod"/>
+            <element name="customize2" optional="true"/>
+            <sequential>
+                <condition else="-testclass @{testClass}" property="test.class.or.method" value="-methods @{testClass}.@{testMethod}">
+                    <isset property="test.method"/>
+                </condition>
+                <condition else="-suitename csip-r2 -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}">
+                    <matches pattern=".*\.xml" string="@{testClass}"/>
+                </condition>
+                <delete dir="${build.test.results.dir}" quiet="true"/>
+                <mkdir dir="${build.test.results.dir}"/>
+                <webproject1:debug args="${testng.cmd.args}" classname="org.testng.TestNG" classpath="${debug.test.classpath}:${j2ee.platform.embeddableejb.classpath}">
+                    <customize>
+                        <customize2/>
+                        <jvmarg value="-ea"/>
+                        <arg line="${testng.debug.mode}"/>
+                        <arg line="-d ${build.test.results.dir}"/>
+                        <arg line="-listener org.testng.reporters.VerboseReporter"/>
+                    </customize>
+                </webproject1:debug>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-testng-debug" if="${testng.available}" name="-init-macrodef-testng-debug-impl">
+        <macrodef name="testng-debug-impl" uri="http://www.netbeans.org/ns/web-project/2">
+            <attribute default="${main.class}" name="testClass"/>
+            <attribute default="" name="testMethod"/>
+            <element implicit="true" name="customize2" optional="true"/>
+            <sequential>
+                <webproject2:testng-debug testClass="@{testClass}" testMethod="@{testMethod}">
+                    <customize2/>
+                </webproject2:testng-debug>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-junit-debug-impl" if="${junit.available}" name="-init-macrodef-test-debug-junit">
+        <macrodef name="test-debug" uri="http://www.netbeans.org/ns/web-project/2">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <attribute default="${main.class}" name="testClass"/>
+            <attribute default="" name="testMethod"/>
+            <sequential>
+                <webproject2:test-debug-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
+                    <customize>
+                        <classpath>
+                            <path path="${run.test.classpath}:${j2ee.platform.classpath}:${j2ee.platform.embeddableejb.classpath}"/>
+                        </classpath>
+                        <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                        <jvmarg line="${runmain.jvmargs}"/>
+                    </customize>
+                </webproject2:test-debug-impl>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-testng-debug-impl" if="${testng.available}" name="-init-macrodef-test-debug-testng">
+        <macrodef name="test-debug" uri="http://www.netbeans.org/ns/web-project/2">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <attribute default="${main.class}" name="testClass"/>
+            <attribute default="" name="testMethod"/>
+            <sequential>
+                <webproject2:testng-debug-impl testClass="@{testClass}" testMethod="@{testMethod}">
+                    <customize2>
+                        <syspropertyset>
+                            <propertyref prefix="test-sys-prop."/>
+                            <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                        </syspropertyset>
+                    </customize2>
+                </webproject2:testng-debug-impl>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-test-debug-junit,-init-macrodef-test-debug-testng" name="-init-macrodef-test-debug"/>
+    <target name="-init-macrodef-java">
+        <macrodef name="java" uri="http://www.netbeans.org/ns/web-project/1">
+            <attribute default="${main.class}" name="classname"/>
+            <attribute default="${debug.classpath}" name="classpath"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <java classname="@{classname}" fork="true">
+                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <jvmarg line="${runmain.jvmargs}"/>
+                    <classpath>
+                        <path path="@{classpath}:${j2ee.platform.classpath}"/>
+                    </classpath>
+                    <syspropertyset>
+                        <propertyref prefix="run-sys-prop."/>
+                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <customize/>
+                </java>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-macrodef-nbjsdebug">
+        <macrodef name="nbjsdebugstart" uri="http://www.netbeans.org/ns/web-project/1">
+            <attribute default="${client.url}" name="webUrl"/>
+            <sequential>
+                <nbjsdebugstart urlPart="${client.urlPart}" webUrl="@{webUrl}"/>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
+        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/web-project/1">
+            <attribute default="${main.class}" name="name"/>
+            <attribute default="${debug.classpath}:${j2ee.platform.classpath}" name="classpath"/>
+            <sequential>
+                <nbjpdastart addressproperty="jpda.address" name="@{name}" transport="${debug-transport}">
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                </nbjpdastart>
+            </sequential>
+        </macrodef>
+        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/web-project/1">
+            <attribute default="${build.classes.dir}" name="dir"/>
+            <sequential>
+                <nbjpdareload>
+                    <fileset dir="@{dir}" includes="${fix.classes}">
+                        <include name="${fix.includes}*.class"/>
+                    </fileset>
+                </nbjpdareload>
+            </sequential>
+        </macrodef>
+        <macrodef name="nbjpdaappreloaded" uri="http://www.netbeans.org/ns/web-project/1">
+            <sequential>
+                <nbjpdaappreloaded/>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-debug-args">
+        <property name="version-output" value="java version &quot;${ant.java.version}"/>
+        <condition property="have-jdk-older-than-1.4">
+            <or>
+                <contains string="${version-output}" substring="java version &quot;1.0"/>
+                <contains string="${version-output}" substring="java version &quot;1.1"/>
+                <contains string="${version-output}" substring="java version &quot;1.2"/>
+                <contains string="${version-output}" substring="java version &quot;1.3"/>
+            </or>
+        </condition>
+        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
+            <istrue value="${have-jdk-older-than-1.4}"/>
+        </condition>
+        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
+            <os family="windows"/>
+        </condition>
+        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
+            <isset property="debug.transport"/>
+        </condition>
+    </target>
+    <target depends="-init-debug-args" name="-init-macrodef-debug">
+        <macrodef name="debug" uri="http://www.netbeans.org/ns/web-project/1">
+            <attribute default="${main.class}" name="classname"/>
+            <attribute default="${debug.classpath}:${j2ee.platform.classpath}" name="classpath"/>
+            <attribute default="${application.args.param}" name="args"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <java classname="@{classname}" fork="true">
+                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <jvmarg line="${debug-args-line}"/>
+                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
+                    <jvmarg line="${runmain.jvmargs}"/>
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                    <syspropertyset>
+                        <propertyref prefix="run-sys-prop."/>
+                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <arg line="@{args}"/>
+                    <customize/>
+                </java>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-taskdefs">
+        <fail unless="libs.CopyLibs.classpath">
+The libs.CopyLibs.classpath property is not set up.
+This property must point to 
+org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part
+of NetBeans IDE installation and is usually located at 
+&lt;netbeans_installation&gt;/java&lt;version&gt;/ant/extra folder.
+Either open the project in the IDE and make sure CopyLibs library
+exists or setup the property manually. For example like this:
+ ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar
+                </fail>
+        <taskdef classpath="${libs.CopyLibs.classpath}" resource="org/netbeans/modules/java/j2seproject/copylibstask/antlib.xml"/>
+    </target>
+    <target name="-init-ap-cmdline-properties">
+        <property name="annotation.processing.enabled" value="true"/>
+        <property name="annotation.processing.processors.list" value=""/>
+        <property name="annotation.processing.run.all.processors" value="true"/>
+        <property name="javac.processorpath" value="${javac.classpath}"/>
+        <property name="javac.test.processorpath" value="${javac.test.classpath}"/>
+        <condition property="ap.supported.internal" value="true">
+            <not>
+                <matches pattern="1\.[0-5](\..*)?" string="${javac.source}"/>
+            </not>
+        </condition>
+    </target>
+    <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-ap-cmdline-supported">
+        <condition else="" property="ap.processors.internal" value="-processor ${annotation.processing.processors.list}">
+            <isfalse value="${annotation.processing.run.all.processors}"/>
+        </condition>
+        <condition else="" property="ap.proc.none.internal" value="-proc:none">
+            <isfalse value="${annotation.processing.enabled}"/>
+        </condition>
+    </target>
+    <target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline">
+        <property name="ap.cmd.line.internal" value=""/>
+    </target>
+    <!--
+                pre NB7.2 profiling section; consider it deprecated
+            -->
+    <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-check" if="profiler.info.jvmargs.agent" name="profile-init"/>
+    <target if="profiler.info.jvmargs.agent" name="-profile-pre-init">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target if="profiler.info.jvmargs.agent" name="-profile-post-init">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="-profile-pre-init, init, -profile-post-init" if="profiler.info.jvmargs.agent" name="-profile-init-check">
+        <fail unless="profiler.info.jvm">Must set JVM to use for profiling in profiler.info.jvm</fail>
+        <fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail>
+    </target>
+    <!--
+                end of pre NB7.2 profiling section
+            -->
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-test,-init-macrodef-test-debug,-init-macrodef-java,-init-macrodef-nbjpda,-init-macrodef-nbjsdebug,-init-macrodef-debug,-init-taskdefs,-init-ap-cmdline" name="init"/>
+    <!--
+                COMPILATION SECTION
+            -->
+    <target depends="init" if="no.dist.ear.dir" name="deps-module-jar" unless="no.deps">
+        <ant antfile="${project.csip-core}/build.xml" inheritall="false" target="jar">
+            <property name="deploy.on.save" value="false"/>
+        </ant>
+    </target>
+    <target depends="init" if="dist.ear.dir" name="deps-ear-jar" unless="no.deps">
+        <ant antfile="${project.csip-core}/build.xml" inheritall="false" target="jar">
+            <property name="deploy.on.save" value="false"/>
+        </ant>
+    </target>
+    <target depends="init, deps-module-jar, deps-ear-jar" name="deps-jar" unless="no.deps"/>
+    <target depends="init,deps-jar,generate-rest-config" name="-pre-pre-compile">
+        <mkdir dir="${build.classes.dir}"/>
+    </target>
+    <target name="-pre-compile">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target name="-copy-webdir">
+        <copy todir="${build.web.dir}">
+            <fileset dir="${web.docbase.dir}" excludes="${build.web.excludes},${excludes}" includes="${includes}"/>
+        </copy>
+        <copy todir="${build.web.dir}/WEB-INF">
+            <fileset dir="${webinf.dir}" excludes="${build.web.excludes}"/>
+        </copy>
+    </target>
+    <target depends="init, deps-jar, -pre-pre-compile, -pre-compile, -copy-manifest, -copy-persistence-xml, -copy-webdir, library-inclusion-in-archive,library-inclusion-in-manifest" if="have.sources" name="-do-compile">
+        <webproject2:javac destdir="${build.classes.dir}" gensrcdir="${build.generated.sources.dir}"/>
+        <copy todir="${build.classes.dir}">
+            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+        </copy>
+    </target>
+    <target if="has.custom.manifest" name="-copy-manifest">
+        <mkdir dir="${build.meta.inf.dir}"/>
+        <copy todir="${build.meta.inf.dir}">
+            <fileset dir="${conf.dir}" includes="MANIFEST.MF"/>
+        </copy>
+    </target>
+    <target if="has.persistence.xml" name="-copy-persistence-xml">
+        <mkdir dir="${build.web.dir}/WEB-INF/classes/META-INF"/>
+        <copy todir="${build.web.dir}/WEB-INF/classes/META-INF">
+            <fileset dir="${persistence.xml.dir}" includes="persistence.xml orm.xml"/>
+        </copy>
+    </target>
+    <target name="-post-compile">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
+    <target name="-pre-compile-single">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
+        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
+        <webproject2:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}"/>
+        <copy todir="${build.classes.dir}">
+            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+        </copy>
+    </target>
+    <target name="-post-compile-single">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
+    <property name="jspc.schemas" value="/resources/schemas/"/>
+    <property name="jspc.dtds" value="/resources/dtds/"/>
+    <target depends="compile" description="Test compile JSP pages to expose compilation errors." if="do.compile.jsps" name="compile-jsps">
+        <mkdir dir="${build.generated.dir}/src"/>
+        <java classname="org.netbeans.modules.web.project.ant.JspC" failonerror="true" fork="true">
+            <arg value="-uriroot"/>
+            <arg file="${basedir}/${build.web.dir}"/>
+            <arg value="-d"/>
+            <arg file="${basedir}/${build.generated.dir}/src"/>
+            <arg value="-die1"/>
+            <arg value="-schemas ${jspc.schemas}"/>
+            <arg value="-dtds ${jspc.dtds}"/>
+            <arg value="-compilerSourceVM ${javac.source}"/>
+            <arg value="-compilerTargetVM ${javac.target}"/>
+            <arg value="-javaEncoding ${source.encoding}"/>
+            <arg value="-sysClasspath ${libs.jsp-compilation-syscp.classpath}"/>
+            <classpath path="${java.home}/../lib/tools.jar:${libs.jsp-compiler.classpath}:${libs.jsp-compilation.classpath}"/>
+        </java>
+        <mkdir dir="${build.generated.dir}/classes"/>
+        <webproject2:javac classpath="${build.classes.dir}:${libs.jsp-compilation.classpath}:${javac.classpath}:${j2ee.platform.classpath}" destdir="${build.generated.dir}/classes" srcdir="${build.generated.dir}/src"/>
+    </target>
+    <target depends="compile" if="jsp.includes" name="-do-compile-single-jsp">
+        <fail unless="javac.jsp.includes">Must select some files in the IDE or set javac.jsp.includes</fail>
+        <mkdir dir="${build.generated.dir}/src"/>
+        <java classname="org.netbeans.modules.web.project.ant.JspCSingle" failonerror="true" fork="true">
+            <arg value="-uriroot"/>
+            <arg file="${basedir}/${build.web.dir}"/>
+            <arg value="-d"/>
+            <arg file="${basedir}/${build.generated.dir}/src"/>
+            <arg value="-die1"/>
+            <arg value="-schemas ${jspc.schemas}"/>
+            <arg value="-dtds ${jspc.dtds}"/>
+            <arg value="-sysClasspath ${libs.jsp-compilation-syscp.classpath}"/>
+            <arg value="-jspc.files"/>
+            <arg path="${jsp.includes}"/>
+            <arg value="-compilerSourceVM ${javac.source}"/>
+            <arg value="-compilerTargetVM ${javac.target}"/>
+            <arg value="-javaEncoding ${source.encoding}"/>
+            <classpath path="${java.home}/../lib/tools.jar:${libs.jsp-compiler.classpath}:${libs.jsp-compilation.classpath}"/>
+        </java>
+        <mkdir dir="${build.generated.dir}/classes"/>
+        <webproject2:javac classpath="${build.classes.dir}:${libs.jsp-compilation.classpath}:${javac.classpath}:${j2ee.platform.classpath}" destdir="${build.generated.dir}/classes" srcdir="${build.generated.dir}/src">
+            <customize>
+                <patternset includes="${javac.jsp.includes}"/>
+            </customize>
+        </webproject2:javac>
+    </target>
+    <target name="compile-single-jsp">
+        <fail unless="jsp.includes">Must select a file in the IDE or set jsp.includes</fail>
+        <antcall target="-do-compile-single-jsp"/>
+    </target>
+    <!--
+                DIST BUILDING SECTION
+            -->
+    <target name="-pre-dist">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,compile-jsps,-pre-dist" if="do.war.package.without.custom.manifest" name="-do-dist-without-manifest">
+        <dirname file="${dist.war}" property="dist.jar.dir"/>
+        <mkdir dir="${dist.jar.dir}"/>
+        <jar compress="${jar.compress}" jarfile="${dist.war}">
+            <fileset dir="${build.web.dir}" excludes="WEB-INF/classes/.netbeans_*,${dist.archive.excludes}"/>
+        </jar>
+    </target>
+    <target depends="init,compile,compile-jsps,-pre-dist" if="do.war.package.with.custom.manifest" name="-do-dist-with-manifest">
+        <dirname file="${dist.war}" property="dist.jar.dir"/>
+        <mkdir dir="${dist.jar.dir}"/>
+        <jar compress="${jar.compress}" jarfile="${dist.war}" manifest="${build.meta.inf.dir}/MANIFEST.MF">
+            <fileset dir="${build.web.dir}" excludes="WEB-INF/classes/.netbeans_*,${dist.archive.excludes}"/>
+        </jar>
+    </target>
+    <target depends="init,compile,compile-jsps,-pre-dist" if="do.tmp.war.package.without.custom.manifest" name="-do-tmp-dist-without-manifest">
+        <dirname file="${dist.war}" property="dist.jar.dir"/>
+        <mkdir dir="${dist.jar.dir}"/>
+        <jar compress="${jar.compress}" jarfile="${dist.war}">
+            <fileset dir="${build.web.dir}" excludes="WEB-INF/classes/.netbeans_*,${dist.archive.excludes}"/>
+        </jar>
+    </target>
+    <target depends="init,compile,compile-jsps,-pre-dist" if="do.tmp.war.package.with.custom.manifest" name="-do-tmp-dist-with-manifest">
+        <dirname file="${dist.war}" property="dist.jar.dir"/>
+        <mkdir dir="${dist.jar.dir}"/>
+        <jar compress="${jar.compress}" jarfile="${dist.war}" manifest="${build.meta.inf.dir}/MANIFEST.MF">
+            <fileset dir="${build.web.dir}" excludes="WEB-INF/classes/.netbeans_*,${dist.archive.excludes}"/>
+        </jar>
+    </target>
+    <target depends="init,compile,compile-jsps,-pre-dist,-do-dist-with-manifest,-do-dist-without-manifest" name="do-dist"/>
+    <target depends="init" if="dist.ear.dir" name="library-inclusion-in-manifest">
+        <copyfiles files="${reference.csip-core.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+        <copyfiles files="${libs.CSIP-Jersey-2.16.classpath}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+        <copyfiles files="${file.reference.Lmod2Rusle2.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+        <copyfiles files="${file.reference.csip-soilsdb-3.0.18.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+        <copyfiles files="${file.reference.csip-gis-objects-2.0.17.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+        <copyfiles files="${file.reference.calcmanstir.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+        <copyfiles files="${file.reference.SDMDriver-1.0.4.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+        <mkdir dir="${build.web.dir}/META-INF"/>
+        <manifest file="${build.web.dir}/META-INF/MANIFEST.MF" mode="update"/>
+    </target>
+    <target depends="init" name="library-inclusion-in-archive" unless="dist.ear.dir">
+        <copyfiles files="${reference.csip-core.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+        <copyfiles files="${libs.CSIP-Jersey-2.16.classpath}" todir="${build.web.dir}/WEB-INF/lib"/>
+        <copyfiles files="${file.reference.Lmod2Rusle2.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+        <copyfiles files="${file.reference.csip-soilsdb-3.0.18.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+        <copyfiles files="${file.reference.csip-gis-objects-2.0.17.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+        <copyfiles files="${file.reference.calcmanstir.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+        <copyfiles files="${file.reference.SDMDriver-1.0.4.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+    </target>
+    <target depends="init" if="dist.ear.dir" name="-clean-webinf-lib">
+        <delete dir="${build.web.dir}/WEB-INF/lib"/>
+    </target>
+    <target depends="init,-clean-webinf-lib,compile,compile-jsps,-pre-dist,library-inclusion-in-manifest" if="do.tmp.war.package" name="do-ear-dist">
+        <dirname file="${dist.ear.war}" property="dist.jar.dir"/>
+        <mkdir dir="${dist.jar.dir}"/>
+        <jar compress="${jar.compress}" jarfile="${dist.ear.war}" manifest="${build.web.dir}/META-INF/MANIFEST.MF">
+            <fileset dir="${build.web.dir}" excludes="WEB-INF/classes/.netbeans_*,${dist.archive.excludes}"/>
+        </jar>
+    </target>
+    <target name="-post-dist">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,-pre-dist,do-dist,-post-dist" description="Build distribution (WAR)." name="dist"/>
+    <target depends="init,-clean-webinf-lib,-init-cos,compile,-pre-dist,do-ear-dist,-post-dist" description="Build distribution (WAR) to be packaged into an EAR." name="dist-ear"/>
+    <!--
+                EXECUTION SECTION
+            -->
+    <target depends="run-deploy,run-display-browser" description="Deploy to server and show in browser." name="run"/>
+    <target name="-pre-run-deploy">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target name="-post-run-deploy">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target name="-pre-nbmodule-run-deploy">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- This target can be overriden by NetBeans modules. Don't override it directly, use -pre-run-deploy task instead. -->
+    </target>
+    <target name="-post-nbmodule-run-deploy">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- This target can be overriden by NetBeans modules. Don't override it directly, use -post-run-deploy task instead. -->
+    </target>
+    <target name="-run-deploy-am">
+        <!-- Task to deploy to the Access Manager runtime. -->
+    </target>
+    <target depends="init,-init-cos,compile,compile-jsps,-do-compile-single-jsp,-pre-dist,-do-tmp-dist-with-manifest,-do-tmp-dist-without-manifest,-pre-run-deploy,-pre-nbmodule-run-deploy,-run-deploy-nb,-init-deploy-ant,-deploy-ant,-run-deploy-am,-post-nbmodule-run-deploy,-post-run-deploy,-do-update-breakpoints" name="run-deploy"/>
+    <target if="netbeans.home" name="-run-deploy-nb">
+        <nbdeploy clientUrlPart="${client.urlPart}" debugmode="false" forceRedeploy="${forceRedeploy}"/>
+    </target>
+    <target name="-init-deploy-ant" unless="netbeans.home">
+        <property name="deploy.ant.archive" value="${dist.war}"/>
+        <property name="deploy.ant.docbase.dir" value="${web.docbase.dir}"/>
+        <property name="deploy.ant.resource.dir" value="${resource.dir}"/>
+        <property name="deploy.ant.enabled" value="true"/>
+    </target>
+    <target depends="dist,-run-undeploy-nb,-init-deploy-ant,-undeploy-ant" name="run-undeploy"/>
+    <target if="netbeans.home" name="-run-undeploy-nb">
+        <fail message="Undeploy is not supported from within the IDE"/>
+    </target>
+    <target depends="init,-pre-dist,dist,-post-dist" name="verify">
+        <nbverify file="${dist.war}"/>
+    </target>
+    <target depends="run-deploy,-init-display-browser,-display-browser-nb-old,-display-browser-nb,-display-browser-cl" name="run-display-browser"/>
+    <target if="do.display.browser" name="-init-display-browser">
+        <condition property="do.display.browser.nb.old">
+            <and>
+                <isset property="netbeans.home"/>
+                <not>
+                    <isset property="browser.context"/>
+                </not>
+            </and>
+        </condition>
+        <condition property="do.display.browser.nb">
+            <and>
+                <isset property="netbeans.home"/>
+                <isset property="browser.context"/>
+            </and>
+        </condition>
+        <condition property="do.display.browser.cl">
+            <isset property="deploy.ant.enabled"/>
+        </condition>
+    </target>
+    <target if="do.display.browser.nb.old" name="-display-browser-nb-old">
+        <nbbrowse url="${client.url}"/>
+    </target>
+    <target if="do.display.browser.nb" name="-display-browser-nb">
+        <nbbrowse context="${browser.context}" url="${client.url}" urlPath="${client.urlPart}"/>
+    </target>
+    <target if="do.display.browser.cl" name="-get-browser" unless="browser">
+        <condition property="browser" value="rundll32">
+            <os family="windows"/>
+        </condition>
+        <condition else="" property="browser.args" value="url.dll,FileProtocolHandler">
+            <os family="windows"/>
+        </condition>
+        <condition property="browser" value="/usr/bin/open">
+            <os family="mac"/>
+        </condition>
+        <property environment="env"/>
+        <condition property="browser" value="${env.BROWSER}">
+            <isset property="env.BROWSER"/>
+        </condition>
+        <condition property="browser" value="/usr/bin/firefox">
+            <available file="/usr/bin/firefox"/>
+        </condition>
+        <condition property="browser" value="/usr/local/firefox/firefox">
+            <available file="/usr/local/firefox/firefox"/>
+        </condition>
+        <condition property="browser" value="/usr/bin/mozilla">
+            <available file="/usr/bin/mozilla"/>
+        </condition>
+        <condition property="browser" value="/usr/local/mozilla/mozilla">
+            <available file="/usr/local/mozilla/mozilla"/>
+        </condition>
+        <condition property="browser" value="/usr/sfw/lib/firefox/firefox">
+            <available file="/usr/sfw/lib/firefox/firefox"/>
+        </condition>
+        <condition property="browser" value="/opt/csw/bin/firefox">
+            <available file="/opt/csw/bin/firefox"/>
+        </condition>
+        <condition property="browser" value="/usr/sfw/lib/mozilla/mozilla">
+            <available file="/usr/sfw/lib/mozilla/mozilla"/>
+        </condition>
+        <condition property="browser" value="/opt/csw/bin/mozilla">
+            <available file="/opt/csw/bin/mozilla"/>
+        </condition>
+    </target>
+    <target depends="-get-browser" if="do.display.browser.cl" name="-display-browser-cl">
+        <fail unless="browser">
+                    Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable.
+                </fail>
+        <property name="browse.url" value="${deploy.ant.client.url}${client.urlPart}"/>
+        <echo>Launching ${browse.url}</echo>
+        <exec executable="${browser}" spawn="true">
+            <arg line="${browser.args} ${browse.url}"/>
+        </exec>
+    </target>
+    <target depends="init,-init-cos,compile-single" name="run-main">
+        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
+        <webproject1:java classname="${run.class}"/>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single" name="run-test-with-main">
+        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
+        <webproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
+    </target>
+    <target depends="init" if="netbeans.home" name="-do-update-breakpoints">
+        <webproject1:nbjpdaappreloaded/>
+    </target>
+    <!--
+                DEBUGGING SECTION
+            -->
+    <target depends="init,-init-cos,compile,compile-jsps,-do-compile-single-jsp,-pre-dist,-do-tmp-dist-with-manifest,-do-tmp-dist-without-manifest" description="Debug project in IDE." if="netbeans.home" name="debug">
+        <nbstartserver debugmode="true"/>
+        <antcall target="connect-debugger"/>
+        <nbdeploy clientUrlPart="${client.urlPart}" debugmode="true" forceRedeploy="true"/>
+        <antcall target="debug-display-browser-old"/>
+        <antcall target="debug-display-browser"/>
+        <antcall target="connect-client-debugger"/>
+    </target>
+    <target if="do.debug.server" name="connect-debugger" unless="is.debugged">
+        <condition property="listeningcp" value="sourcepath">
+            <istrue value="${j2ee.compile.on.save}"/>
+        </condition>
+        <nbjpdaconnect address="${jpda.address}" host="${jpda.host}" listeningcp="${listeningcp}" name="${name}" transport="${jpda.transport}">
+            <classpath>
+                <path path="${debug.classpath}:${j2ee.platform.classpath}"/>
+            </classpath>
+            <sourcepath>
+                <path path="${web.docbase.dir}"/>
+            </sourcepath>
+        </nbjpdaconnect>
+    </target>
+    <target if="do.display.browser.debug.old" name="debug-display-browser-old">
+        <nbbrowse url="${client.url}"/>
+    </target>
+    <target if="do.display.browser.debug" name="debug-display-browser">
+        <nbbrowse context="${browser.context}" url="${client.url}" urlPath="${client.urlPart}"/>
+    </target>
+    <target if="do.debug.client" name="connect-client-debugger">
+        <webproject1:nbjsdebugstart webUrl="${client.url}"/>
+    </target>
+    <target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test">
+        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
+        <webproject1:debug classname="${debug.class}" classpath="${debug.test.classpath}"/>
+    </target>
+    <target depends="init,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>
+    <target depends="init,compile,compile-jsps,-do-compile-single-jsp,debug" if="netbeans.home" name="debug-single"/>
+    <target depends="init" if="netbeans.home" name="-debug-start-debugger-main-test">
+        <webproject1:nbjpdastart classpath="${debug.test.classpath}" name="${debug.class}"/>
+    </target>
+    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
+        <webproject1:nbjpdastart name="${debug.class}"/>
+    </target>
+    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
+        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
+        <webproject1:debug classname="${debug.class}"/>
+    </target>
+    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single-main"/>
+    <target depends="init" name="-pre-debug-fix">
+        <fail unless="fix.includes">Must set fix.includes</fail>
+        <property name="javac.includes" value="${fix.includes}.java"/>
+    </target>
+    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
+        <webproject1:nbjpdareload/>
+    </target>
+    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
+    <!--
+            =================
+            PROFILING SECTION
+            =================
+            -->
+    <!--
+                pre NB7.2 profiling section; consider it deprecated
+            -->
+    <target description="Profile a J2EE project in the IDE." if="profiler.info.jvmargs.agent" name="-profile-pre72">
+        <condition else="start-profiled-server" property="profiler.startserver.target" value="start-profiled-server-extraargs">
+            <isset property="profiler.info.jvmargs.extra"/>
+        </condition>
+        <antcall target="${profiler.startserver.target}"/>
+        <antcall target="run"/>
+        <antcall target="-profile-start-loadgen"/>
+    </target>
+    <target if="profiler.info.jvmargs.agent" name="start-profiled-server">
+        <nbstartprofiledserver forceRestart="${profiler.j2ee.serverForceRestart}" javaPlatform="${profiler.info.javaPlatform}" startupTimeout="${profiler.j2ee.serverStartupTimeout}">
+            <jvmarg value="${profiler.info.jvmargs.agent}"/>
+            <jvmarg value="${profiler.j2ee.agentID}"/>
+        </nbstartprofiledserver>
+    </target>
+    <target if="profiler.info.jvmargs.agent" name="start-profiled-server-extraargs">
+        <nbstartprofiledserver forceRestart="${profiler.j2ee.serverForceRestart}" javaPlatform="${profiler.info.javaPlatform}" startupTimeout="${profiler.j2ee.serverStartupTimeout}">
+            <jvmarg value="${profiler.info.jvmargs.extra}"/>
+            <jvmarg value="${profiler.info.jvmargs.agent}"/>
+            <jvmarg value="${profiler.j2ee.agentID}"/>
+        </nbstartprofiledserver>
+    </target>
+    <target depends="profile-init,compile-test-single" if="profiler.info.jvmargs.agent" name="-profile-test-single-pre72">
+        <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
+        <nbprofiledirect>
+            <classpath>
+                <path path="${run.test.classpath}"/>
+                <path path="${j2ee.platform.classpath}"/>
+            </classpath>
+        </nbprofiledirect>
+        <junit dir="${profiler.info.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" jvm="${profiler.info.jvm}" showoutput="true">
+            <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
+            <jvmarg value="${profiler.info.jvmargs.agent}"/>
+            <jvmarg line="${profiler.info.jvmargs}"/>
+            <test name="${profile.class}"/>
+            <classpath>
+                <path path="${run.test.classpath}"/>
+                <path path="${j2ee.platform.classpath}"/>
+            </classpath>
+            <syspropertyset>
+                <propertyref prefix="test-sys-prop."/>
+                <mapper from="test-sys-prop.*" to="*" type="glob"/>
+            </syspropertyset>
+            <formatter type="brief" usefile="false"/>
+            <formatter type="xml"/>
+        </junit>
+    </target>
+    <target if="netbeans.home" name="-profile-check">
+        <condition property="profiler.configured">
+            <or>
+                <contains casesensitive="true" string="${run.jvmargs.ide}" substring="-agentpath:"/>
+                <contains casesensitive="true" string="${run.jvmargs.ide}" substring="-javaagent:"/>
+            </or>
+        </condition>
+    </target>
+    <target depends="init,-init-cos,compile,compile-jsps,-do-compile-single-jsp,-pre-dist,-do-tmp-dist-with-manifest,-do-tmp-dist-without-manifest" name="-do-profile">
+        <startprofiler/>
+        <nbstartserver profilemode="true"/>
+        <nbdeploy clientUrlPart="${client.urlPart}" forceRedeploy="true" profilemode="true"/>
+        <antcall target="debug-display-browser-old"/>
+        <antcall target="debug-display-browser"/>
+        <antcall target="-profile-start-loadgen"/>
+    </target>
+    <target depends="-profile-check,-profile-pre72" description="Profile a J2EE project in the IDE." if="profiler.configured" name="profile" unless="profiler.info.jvmargs.agent">
+        <antcall target="-do-profile"/>
+    </target>
+    <target depends="-profile-test-single-pre72" name="profile-test-single"/>
+    <target depends="-profile-check" if="profiler.configured" name="profile-test" unless="profiler.info.jvmargs.agent">
+        <startprofiler/>
+        <antcall target="test-single"/>
+    </target>
+    <target if="profiler.loadgen.path" name="-profile-start-loadgen">
+        <loadgenstart path="${profiler.loadgen.path}"/>
+    </target>
+    <!--
+                JAVADOC SECTION
+            -->
+    <target depends="init" if="have.sources" name="javadoc-build">
+        <mkdir dir="${dist.javadoc.dir}"/>
+        <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
+            <classpath>
+                <path path="${javac.classpath}:${j2ee.platform.classpath}"/>
+            </classpath>
+            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
+                <filename name="**/*.java"/>
+            </fileset>
+            <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
+                <include name="**/*.java"/>
+            </fileset>
+        </javadoc>
+        <copy todir="${dist.javadoc.dir}">
+            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
+                <filename name="**/doc-files/**"/>
+            </fileset>
+            <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
+                <include name="**/doc-files/**"/>
+            </fileset>
+        </copy>
+    </target>
+    <target depends="init,javadoc-build" if="netbeans.home" name="javadoc-browse" unless="no.javadoc.preview">
+        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
+    </target>
+    <target depends="init,javadoc-build,javadoc-browse" description="Build Javadoc." name="javadoc"/>
+    <!--
+                
+                TEST COMPILATION SECTION
+            -->
+    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
+        <mkdir dir="${build.test.classes.dir}"/>
+        <property name="j2ee.platform.embeddableejb.classpath" value=""/>
+    </target>
+    <target name="-pre-compile-test">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test" if="have.tests" name="-do-compile-test">
+        <webproject2:javac classpath="${javac.test.classpath}:${j2ee.platform.classpath}:${j2ee.platform.embeddableejb.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
+        <copy todir="${build.test.classes.dir}">
+            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+        </copy>
+    </target>
+    <target name="-post-compile-test">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
+    <target name="-pre-compile-test-single">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
+        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
+        <webproject2:javac classpath="${javac.test.classpath}:${j2ee.platform.classpath}:${j2ee.platform.embeddableejb.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" srcdir="${test.src.dir}"/>
+        <copy todir="${build.test.classes.dir}">
+            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+        </copy>
+    </target>
+    <target name="-post-compile-test-single">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
+    <!--
+                
+                TEST EXECUTION SECTION
+            -->
+    <target depends="init" if="have.tests" name="-pre-test-run">
+        <mkdir dir="${build.test.results.dir}"/>
+    </target>
+    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
+        <webproject2:test includes="${includes}" testincludes="**/*Test.java"/>
+    </target>
+    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
+        <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
+    </target>
+    <target depends="init" if="have.tests" name="test-report"/>
+    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
+    <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
+    <target depends="init" if="have.tests" name="-pre-test-run-single">
+        <mkdir dir="${build.test.results.dir}"/>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
+        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
+        <webproject2:test excludes="" includes="${test.includes}" testincludes="${test.includes}"/>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
+        <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
+    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single-method">
+        <fail unless="test.class">Must select some files in the IDE or set test.class</fail>
+        <fail unless="test.method">Must select some method in the IDE or set test.method</fail>
+        <webproject2:test excludes="" includes="${javac.includes}" testincludes="${test.class}" testmethods="${test.method}"/>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single-method" if="have.tests" name="-post-test-run-single-method">
+        <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single-method,-post-test-run-single-method" description="Run single unit test." name="test-single-method"/>
+    <!--
+                
+                TEST DEBUGGING SECTION
+            -->
+    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test">
+        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
+        <webproject2:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testincludes="${javac.includes}"/>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test-method">
+        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
+        <fail unless="test.method">Must select some method in the IDE or set test.method</fail>
+        <webproject2:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testMethod="${test.method}" testincludes="${test.class}" testmethods="${test.method}"/>
+    </target>
+    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
+        <webproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
+    </target>
+    <target depends="init,compile-test,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
+    <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test-method" name="debug-test-method"/>
+    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
+        <webproject1:nbjpdareload dir="${build.test.classes.dir}"/>
+    </target>
+    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
+    <!--
+                
+                CLEANUP SECTION
+            -->
+    <target depends="init" name="deps-clean" unless="no.deps">
+        <ant antfile="${project.csip-core}/build.xml" inheritall="false" target="clean"/>
+    </target>
+    <target depends="init" name="do-clean">
+        <condition property="build.dir.to.clean" value="${build.web.dir}">
+            <isset property="dist.ear.dir"/>
+        </condition>
+        <property name="build.dir.to.clean" value="${build.web.dir}"/>
+        <delete includeEmptyDirs="true" quiet="true">
+            <fileset dir="${build.dir.to.clean}/WEB-INF/lib"/>
+        </delete>
+        <delete dir="${build.dir}"/>
+        <available file="${build.dir.to.clean}/WEB-INF/lib" property="status.clean-failed" type="dir"/>
+        <delete dir="${dist.dir}"/>
+    </target>
+    <target depends="do-clean" if="status.clean-failed" name="check-clean">
+        <echo message="Warning: unable to delete some files in ${build.web.dir}/WEB-INF/lib - they are probably locked by the J2EE server. "/>
+        <echo level="info" message="To delete all files undeploy the module from Server Registry in Runtime tab and then use Clean again."/>
+    </target>
+    <target depends="init" if="netbeans.home" name="undeploy-clean">
+        <nbundeploy failOnError="false" startServer="false"/>
+    </target>
+    <target name="-post-clean">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,undeploy-clean,deps-clean,do-clean,check-clean,-post-clean" description="Clean build products." name="clean"/>
+    <target depends="clean" description="Clean build products." name="clean-ear"/>
+</project>

nbproject/genfiles.properties

@@ -1,12 +1,12 @@
-build.xml.data.CRC32=b029a393
-build.xml.script.CRC32=388e9258
-build.xml.stylesheet.CRC32=651128d4@1.65.1.1
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=e82fb55e
-nbproject/build-impl.xml.script.CRC32=f9967a88
-nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.77.1.1
-nbproject/rest-build.xml.data.CRC32=bff4a8fe
-nbproject/rest-build.xml.script.CRC32=4734534b
-nbproject/rest-build.xml.stylesheet.CRC32=5f13befe@1.21
-nbproject/jaxws-build.xml.stylesheet.CRC32=6608c2cf
+build.xml.data.CRC32=b029a393
+build.xml.script.CRC32=388e9258
+build.xml.stylesheet.CRC32=651128d4@1.65.1.1
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=e82fb55e
+nbproject/build-impl.xml.script.CRC32=f9967a88
+nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.77.1.1
+nbproject/rest-build.xml.data.CRC32=bff4a8fe
+nbproject/rest-build.xml.script.CRC32=4734534b
+nbproject/rest-build.xml.stylesheet.CRC32=5f13befe@1.21
+nbproject/jaxws-build.xml.stylesheet.CRC32=6608c2cf

nbproject/project.properties

@@ -1,106 +1,106 @@
-file.reference.calcmanstir.jar=lib/calcmanstir.jar
-file.reference.commons-codec-1.10.jar=lib/commons-codec-1.10.jar
-file.reference.commons-vfs2-2.1.jar=lib/commons-vfs2-2.1.jar
-file.reference.csip-gis-objects-2.0.17.jar=lib/csip-gis-objects-2.0.17.jar
-file.reference.csip-soilsdb-3.0.18.jar=lib/csip-soilsdb-3.0.18.jar
-file.reference.Lmod2Rusle2.jar=lib/Lmod2Rusle2.jar
-file.reference.SDMDriver-1.0.4.jar=lib/SDMDriver-1.0.4.jar
-j2ee.platform.classpath=${j2ee.server.home}/lib/annotations-api.jar:${j2ee.server.home}/lib/catalina-ant.jar:${j2ee.server.home}/lib/catalina-ha.jar:${j2ee.server.home}/lib/catalina-storeconfig.jar:${j2ee.server.home}/lib/catalina-tribes.jar:${j2ee.server.home}/lib/catalina.jar:${j2ee.server.home}/lib/ecj-4.4.1.jar:${j2ee.server.home}/lib/el-api.jar:${j2ee.server.home}/lib/jasper-el.jar:${j2ee.server.home}/lib/jasper.jar:${j2ee.server.home}/lib/jsp-api.jar:${j2ee.server.home}/lib/servlet-api.jar:${j2ee.server.home}/lib/tomcat-api.jar:${j2ee.server.home}/lib/tomcat-coyote.jar:${j2ee.server.home}/lib/tomcat-dbcp.jar:${j2ee.server.home}/lib/tomcat-i18n-es.jar:${j2ee.server.home}/lib/tomcat-i18n-fr.jar:${j2ee.server.home}/lib/tomcat-i18n-ja.jar:${j2ee.server.home}/lib/tomcat-jdbc.jar:${j2ee.server.home}/lib/tomcat-jni.jar:${j2ee.server.home}/lib/tomcat-spdy.jar:${j2ee.server.home}/lib/tomcat-util-scan.jar:${j2ee.server.home}/lib/tomcat-util.jar:${j2ee.server.home}/lib/tomcat-websocket.jar:${j2ee.server.home}/lib/websocket-api.jar
-#Thu Dec 17 13:44:22 MST 2015
-javadoc.splitindex=true
-lib.dir=${web.docbase.dir}/WEB-INF/lib
-auxiliary.org-netbeans-modules-css-prep.sass_2e_mappings=/scss\:/css
-build.classes.excludes=**/*.java,**/*.form
-javadoc.author=false
-j2ee.platform=1.6-web
-dist.war=${dist.dir}/${war.name}
-javac.target=1.8
-build.generated.dir=${build.dir}/generated
-project.csip-core=../csip-core
-reference.csip-core.jar=${project.csip-core}/dist/csip-core.jar
-resource.dir=setup
-build.web.excludes=${build.classes.excludes}
-war.ear.name=${war.name}
-j2ee.compile.on.save=true
-debug.test.classpath=${run.test.classpath}
-build.dir=build
-javac.deprecation=false
-persistence.xml.dir=${conf.dir}
-j2ee.copy.static.files.on.save=true
-auxiliary.org-netbeans-modules-css-prep.less_2e_mappings=/less\:/css
-test.src.dir=test
-auxiliary.org-netbeans-modules-css-prep.sass_2e_compiler_2e_options=
-junit.selected.version=4
-includes=**
-jar.compress=false
-annotation.processing.processors.list=
-javadoc.version=false
-build.classes.dir=${build.web.dir}/WEB-INF/classes
-dist.dir=dist
-rest.config.type=ide
-javac.source=1.8
-javac.debug=true
-javac.test.processorpath=${javac.test.classpath}
-run.test.classpath=\
-    ${javac.test.classpath}:\
-    ${build.test.classes.dir}
-build.generated.sources.dir=${build.dir}/generated-sources
-auxiliary.org-netbeans-modules-css-prep.less_2e_enabled=false
-javadoc.notree=false
-source.root=src
-runmain.jvmargs=
-platform.active=default_platform
-javadoc.preview=true
-j2ee.deploy.on.save=true
-annotation.processing.enabled=true
-war.content.additional=
-dist.javadoc.dir=${dist.dir}/javadoc
-client.urlPart=
-javadoc.additionalparam=
-javac.classpath=\
-    ${reference.csip-core.jar}:\
-    ${libs.CSIP-Jersey-2.16.classpath}:\
-    ${file.reference.Lmod2Rusle2.jar}:\
-    ${file.reference.commons-vfs2-2.1.jar}:\
-    ${file.reference.commons-codec-1.10.jar}:\
-    ${file.reference.csip-soilsdb-3.0.18.jar}:\
-    ${file.reference.csip-gis-objects-2.0.17.jar}:\
-    ${file.reference.calcmanstir.jar}:\
-    ${file.reference.SDMDriver-1.0.4.jar}
-javadoc.noindex=false
-webinf.dir=web/WEB-INF
-annotation.processing.enabled.in.editor=true
-javadoc.private=false
-javadoc.encoding=${source.encoding}
-build.test.classes.dir=${build.dir}/test/classes
-auxiliary.org-netbeans-modules-css-prep.less_2e_compiler_2e_options=
-web.docbase.dir=web
-javac.compilerargs=
-auxiliary.org-netbeans-modules-web-clientproject-api.js_2e_libs_2e_folder=js/libs
-auxiliary.org-netbeans-modules-css-prep.sass_2e_enabled=false
-source.encoding=UTF-8
-dist.ear.war=${dist.dir}/${war.ear.name}
-j2ee.server.type=Tomcat
-conf.dir=${source.root}/conf
-annotation.processing.run.all.processors=true
-compile.jsps=false
-excludes=
-javac.processorpath=\
-    ${javac.classpath}
-build.test.results.dir=${build.dir}/test/results
-display.browser=false
-endorsed.classpath=\
-    ${libs.javaee-endorsed-api-6.0.classpath}
-javadoc.use=true
-build.web.dir=${build.dir}/web
-javadoc.nonavbar=false
-war.name=csip-r2.war
-javadoc.windowtitle=
-javac.test.classpath=\
-    ${javac.classpath}:\
-    ${build.classes.dir}:\
-    ${libs.junit_4.classpath}:\
-    ${libs.hamcrest.classpath}
-src.dir=${source.root}/java
-annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
-debug.classpath=${build.classes.dir}\:${javac.classpath}
+file.reference.calcmanstir.jar=lib/calcmanstir.jar
+file.reference.commons-codec-1.10.jar=lib/commons-codec-1.10.jar
+file.reference.commons-vfs2-2.1.jar=lib/commons-vfs2-2.1.jar
+file.reference.csip-gis-objects-2.0.17.jar=lib/csip-gis-objects-2.0.17.jar
+file.reference.csip-soilsdb-3.0.18.jar=lib/csip-soilsdb-3.0.18.jar
+file.reference.Lmod2Rusle2.jar=lib/Lmod2Rusle2.jar
+file.reference.SDMDriver-1.0.4.jar=lib/SDMDriver-1.0.4.jar
+j2ee.platform.classpath=${j2ee.server.home}/lib/annotations-api.jar:${j2ee.server.home}/lib/catalina-ant.jar:${j2ee.server.home}/lib/catalina-ha.jar:${j2ee.server.home}/lib/catalina-storeconfig.jar:${j2ee.server.home}/lib/catalina-tribes.jar:${j2ee.server.home}/lib/catalina.jar:${j2ee.server.home}/lib/ecj-4.4.2.jar:${j2ee.server.home}/lib/el-api.jar:${j2ee.server.home}/lib/jasper-el.jar:${j2ee.server.home}/lib/jasper.jar:${j2ee.server.home}/lib/jsp-api.jar:${j2ee.server.home}/lib/servlet-api.jar:${j2ee.server.home}/lib/tomcat-api.jar:${j2ee.server.home}/lib/tomcat-coyote.jar:${j2ee.server.home}/lib/tomcat-dbcp.jar:${j2ee.server.home}/lib/tomcat-i18n-es.jar:${j2ee.server.home}/lib/tomcat-i18n-fr.jar:${j2ee.server.home}/lib/tomcat-i18n-ja.jar:${j2ee.server.home}/lib/tomcat-jdbc.jar:${j2ee.server.home}/lib/tomcat-jni.jar:${j2ee.server.home}/lib/tomcat-util-scan.jar:${j2ee.server.home}/lib/tomcat-util.jar:${j2ee.server.home}/lib/tomcat-websocket.jar:${j2ee.server.home}/lib/websocket-api.jar
+#Thu Dec 17 13:44:22 MST 2015
+javadoc.splitindex=true
+lib.dir=${web.docbase.dir}/WEB-INF/lib
+auxiliary.org-netbeans-modules-css-prep.sass_2e_mappings=/scss\:/css
+build.classes.excludes=**/*.java,**/*.form
+javadoc.author=false
+j2ee.platform=1.6-web
+dist.war=${dist.dir}/${war.name}
+javac.target=1.8
+build.generated.dir=${build.dir}/generated
+project.csip-core=../csip-core
+reference.csip-core.jar=${project.csip-core}/dist/csip-core.jar
+resource.dir=setup
+build.web.excludes=${build.classes.excludes}
+war.ear.name=${war.name}
+j2ee.compile.on.save=true
+debug.test.classpath=${run.test.classpath}
+build.dir=build
+javac.deprecation=false
+persistence.xml.dir=${conf.dir}
+j2ee.copy.static.files.on.save=true
+auxiliary.org-netbeans-modules-css-prep.less_2e_mappings=/less\:/css
+test.src.dir=test
+auxiliary.org-netbeans-modules-css-prep.sass_2e_compiler_2e_options=
+junit.selected.version=4
+includes=**
+jar.compress=false
+annotation.processing.processors.list=
+javadoc.version=false
+build.classes.dir=${build.web.dir}/WEB-INF/classes
+dist.dir=dist
+rest.config.type=ide
+javac.source=1.8
+javac.debug=true
+javac.test.processorpath=${javac.test.classpath}
+run.test.classpath=\
+    ${javac.test.classpath}:\
+    ${build.test.classes.dir}
+build.generated.sources.dir=${build.dir}/generated-sources
+auxiliary.org-netbeans-modules-css-prep.less_2e_enabled=false
+javadoc.notree=false
+source.root=src
+runmain.jvmargs=
+platform.active=default_platform
+javadoc.preview=true
+j2ee.deploy.on.save=true
+annotation.processing.enabled=true
+war.content.additional=
+dist.javadoc.dir=${dist.dir}/javadoc
+client.urlPart=
+javadoc.additionalparam=
+javac.classpath=\
+    ${reference.csip-core.jar}:\
+    ${libs.CSIP-Jersey-2.16.classpath}:\
+    ${file.reference.Lmod2Rusle2.jar}:\
+    ${file.reference.commons-vfs2-2.1.jar}:\
+    ${file.reference.commons-codec-1.10.jar}:\
+    ${file.reference.csip-soilsdb-3.0.18.jar}:\
+    ${file.reference.csip-gis-objects-2.0.17.jar}:\
+    ${file.reference.calcmanstir.jar}:\
+    ${file.reference.SDMDriver-1.0.4.jar}
+javadoc.noindex=false
+webinf.dir=web/WEB-INF
+annotation.processing.enabled.in.editor=true
+javadoc.private=false
+javadoc.encoding=${source.encoding}
+build.test.classes.dir=${build.dir}/test/classes
+auxiliary.org-netbeans-modules-css-prep.less_2e_compiler_2e_options=
+web.docbase.dir=web
+javac.compilerargs=
+auxiliary.org-netbeans-modules-web-clientproject-api.js_2e_libs_2e_folder=js/libs
+auxiliary.org-netbeans-modules-css-prep.sass_2e_enabled=false
+source.encoding=UTF-8
+dist.ear.war=${dist.dir}/${war.ear.name}
+j2ee.server.type=Tomcat
+conf.dir=${source.root}/conf
+annotation.processing.run.all.processors=true
+compile.jsps=false
+excludes=
+javac.processorpath=\
+    ${javac.classpath}
+build.test.results.dir=${build.dir}/test/results
+display.browser=false
+endorsed.classpath=\
+    ${libs.javaee-endorsed-api-6.0.classpath}
+javadoc.use=true
+build.web.dir=${build.dir}/web
+javadoc.nonavbar=false
+war.name=csip-r2.war
+javadoc.windowtitle=
+javac.test.classpath=\
+    ${javac.classpath}:\
+    ${build.classes.dir}:\
+    ${libs.junit_4.classpath}:\
+    ${libs.hamcrest.classpath}
+src.dir=${source.root}/java
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+debug.classpath=${build.classes.dir}\:${javac.classpath}

nbproject/project.xml

@@ -1,69 +1,69 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://www.netbeans.org/ns/project/1">
-    <type>org.netbeans.modules.web.project</type>
-    <configuration>
-        <buildExtensions xmlns="http://www.netbeans.org/ns/ant-build-extender/1">
-            <extension file="rest-build.xml" id="rest.4">
-                <dependency dependsOn="generate-rest-config" target="-pre-pre-compile"/>
-            </extension>
-        </buildExtensions>
-        <data xmlns="http://www.netbeans.org/ns/web-project/3">
-            <name>csip-r2</name>
-            <minimum-ant-version>1.6.5</minimum-ant-version>
-            <web-module-libraries>
-                <library dirs="200">
-                    <file>${reference.csip-core.jar}</file>
-                    <path-in-war>WEB-INF/lib</path-in-war>
-                </library>
-                <library dirs="200">
-                    <file>${libs.CSIP-Jersey-2.16.classpath}</file>
-                    <path-in-war>WEB-INF/lib</path-in-war>
-                </library>
-                <library dirs="200">
-                    <file>${file.reference.Lmod2Rusle2.jar}</file>
-                    <path-in-war>WEB-INF/lib</path-in-war>
-                </library>
-                <library dirs="200">
-                    <file>${file.reference.commons-vfs2-2.1.jar}</file>
-                </library>
-                <library dirs="200">
-                    <file>${file.reference.commons-codec-1.10.jar}</file>
-                </library>
-                <library dirs="200">
-                    <file>${file.reference.csip-soilsdb-3.0.18.jar}</file>
-                    <path-in-war>WEB-INF/lib</path-in-war>
-                </library>
-                <library dirs="200">
-                    <file>${file.reference.csip-gis-objects-2.0.17.jar}</file>
-                    <path-in-war>WEB-INF/lib</path-in-war>
-                </library>
-                <library dirs="200">
-                    <file>${file.reference.calcmanstir.jar}</file>
-                    <path-in-war>WEB-INF/lib</path-in-war>
-                </library>
-                <library dirs="200">
-                    <file>${file.reference.SDMDriver-1.0.4.jar}</file>
-                    <path-in-war>WEB-INF/lib</path-in-war>
-                </library>
-            </web-module-libraries>
-            <web-module-additional-libraries/>
-            <source-roots>
-                <root id="src.dir"/>
-            </source-roots>
-            <test-roots>
-                <root id="test.src.dir"/>
-            </test-roots>
-        </data>
-        <libraries xmlns="http://www.netbeans.org/ns/cdnjs-libraries/1"/>
-        <references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
-            <reference>
-                <foreign-project>csip-core</foreign-project>
-                <artifact-type>jar</artifact-type>
-                <script>build.xml</script>
-                <target>jar</target>
-                <clean-target>clean</clean-target>
-                <id>jar</id>
-            </reference>
-        </references>
-    </configuration>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+    <type>org.netbeans.modules.web.project</type>
+    <configuration>
+        <buildExtensions xmlns="http://www.netbeans.org/ns/ant-build-extender/1">
+            <extension file="rest-build.xml" id="rest.4">
+                <dependency dependsOn="generate-rest-config" target="-pre-pre-compile"/>
+            </extension>
+        </buildExtensions>
+        <data xmlns="http://www.netbeans.org/ns/web-project/3">
+            <name>csip-r2</name>
+            <minimum-ant-version>1.6.5</minimum-ant-version>
+            <web-module-libraries>
+                <library dirs="200">
+                    <file>${reference.csip-core.jar}</file>
+                    <path-in-war>WEB-INF/lib</path-in-war>
+                </library>
+                <library dirs="200">
+                    <file>${libs.CSIP-Jersey-2.16.classpath}</file>
+                    <path-in-war>WEB-INF/lib</path-in-war>
+                </library>
+                <library dirs="200">
+                    <file>${file.reference.Lmod2Rusle2.jar}</file>
+                    <path-in-war>WEB-INF/lib</path-in-war>
+                </library>
+                <library dirs="200">
+                    <file>${file.reference.commons-vfs2-2.1.jar}</file>
+                </library>
+                <library dirs="200">
+                    <file>${file.reference.commons-codec-1.10.jar}</file>
+                </library>
+                <library dirs="200">
+                    <file>${file.reference.csip-soilsdb-3.0.18.jar}</file>
+                    <path-in-war>WEB-INF/lib</path-in-war>
+                </library>
+                <library dirs="200">
+                    <file>${file.reference.csip-gis-objects-2.0.17.jar}</file>
+                    <path-in-war>WEB-INF/lib</path-in-war>
+                </library>
+                <library dirs="200">
+                    <file>${file.reference.calcmanstir.jar}</file>
+                    <path-in-war>WEB-INF/lib</path-in-war>
+                </library>
+                <library dirs="200">
+                    <file>${file.reference.SDMDriver-1.0.4.jar}</file>
+                    <path-in-war>WEB-INF/lib</path-in-war>
+                </library>
+            </web-module-libraries>
+            <web-module-additional-libraries/>
+            <source-roots>
+                <root id="src.dir"/>
+            </source-roots>
+            <test-roots>
+                <root id="test.src.dir"/>
+            </test-roots>
+        </data>
+        <libraries xmlns="http://www.netbeans.org/ns/cdnjs-libraries/1"/>
+        <references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
+            <reference>
+                <foreign-project>csip-core</foreign-project>
+                <artifact-type>jar</artifact-type>
+                <script>build.xml</script>
+                <target>jar</target>
+                <clean-target>clean</clean-target>
+                <id>jar</id>
+            </reference>
+        </references>
+    </configuration>
+</project>

src/java/m/ApplicationConfig.java

@@ -51,6 +51,7 @@
         resources.add(csip.CatalogService.class);
         resources.add(csip.ControlService.class);
         resources.add(csip.DynamicPyModelDataService.class);
+        resources.add(csip.GzipWriterInterceptor.class);
         resources.add(csip.QueryService.class);
         resources.add(csip.QueueingModelDataService.class);
         resources.add(csip.ReportService.class);
@@ -59,7 +60,7 @@
         resources.add(m.rusle2.V1_3.class);
         resources.add(m.rusle2.V2_1.class);
         resources.add(m.rusle2.V3_0.class);
-        resources.add(m.rusle2.V4_0.class);
-    resources.add(m.rusle2.V5_0.class);
+    resources.add(m.rusle2.V4_0.class);
+        resources.add( m.rusle2.V5_0.class );
     }
 }

src/java/m/rusle2/R2Run.java

@@ -15,12 +15,12 @@
 import csip.Executable;
 import csip.ServiceException;
 import csip.SessionLogger;
+import static csip.Utils.removeFirstLastChar;
+import java.io.BufferedReader;
 import java.io.File;
-import java.io.IOException;
-import csip.utils.Services;
-import java.io.BufferedReader;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
+import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.Writer;
 import java.net.HttpURLConnection;
@@ -36,358 +36,352 @@
  */
 class R2Run {
 
-  SessionLogger LOG;
-  String stdout;
+    SessionLogger LOG;
+    String stdout;
 
-
-  void setLogger(SessionLogger l) {
-    LOG = l;
-  }
-
-
-  /**
-   * Execute the rusle2 pyrome python script
-   *
-   * We assume that Python3.4 is installed under
-   * /home/ubuntu/.wine/drive_c/Python34 and that wine's working dir is
-   * /home/ubuntu/.wine The ownership of wine's working directory must
-   * correspond with the user running tomcat
-   *
-   * @param r2_rsh
-   * @return
-   * @throws IOException
-   */
-  int executePyrome(File r2_rsh, Executable python) throws IOException, ServiceException {
-    python.setArguments("rusle2csip.py");
-    LOG.info("Executing pyrome rusle2");
-    int ret = python.exec();
-    if (ret != 0) {
-      String stderr = FileUtils.readFileToString(python.stderr());
-      throw new ServiceException("RUSLE 2 PYTHON error: error executing pyrome:" + stderr);
+    void setLogger ( SessionLogger l ) {
+        LOG = l;
     }
 
-//        String runrusle2 = "winetricks vd=off ; wine /home/ubuntu/.wine/drive_c/Python34/python.exe rusle2csip.py\n"; 
-    stdout += "\n" + FileUtils.readFileToString(python.stdout());
-    if (LOG.isLoggable(Level.INFO)) {
-      LOG.info("stdout: " + stdout);
-      LOG.info("exit val: " + ret);
-    }
-    return ret;
-  }
+    /**
+     * Execute the rusle2 pyrome python script
+     *
+     * We assume that Python3.4 is installed under
+     * /home/ubuntu/.wine/drive_c/Python34 and that wine's working dir is
+     * /home/ubuntu/.wine The ownership of wine's working directory must
+     * correspond with the user running tomcat
+     *
+     * @param r2_rsh
+     * @return
+     * @throws IOException
+     */
+    int executePyrome ( File r2_rsh, Executable python ) throws IOException, ServiceException {
+        python.setArguments( "rusle2csip.py" );
+        LOG.info( "Executing pyrome rusle2" );
+        int ret = python.exec();
+        if ( ret != 0 ) {
+            String stderr = FileUtils.readFileToString( python.stderr() );
+            throw new ServiceException( "RUSLE 2 PYTHON error: error executing pyrome:" + stderr );
+        }
 
-
-  // Must find the hydraulic element flow path element of a hydraulic element system
-  // download this file, and modify the header, so it can be fed to python
-  void prepareHydraulicElementFlowPathJ(String hydElemPtr, String r2db, File workingDir) throws IOException {
-    final String hydelemFile = "hydelem_file.tmp";
-    String hydelemflowpathFile = "";
-    BufferedReader br = null;
-    try {
-      // first open hydElemPtr file
-      getFile(hydElemPtr, workingDir.getParentFile(), hydelemFile);
-      // look for HYD_SYSTEM_FLOW_PATH_TYPE
-      LOG.info("reading --- " + workingDir.getParent() + "/" + hydelemFile);
-      File hydElemFile = new File(workingDir.getParent(), hydelemFile);
-      br = new BufferedReader(new FileReader(hydElemFile));
-      String inLine;
-      while ((inLine = br.readLine()) != null) {
-        if (inLine.contains("HYD_SYSTEM_FLOW_PATH_TYPE")) {
-          // get the text between the single two quotes- this will be the flowpathfile we need to get
-          // <ObR><Name>HYD_SYSTEM_FLOW_PATH_TYPE</Name><Data>'0.3% grade channel'</Data><Type>HYD_ELEMENT_FLOW_PATH</Type></ObR></Obj>
-          hydelemflowpathFile = inLine.split("'")[1];
-          LOG.info("Read hydelemflowpathFile as =" + hydelemflowpathFile);
+//        String runrusle2 = "winetricks vd=off ; wine /home/ubuntu/.wine/drive_c/Python34/python.exe rusle2csip.py\n";
+        stdout += "\n" + FileUtils.readFileToString( python.stdout() );
+        if ( LOG.isLoggable( Level.INFO ) ) {
+            LOG.info( "stdout: " + stdout );
+            LOG.info( "exit val: " + ret );
         }
-      }
-      String hydElemFlowPathPtr = r2db + "/hydraulic-element-flow-paths/" + hydelemflowpathFile + ".xml";
-      LOG.info("HydelemflowpathPTR is =" + hydElemFlowPathPtr);
-      // call ingprepareFileJ to finish the work...
-      // next open the flowpathfile, and perform the standard formatting
-      // of adding the <Obj> tag and the <Filename> tag...
-      prepareFileJ(hydElemFlowPathPtr, new File(workingDir.getParent(), "hydelemflowpath_file.xml"), "", "hydraulic-element-flow-paths", "hydelemflowpath", false);
-    } catch (Exception ioe) {
-      LOG.info("IO Exception while preparing file=" + ioe.toString());
-    } finally {
-      if (br != null) {
-        br.close();
-      }
-    }
-  }
-
-
-  int determineNumberOfFlowPaths(String hydElemPtr) {
-    hydElemPtr = hydElemPtr.substring(hydElemPtr.lastIndexOf("\\") + 1);
-
-    // This rediumentary algorithm for determining the number of flow paths for
-    // a hydaulic element system is based on conversation with Jack Carlson in late 03/2016
-    LOG.info("********\n\n\n\nHYD ELEM PTR=" + hydElemPtr);
-    //if (hydElemPtr.substring(hydElemPtr.lastIndexOf("\")+1).startsWith("1"))
-    if (hydElemPtr.startsWith("1")) {
-      if (hydElemPtr.contains("middle")) {
-        return 2;
-      } else {
-        return 1;
-      }
+        return ret;
     }
 
-    // presently there are only 2 kinds of hydraulic element systems with 2 elements.  
-    // ones with only "middle" in the name which should have 3 flow paths (all evenly distributed along the slope),
-    // and ones with "middle" and "bottom" in the name which should have 2 flow paths (one in middle, one at bottom).
-    //
-    // presently there is one hydraulic element with "along" instead of "middle" in the name
-    // "2 Water and Sediment Control Basins along RUSLE slope.xml"  This should be treated the same as middle.
-    // 
-    if (hydElemPtr.startsWith("2")) {
-      if (((hydElemPtr.contains("middle")) || (hydElemPtr.contains("along"))) && (!hydElemPtr.contains("bottom"))) {
-        return 3;
-      } else {
-        // These should have middle and bottom
-        return 2;
-      }
+    // Must find the hydraulic element flow path element of a hydraulic element system
+    // download this file, and modify the header, so it can be fed to python
+    void prepareHydraulicElementFlowPathJ ( String hydElemPtr, String r2db, File workingDir ) throws IOException {
+        final String hydelemFile = "hydelem_file.tmp";
+        String hydelemflowpathFile = "";
+        BufferedReader br = null;
+        try {
+            // first open hydElemPtr file
+            getFile( hydElemPtr, workingDir.getParentFile(), hydelemFile );
+            // look for HYD_SYSTEM_FLOW_PATH_TYPE
+            LOG.info( "reading --- " + workingDir.getParent() + "/" + hydelemFile );
+            File hydElemFile = new File( workingDir.getParent(), hydelemFile );
+            br = new BufferedReader( new FileReader( hydElemFile ) );
+            String inLine;
+            while ( ( inLine = br.readLine() ) != null ) {
+                if ( inLine.contains( "HYD_SYSTEM_FLOW_PATH_TYPE" ) ) {
+                    // get the text between the single two quotes- this will be the flowpathfile we need to get
+                    // <ObR><Name>HYD_SYSTEM_FLOW_PATH_TYPE</Name><Data>'0.3% grade channel'</Data><Type>HYD_ELEMENT_FLOW_PATH</Type></ObR></Obj>
+                    hydelemflowpathFile = inLine.split( "'" )[1];
+                    LOG.info( "Read hydelemflowpathFile as =" + hydelemflowpathFile );
+                }
+            }
+            String hydElemFlowPathPtr = r2db + "/hydraulic-element-flow-paths/" + hydelemflowpathFile + ".xml";
+            LOG.info( "HydelemflowpathPTR is =" + hydElemFlowPathPtr );
+            // call ingprepareFileJ to finish the work...
+            // next open the flowpathfile, and perform the standard formatting
+            // of adding the <Obj> tag and the <Filename> tag...
+            prepareFileJ( hydElemFlowPathPtr, new File( workingDir.getParent(), "hydelemflowpath_file.xml" ), "", "hydraulic-element-flow-paths", "hydelemflowpath", false );
+        }
+        catch ( Exception ioe ) {
+            LOG.info( "IO Exception while preparing file=" + ioe.toString() );
+        }
+        finally {
+            if ( br != null ) {
+                br.close();
+            }
+        }
     }
 
-    // presently there are only 2 kinds of hydraulic element systems with 3 elements.  
-    // ones with only "middle" in the name which should have 4 flow paths (all evenly distributed along the slope),
-    // and ones with "middle" and "bottom" in the name which should have 3 flow paths (two in middle, one at bottom).
-    if (hydElemPtr.startsWith("3")) {
-      if ((hydElemPtr.contains("middle")) && (!hydElemPtr.contains("bottom"))) {
-        return 4;
-      } else {
-        // These should have middle and bottom
-        return 3;
-      }
-    }
-    // Should not get here.
-    return 0;
-  }
+    int determineNumberOfFlowPaths ( String hydElemPtr ) {
+        hydElemPtr = hydElemPtr.substring( hydElemPtr.lastIndexOf( "\\" ) + 1 );
 
+        // This rediumentary algorithm for determining the number of flow paths for
+        // a hydaulic element system is based on conversation with Jack Carlson in late 03/2016
+        LOG.info( "********\n\n\n\nHYD ELEM PTR=" + hydElemPtr );
+        //if (hydElemPtr.substring(hydElemPtr.lastIndexOf("\")+1).startsWith("1"))
+        if ( hydElemPtr.startsWith( "1" ) ) {
+            if ( hydElemPtr.contains( "middle" ) ) {
+                return 2;
+            } else {
+                return 1;
+            }
+        }
 
-  double[] determineFlowPathDistribution(String hydElemPtr) {
-    hydElemPtr = hydElemPtr.substring(hydElemPtr.lastIndexOf("\\") + 1);
-    // This rediumentary algorithm for determining the hyd elem flow path position relative to slope length for
-    // a hydaulic element system is based on conversation with Jack Carlson in late 03/2016
-    if (hydElemPtr.substring(hydElemPtr.lastIndexOf("\\") + 1).startsWith("1")) {
-      if (hydElemPtr.contains("middle")) {
-        return new double[]{.5, 1};
-      } else {
-        return new double[]{1};
-      }
+        // presently there are only 2 kinds of hydraulic element systems with 2 elements.
+        // ones with only "middle" in the name which should have 3 flow paths (all evenly distributed along the slope),
+        // and ones with "middle" and "bottom" in the name which should have 2 flow paths (one in middle, one at bottom).
+        //
+        // presently there is one hydraulic element with "along" instead of "middle" in the name
+        // "2 Water and Sediment Control Basins along RUSLE slope.xml"  This should be treated the same as middle.
+        //
+        if ( hydElemPtr.startsWith( "2" ) ) {
+            if ( ( ( hydElemPtr.contains( "middle" ) ) || ( hydElemPtr.contains( "along" ) ) ) && ( !hydElemPtr.contains( "bottom" ) ) ) {
+                return 3;
+            } else {
+                // These should have middle and bottom
+                return 2;
+            }
+        }
+
+        // presently there are only 2 kinds of hydraulic element systems with 3 elements.
+        // ones with only "middle" in the name which should have 4 flow paths (all evenly distributed along the slope),
+        // and ones with "middle" and "bottom" in the name which should have 3 flow paths (two in middle, one at bottom).
+        if ( hydElemPtr.startsWith( "3" ) ) {
+            if ( ( hydElemPtr.contains( "middle" ) ) && ( !hydElemPtr.contains( "bottom" ) ) ) {
+                return 4;
+            } else {
+                // These should have middle and bottom
+                return 3;
+            }
+        }
+        // Should not get here.
+        return 0;
     }
 
-    // presently there are only 2 kinds of hydraulic element systems with 2 elements.  
-    // ones with only "middle" in the name which should have 3 flow paths (all evenly distributed along the slope),
-    // and ones with "middle" and "bottom" in the name which should have 2 flow paths (one in middle, one at bottom).
-    //
-    // presently there is one hydraulic element with "along" instead of "middle" in the name
-    // "2 Water and Sediment Control Basins along RUSLE slope.xml"  This should be treated the same as middle.
-    // 
-    if (hydElemPtr.startsWith("2")) {
-      if (((hydElemPtr.contains("middle")) || (hydElemPtr.contains("along"))) && (!hydElemPtr.contains("bottom"))) {
-        return new double[]{.333, .666, 1};
-      } else {
-        // These should have middle and bottom
-        return new double[]{.5, 1};
-      }
+    double[] determineFlowPathDistribution ( String hydElemPtr ) {
+        hydElemPtr = hydElemPtr.substring( hydElemPtr.lastIndexOf( "\\" ) + 1 );
+        // This rediumentary algorithm for determining the hyd elem flow path position relative to slope length for
+        // a hydaulic element system is based on conversation with Jack Carlson in late 03/2016
+        if ( hydElemPtr.substring( hydElemPtr.lastIndexOf( "\\" ) + 1 ).startsWith( "1" ) ) {
+            if ( hydElemPtr.contains( "middle" ) ) {
+                return new double[] {.5, 1};
+            } else {
+                return new double[] {1};
+            }
+        }
+
+        // presently there are only 2 kinds of hydraulic element systems with 2 elements.
+        // ones with only "middle" in the name which should have 3 flow paths (all evenly distributed along the slope),
+        // and ones with "middle" and "bottom" in the name which should have 2 flow paths (one in middle, one at bottom).
+        //
+        // presently there is one hydraulic element with "along" instead of "middle" in the name
+        // "2 Water and Sediment Control Basins along RUSLE slope.xml"  This should be treated the same as middle.
+        //
+        if ( hydElemPtr.startsWith( "2" ) ) {
+            if ( ( ( hydElemPtr.contains( "middle" ) ) || ( hydElemPtr.contains( "along" ) ) ) && ( !hydElemPtr.contains( "bottom" ) ) ) {
+                return new double[] {.333, .666, 1};
+            } else {
+                // These should have middle and bottom
+                return new double[] {.5, 1};
+            }
+        }
+
+        // presently there are only 2 kinds of hydraulic element systems with 3 elements.
+        // ones with only "middle" in the name which should have 4 flow paths (all evenly distributed along the slope),
+        // and ones with "middle" and "bottom" in the name which should have 3 flow paths (two in middle, one at bottom).
+        if ( hydElemPtr.startsWith( "3" ) ) {
+            if ( ( hydElemPtr.contains( "middle" ) ) && ( !hydElemPtr.contains( "bottom" ) ) ) {
+                return new double[] {.25, .5, .75, 1};
+            } else {
+                // These should have middle and bottom
+                return new double[] {.333, .666, 1};
+            }
+        }
+        // Should not get here...
+        return new double[] {0};
     }
 
-    // presently there are only 2 kinds of hydraulic element systems with 3 elements.  
-    // ones with only "middle" in the name which should have 4 flow paths (all evenly distributed along the slope),
-    // and ones with "middle" and "bottom" in the name which should have 3 flow paths (two in middle, one at bottom).
-    if (hydElemPtr.startsWith("3")) {
-      if ((hydElemPtr.contains("middle")) && (!hydElemPtr.contains("bottom"))) {
-        return new double[]{.25, .5, .75, 1};
-      } else {
-        // These should have middle and bottom
-        return new double[]{.333, .666, 1};
-      }
-    }
-    // Should not get here...
-    return new double[]{0};
-  }
+    // Generic File Preparation routine
+    // Downloads, and prepares a file for use in Rusle2 Pyrome
+    //
+    // fileType: the type of file to process
+    // Valid fileType(s) include: "contour",
+    //
+    // fileDir: the dir of the filename specified in the <Filename> tag in the R2 XML file
+    // Valid fileDir(s) include: "countour-systems"
+    //
+    // idx: An index value, if there are multiple items of the same type for slope segments
+    void prepareFileJ ( String httpPtr, File outputFile, String fileType, String fileDir, String basefilename, boolean prepareSoilForPyrome ) throws IOException {
+        BufferedReader br = null;
+        Writer bw = null;
 
+        String fn = ( ( ( basefilename != null ) & ( basefilename.length() > 0 ) ) ? "\\" + basefilename + "1" : "\\aaa" );
+        try {
+            // Generate shell script to prepare --fileType-- file for pyrome
+            LOG.info( "******** the " + fileType + " file name=" + outputFile.getName() );
+            String tmpFilename = outputFile.getName().substring( 0, outputFile.getName().length() - 4 ) + ".tmp";
+            LOG.info( "******** the " + fileType + " tmp file name=" + tmpFilename );
 
-  // Generic File Preparation routine
-  // Downloads, and prepares a file for use in Rusle2 Pyrome
-  //
-  // fileType: the type of file to process
-  // Valid fileType(s) include: "contour",  
-  //
-  // fileDir: the dir of the filename specified in the <Filename> tag in the R2 XML file
-  // Valid fileDir(s) include: "countour-systems"
-  //
-  // idx: An index value, if there are multiple items of the same type for slope segments
-  void prepareFileJ(String httpPtr, File outputFile, String fileType, String fileDir, String basefilename, boolean prepareSoilForPyrome) throws IOException {
-    BufferedReader br = null;
-    Writer bw = null;
+            getFile( httpPtr, outputFile.getParentFile(), tmpFilename );
+            bw = new PrintWriter( outputFile );
 
-    String fn = (((basefilename != null) & (basefilename.length() > 0)) ? "\\" + basefilename + "1" : "\\aaa");
-    try {
-      // Generate shell script to prepare --fileType-- file for pyrome
-      LOG.info("******** the " + fileType + " file name=" + outputFile.getName());
-      String tmpFilename = outputFile.getName().substring(0, outputFile.getName().length() - 4) + ".tmp";
-      LOG.info("******** the " + fileType + " tmp file name=" + tmpFilename);
+            File origFile = new File( outputFile.getParent(), tmpFilename );
+            br = new BufferedReader( new FileReader( origFile ) );
 
-      getFile(httpPtr, outputFile.getParentFile(), tmpFilename);
-      bw = new PrintWriter(outputFile);
-
-      File origFile = new File(outputFile.getParent(), tmpFilename);
-      br = new BufferedReader(new FileReader(origFile));
-
-      if ((fileType.contentEquals("CLIMATE")) || (fileType.contentEquals("SOIL")) || (prepareSoilForPyrome)) {
-        bw.write("<?xml version=\"1.0\"?>\n");
-      }
-      if (!fileType.contentEquals("SOIL")) {
-        bw.write("<Obj>\n");
-        if (fileType.length() > 1) {
-          bw.write("<Type>" + fileType + "</Type>\n");
+            if ( ( fileType.contentEquals( "CLIMATE" ) ) || ( fileType.contentEquals( "SOIL" ) ) || ( prepareSoilForPyrome ) ) {
+                bw.write( "<?xml version=\"1.0\"?>\n" );
+            }
+            if ( !fileType.contentEquals( "SOIL" ) ) {
+                bw.write( "<Obj>\n" );
+                if ( fileType.length() > 1 ) {
+                    bw.write( "<Type>" + fileType + "</Type>\n" );
+                }
+                // if an incrementing index is needed, replace "0" with counter variable
+                bw.write( "<Filename>" + fileDir + fn + "</Filename>\n" );
+            }
+            int i = 0;
+            String inputLine;
+            while ( ( inputLine = br.readLine() ) != null ) {
+                // skip the first line of the file, except for soil files which only have 1 line
+                if ( ( i > 0 ) || ( fileType.contentEquals( "SOIL" ) && ( i == 0 ) && ( inputLine.startsWith( "<Obj>" ) ) ) ) {
+                    bw.write( inputLine + "\n" );
+                }
+                i++;
+            }
         }
-        // if an incrementing index is needed, replace "0" with counter variable
-        bw.write("<Filename>" + fileDir + fn + "</Filename>\n");
-      }
-      int i = 0;
-      String inputLine;
-      while ((inputLine = br.readLine()) != null) {
-        // skip the first line of the file, except for soil files which only have 1 line
-        if ((i > 0) || (fileType.contentEquals("SOIL") && (i == 0) && (inputLine.startsWith("<Obj>")))) {
-          bw.write(inputLine + "\n");
+        catch ( IOException ioe ) {
+            LOG.info( "IO Exception while preparing flie=" + outputFile.getName() + "---" + ioe.toString() );
         }
-        i++;
-      }
-    } catch (IOException ioe) {
-      LOG.info("IO Exception while preparing flie=" + outputFile.getName() + "---" + ioe.toString());
-    } finally {
-      if (br != null) {
-        br.close();
-      }
-      if (bw != null) {
-        bw.close();
-      }
-    }
-  }
-
-
-  // TO DO
-  // Consider moving to a helper class since this is a generally applicable function
-  private boolean getFile(String url, File destDir, String filename) throws FileNotFoundException, IOException {
-    String u = XMLUtils.escapeURL(url);
-    if (exists(u)) {
-      File f = new File(destDir, filename);
-      FileUtils.copyURLToFile(new URL(u), f);
-      return f.exists();
-    }
-    return false;
-  }
-
-
-  public static boolean exists(String URLName) throws IOException{
-      HttpURLConnection.setFollowRedirects(false);
-      // note : you may also need
-      //        HttpURLConnection.setInstanceFollowRedirects(false)
-      HttpURLConnection con = (HttpURLConnection) new URL(URLName).openConnection();
-      con.setRequestMethod("GET");
-      return (con.getResponseCode() == HttpURLConnection.HTTP_OK);
-  }
-
-
-  /**
-   * Gets results returned from RomeShell
-   * @param key
-   * @return
-   */
-  protected String getResult(String key) {
-    String sPattern = "RomeFileGetAttrValue " + key;
-
-    // Check if attr is available via the GetAttrValue cmd and return if so
-    if (stdout.contains(sPattern)) {
-      int start = stdout.indexOf(sPattern) + sPattern.length() + 2;
-      int end = stdout.indexOf('\r', start);
-      return stdout.substring(start, end).trim();
+        finally {
+            if ( br != null ) {
+                br.close();
+            }
+            if ( bw != null ) {
+                bw.close();
+            }
+        }
     }
 
-    // Check if attr is available via the TestAttrValue cmd and return if so
-    sPattern = "RomeFileTestAttrValue " + key;
-    if (stdout.contains(sPattern)) {
-      int start = stdout.indexOf(sPattern) + sPattern.length() + 2;
-      int end = stdout.indexOf('\r', start);
-      return stdout.substring(start, end).trim();
+    // TO DO
+    // Consider moving to a helper class since this is a generally applicable function
+    private boolean getFile ( String url, File destDir, String filename ) throws FileNotFoundException, IOException {
+        String u = XMLUtils.escapeURL( url );
+        if ( exists( u ) ) {
+            File f = new File( destDir, filename );
+            FileUtils.copyURLToFile( new URL( u ), f );
+            return f.exists();
+        }
+        return false;
     }
 
-    sPattern = ":" + Services.removeFirstLastChar(key) + "\"";
-    if (stdout.contains(sPattern)) {
-      int start = stdout.indexOf(sPattern) + sPattern.length() + 2;
-      int end = stdout.indexOf('\r', start);
-      String output = stdout.substring(start, end).trim();
-      if ((output == null) || (output.length() <= 0)) {
-        output = "null";
-      }
-      return output;
+    public static boolean exists ( String URLName ) throws IOException {
+        HttpURLConnection.setFollowRedirects( false );
+        // note : you may also need
+        //        HttpURLConnection.setInstanceFollowRedirects(false)
+        HttpURLConnection con = ( HttpURLConnection ) new URL( URLName ).openConnection();
+        con.setRequestMethod( "GET" );
+        return ( con.getResponseCode() == HttpURLConnection.HTTP_OK );
     }
-    // If attr is not available return null
-    return "null";
-  }
 
+    /**
+     * Gets results returned from RomeShell
+     *
+     * @param key
+     * @return
+     */
+    protected String getResult ( String key ) {
+        String sPattern = "RomeFileGetAttrValue " + key;
 
-  /**
-   * Gets results returned from Pyrome
-   * @param key
-   * @return
-   */
-  protected String getResultPyrome(String key) {
-    if (stdout.contains(key)) {
-      int start = stdout.indexOf(key) + key.length() + 1;
-      int end = stdout.indexOf('\r', start);
-      return stdout.substring(start, end).trim();
+        // Check if attr is available via the GetAttrValue cmd and return if so
+        if ( stdout.contains( sPattern ) ) {
+            int start = stdout.indexOf( sPattern ) + sPattern.length() + 2;
+            int end = stdout.indexOf( '\r', start );
+            return stdout.substring( start, end ).trim();
+        }
+
+        // Check if attr is available via the TestAttrValue cmd and return if so
+        sPattern = "RomeFileTestAttrValue " + key;
+        if ( stdout.contains( sPattern ) ) {
+            int start = stdout.indexOf( sPattern ) + sPattern.length() + 2;
+            int end = stdout.indexOf( '\r', start );
+            return stdout.substring( start, end ).trim();
+        }
+
+        sPattern = ":" + removeFirstLastChar( key ) + "\"";
+        if ( stdout.contains( sPattern ) ) {
+            int start = stdout.indexOf( sPattern ) + sPattern.length() + 2;
+            int end = stdout.indexOf( '\r', start );
+            String output = stdout.substring( start, end ).trim();
+            if ( ( output == null ) || ( output.length() <= 0 ) ) {
+                output = "null";
+            }
+            return output;
+        }
+        // If attr is not available return null
+        return "null";
     }
-    return "null";
-  }
 
+    /**
+     * Gets results returned from Pyrome
+     *
+     * @param key
+     * @return
+     */
+    protected String getResultPyrome ( String key ) {
+        if ( stdout.contains( key ) ) {
+            int start = stdout.indexOf( key ) + key.length() + 1;
+            int end = stdout.indexOf( '\r', start );
+            return stdout.substring( start, end ).trim();
+        }
+        return "null";
+    }
 
-  /**
-   * Gets results returned from Pyrome
-   * @param key
-   * @return
-   */
-  protected String getResultPyromeArray(String key, boolean bQuoted, boolean bEscape, boolean bIndexed) {
-    StringBuilder result = new StringBuilder("[");
-    String sPattern = "";
-    String text = "";
-    int idx = 0;
-    do {
-      sPattern = bIndexed ? (key + ":" + idx) : key;
-      LOG.info("Searching for key=" + sPattern);
-      text = getResultPyrome(sPattern);
-      LOG.info("Result of search=" + text);
-      if (!text.contentEquals("null")) {
-        if (idx > 0) {
-          result.append(",");
+    /**
+     * Gets results returned from Pyrome
+     *
+     * @param key
+     * @return
+     */
+    protected String getResultPyromeArray ( String key, boolean bQuoted, boolean bEscape, boolean bIndexed ) {
+        StringBuilder result = new StringBuilder( "[" );
+        String sPattern = "";
+        String text = "";
+        int idx = 0;
+        do {
+            sPattern = bIndexed ? ( key + ":" + idx ) : key;
+            LOG.info( "Searching for key=" + sPattern );
+            text = getResultPyrome( sPattern );
+            LOG.info( "Result of search=" + text );
+            if ( !text.contentEquals( "null" ) ) {
+                if ( idx > 0 ) {
+                    result.append( "," );
+                }
+                if ( bQuoted ) {
+                    result.append( "\"" + ( bEscape ? StringEscapeUtils.escapeJava( text ) : text ) + "\"" );
+                } else {
+                    result.append( bEscape ? StringEscapeUtils.escapeJava( text ) : text );
+                }
+                idx++;
+            }
         }
-        if (bQuoted) {
-          result.append("\"" + (bEscape ? StringEscapeUtils.escapeJava(text) : text) + "\"");
-        } else {
-          result.append(bEscape ? StringEscapeUtils.escapeJava(text) : text);
-        }
-        idx++;
-      }
-    } while (!text.contentEquals("null"));
-    result.append("]");
-    return result.toString();
-  }
+        while ( !text.contentEquals( "null" ) );
+        result.append( "]" );
+        return result.toString();
+    }
 
+    public boolean isFileUrlReachable ( String targetUrl ) throws IOException {
+        String fileUrl = XMLUtils.escapeXMLFileURL( targetUrl );
+        return isUrlReachable( fileUrl );
+    }
 
-  public boolean isFileUrlReachable(String targetUrl) throws IOException {
-    String fileUrl = XMLUtils.escapeXMLFileURL(targetUrl);
-    return isUrlReachable(fileUrl);
-  }
+    public boolean isUrlReachable ( String targetUrl ) throws IOException {
+        String r2db = Config.getString( "r2.db", "http://oms-db.engr.colostate.edu/r2" );
+        String testUrl = r2db + "/" + targetUrl;
+        return exists( testUrl );
+    }
 
-
-  public boolean isUrlReachable(String targetUrl) throws IOException {
-    String r2db = Config.getString("r2.db", "http://oms-db.engr.colostate.edu/r2");
-    String testUrl = r2db + "/" + targetUrl;
-    return exists(testUrl);
-  }
-
-
-  protected static String escapeJavaNoFwdSlash(String text) {
-    String javaEsc = StringEscapeUtils.escapeJava(text);
-    return javaEsc.replace("\\/", "/");
-  }
+    protected static String escapeJavaNoFwdSlash ( String text ) {
+        String javaEsc = StringEscapeUtils.escapeJava( text );
+        return javaEsc.replace( "\\/", "/" );
+    }
 }

src/java/m/rusle2/V1_3.java

@@ -13,55 +13,46 @@
 
 import csip.Config;
 import csip.Executable;
+import csip.ModelDataService;
 import csip.ServiceException;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.util.*;
-import javax.ws.rs.*;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.codehaus.jettison.json.JSONArray;
-import org.codehaus.jettison.json.JSONObject;
-import org.codehaus.jettison.json.JSONException;
-import org.w3c.dom.Document;
-import org.w3c.dom.NodeList;
-import csip.ModelDataService;
-import static csip.ModelDataService.KEY_REQUEST_RESULTS;
-import static csip.ModelDataService.REPORT_DIM;
-import static csip.ModelDataService.REPORT_NAME;
-import static csip.ModelDataService.REPORT_TYPE;
-import static csip.ModelDataService.VALUE;
+import static csip.Utils.removeFirstLastChar;
 import csip.annotations.*;
-import static util.Constants.*;
-
-import csip.utils.JSONUtils;
-import csip.utils.Services;
-import csip.annotations.Polling;
-import csip.annotations.Resource;
 import static csip.annotations.ResourceType.EXECUTABLE;
 import static csip.annotations.ResourceType.FILE;
 import static csip.annotations.ResourceType.JDBC;
 import static csip.annotations.State.RELEASED;
+import csip.utils.JSONUtils;
 import database.GIS_DB;
 import database.SqlGIS;
 import java.io.BufferedReader;
 import java.io.BufferedWriter;
+import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.net.UnknownHostException;
+import java.util.*;
 import java.util.logging.Level;
-
+import javax.ws.rs.*;
 import static m.rusle2.V1_3.*;
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpUriRequest;
 import org.apache.http.impl.client.DefaultHttpClient;
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import static util.Constants.*;
 import util.XMLUtils;
 
 /**
@@ -69,23 +60,23 @@
  *
  * @author wlloyd, od
  */
-@Name("Rusle2")
-@Description("“FtM / pyrome version of R2; RomeDLL 2.5.2.11; references SSURGO 2015")
-@VersionInfo("1.3")
-@Path("m/rusle2/1.3")
-@Polling(first = 5000, next = 1000)
-@State(RELEASED)
+@Name( "Rusle2" )
+@Description( "“FtM / pyrome version of R2; RomeDLL 2.5.2.11; references SSURGO 2015" )
+@VersionInfo( "1.3" )
+@Path( "m/rusle2/1.3" )
+@Polling( first = 5000, next = 1000 )
+@State( RELEASED )
 // R2
-@Resource(type = EXECUTABLE, file = "/bin/win-x86/2.5.2.11/RomeShell.exe", wine = true, id = ROME_EXE)
-@Resource(type = FILE, file = "/bin/win-x86/2.5.2.11/RomeDLL.dll")
+@Resource( type = EXECUTABLE, file = "/bin/win-x86/2.5.2.11/RomeShell.exe", wine = true, id = ROME_EXE )
+@Resource( type = FILE, file = "/bin/win-x86/2.5.2.11/RomeDLL.dll" )
 
-@Resource(type = EXECUTABLE, file = "/bin/win-x86/preparesoils.sh", id = PREP_SOILS)
+@Resource( type = EXECUTABLE, file = "/bin/win-x86/preparesoils.sh", id = PREP_SOILS )
 
-@Resource(type = FILE, file = "/bin/win-x86/rusle2_report.rsh", id = REPORT_RSH)
-@Resource(type = FILE, file = "/bin/win-x86/Rusle2_Report.json", id = REPORT_JSON)
+@Resource( type = FILE, file = "/bin/win-x86/rusle2_report.rsh", id = REPORT_RSH )
+@Resource( type = FILE, file = "/bin/win-x86/Rusle2_Report.json", id = REPORT_JSON )
 
 // database
-@Resource(type = JDBC, file = "${conservation_resources.db}", id = DB)
+@Resource( type = JDBC, file = "${conservation_resources.db}", id = DB )
 
 public class V1_3 extends ModelDataService {
 
@@ -107,7 +98,7 @@
      */
 //    final R2Run r2run = new R2Run();
     // These are the allowable potential results returnable from the R2 service
-    static final List<String> potResults = Collections.unmodifiableList(Arrays.asList(
+    static final List<String> potResults = Collections.unmodifiableList( Arrays.asList(
             RES_SLOPE_DELIVERY,
             RES_SLOPE_T_VALUE,
             RES_SLOPE_DEGRAD,
@@ -123,7 +114,7 @@
             RES_SURF_RES_OUTPUTS_SURF_COV_AT_OP,
             RES_SOIL_COND_INDEX_OM_SUBFACTOR,
             RES_SOIL_COND_INDEX_FO_SUBFACTOR,
-            RES_SOIL_COND_INDEX_ER_SUBFACTOR));
+            RES_SOIL_COND_INDEX_ER_SUBFACTOR ) );
     //
     String climate;
     String soil;
@@ -134,106 +125,104 @@
 
     File stdout;
 
-    File r2script = new File(getWorkspaceDir(), R2_TMP_FILENAME + R2_TMP_FILEEXT);
-
+    File r2script = new File( getWorkspaceDir(), R2_TMP_FILENAME + R2_TMP_FILEEXT );
 
     @Override
-    protected void preProcess() throws Exception {
+    protected void preProcess () throws Exception {
         try {
-            LOG.info("\n\n\n\n\nMETAINFO:");
-            LOG.info("\n" + getMetainfo().toString());
-            LOG.info("\n\n\n");
-            JSONUtils.checkValidResultRequest(getMetainfo(), potResults);
-        } catch (ServiceException se) {
-            LOG.severe("\n\n\nERROR!!!\n\n\n" + se.toString());
-            LOG.warning("No Rusle2 return parameters requested! Will use defaults: SLOPE_DELIVERY, SLOPE_T_VALUE, SLOPE_DEGRAD");
+            LOG.info( "\n\n\n\n\nMETAINFO:" );
+            LOG.info( "\n" + getMetainfo().toString() );
+            LOG.info( "\n\n\n" );
+            JSONUtils.checkValidResultRequest( getMetainfo(), potResults );
+        }
+        catch ( ServiceException se ) {
+            LOG.severe( "\n\n\nERROR!!!\n\n\n" + se.toString() );
+            LOG.warning( "No Rusle2 return parameters requested! Will use defaults: SLOPE_DELIVERY, SLOPE_T_VALUE, SLOPE_DEGRAD" );
             List<String> params = new LinkedList<String>();
-            params.add(RES_SLOPE_DELIVERY);
-            params.add(RES_SLOPE_T_VALUE);
-            params.add(RES_SLOPE_DEGRAD);
+            params.add( RES_SLOPE_DELIVERY );
+            params.add( RES_SLOPE_T_VALUE );
+            params.add( RES_SLOPE_DEGRAD );
 
             // check if these are being set
-            if (JSONUtils.checkKeyExistsB(getParamMap(), KEY_CONTOUR_SYSTEM_PTR)) {
-                params.add("CONTOUR_SYSTEM_PTR");
+            if ( JSONUtils.checkKeyExistsB( getParamMap(), KEY_CONTOUR_SYSTEM_PTR ) ) {
+                params.add( "CONTOUR_SYSTEM_PTR" );
             }
-            if (JSONUtils.checkKeyExistsB(getParamMap(), KEY_STRIP_BARRIER_SYSTEM_PTR)) {
-                params.add("STRIP_BARRIER_SYSTEM_PTR");
+            if ( JSONUtils.checkKeyExistsB( getParamMap(), KEY_STRIP_BARRIER_SYSTEM_PTR ) ) {
+                params.add( "STRIP_BARRIER_SYSTEM_PTR" );
             }
-            if (JSONUtils.checkKeyExistsB(getParamMap(), KEY_HYD_ELEM_SYSTEM_PTR)) {
-                params.add("HYD_ELEM_SYSTEM_PTR");
+            if ( JSONUtils.checkKeyExistsB( getParamMap(), KEY_HYD_ELEM_SYSTEM_PTR ) ) {
+                params.add( "HYD_ELEM_SYSTEM_PTR" );
             }
-            getMetainfo().put(KEY_REQUEST_RESULTS, params);
+            getMetainfo().put( KEY_REQUEST_RESULTS, params );
         }
 
         // check if sufficient input is there.
         //JSONUtils.checkKeyExists(getParamMap(), KEY_CLIMATES);
-        JSONUtils.checkKeyExists(getParamMap(), KEY_SOILS);
+        JSONUtils.checkKeyExists( getParamMap(), KEY_SOILS );
 //        JSONUtils.checkKeyExists(getParamMap(), KEY_MANAGEMENTS);
-        JSONUtils.checkKeyExists(getParamMap(), KEY_LENGTH);
-        JSONUtils.checkKeyExists(getParamMap(), KEY_STEEPNESS);
-        JSONUtils.checkKeyExists(getParamMap(), KEY_MGMTS);
-        
-        if(!isUrlReachable(""))
-            throw new ServiceException("R2 file server unreachable at: " + Config.getString("r2.db", "http://oms-db.engr.colostate.edu/r2"));
+        JSONUtils.checkKeyExists( getParamMap(), KEY_LENGTH );
+        JSONUtils.checkKeyExists( getParamMap(), KEY_STEEPNESS );
+        JSONUtils.checkKeyExists( getParamMap(), KEY_MGMTS );
 
-        createInputFile(r2script, getMetainfo(), getParamMap());
+        if ( !isUrlReachable( "" ) ) {
+            throw new ServiceException( "R2 file server unreachable at: " + Config.getString( "r2.db", "http://oms-db.engr.colostate.edu/r2" ) );
+        }
+
+        createInputFile( r2script, getMetainfo(), getParamMap() );
     }
 
+    @Override
+    protected void doProcess () throws Exception {
+        stdout = execute( r2script );
+    }
 
     @Override
-    protected void doProcess() throws Exception {
-        stdout = execute(r2script);
-    }
-
-
-    @Override
-    protected void postProcess() throws IOException, JSONException, ServiceException{
+    protected void postProcess () throws IOException, JSONException, ServiceException {
         int errors = 0;
-        for (int i = 0; i < operations.size(); i++) {
-            String op = operations.get(i);
-            if (isFileUrlReachable(op)) {
-                results().put("OPERATION_" + (i + 1), op, "operation is valid");
+        for ( int i = 0; i < operations.size(); i++ ) {
+            String op = operations.get( i );
+            if ( isFileUrlReachable( op ) ) {
+                results().put( "OPERATION_" + ( i + 1 ), op, "operation is valid" );
             } else {
-                results().put("OPERATION_INVALID_" + (i + 1), op, "OPERATION IS MISSING!");
+                results().put( "OPERATION_INVALID_" + ( i + 1 ), op, "OPERATION IS MISSING!" );
                 errors++;
             }
         }
-        for (int i = 0; i < vegetations.size(); i++) {
-            String vege = vegetations.get(i);
-            if (isFileUrlReachable(vege)) {
-                results().put("VEGETATION_" + (i + 1),vege,"vegetation is valid");
+        for ( int i = 0; i < vegetations.size(); i++ ) {
+            String vege = vegetations.get( i );
+            if ( isFileUrlReachable( vege ) ) {
+                results().put( "VEGETATION_" + ( i + 1 ), vege, "vegetation is valid" );
             } else {
-                results().put("VEGETATION_INVALID_" + (i + 1), vege, "VEGETATION IS MISSING");
+                results().put( "VEGETATION_INVALID_" + ( i + 1 ), vege, "VEGETATION IS MISSING" );
                 errors++;
             }
         }
-        for (int i = 0; i < residues.size(); i++) {
-            String res = residues.get(i);
-            if (isFileUrlReachable(res)) {
-                results().put("RESIDUE_" + (i + 1), res, "residue is valid");
+        for ( int i = 0; i < residues.size(); i++ ) {
+            String res = residues.get( i );
+            if ( isFileUrlReachable( res ) ) {
+                results().put( "RESIDUE_" + ( i + 1 ), res, "residue is valid" );
             } else {
-                results().put("RESIDUE_INVALID_" + (i + 1), res, "RESIDUE IS MISSING");
+                results().put( "RESIDUE_INVALID_" + ( i + 1 ), res, "RESIDUE IS MISSING" );
                 errors++;
             }
         }
 
 //      results.put(JSONUtils.data(KEY_SLOPE_DELIVERY, 3.0));
-        String sout = FileUtils.readFileToString(stdout);
-        for (String r : JSONUtils.getRequestedResults(getMetainfo())) {
-            if ((errors > 0) && (r.equals(RES_SLOPE_DEGRAD))) {
-                results().put(r, getResult(sout, r), R2_MISSING_XML_FILES_WARNING_MSG);
+        String sout = FileUtils.readFileToString( stdout );
+        for ( String r : JSONUtils.getRequestedResults( getMetainfo() ) ) {
+            if ( ( errors > 0 ) && ( r.equals( RES_SLOPE_DEGRAD ) ) ) {
+                results().put( r, getResult( sout, r ), R2_MISSING_XML_FILES_WARNING_MSG );
             } else {
-                results().put(r, getResult(sout, r));
+                results().put( r, getResult( sout, r ) );
             }
         }
-        if (errors > 0) {
-            metainfo().appendWarning(R2_MISSING_XML_FILES_WARNING_MSG);
+        if ( errors > 0 ) {
+            metainfo().appendWarning( R2_MISSING_XML_FILES_WARNING_MSG );
         }
-        
-        
-        results().put(KEY_CLIMATES, climate);
-        results().put(KEY_SOILS, soil);
-        results().put(KEY_MANAGEMENTS, mgmt);
+
+        results().put( KEY_CLIMATES, climate );
+        results().put( KEY_SOILS, soil );
+        results().put( KEY_MANAGEMENTS, mgmt );
 //      results.put(JSONUtils.data(KEY_ALT_R2DB, in_ALT_R2DB));
     }
 
@@ -244,197 +233,198 @@
      * @return
      * @throws IOException
      */
-    private File execute(File r2_rsh) throws ServiceException, IOException {
-        Executable exe = resources().getExe(ROME_EXE);
-        exe.setArguments(r2_rsh.toString());
+    private File execute ( File r2_rsh ) throws ServiceException, IOException {
+        Executable exe = resources().getExe( ROME_EXE );
+        exe.setArguments( r2_rsh.toString() );
         int result = exe.exec();
-        if (result != 0) {
-            throw new ServiceException("ROME exit error :" + result);
+        if ( result != 0 ) {
+            throw new ServiceException( "ROME exit error :" + result );
         }
         return exe.stdout();
     }
 
-    private boolean isFileUrlReachable(String targetUrl) throws IOException{
-        String fileUrl = XMLUtils.escapeXMLFileURL(targetUrl);
-        return isUrlReachable(fileUrl);
+    private boolean isFileUrlReachable ( String targetUrl ) throws IOException {
+        String fileUrl = XMLUtils.escapeXMLFileURL( targetUrl );
+        return isUrlReachable( fileUrl );
     }
-    
-    private boolean isUrlReachable(String targetUrl) throws IOException {
-        String r2db = Config.getString("r2.db", "http://oms-db.engr.colostate.edu/r2");
+
+    private boolean isUrlReachable ( String targetUrl ) throws IOException {
+        String r2db = Config.getString( "r2.db", "http://oms-db.engr.colostate.edu/r2" );
         String testUrl = r2db + "/" + targetUrl;
-        LOG.info("Testing URL=" + testUrl);
-        URL url = new URL(testUrl);
-        HttpURLConnection httpUrlConnection = (HttpURLConnection) url.openConnection();
-        httpUrlConnection.setRequestMethod("GET");
+        LOG.info( "Testing URL=" + testUrl );
+        URL url = new URL( testUrl );
+        HttpURLConnection httpUrlConnection = ( HttpURLConnection ) url.openConnection();
+        httpUrlConnection.setRequestMethod( "GET" );
         try {
             int responseCode = httpUrlConnection.getResponseCode();
-            LOG.info("response code=" + responseCode);
+            LOG.info( "response code=" + responseCode );
             return responseCode == HttpURLConnection.HTTP_OK;
-        } catch (UnknownHostException E) {
+        }
+        catch ( UnknownHostException E ) {
             return false;
         }
     }
 
-
-    int prepareSoilsFile(String soilsHttpPtr, File workingDir, boolean bPyrome, String idx) throws IOException, ServiceException {
-        Executable exe = resources().getExe(PREP_SOILS);
-        exe.setArguments(soilsHttpPtr);
+    int prepareSoilsFile ( String soilsHttpPtr, File workingDir, boolean bPyrome, String idx ) throws IOException, ServiceException {
+        Executable exe = resources().getExe( PREP_SOILS );
+        exe.setArguments( soilsHttpPtr );
         int result = exe.exec();
-        if (result != 0) {
-            throw new ServiceException("Prep soils exit error :" + result);
+        if ( result != 0 ) {
+            throw new ServiceException( "Prep soils exit error :" + result );
         }
         return result;
     }
 
-
-    void prepareFileJ(String httpPtr, File outputFile, String fileType, String fileDir, String basefilename, boolean prepareSoilForPyrome) throws IOException {
+    void prepareFileJ ( String httpPtr, File outputFile, String fileType, String fileDir, String basefilename, boolean prepareSoilForPyrome ) throws IOException {
         BufferedReader br = null;
         BufferedWriter bw = null;
-        String fn = (((basefilename != null) & (basefilename.length() > 0)) ? "\\" + basefilename + "1" : "\\aaa");
+        String fn = ( ( ( basefilename != null ) & ( basefilename.length() > 0 ) ) ? "\\" + basefilename + "1" : "\\aaa" );
         try {
             // Generate shell script to prepare --fileType-- file for pyrome
-            LOG.info("***********************************************************************************the " + fileType + " file name=" + outputFile.getName());
-            String tmpFilename = outputFile.getName().substring(0, outputFile.getName().length() - 4) + ".tmp";
-            LOG.info("***********************************************************************************the " + fileType + " tmp file name=" + tmpFilename);
-            getFile(httpPtr, outputFile.getParent(), tmpFilename);
-            FileOutputStream fos = new FileOutputStream(outputFile);
-            bw = new BufferedWriter(new OutputStreamWriter(fos));
-            File origFile = new File(outputFile.getParent() + "/" + tmpFilename);
-            FileInputStream fis = new FileInputStream(origFile);
-            br = new BufferedReader(new InputStreamReader(fis));
-            if ((fileType.contentEquals("CLIMATE")) || (fileType.contentEquals("SOIL")) || (prepareSoilForPyrome)) {
-                bw.write("<?xml version=\"1.0\"?>\n");
+            LOG.info( "***********************************************************************************the " + fileType + " file name=" + outputFile.getName() );
+            String tmpFilename = outputFile.getName().substring( 0, outputFile.getName().length() - 4 ) + ".tmp";
+            LOG.info( "***********************************************************************************the " + fileType + " tmp file name=" + tmpFilename );
+            getFile( httpPtr, outputFile.getParent(), tmpFilename );
+            FileOutputStream fos = new FileOutputStream( outputFile );
+            bw = new BufferedWriter( new OutputStreamWriter( fos ) );
+            File origFile = new File( outputFile.getParent() + "/" + tmpFilename );
+            FileInputStream fis = new FileInputStream( origFile );
+            br = new BufferedReader( new InputStreamReader( fis ) );
+            if ( ( fileType.contentEquals( "CLIMATE" ) ) || ( fileType.contentEquals( "SOIL" ) ) || ( prepareSoilForPyrome ) ) {
+                bw.write( "<?xml version=\"1.0\"?>\n" );
             }
-            if (!fileType.contentEquals("SOIL")) {
-                bw.write("<Obj>\n");
-                if ((fileType != null) && (fileType.length() > 1)) {
-                    bw.write("<Type>" + fileType + "</Type>\n");
+            if ( !fileType.contentEquals( "SOIL" ) ) {
+                bw.write( "<Obj>\n" );
+                if ( ( fileType != null ) && ( fileType.length() > 1 ) ) {
+                    bw.write( "<Type>" + fileType + "</Type>\n" );
                 }
                 // if an incrementing index is needed, replace "0" with counter variable
-                bw.write("<Filename>" + fileDir + fn + "</Filename>\n");
+                bw.write( "<Filename>" + fileDir + fn + "</Filename>\n" );
             }
             int i = 0;
             String inputLine;
-            while ((inputLine = br.readLine()) != null) {
+            while ( ( inputLine = br.readLine() ) != null ) {
                 // skip the first line of the file, except for soil files which only have 1 line
-                if ((i > 0) || (fileType.contentEquals("SOIL") && (i == 0) && (inputLine.startsWith("<Obj>")))) {
-                    bw.write(inputLine + "\n");
+                if ( ( i > 0 ) || ( fileType.contentEquals( "SOIL" ) && ( i == 0 ) && ( inputLine.startsWith( "<Obj>" ) ) ) ) {
+                    bw.write( inputLine + "\n" );
                 }
                 i++;
             }
             fis.close();
-        } catch (IOException ioe) {
-            LOG.info("IO Exception while preparing flie=" + outputFile.getName() + "---" + ioe.toString());
-        } finally {
-            if (br != null) {
+        }
+        catch ( IOException ioe ) {
+            LOG.info( "IO Exception while preparing flie=" + outputFile.getName() + "---" + ioe.toString() );
+        }
+        finally {
+            if ( br != null ) {
                 br.close();
             }
-            if (bw != null) {
+            if ( bw != null ) {
                 bw.close();
             }
         }
     }
 
+    private void getFile ( String url, String destDir, String filename ) {
+        FileOutputStream fos = null;
+        String escapedUrl = XMLUtils.escapeURL( url );
+        try {
+            LOG.info( "*************************************\n\n\n\nTRYING TO GET FILE=" + url + "\n" );
+            LOG.info( "Where the URI is =" );
+            LOG.info( escapedUrl + "\n\n\n\n\n*************************************************************" );
+            HttpClient client = new DefaultHttpClient();
+            HttpGet httpget = new HttpGet( escapedUrl );
+            HttpResponse response = client.execute( ( HttpUriRequest ) httpget );
 
-    private void getFile(String url, String destDir, String filename) {
-        FileOutputStream fos = null;
-        String escapedUrl = XMLUtils.escapeURL(url);
-        try {
-            LOG.info("*************************************\n\n\n\nTRYING TO GET FILE=" + url + "\n");
-            LOG.info("Where the URI is =");
-            LOG.info(escapedUrl + "\n\n\n\n\n*************************************************************");
-            HttpClient client = new DefaultHttpClient();
-            HttpGet httpget = new HttpGet(escapedUrl);
-            HttpResponse response = client.execute((HttpUriRequest) httpget);
-
-            byte[] soilData = IOUtils.toByteArray(response.getEntity().getContent());
-            fos = new FileOutputStream(new File(destDir + "/" + filename));
-            fos.write(soilData);
+            byte[] soilData = IOUtils.toByteArray( response.getEntity().getContent() );
+            fos = new FileOutputStream( new File( destDir + "/" + filename ) );
+            fos.write( soilData );
             fos.close();
-        } catch (IOException ie) {
-            LOG.log(Level.SEVERE, "ERROR GETTING SOILS IFC FILE!:" + ie.toString());
-            throw new RuntimeException(ie);
-        } finally {
-            if (fos != null) {
+        }
+        catch ( IOException ie ) {
+            LOG.log( Level.SEVERE, "ERROR GETTING SOILS IFC FILE!:" + ie.toString() );
+            throw new RuntimeException( ie );
+        }
+        finally {
+            if ( fos != null ) {
                 try {
                     fos.close();
-                } catch (Exception fe) {
+                }
+                catch ( Exception fe ) {
                 }
             }
         }
     }
 
-
-    String getResult(String stdout, String key) {
+    String getResult ( String stdout, String key ) {
         String sPattern = "RomeFileGetAttrValue " + key;
 
         //LOG.info("seeking='" + sPattern + "'");
         // Check if attr is available via the GetAttrValue cmd and return if so
-        if (stdout.contains(sPattern)) {
-            int start = stdout.indexOf(sPattern) + sPattern.length() + 2;
-            int end = stdout.indexOf('\r', start);
+        if ( stdout.contains( sPattern ) ) {
+            int start = stdout.indexOf( sPattern ) + sPattern.length() + 2;
+            int end = stdout.indexOf( '\r', start );
             //LOG.info("returning='" + stdout.substring(start, end).trim() + "'");
-            return stdout.substring(start, end).trim();
+            return stdout.substring( start, end ).trim();
         }
 
         // Check if attr is available via the TestAttrValue cmd and return if so
         sPattern = "RomeFileTestAttrValue " + key;
-        //LOG.info("seeking='" + sPattern + "'");        
-        if (stdout.contains(sPattern)) {
-            int start = stdout.indexOf(sPattern) + sPattern.length() + 2;
-            int end = stdout.indexOf('\r', start);
-            //LOG.info("returning='" + stdout.substring(start, end).trim() + "'");            
-            return stdout.substring(start, end).trim();
+        //LOG.info("seeking='" + sPattern + "'");
+        if ( stdout.contains( sPattern ) ) {
+            int start = stdout.indexOf( sPattern ) + sPattern.length() + 2;
+            int end = stdout.indexOf( '\r', start );
+            //LOG.info("returning='" + stdout.substring(start, end).trim() + "'");
+            return stdout.substring( start, end ).trim();
         }
 
         //String key2 = "\"#RD:MAN_PTR:#RD:MAN_IRRIG_SUB_OBJ_PTR:" + key.substring(1);
-        sPattern = ":" + Services.removeFirstLastChar(key) + "\"";
-        //LOG.info("seeking='" +  sPattern + "'");        
-        if (stdout.contains(sPattern)) {
-            int start = stdout.indexOf(sPattern) + sPattern.length() + 2;
-            int end = stdout.indexOf('\r', start);
-            String output = stdout.substring(start, end).trim();
-            if ((output == null) || (output.length() <= 0)) {
+        sPattern = ":" + removeFirstLastChar( key ) + "\"";
+        //LOG.info("seeking='" +  sPattern + "'");
+        if ( stdout.contains( sPattern ) ) {
+            int start = stdout.indexOf( sPattern ) + sPattern.length() + 2;
+            int end = stdout.indexOf( '\r', start );
+            String output = stdout.substring( start, end ).trim();
+            if ( ( output == null ) || ( output.length() <= 0 ) ) {
                 output = "null";
             }
-            //LOG.info("returning='" + output + "'");            
+            //LOG.info("returning='" + output + "'");
             return output;
         }
 
         // If attr is not available return null
-        LOG.info("returning='null'");
+        LOG.info( "returning='null'" );
         return "null";
     }
 
-
-    private void createInputFile(File file, JSONObject metainfo, Map<String, JSONObject> param)
+    private void createInputFile ( File file, JSONObject metainfo, Map<String, JSONObject> param )
             throws Exception {
 
-        double steepness = JSONUtils.getDoubleParam(param, KEY_STEEPNESS, 0.0);
-        double length = JSONUtils.getDoubleParam(param, KEY_LENGTH, 0.0);
-        boolean resolveLoc = JSONUtils.getBooleanParam(param, KEY_RESOLVE_LOCATION, false);
-        double latitude = JSONUtils.getDoubleParam(param, KEY_LATITUDE, 0.0);
-        double longitude = JSONUtils.getDoubleParam(param, KEY_LONGITUDE, 0.0);
-        double simpleRockCoverPercent = JSONUtils.getDoubleParam(param, KEY_SIMPLE_ROCK_COVER, 0.0);
+        double steepness = JSONUtils.getDoubleParam( param, KEY_STEEPNESS, 0.0 );
+        double length = JSONUtils.getDoubleParam( param, KEY_LENGTH, 0.0 );
+        boolean resolveLoc = JSONUtils.getBooleanParam( param, KEY_RESOLVE_LOCATION, false );
+        double latitude = JSONUtils.getDoubleParam( param, KEY_LATITUDE, 0.0 );
+        double longitude = JSONUtils.getDoubleParam( param, KEY_LONGITUDE, 0.0 );
+        double simpleRockCoverPercent = JSONUtils.getDoubleParam( param, KEY_SIMPLE_ROCK_COVER, 0.0 );
 
-        LOG.info("Rock cover read by service is=" + simpleRockCoverPercent);
+        LOG.info( "Rock cover read by service is=" + simpleRockCoverPercent );
 
-        JSONArray aRockCover = JSONUtils.getJSONArrayParam(param, KEY_SIMPLE_ROCK_COVER);
-        for (int i = 0; i < aRockCover.length(); i++) {
-            LOG.info("Rock cover [" + i + "]=" + aRockCover.getDouble(i));
+        JSONArray aRockCover = JSONUtils.getJSONArrayParam( param, KEY_SIMPLE_ROCK_COVER );
+        for ( int i = 0; i < aRockCover.length(); i++ ) {
+            LOG.info( "Rock cover [" + i + "]=" + aRockCover.getDouble( i ) );
             // this is temporary, since R2 will be using slope segments soon
-            if (i == 0) {
-                simpleRockCoverPercent = aRockCover.getDouble(i);
+            if ( i == 0 ) {
+                simpleRockCoverPercent = aRockCover.getDouble( i );
             }
         }
 
-        String climatePtr = JSONUtils.getStringParam(param, KEY_CLIMATES, "");
-        String soilPtr = JSONUtils.getStringParam(param, KEY_SOILS, "");
-        String managementFormalName[] = new String[]{};
+        String climatePtr = JSONUtils.getStringParam( param, KEY_CLIMATES, "" );
+        String soilPtr = JSONUtils.getStringParam( param, KEY_SOILS, "" );
+        String managementFormalName[] = new String[] {};
 
-        String contourSystem = JSONUtils.getStringParam(param, KEY_CONTOUR_SYSTEM_PTR, "");
-        String stripBarrierSystem = JSONUtils.getStringParam(param, KEY_STRIP_BARRIER_SYSTEM_PTR, "");
-        String hydElemSystem = JSONUtils.getStringParam(param, KEY_HYD_ELEM_SYSTEM_PTR, "");
+        String contourSystem = JSONUtils.getStringParam( param, KEY_CONTOUR_SYSTEM_PTR, "" );
+        String stripBarrierSystem = JSONUtils.getStringParam( param, KEY_STRIP_BARRIER_SYSTEM_PTR, "" );
+        String hydElemSystem = JSONUtils.getStringParam( param, KEY_HYD_ELEM_SYSTEM_PTR, "" );
 
 //        String mgmtPtr = JSONUtils.getStringParam(param, KEY_MANAGEMENTS, "");
 //        if (!mgmtPtr.startsWith("managements\\")) {
@@ -442,24 +432,24 @@
 //        }
         // management conversion
         // Make file line separator unix compatible. ???? not sure if needed.
-        System.setProperty("line.separator", "\n");
+        System.setProperty( "line.separator", "\n" );
         //
-        JSONArray managements = JSONUtils.getJSONArrayParam(param, KEY_MGMTS);
+        JSONArray managements = JSONUtils.getJSONArrayParam( param, KEY_MGMTS );
 
-        LOG.info("managements array=" + managements.toString());
+        LOG.info( "managements array=" + managements.toString() );
         managementFormalName = new String[managements.length()];
 
-        for (int i = 0; i < managements.length(); i++) {
-            LOG.info("management #" + i);
+        for ( int i = 0; i < managements.length(); i++ ) {
+            LOG.info( "management #" + i );
 
-            JSONObject lmod = (JSONObject) managements.get(i);
-            LOG.info(lmod.toString());
+            JSONObject lmod = ( JSONObject ) managements.get( i );
+            LOG.info( lmod.toString() );
 
-            LOG.info("creating Jim's translator.");
+            LOG.info( "creating Jim's translator." );
             lmod2rusle2.Rusle2Translator translator = new lmod2rusle2.Rusle2Translator();
-            LOG.info("trying to put in the lmod json");
-            translator.readJsonString(lmod.toString());
-            LOG.info("trying to translate=" + translator.Translate());
+            LOG.info( "trying to put in the lmod json" );
+            translator.readJsonString( lmod.toString() );
+            LOG.info( "trying to translate=" + translator.Translate() );
 
 //            // extract the element as JSON
 //            Document lmod_xml = Lmod2Rusle2.readJSON(lmod, false);
@@ -467,50 +457,50 @@
 //            Document r2_xml = Lmod2Rusle2.LmodXmlToRusle2Xml(lmod_xml, "F");
             Document r2_xml = translator.getDocument();
 
-            LOG.info("R2 XML FILE from trhe translator:\n\n" + translator.getRusle2Xml());
-            LOG.info("R2 XML FILE:\n\n" + translator.getRusle2Xml());
+            LOG.info( "R2 XML FILE from trhe translator:\n\n" + translator.getRusle2Xml() );
+            LOG.info( "R2 XML FILE:\n\n" + translator.getRusle2Xml() );
             //LOG.info("LMOD XML FILE:\n\n" + lmod_xml.getTextContent());
 
 //            if ((lmod_xml != null) && (lmod_xml.getElementById("Filename") != null))
 //                managementFormalName[i] = lmod_xml.getElementById("Filename").getTextContent();
-            if ((r2_xml != null) && (r2_xml.getElementsByTagName("Filename") != null)) {
-                NodeList nl = r2_xml.getElementsByTagName("Filename");
-                for (int ii = 0; ii < nl.getLength(); ii++) {
-                    LOG.info("filename node=" + nl.item(ii).getTextContent());
-                    managementFormalName[i] = nl.item(ii).getTextContent();
+            if ( ( r2_xml != null ) && ( r2_xml.getElementsByTagName( "Filename" ) != null ) ) {
+                NodeList nl = r2_xml.getElementsByTagName( "Filename" );
+                for ( int ii = 0; ii < nl.getLength(); ii++ ) {
+                    LOG.info( "filename node=" + nl.item( ii ).getTextContent() );
+                    managementFormalName[i] = nl.item( ii ).getTextContent();
                 }
             }
-            translator.writeRusle2Xml(getWorkspaceDir().toString(), "lmod_file" + i + ".xml");
+            translator.writeRusle2Xml( getWorkspaceDir().toString(), "lmod_file" + i + ".xml" );
             operations = translator.getOperationFiles();
             vegetations = translator.getVegetationFiles();
             residues = translator.getResidueFiles();
 
-            for (String operation : translator.getOperationFiles()) {
-                System.out.println("operation=" + operation);
+            for ( String operation : translator.getOperationFiles() ) {
+                System.out.println( "operation=" + operation );
             }
-            for (String vege : translator.getVegetationFiles()) {
-                System.out.println("vegetation=" + vege);
+            for ( String vege : translator.getVegetationFiles() ) {
+                System.out.println( "vegetation=" + vege );
             }
-            for (String residue : translator.getResidueFiles()) {
-                System.out.println("residue=" + residue);
+            for ( String residue : translator.getResidueFiles() ) {
+                System.out.println( "residue=" + residue );
             }
         }
 
         String altR2db = null;
-        if (param.get(KEY_ALT_R2DB) != null) {
-            altR2db = param.get(KEY_ALT_R2DB).getString(VALUE);
+        if ( param.get( KEY_ALT_R2DB ) != null ) {
+            altR2db = param.get( KEY_ALT_R2DB ).getString( VALUE );
         }
 
-        GIS_DB db = new SqlGIS(resources().getJDBC(DB));
+        GIS_DB db = new SqlGIS( resources().getJDBC( DB ) );
 
         // If this is a Lat/Lng request, then we need to make a DB lookup
         // to obtain the Climate and Soil information and ignore whatever
         // may have been passed in
-        LOG.info("Rulse 2 model request resolveLocation=" + resolveLoc);
+        LOG.info( "Rulse 2 model request resolveLocation=" + resolveLoc );
 
-        GIS_DB.FileQryResult cli = db.findClimate(latitude, longitude);
-        if (cli == null) {
-            LOG.warning("no climate for lat=" + latitude + "\nfor long=" + longitude + "\n");
+        GIS_DB.FileQryResult cli = db.findClimate( latitude, longitude );
+        if ( cli == null ) {
+            LOG.warning( "no climate for lat=" + latitude + "\nfor long=" + longitude + "\n" );
             climatePtr = "";
         } else {
             climatePtr = cli.file_path + "\\" + cli.file_name;
@@ -518,22 +508,22 @@
 
         // to do
         // use only the first soil for now - later we need to use all of them
-        String cokey = soilPtr.replace(",", " ");
+        String cokey = soilPtr.replace( ",", " " );
         // strip first and last char
-        String t2 = cokey.substring(1, cokey.length() - 1);
+        String t2 = cokey.substring( 1, cokey.length() - 1 );
         String delims = "\"";
-        String tokens[] = t2.split(delims);
+        String tokens[] = t2.split( delims );
         LinkedList<String> lst = new LinkedList();
-        for (String token : tokens) {
-            if (token.trim().length() > 0) {
-                lst.add(token);
+        for ( String token : tokens ) {
+            if ( token.trim().length() > 0 ) {
+                lst.add( token );
             }
         }
-        cokey = lst.get(0);  // first soil only for now
-        GIS_DB.FileQryResult so = db.findSoilsByCokey(cokey, longitude);
-        if (so == null) {
-            LOG.warning("No soil for lat=" + latitude + "\nfor long=" + longitude + "\n");
-            metainfo().appendWarning(R2_NO_SOIL_FOR_PROVIDED_COKEY);
+        cokey = lst.get( 0 );  // first soil only for now
+        GIS_DB.FileQryResult so = db.findSoilsByCokey( cokey, longitude );
+        if ( so == null ) {
+            LOG.warning( "No soil for lat=" + latitude + "\nfor long=" + longitude + "\n" );
+            metainfo().appendWarning( R2_NO_SOIL_FOR_PROVIDED_COKEY );
             soilPtr = "";
         } else {
             soilPtr = so.file_path + "\\" + so.file_name;
@@ -541,35 +531,35 @@
 
         db.close();
 
-        FileOutputStream fos = new FileOutputStream(file);
+        FileOutputStream fos = new FileOutputStream( file );
         // to enable/disable romeconsole logging
-        if (!PRODUCTION_MODE) {
-            fos.write("Log ON\n".getBytes());
+        if ( !PRODUCTION_MODE ) {
+            fos.write( "Log ON\n".getBytes() );
         }
-        fos.write("JSON ON\n".getBytes());
-        fos.write("RomeInit\n".getBytes());
+        fos.write( "JSON ON\n".getBytes() );
+        fos.write( "RomeInit\n".getBytes() );
 
-        if (!PRODUCTION_MODE) {
-            String timingFilename = IO_TIMING_FILENAME + getFilenumber(file.getName()) + IO_TIMING_FILEEXT;
-            fos.write(("RomeSetTitle \"App.Files.IoLogging\" \"" + timingFilename + "\"\n").getBytes());
+        if ( !PRODUCTION_MODE ) {
+            String timingFilename = IO_TIMING_FILENAME + getFilenumber( file.getName() ) + IO_TIMING_FILEEXT;
+            fos.write( ( "RomeSetTitle \"App.Files.IoLogging\" \"" + timingFilename + "\"\n" ).getBytes() );
         }
 
-        String r2db = Config.getString("r2.db", "http://oms-db.engr.colostate.edu/r2");
-        if (altR2db == null) {
-            fos.write(("DatabaseOpen \"" + r2db + "\"\n").getBytes());
+        String r2db = Config.getString( "r2.db", "http://oms-db.engr.colostate.edu/r2" );
+        if ( altR2db == null ) {
+            fos.write( ( "DatabaseOpen \"" + r2db + "\"\n" ).getBytes() );
         } else {
-            String altr2db = r2db.substring(0, r2db.lastIndexOf("/")) + "/model-data/" + altR2db;
-            fos.write(("DatabaseOpen \"" + altr2db + "\"\n").getBytes());
+            String altr2db = r2db.substring( 0, r2db.lastIndexOf( "/" ) ) + "/model-data/" + altR2db;
+            fos.write( ( "DatabaseOpen \"" + altr2db + "\"\n" ).getBytes() );
         }
 
-        fos.write("FilesOpen profiles\\#ENTRY_MODEL PRIVATE\n".getBytes());
-        fos.write("Activate profiles\\model\n".getBytes());
+        fos.write( "FilesOpen profiles\\#ENTRY_MODEL PRIVATE\n".getBytes() );
+        fos.write( "Activate profiles\\model\n".getBytes() );
 
         // OLD VERSION, WHERE WE GOT CLIMATE DIRECTLY FROM NGINX AND DIDN'T MODIFY IT
         // fos.write(("RomeFileSetAttrValue CLIMATE_PTR \"" + climatePtr + "\"\n").getBytes());
         // NEW VERSION, Where the climate file must be modified to work
-        fos.write(("FilesOpen \"#XML:" + new File(getWorkspaceDir(), "cli_file" + 0 + ".xml" + "\"\n")).getBytes());
-        fos.write(("RomeFileSetAttrValue CLIMATE_PTR \"climates\\aaa\"\n").getBytes());
+        fos.write( ( "FilesOpen \"#XML:" + new File( getWorkspaceDir(), "cli_file" + 0 + ".xml" + "\"\n" ) ).getBytes() );
+        fos.write( ( "RomeFileSetAttrValue CLIMATE_PTR \"climates\\aaa\"\n" ).getBytes() );
 
         // New version, where we have to process the nginx file so R2 reads it
         // climate stub if needed
@@ -584,132 +574,132 @@
 //            //reference the lmod file(s)
 //            fos.write(("RomeFileSetAttrValue MAN_PTR \"" + new File(getWorkspace(), "lmod_file" + i + ".xml" + "\"\n")).getBytes());
 //        }
-        if ((managements != null) && (managements.length() >= 1)) {
-            fos.write(("FilesOpen \"#XML:" + new File(getWorkspaceDir(), "lmod_file" + 0 + ".xml" + "\"\n")).getBytes());
+        if ( ( managements != null ) && ( managements.length() >= 1 ) ) {
+            fos.write( ( "FilesOpen \"#XML:" + new File( getWorkspaceDir(), "lmod_file" + 0 + ".xml" + "\"\n" ) ).getBytes() );
             // fos.write(("Activate \"" + managementFormalName[0] + "\"\n").getBytes());
-            fos.write(("RomeFileSetAttrValue MAN_BASE_PTR \"" + managementFormalName[0] + "\"\n").getBytes());
+            fos.write( ( "RomeFileSetAttrValue MAN_BASE_PTR \"" + managementFormalName[0] + "\"\n" ).getBytes() );
             mgmt = managementFormalName[0];
         }
 
-        // to do 
+        // to do
         // commented out - using default for now
-        fos.write(("FilesOpen \"#XML:" + new File(getWorkspaceDir(), "soils_file0.xml" + "\"\n")).getBytes());
-        String soilHttpPtr = r2db + "/" + soilPtr.replace("\\", "/") + ".xml";
-        prepareSoilsFile(soilHttpPtr, new File(getWorkspaceDir(), "soils_file0.xml"), false, "0");
+        fos.write( ( "FilesOpen \"#XML:" + new File( getWorkspaceDir(), "soils_file0.xml" + "\"\n" ) ).getBytes() );
+        String soilHttpPtr = r2db + "/" + soilPtr.replace( "\\", "/" ) + ".xml";
+        prepareSoilsFile( soilHttpPtr, new File( getWorkspaceDir(), "soils_file0.xml" ), false, "0" );
         //r2run.prepareFileJ(soilHttpPtr, new File(getWorkspaceDir(), "soils_file0.xml"), "SOILS", "", "", false);
 
-        String cliHttpPtr = r2db + "/" + climatePtr.replace("\\", "/") + ".xml";
-        prepareFileJ(cliHttpPtr, new File(getWorkspaceDir(), "cli_file0.xml"), "CLIMATE", "climates", "", false);
+        String cliHttpPtr = r2db + "/" + climatePtr.replace( "\\", "/" ) + ".xml";
+        prepareFileJ( cliHttpPtr, new File( getWorkspaceDir(), "cli_file0.xml" ), "CLIMATE", "climates", "", false );
 
-        fos.write(("RomeFileSetAttrValue SOIL_PTR \"" + soilPtr + ".xml\"\n").getBytes());
-        fos.write(("RomeFileSetAttrValue SLOPE_HORIZ \"" + length + "\"\n").getBytes());
-        fos.write(("RomeFileSetAttrValue SLOPE_STEEP \"" + steepness + "\"\n").getBytes());
+        fos.write( ( "RomeFileSetAttrValue SOIL_PTR \"" + soilPtr + ".xml\"\n" ).getBytes() );
+        fos.write( ( "RomeFileSetAttrValue SLOPE_HORIZ \"" + length + "\"\n" ).getBytes() );
+        fos.write( ( "RomeFileSetAttrValue SLOPE_STEEP \"" + steepness + "\"\n" ).getBytes() );
 
-        if ((contourSystem != null) && (contourSystem.length() > 1)) {
-            fos.write(("RomeFileSetAttrValue CONTOUR_SYSTEM_PTR \"" + contourSystem + "\"\n").getBytes());
+        if ( ( contourSystem != null ) && ( contourSystem.length() > 1 ) ) {
+            fos.write( ( "RomeFileSetAttrValue CONTOUR_SYSTEM_PTR \"" + contourSystem + "\"\n" ).getBytes() );
         }
 
-        if ((stripBarrierSystem != null) && (stripBarrierSystem.length() > 1)) {
-            fos.write(("RomeFileSetAttrValue STRIP_BARRIER_SYSTEM_PTR \"" + stripBarrierSystem + "\"\n").getBytes());
+        if ( ( stripBarrierSystem != null ) && ( stripBarrierSystem.length() > 1 ) ) {
+            fos.write( ( "RomeFileSetAttrValue STRIP_BARRIER_SYSTEM_PTR \"" + stripBarrierSystem + "\"\n" ).getBytes() );
         }
 
-        if ((hydElemSystem != null) && (hydElemSystem.length() > 1)) {
-            fos.write(("RomeFileSetAttrValue HYD_ELEM_SYSTEM_PTR \"" + hydElemSystem + "\"\n").getBytes());
+        if ( ( hydElemSystem != null ) && ( hydElemSystem.length() > 1 ) ) {
+            fos.write( ( "RomeFileSetAttrValue HYD_ELEM_SYSTEM_PTR \"" + hydElemSystem + "\"\n" ).getBytes() );
         }
 
-        if (JSONUtils.checkKeyExistsB(param, KEY_SIMPLE_ROCK_COVER)) {
-            fos.write(("RomeFileSetAttrValue SIMPLE_ROCK_COVER \"" + simpleRockCoverPercent + "\"\n").getBytes());
+        if ( JSONUtils.checkKeyExistsB( param, KEY_SIMPLE_ROCK_COVER ) ) {
+            fos.write( ( "RomeFileSetAttrValue SIMPLE_ROCK_COVER \"" + simpleRockCoverPercent + "\"\n" ).getBytes() );
         }
 
-        fos.write("RomeEngineRun\n".getBytes());
-        for (String r : JSONUtils.getRequestedResults(metainfo)) {
-            fos.write(("RomeFileGetAttrValue " + r + "\n").getBytes());
+        fos.write( "RomeEngineRun\n".getBytes() );
+        for ( String r : JSONUtils.getRequestedResults( metainfo ) ) {
+            fos.write( ( "RomeFileGetAttrValue " + r + "\n" ).getBytes() );
         }
 
 //        fos.write(("RomeFileGetAttrValue CONTOUR_SYSTEM_PTR\n").getBytes());
 //        fos.write(("RomeFileGetAttrValue STRIP_BARRIER_SYSTEM_PTR\n").getBytes());
 //        fos.write(("RomeFileGetAttrValue HYD_ELEMENT_SYSTEM_PTR\n").getBytes());
         // optionally only include this line when reporting is requested to save service execution time
-        fos.write("READ \"rusle2_report.rsh\"\n".getBytes());
-        fos.write("RomeExit\n".getBytes());
-        fos.write("Exit\n".getBytes());
+        fos.write( "READ \"rusle2_report.rsh\"\n".getBytes() );
+        fos.write( "RomeExit\n".getBytes() );
+        fos.write( "Exit\n".getBytes() );
         fos.close();
 
-        // Unpack the report rsh file in the work space dir 
-        FileUtils.copyFileToDirectory(resources().getFile(REPORT_RSH), getWorkspaceDir());
+        // Unpack the report rsh file in the work space dir
+        FileUtils.copyFileToDirectory( resources().getFile( REPORT_RSH ), getWorkspaceDir() );
 
         climate = climatePtr;
         soil = soilPtr;
 //        mgmt = mgmtPtr;
 
-        LOG.info("R2 script: " + file.toString());
+        LOG.info( "R2 script: " + file.toString() );
     }
 
-
-    private String getFilenumber(String filename) {
-        return filename.substring(R2_TMP_FILENAME.length(), filename.length() - R2_TMP_FILEEXT.length());
+    private String getFilenumber ( String filename ) {
+        return filename.substring( R2_TMP_FILENAME.length(), filename.length() - R2_TMP_FILEEXT.length() );
     }
 
+    @Override
+    protected void doReport () throws Exception {
+        String sReportJSON = FileUtils.readFileToString( resources().getFile( REPORT_JSON ) );
+        JSONArray reportItemsFromTemplate = new JSONArray( sReportJSON );
 
-    @Override
-    protected void doReport() throws Exception {
-        String sReportJSON = FileUtils.readFileToString(resources().getFile(REPORT_JSON));
-        JSONArray reportItemsFromTemplate = new JSONArray(sReportJSON);
+        String sout = FileUtils.readFileToString( stdout );
 
-        String sout = FileUtils.readFileToString(stdout);
+        for ( int i = 0; i < reportItemsFromTemplate.length(); i++ ) {
 
-        for (int i = 0; i < reportItemsFromTemplate.length(); i++) {
-            
-            JSONObject obj = (JSONObject) reportItemsFromTemplate.get(i);
-            String itemName = obj.getString(REPORT_NAME);
-            String dimension = JSONUtils.getJSONString(obj, REPORT_DIM, null);
-            String type = JSONUtils.getJSONString(obj, REPORT_TYPE, "");
-            String units = JSONUtils.getJSONString(obj, REPORT_UNITS, null);
-            String desc = JSONUtils.getJSONString(obj, REPORT_DESC, null);
+            JSONObject obj = ( JSONObject ) reportItemsFromTemplate.get( i );
+            String itemName = obj.getString( REPORT_NAME );
+            String dimension = JSONUtils.getJSONString( obj, REPORT_DIM, null );
+            String type = JSONUtils.getJSONString( obj, REPORT_TYPE, "" );
+            String units = JSONUtils.getJSONString( obj, REPORT_UNITS, null );
+            String desc = JSONUtils.getJSONString( obj, REPORT_DESC, null );
             //LOG.info("Attempting to fetch results for:" + itemName);
-            String value = getResult(sout, "\"" + itemName + "\"");
+            String value = getResult( sout, "\"" + itemName + "\"" );
             //LOG.info("the value='" + value + "'");
-            if ((value != null) && (value.equals("null"))) {
-                report().put(itemName, value, desc, units);
+            if ( ( value != null ) && ( value.equals( "null" ) ) ) {
+                report().put( itemName, value, desc, units );
                 // if there is no value, then item should be removed from the array
             } else {
-                if ((dimension != null) && (dimension.length() > 0) && (value != null) && (!value.equals("null"))) {
+                if ( ( dimension != null ) && ( dimension.length() > 0 ) && ( value != null ) && ( !value.equals( "null" ) ) ) {
                     try {
-                    report().put(itemName, new JSONArray(value), desc, units);
-                      
-                    } catch (JSONException je) { 
-                        processReportElement(itemName,dimension,units,desc, type, value);
+                        report().put( itemName, new JSONArray( value ), desc, units );
+
+                    }
+                    catch ( JSONException je ) {
+                        processReportElement( itemName, dimension, units, desc, type, value );
                     }
                 } else {
-                    processReportElement(itemName,dimension,units,desc, type, value);
+                    processReportElement( itemName, dimension, units, desc, type, value );
                 }
             }
-            if(dimension != null)
-                report().putMetaInfo(itemName,REPORT_DIM,new JSONArray(dimension));
+            if ( dimension != null ) {
+                report().putMetaInfo( itemName, REPORT_DIM, new JSONArray( dimension ) );
+            }
         }
     }
 
     // This is a gross signiture but due to csip report changes this is the easiest way to change it without losing Wes's logic.
-    private void processReportElement(String itemName, String dim, String units, String desc, String type, String value) throws Exception {
-        if ((type.equals("TEXT")) || (type.equals("FILENAME")) || (type.equals("DATE"))) {
+    private void processReportElement ( String itemName, String dim, String units, String desc, String type, String value ) throws Exception {
+        if ( ( type.equals( "TEXT" ) ) || ( type.equals( "FILENAME" ) ) || ( type.equals( "DATE" ) ) ) {
             // because the RomeShell returns escaped strings, and the JSONObject in Java re-escapes them
-            // we have to remove one level of "escaping" !!! 
-            String newString = StringEscapeUtils.unescapeJava(value);
-            report().put(itemName, Services.removeFirstLastChar(newString), desc, units);
+            // we have to remove one level of "escaping" !!!
+            String newString = StringEscapeUtils.unescapeJava( value );
+            report().put( itemName, removeFirstLastChar( newString ), desc, units );
         }
-        if (type.equals("INTEGER") && (value != null) && (!value.equals("null")) && (!value.equals("\"\""))) {
-            report().put(itemName, new Double(value).intValue(), desc, units);
+        if ( type.equals( "INTEGER" ) && ( value != null ) && ( !value.equals( "null" ) ) && ( !value.equals( "\"\"" ) ) ) {
+            report().put( itemName, new Double( value ).intValue(), desc, units );
         }
-        if (type.equals("REAL") && (value != null)) {
-            if ((!value.equals("null")) && (!value.equals("\"\""))) {
-                report().put(itemName, Double.parseDouble(value), desc, units);
+        if ( type.equals( "REAL" ) && ( value != null ) ) {
+            if ( ( !value.equals( "null" ) ) && ( !value.equals( "\"\"" ) ) ) {
+                report().put( itemName, Double.parseDouble( value ), desc, units );
             }
-            if (value.equals("\"\"")) {
-                report().put(itemName, new Double(0), desc, units);
+            if ( value.equals( "\"\"" ) ) {
+                report().put( itemName, new Double( 0 ), desc, units );
             }
         }
-        if (type.equals("")) {
-            report().put(itemName, value, desc, units);
+        if ( type.equals( "" ) ) {
+            report().put( itemName, value, desc, units );
         }
     }
 }

src/java/m/rusle2/V2_1.java

@@ -13,32 +13,19 @@
 
 import csip.Client;
 import csip.Config;
+import csip.ModelDataService;
 import csip.ServiceException;
-import java.io.File;
-import java.util.*;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.codehaus.jettison.json.JSONArray;
-import org.codehaus.jettison.json.JSONObject;
-import org.codehaus.jettison.json.JSONException;
-import org.w3c.dom.Document;
-import org.w3c.dom.NodeList;
-import csip.ModelDataService;
-import static csip.ModelDataService.KEY_REQUEST_RESULTS;
-import static csip.ModelDataService.REPORT_DIM;
-import static csip.ModelDataService.REPORT_NAME;
-import static csip.ModelDataService.REPORT_TYPE;
+import static csip.Utils.removeFirstLastChar;
 import csip.annotations.*;
 import static csip.annotations.ResourceType.ARCHIVE;
 import static csip.annotations.ResourceType.FILE;
 import static csip.annotations.ResourceType.REFERENCE;
 import static csip.annotations.State.RELEASED;
-import static util.Constants.*;
-
 import csip.utils.JSONUtils;
-import csip.utils.Services;
+import java.io.File;
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.util.*;
 import java.util.logging.Level;
 import javax.ws.rs.Path;
 import javax.xml.parsers.DocumentBuilder;
@@ -46,843 +33,844 @@
 import javax.xml.parsers.ParserConfigurationException;
 import lmod2rusle2.Rusle2Translator;
 import static m.rusle2.V2_1.*;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
+import static util.Constants.*;
 
 /**
  * REST Web Service. Front end callable.
  *
  * @author wlloyd, od
  */
-@Name("Rusle2")
-@Description("IET / pyrome version of R2; RomeDLL 2.5.2.11; references NRCS Soil Data Mart")
-@VersionInfo("2.1")
-@State(RELEASED)
-@Path("m/rusle2/2.1")
-@Polling(first = 1000, next = 1000)
-@Resource(type = FILE, file = "/bin/win-x86/2.5.2.11/RomeDLL.dll", id = ROMEDLL)
-@Resource(type = FILE, file = "/bin/win-x86/2.5.2.11/pyrome.py", id = PYROMESRC)
-@Resource(type = FILE, file = "/bin/win-x86/2.5.2.11/_pyrome.pyd", id = PYROME)
-@Resource(type = ARCHIVE, file = "/bin/win-x86/Python34.zip")
-@Resource(type = REFERENCE, file = "${csip.dir}/bin/win-x86/Python34/python.exe", wine = true, id = PYTHON)
-@Resource(type = FILE, file = "/bin/win-x86/rusle2_report.py", id = REPORT_PY_FILENAME)
-@Resource(type = FILE, file = "/bin/win-x86/Rusle2_Report.json", id = REPORT_JSON_TEMPLATE_FILENAME)
+@Name( "Rusle2" )
+@Description( "IET / pyrome version of R2; RomeDLL 2.5.2.11; references NRCS Soil Data Mart" )
+@VersionInfo( "2.1" )
+@State( RELEASED )
+@Path( "m/rusle2/2.1" )
+@Polling( first = 1000, next = 1000 )
+@Resource( type = FILE, file = "/bin/win-x86/2.5.2.11/RomeDLL.dll", id = ROMEDLL )
+@Resource( type = FILE, file = "/bin/win-x86/2.5.2.11/pyrome.py", id = PYROMESRC )
+@Resource( type = FILE, file = "/bin/win-x86/2.5.2.11/_pyrome.pyd", id = PYROME )
+@Resource( type = ARCHIVE, file = "/bin/win-x86/Python34.zip" )
+@Resource( type = REFERENCE, file = "${csip.dir}/bin/win-x86/Python34/python.exe", wine = true, id = PYTHON )
+@Resource( type = FILE, file = "/bin/win-x86/rusle2_report.py", id = REPORT_PY_FILENAME )
+@Resource( type = FILE, file = "/bin/win-x86/Rusle2_Report.json", id = REPORT_JSON_TEMPLATE_FILENAME )
 public class V2_1 extends ModelDataService {
 
-  static final String R2_TMP_FILENAME = "rusle2csip.py";
-  static final String ROMEDLL = "RomeDLL.dll";
-  static final String PYROMESRC = "pyrome.py";
-  static final String PYROME = "_pyrome.pyd";
-  static final String PYTHON = "python.exe";
-  static final String REPORT_JSON_TEMPLATE_FILENAME = "Rusle2_Report.json";
-  static final String REPORT_PY_FILENAME = "rusle2_report.py";
-  static final String KEY_COKEY = "cokey";
+    static final String R2_TMP_FILENAME = "rusle2csip.py";
+    static final String ROMEDLL = "RomeDLL.dll";
+    static final String PYROMESRC = "pyrome.py";
+    static final String PYROME = "_pyrome.pyd";
+    static final String PYTHON = "python.exe";
+    static final String REPORT_JSON_TEMPLATE_FILENAME = "Rusle2_Report.json";
+    static final String REPORT_PY_FILENAME = "rusle2_report.py";
+    static final String KEY_COKEY = "cokey";
 
-  /*
+    /*
    * The R2 Run
-   */
-  R2Run r2run = new R2Run();
-  static final List<String> POT_RESULTS = Collections.unmodifiableList(Arrays.asList(
-      RES_SLOPE_DELIVERY,
-      RES_SLOPE_T_VALUE,
-      RES_SLOPE_DEGRAD,
-      RES_SLOPE_EQUIV_DIESEL_USE_PER_AREA,
-      RES_SOIL_COND_INDEX_STIR_VAL,
-      RES_SOIL_COND_INDEX_RESULT,
-      RES_SEG_SIM_DAY_LIVE_BIOMASS,
-      RES_SEG_SIM_DAY_COVER_MASS_SUM,
-      RES_SEG_SIM_DAY_STAND_MASS_SUM,
-      RES_SEG_SIM_DAY_CANOPY_COVER,
-      RES_SEG_SIM_DAY_PERENN_VEG_LIVE_HEIGHT,
-      RES_SLOPE_SIM_DAY_DEGRAD,
-      RES_SURF_RES_OUTPUTS_SURF_COV_AT_OP,
-      RES_SOIL_COND_INDEX_OM_SUBFACTOR,
-      RES_SOIL_COND_INDEX_FO_SUBFACTOR,
-      RES_SOIL_COND_INDEX_ER_SUBFACTOR));
-  //
-  String climate;
-  String soil;
-  String mgmt;
-  List<String> operations;
-  List<String> vegetations;
-  List<String> residues;
+     */
+    R2Run r2run = new R2Run();
+    static final List<String> POT_RESULTS = Collections.unmodifiableList( Arrays.asList(
+            RES_SLOPE_DELIVERY,
+            RES_SLOPE_T_VALUE,
+            RES_SLOPE_DEGRAD,
+            RES_SLOPE_EQUIV_DIESEL_USE_PER_AREA,
+            RES_SOIL_COND_INDEX_STIR_VAL,
+            RES_SOIL_COND_INDEX_RESULT,
+            RES_SEG_SIM_DAY_LIVE_BIOMASS,
+            RES_SEG_SIM_DAY_COVER_MASS_SUM,
+            RES_SEG_SIM_DAY_STAND_MASS_SUM,
+            RES_SEG_SIM_DAY_CANOPY_COVER,
+            RES_SEG_SIM_DAY_PERENN_VEG_LIVE_HEIGHT,
+            RES_SLOPE_SIM_DAY_DEGRAD,
+            RES_SURF_RES_OUTPUTS_SURF_COV_AT_OP,
+            RES_SOIL_COND_INDEX_OM_SUBFACTOR,
+            RES_SOIL_COND_INDEX_FO_SUBFACTOR,
+            RES_SOIL_COND_INDEX_ER_SUBFACTOR ) );
+    //
+    String climate;
+    String soil;
+    String mgmt;
+    List<String> operations;
+    List<String> vegetations;
+    List<String> residues;
 
-  String r2db = Config.getString("r2.db", "http://oms-db.engr.colostate.edu/r2");
+    String r2db = Config.getString( "r2.db", "http://oms-db.engr.colostate.edu/r2" );
 
+    @Override
+    protected void preProcess () throws Exception {
+        // check for requested output.
+        r2run.setLogger( LOG );
+        try {
+            if ( LOG.isLoggable( Level.INFO ) ) {
+                LOG.info( "\n\nMETAINFO:" );
+                LOG.info( "\n" + getMetainfo().toString() );
+                LOG.info( "\n\n\n" );
+            }
+            JSONUtils.checkValidResultRequest( getMetainfo(), POT_RESULTS );
+        }
+        catch ( ServiceException se ) {
+            LOG.severe( "\n\n\nERROR!!!\n\n\n" + se.toString() );
+            LOG.warning( "No Rusle2 return parameters requested! Will use defaults: SLOPE_DELIVERY, SLOPE_T_VALUE, SLOPE_DEGRAD" );
+            List<String> params = new LinkedList<>();
+            params.add( RES_SLOPE_DELIVERY );
+            params.add( RES_SLOPE_T_VALUE );
+            params.add( RES_SLOPE_DEGRAD );
 
-  @Override
-  protected void preProcess() throws Exception {
-    // check for requested output.
-    r2run.setLogger(LOG);
-    try {
-      if (LOG.isLoggable(Level.INFO)) {
-        LOG.info("\n\nMETAINFO:");
-        LOG.info("\n" + getMetainfo().toString());
-        LOG.info("\n\n\n");
-      }
-      JSONUtils.checkValidResultRequest(getMetainfo(), POT_RESULTS);
-    } catch (ServiceException se) {
-      LOG.severe("\n\n\nERROR!!!\n\n\n" + se.toString());
-      LOG.warning("No Rusle2 return parameters requested! Will use defaults: SLOPE_DELIVERY, SLOPE_T_VALUE, SLOPE_DEGRAD");
-      List<String> params = new LinkedList<>();
-      params.add(RES_SLOPE_DELIVERY);
-      params.add(RES_SLOPE_T_VALUE);
-      params.add(RES_SLOPE_DEGRAD);
+            // check if these are being set
+            if ( parameter().has( KEY_CONTOUR_SYSTEM_PTR ) ) {
+                params.add( "CONTOUR_SYSTEM_PTR" );
+            }
+            if ( parameter().has( KEY_STRIP_BARRIER_SYSTEM_PTR ) ) {
+                params.add( "STRIP_BARRIER_SYSTEM_PTR" );
+            }
+            if ( parameter().has( KEY_HYD_ELEM_SYSTEM_PTR ) ) {
+                params.add( "HYD_ELEM_SYSTEM_PTR" );
+            }
+            getMetainfo().put( KEY_REQUEST_RESULTS, params );
+        }
 
-      // check if these are being set
-      if (parameter().has(KEY_CONTOUR_SYSTEM_PTR)) {
-        params.add("CONTOUR_SYSTEM_PTR");
-      }
-      if (parameter().has(KEY_STRIP_BARRIER_SYSTEM_PTR)) {
-        params.add("STRIP_BARRIER_SYSTEM_PTR");
-      }
-      if (parameter().has(KEY_HYD_ELEM_SYSTEM_PTR)) {
-        params.add("HYD_ELEM_SYSTEM_PTR");
-      }
-      getMetainfo().put(KEY_REQUEST_RESULTS, params);
+        // check if sufficient input is there.
+        parameter().require( KEY_SOILS, KEY_LENGTH, KEY_STEEPNESS, KEY_MGMTS );
+
+        if ( !r2run.isUrlReachable( "" ) ) {
+            throw new ServiceException( "R2 file server unreachable at: " + r2db );
+        }
+
+        File r2script = getWorkspaceFile( R2_TMP_FILENAME );
+        createInputFile( r2script, getMetainfo(), getParamMap() );
     }
 
-    // check if sufficient input is there.
-    parameter().require(KEY_SOILS, KEY_LENGTH, KEY_STEEPNESS, KEY_MGMTS);
-
-    if (!r2run.isUrlReachable("")) {
-      throw new ServiceException("R2 file server unreachable at: " + r2db);
+    @Override
+    protected void doProcess () throws Exception {
+        r2run.executePyrome( getWorkspaceFile( R2_TMP_FILENAME ), resources().getExe( PYTHON ) );
     }
 
-    File r2script = getWorkspaceFile(R2_TMP_FILENAME);
-    createInputFile(r2script, getMetainfo(), getParamMap());
-  }
+    @Override
+    protected void postProcess () throws Exception {
+        int errors = 0;
+        for ( int i = 0; i < operations.size(); i++ ) {
+            String op = operations.get( i );
+            if ( r2run.isFileUrlReachable( op ) ) {
+                results().put( "OPERATION_" + ( i + 1 ), op, "operation is valid" );
+            } else {
+                results().put( "OPERATION_INVALID_" + ( i + 1 ), op, "OPERATION IS MISSING!" );
+                errors++;
+            }
+        }
+        for ( int i = 0; i < vegetations.size(); i++ ) {
+            String vege = vegetations.get( i );
+            if ( r2run.isFileUrlReachable( vege ) ) {
+                results().put( "VEGETATION_" + ( i + 1 ), vege, "vegetation is valid" );
+            } else {
+                results().put( "VEGETATION_INVALID_" + ( i + 1 ), vege, "VEGETATION IS MISSING" );
+                errors++;
+            }
+        }
+        for ( int i = 0; i < residues.size(); i++ ) {
+            String res = residues.get( i );
+            if ( r2run.isFileUrlReachable( res ) ) {
+                results().put( "RESIDUE_" + ( i + 1 ), res, "residue is valid" );
+            } else {
+                results().put( "RESIDUE_INVALID_" + ( i + 1 ), res, "RESIDUE IS MISSING" );
+                errors++;
+            }
+        }
 
+        for ( String r : JSONUtils.getRequestedResults( getMetainfo() ) ) {
+            if ( ( errors > 0 ) && ( r.equals( RES_SLOPE_DEGRAD ) ) ) {
+                results().put( r, r2run.getResultPyrome( r ), R2_MISSING_XML_FILES_WARNING_MSG );
+            } else {
+                results().put( r, r2run.getResultPyrome( r ) );
+            }
+        }
 
-  @Override
-  protected void doProcess() throws Exception {
-    r2run.executePyrome(getWorkspaceFile(R2_TMP_FILENAME), resources().getExe(PYTHON));
-  }
-
-
-  @Override
-  protected void postProcess() throws Exception {
-    int errors = 0;
-    for (int i = 0; i < operations.size(); i++) {
-      String op = operations.get(i);
-      if (r2run.isFileUrlReachable(op)) {
-        results().put("OPERATION_" + (i + 1), op, "operation is valid");
-      } else {
-        results().put("OPERATION_INVALID_" + (i + 1), op, "OPERATION IS MISSING!");
-        errors++;
-      }
-    }
-    for (int i = 0; i < vegetations.size(); i++) {
-      String vege = vegetations.get(i);
-      if (r2run.isFileUrlReachable(vege)) {
-        results().put("VEGETATION_" + (i + 1), vege, "vegetation is valid");
-      } else {
-        results().put("VEGETATION_INVALID_" + (i + 1), vege, "VEGETATION IS MISSING");
-        errors++;
-      }
-    }
-    for (int i = 0; i < residues.size(); i++) {
-      String res = residues.get(i);
-      if (r2run.isFileUrlReachable(res)) {
-        results().put("RESIDUE_" + (i + 1), res, "residue is valid");
-      } else {
-        results().put("RESIDUE_INVALID_" + (i + 1), res, "RESIDUE IS MISSING");
-        errors++;
-      }
+        // Get erosion for segments
+        if ( parameter().has( KEY_TOPO_LENGTH ) ) {
+            JSONArray aTopoLength = JSONUtils.getJSONArrayParam( getParamMap(), KEY_TOPO_LENGTH );
+            if ( aTopoLength.length() > 0 ) {
+                JSONArray aSoilLoss = new JSONArray( r2run.getResultPyromeArray( "SEG_SOIL_LOSS", false, false, true ) );
+                results().put( "SEG_SOIL_LOSS", aSoilLoss );
+                results().put( KEY_CLIMATES, climate );
+                if ( LOG.isLoggable( Level.INFO ) ) {
+                    LOG.info( "\n\n\n\n\n\nSEG SOIL OUTPUT=" + r2run.getResultPyromeArray( "SEG_SOIL", true, true, true ) + "\n\n\n\n" );
+                    LOG.info( "\n\n\n\n\n\nSEG SOIL OUTPUT=" + r2run.getResultPyromeArray( "SEG_MAN", true, true, true ) + "\n\n\n\n" );
+                }
+                results().put( KEY_SOILS, new JSONArray( r2run.getResultPyromeArray( "SEG_SOIL", true, true, true ) ) );
+                results().put( KEY_MANAGEMENTS, new JSONArray( r2run.getResultPyromeArray( "SEG_MAN", true, true, true ) ) );
+                if ( parameter().has( KEY_DIVERSIONS ) ) {
+                    results().put( KEY_DIVERSIONS, r2run.getResultPyromeArray( "HYD_ELEM_SYS", true, true, true ) );
+                }
+                if ( parameter().has( KEY_STRIP_BARRIER_SYSTEMS ) ) {
+                    results().put( KEY_STRIP_BARRIER_SYSTEMS, r2run.getResultPyromeArray( "STRIP_BARRIER_SYS", true, true, true ) );
+                }
+            }
+        } else {
+            results().put( KEY_CLIMATES, climate );
+            results().put( KEY_SOILS, new JSONArray( r2run.getResultPyromeArray( "SEG_SOIL", true, true, true ) ) );
+            results().put( KEY_MANAGEMENTS, new JSONArray( r2run.getResultPyromeArray( "SEG_MAN", true, true, true ) ) );
+        }
     }
 
-    for (String r : JSONUtils.getRequestedResults(getMetainfo())) {
-      if ((errors > 0) && (r.equals(RES_SLOPE_DEGRAD))) {
-        results().put(r, r2run.getResultPyrome(r), R2_MISSING_XML_FILES_WARNING_MSG);
-      } else {
-        results().put(r, r2run.getResultPyrome(r));
-      }
+    private void createInputFile ( File file, JSONObject metainfo, Map<String, JSONObject> param )
+            throws Exception {
+
+        double steepness = parameter().getDouble( KEY_STEEPNESS, 0.0 );
+        double length = parameter().getDouble( KEY_LENGTH, 0.0 );
+        boolean resolveLoc = parameter().getBoolean( KEY_RESOLVE_LOCATION, false );
+        double latitude = parameter().getDouble( KEY_LATITUDE, 0.0 );
+        double longitude = parameter().getDouble( KEY_LONGITUDE, 0.0 );
+        double simpleRockCoverPercent = 0.0;
+
+        LOG.info( "Rock cover read by service is=" + simpleRockCoverPercent );
+
+        JSONArray aRockCover = JSONUtils.getJSONArrayParam( param, KEY_SIMPLE_ROCK_COVER );
+        for ( int i = 0; i < aRockCover.length(); i++ ) {
+            LOG.info( "Rock cover [" + i + "]=" + aRockCover.getDouble( i ) );
+            // this is temporary, since R2 will be using slope segments soon
+            if ( i == 0 ) {
+                simpleRockCoverPercent = aRockCover.getDouble( i );
+            }
+        }
+
+        JSONArray aSoils = JSONUtils.getJSONArrayParam( param, KEY_SOILS );
+        if ( LOG.isLoggable( Level.INFO ) ) {
+            for ( int i = 0; i < aSoils.length(); i++ ) {
+                LOG.info( "soil [" + i + "]=" + aSoils.getInt( i ) );
+            }
+        }
+
+        // scalar variables for non-segmented runs
+        String contourSystem = "";
+        String stripBarrierSystem = "";
+        String hydElemSystem = "";
+
+        // Get the Contour System if not default
+        if ( parameter().has( KEY_CONTOUR_SYSTEM_PTR ) ) {
+            contourSystem = parameter().getString( KEY_CONTOUR_SYSTEM_PTR, "" );
+        }
+
+        // Get the Strip Barrier System
+        if ( parameter().has( KEY_STRIP_BARRIER_SYSTEM_PTR ) ) {
+            stripBarrierSystem = parameter().getString( KEY_STRIP_BARRIER_SYSTEM_PTR, "" );
+        }
+
+        // Get the Hydraylic Element System Pointer
+        if ( parameter().has( KEY_HYD_ELEM_SYSTEM_PTR ) ) {
+            hydElemSystem = parameter().getString( KEY_HYD_ELEM_SYSTEM_PTR, "" );
+        }
+
+        JSONArray aTopoLength = new JSONArray();
+        JSONArray aTopoSteepness = new JSONArray();
+        JSONArray aSoilIdx = new JSONArray();
+        JSONArray aManIdx = new JSONArray();
+        JSONArray aManLength = new JSONArray();
+
+        if ( parameter().has( KEY_TOPO_LENGTH ) ) {
+            aTopoLength = JSONUtils.getJSONArrayParam( param, KEY_TOPO_LENGTH );
+            if ( LOG.isLoggable( Level.INFO ) ) {
+                for ( int i = 0; i < aTopoLength.length(); i++ ) {
+                    LOG.info( "Topo Length [" + i + "]=" + aTopoLength.getDouble( i ) );
+                }
+            }
+        }
+
+        if ( parameter().has( KEY_TOPO_STEEPNESS ) ) {
+            aTopoSteepness = JSONUtils.getJSONArrayParam( param, KEY_TOPO_STEEPNESS );
+            if ( LOG.isLoggable( Level.INFO ) ) {
+                for ( int i = 0; i < aTopoSteepness.length(); i++ ) {
+                    LOG.info( "Topo Steepness [" + i + "]=" + aTopoSteepness.getDouble( i ) );
+                }
+            }
+        }
+
+        if ( parameter().has( KEY_SOIL_INDEX ) ) {
+            aSoilIdx = JSONUtils.getJSONArrayParam( param, KEY_SOIL_INDEX );
+            if ( LOG.isLoggable( Level.INFO ) ) {
+                for ( int i = 0; i < aSoilIdx.length(); i++ ) {
+                    LOG.info( "Soil Index [" + i + "]=" + aSoilIdx.getInt( i ) );
+                }
+            }
+        }
+
+        if ( parameter().has( KEY_MAN_INDEX ) ) {
+            aManIdx = JSONUtils.getJSONArrayParam( param, KEY_MAN_INDEX );
+            if ( LOG.isLoggable( Level.INFO ) ) {
+                for ( int i = 0; i < aManIdx.length(); i++ ) {
+                    LOG.info( "Man Index [" + i + "]=" + aManIdx.getInt( i ) );
+                }
+            }
+        }
+
+        if ( parameter().has( KEY_MAN_LENGTH ) ) {
+            aManLength = JSONUtils.getJSONArrayParam( param, KEY_MAN_LENGTH );
+            for ( int i = 0; i < aManLength.length(); i++ ) {
+                LOG.info( "Man Length [" + i + "]=" + aManLength.getInt( i ) );
+            }
+        }
+
+        if ( parameter().has( KEY_TOPO_LENGTH ) ) {
+            if ( aTopoLength.length() != aTopoSteepness.length() ) {
+                throw new ServiceException( "RUSLE2 SEGMENT RUN ERROR! SEGMENT ARRAYS FOR TOPO LENGTH AND TOPO STEEPNESS MUST BE OF EQUAL SIZE!" );
+            }
+        }
+
+        if ( parameter().has( KEY_MAN_INDEX ) ) {
+            if ( aManLength.length() != aManIdx.length() ) {
+                throw new ServiceException( "RUSLE2 SEGMENT RUN ERROR! SEGMENT ARRAYS FOR MGMT LENGTH AND MGMT INDEX MUST BE OF EQUAL SIZE!" );
+            }
+        }
+
+        // management conversion
+        // Make file line separator unix compatible. ???? not sure if needed.
+        System.setProperty( "line.separator", "\n" );
+
+        JSONArray managements = JSONUtils.getJSONArrayParam( param, KEY_MGMTS );
+
+        LOG.info( "managements array=" + managements.toString() );
+        String[] managementFormalName = new String[managements.length()];
+
+        for ( int i = 0; i < managements.length(); i++ ) {
+            LOG.info( "management #" + i );
+
+            JSONObject lmod = ( JSONObject ) managements.get( i );
+            if ( LOG.isLoggable( Level.INFO ) ) {
+                LOG.info( lmod.toString() );
+            }
+
+            Rusle2Translator translator = new Rusle2Translator();
+            translator.readJsonString( lmod.toString() );
+
+            boolean success = translator.Translate();
+            LOG.info( "translation successful =" + success );
+
+            Document r2_xml = translator.getDocument();
+
+            if ( LOG.isLoggable( Level.INFO ) ) {
+                LOG.info( "R2 XML FILE from translator:\n\n" + translator.getRusle2Xml() );
+            }
+
+            if ( ( r2_xml != null ) && ( r2_xml.getElementsByTagName( "Filename" ) != null ) ) {
+                NodeList nl = r2_xml.getElementsByTagName( "Filename" );
+                for ( int ii = 0; ii < nl.getLength(); ii++ ) {
+                    if ( LOG.isLoggable( Level.INFO ) ) {
+                        LOG.info( "filename node=" + nl.item( ii ).getTextContent() );
+                    }
+                    managementFormalName[i] = nl.item( ii ).getTextContent();
+                }
+            }
+
+            translator.writeRusle2Xml( getWorkspaceDir().toString(), "lmod_file" + i + ".xml" );
+            operations = translator.getOperationFiles();
+            vegetations = translator.getVegetationFiles();
+            residues = translator.getResidueFiles();
+
+            if ( LOG.isLoggable( Level.INFO ) ) {
+                operations.forEach( (operation) -> {
+                    LOG.info( "operation=" + operation );
+                } );
+                vegetations.forEach( (vege) -> {
+                    LOG.info( "vegetation=" + vege );
+                } );
+                residues.forEach( (residue) -> {
+                    LOG.info( "residue=" + residue );
+                } );
+            }
+        }
+
+        // If this is a Lat/Lng request, then we need to make a DB lookup
+        // to obtain the Climate and Soil information and ignore whatever
+        // may have been passed in
+        LOG.info( "Rulse 2 model request resolveLocation=" + resolveLoc );
+
+        // Sub-service calls.
+        String climatePtr = getClimateFilePath( latitude, longitude );
+        String[] soilPtr = getSoilFiles( aSoils );
+
+        PrintWriter pw = new PrintWriter( file );
+        pw.append( "import sys\n"
+                // could rewrite this line based on the OS, but python is interpretting it ok on windows
+                + "sys.path.append('" + resources().getFile( PYROMESRC ).getParent().replace( '\\', '/' ) + "')\n"
+                + "from pyrome import *\n"
+                + "\n"
+                + "def linearTest(save = False, openFlags = RX_FILESOPEN_TEMP):\n"
+                + "    romeDLL = RomeInit('')\n"
+                + "    files = RomeGetFiles(romeDLL)\n"
+                + "    engine = RomeGetEngine(romeDLL)\n"
+                + "    RomeEngineSetAutorun(engine,RX_FALSE)\n"
+                + "    #Inputs\n" );
+
+        if ( aTopoLength.length() > 1 ) {
+            String text = "    slopes=[";
+            for ( int i = 0; i < aTopoSteepness.length(); i++ ) {
+                text += "'" + aTopoSteepness.getInt( i ) + "'";
+                text += ( i == aTopoSteepness.length() - 1 ) ? "]\n" : ",";
+            }
+            pw.append( text );
+            text = "    lengths=[";
+            for ( int i = 0; i < aTopoLength.length(); i++ ) {
+                text += "'" + aTopoLength.getInt( i ) + "'";
+                text += ( i == aTopoLength.length() - 1 ) ? "]\n" : ",";
+            }
+            pw.append( text );
+            if ( ( aSoilIdx != null ) && ( aSoilIdx.length() > 0 ) ) {
+                text = "    soilIndex=[";
+                for ( int i = 0; i < aSoilIdx.length(); i++ ) {
+                    text += aSoilIdx.getInt( i ) + "";
+                    text += ( i == aSoilIdx.length() - 1 ) ? "]\n" : ",";
+                }
+                pw.append( text );
+            }
+            text = "    manIndex=[";
+            for ( int i = 0; i < aManIdx.length(); i++ ) {
+                text += aManIdx.getInt( i ) + "";
+                text += ( i == aManIdx.length() - 1 ) ? "]\n" : ",";
+            }
+            pw.append( text );
+        } else {
+            pw.append( "    slopes=['" + steepness + "']\n"
+                    + "    lengths=['" + length + "']\n"
+                    + "    soilIndex=[0]\n"
+                    + "    manIndex=[0]\n" );
+        }
+
+        pw.append( "    results = list()\n"
+                + "    #Run a simple profile\n"
+                + "    profile = RomeFilesOpen(files,'profiles\\\\csippyrome',openFlags)\n" );
+
+        // Open all of the mgmt files...
+        for ( int i = 0; i < managements.length(); i++ ) {
+            pw.append( "    mgmt = RomeFilesOpen(files, '#XML:lmod_file" + i + ".xml',0)\n" );
+        }
+        pw.append( "    cli = RomeFilesOpen(files, '#XML:cli_file0.xml',0)\n" );
+        for ( int i = 0; i < aSoils.length(); i++ ) {
+            pw.append( "    soil" + i + " = RomeFilesOpen(files, '#XML:soils_file" + i + ".xml',0)\n" );
+        }
+        pw.append( "    # SET SLOPE\n"
+                + "    RomeFileSetAttrValue(profile, 'SLOPE_HORIZ', '" + length + "', 0)\n"
+                + "    RomeFileSetAttrValue(profile, 'SLOPE_STEEP', '" + steepness + "', 0)\n"
+                + "    # SET CLIMATE_PTR\n"
+                + "    RomeFileSetAttrValue(profile, 'CLIMATE_PTR','climates\\\\aaa',0)\n"
+                + "    print('CLIMATE_PTR=%s' % RomeFileGetAttrValue(profile, 'CLIMATE_PTR', 0))\n" );
+
+        pw.append( "    # SET TOPO LAYER\n" );
+        if ( aTopoLength.length() > 0 ) {
+            pw.append( "    RomeFileSetAttrSize(profile, 'TOPO_LAYER', " + aTopoLength.length() + ")\n" );
+            for ( int i = 0; i < aTopoLength.length(); i++ ) {
+                pw.append( "    RomeFileSetAttrValue(profile, 'TOPO_HORIZ', '" + aTopoLength.getString( i ) + "', " + i + ")\n"
+                        + "    RomeFileSetAttrValue(profile, 'TOPO_STEEP', '" + aTopoSteepness.getString( i ) + "', " + i + ")\n" );
+            }
+        }
+
+        // Presently we do not support multiple soils
+        pw.append( "    # SET SOIL LAYER\n" );
+        if ( aSoils.length() > 0 ) {
+            pw.append( "    RomeFileSetAttrSize(profile, 'SOIL_LAYER', " + aSoils.length() + ")\n"
+                    + "    RomeFileSetAttrValue(profile, 'SOIL_HORIZ', '" + length + "', 0)\n"
+                    + "    RomeFileSetAttrValue(profile, 'SOIL_PTR', '" + StringEscapeUtils.escapeJava( soilPtr[0] ) + "', " + 0 + ")\n" );
+        }
+
+        // Must be after set soils or the soils code resets it...sometimes
+        if ( parameter().has( KEY_SIMPLE_ROCK_COVER ) ) {
+            pw.append( "    RomeFileSetAttrValue(profile, 'SIMPLE_ROCK_COVER', '" + simpleRockCoverPercent + "' ,0)\n" );
+        }
+        pw.append( "    # SET MAN LAYER\n" );
+        if ( aManIdx.length() > 0 ) {
+            pw.append( "    RomeFileSetAttrSize(profile, 'MAN_LAYER', " + aManIdx.length() + ")\n" );
+            for ( int i = 0; i < aManIdx.length(); i++ ) {
+                pw.append( "    RomeFileSetAttrValue(profile, 'MAN_HORIZ', '" + aManLength.getString( i ) + "', " + i + ")\n" );
+                if ( LOG.isLoggable( Level.INFO ) ) {
+                    LOG.info( "escapeJava test=" + StringEscapeUtils.escapeJava( "simple / test" ) );
+                    LOG.info( "escapeJava test=" + StringEscapeUtils.escapeJavaScript( "simple / test" ) );
+                    LOG.info( "\n\n\n********************--- escapeJava man name=" + StringEscapeUtils.escapeJava( managementFormalName[aManIdx.getInt( i )] ) );
+                    LOG.info( "********************--- escapeJavaScript man name=" + StringEscapeUtils.escapeJavaScript( managementFormalName[aManIdx.getInt( i )] ) );
+                    LOG.info( "********************--- escapeHtml man name=" + StringEscapeUtils.escapeHtml( managementFormalName[aManIdx.getInt( i )] ) );
+                    LOG.info( "********************--- escapeSql man name=" + StringEscapeUtils.escapeSql( managementFormalName[aManIdx.getInt( i )] ) );
+                    LOG.info( "********************--- escapeXml man name=" + StringEscapeUtils.escapeXml( managementFormalName[aManIdx.getInt( i )] ) );
+                    LOG.info( "********************--- raw Value is=" + managementFormalName[aManIdx.getInt( i )] );
+                }
+                pw.append( "    RomeFileSetAttrValue(profile, 'MAN_PTR', '" + R2Run.escapeJavaNoFwdSlash( managementFormalName[aManIdx.getInt( i )] ) + "', " + i + ")\n" );
+            }
+        } else {
+            // IF no max_idx array provided, defaulting to single mgmt
+            pw.append( "    RomeFileSetAttrSize(profile, 'MAN_LAYER', 1)\n"
+                    + "    RomeFileSetAttrValue(profile, 'MAN_HORIZ', '" + length + "', 0)\n" );
+
+            if ( LOG.isLoggable( Level.INFO ) ) {
+                LOG.info( "escapeJava test=" + StringEscapeUtils.escapeJava( "simple / test" ) );
+                LOG.info( "escapeJava test=" + StringEscapeUtils.escapeJavaScript( "simple / test" ) );
+                LOG.info( "\n\n\n********************--- escapeJava man name=" + StringEscapeUtils.escapeJava( managementFormalName[0] ) );
+                LOG.info( "********************--- escapeJavaScript man name=" + StringEscapeUtils.escapeJavaScript( managementFormalName[0] ) );
+                LOG.info( "********************--- escapeHtml man name=" + StringEscapeUtils.escapeHtml( managementFormalName[0] ) );
+                LOG.info( "********************--- escapeSql man name=" + StringEscapeUtils.escapeSql( managementFormalName[0] ) );
+                LOG.info( "********************--- escapeXml man name=" + StringEscapeUtils.escapeXml( managementFormalName[0] ) );
+                LOG.info( "********************--- raw Value is=" + managementFormalName[0] );
+            }
+            pw.append( "    RomeFileSetAttrValue(profile, 'MAN_PTR', '" + R2Run.escapeJavaNoFwdSlash( managementFormalName[0] ) + "', 0)\n" );
+        }
+        pw.append( "    print('SOIL_PTR=%s' % RomeFileGetAttrValue(profile, 'SOIL_PTR', 0))\n" );
+
+        if ( ( contourSystem != null ) && ( contourSystem.length() > 1 ) ) {
+            // Contour Systems can simply point to the nginx XML file - no need to prefetch because of no special
+            // characters in the file name
+            pw.append( "    RomeFileSetAttrValue(profile, 'CONTOUR_SYSTEM_PTR', '" + StringEscapeUtils.escapeJava( contourSystem ) + "', 0)\n" );
+        }
+
+        // To prevent issues with pyrome converting special chars in filenames to invalid chars for web server retrieval,
+        // we prefetch the file, insert a dummy name, and point to it here
+        if ( ( stripBarrierSystem != null ) && ( stripBarrierSystem.length() > 1 ) ) {
+            // for some reason, must reset SLOPE_HORIZ & SLOPE_STEEP immediately before setting a strip and barrier !!! R2 BUG
+            // This is required for the internal Rusle2 wizard to calculate proper slope segment lengths
+            pw.append( "    stripbarr = RomeFilesOpen(files, '#XML:stripbarr_file0.xml',0)\n"
+                    + "    RomeFileSetAttrValue(profile, 'STRIP_BARRIER_SYSTEM_PTR', 'strip-barrier-systems\\\\aaa', 0)\n" );
+        }
+
+        // Runs with a Hydraulic Element System, use a hydraulic element flow path
+        if ( ( hydElemSystem != null ) && ( hydElemSystem.length() > 1 ) ) {
+            // Load the hyd elem flow path into the workspace
+            pw.append( "    hydelem = RomeFilesOpen(files, '#XML:hydelemflowpath_file.xml',0)\n" );
+            int numFlowPaths = r2run.determineNumberOfFlowPaths( hydElemSystem );
+            pw.append( "    RomeFileSetAttrSize(profile, 'NUM_FLOW_PATHS', " + numFlowPaths + ")\n" );
+            double offsets[] = r2run.determineFlowPathDistribution( hydElemSystem );
+            for ( int i = 0; i < numFlowPaths; i++ ) {
+                pw.append( "    RomeFileSetAttrValue(profile, 'FLOW_PATH_HORIZ', '" + length * offsets[i] + "', " + i + ")\n" );
+                if ( i < ( numFlowPaths - 1 ) ) {
+                    pw.append( "    RomeFileSetAttrValue(profile, 'HYD_ELEM_FLOW_PATH_PTR', 'hydraulic-element-flow-paths\\hydelemflowpath1', " + i + ")\n" );
+                } else {
+                    // last flow path is always the default
+                    pw.append( "    RomeFileSetAttrValue(profile, 'HYD_ELEM_FLOW_PATH_PTR', 'hydraulic-element-flow-paths\\default', " + i + ")\n" );
+                }
+            }
+        }
+
+        pw.append( "    RomeFileSave(profile)\n"
+                + "    RomeEngineRun(engine)\n" );
+
+        // Request specific outputs from Rusle2
+        for ( String r : JSONUtils.getRequestedResults( metainfo ) ) {
+            pw.append( "    paramsize = RomeFileGetAttrSize(profile,'" + r + "')\n"
+                    + "    if paramsize > 1:\n"
+                    + "        text = '['\n"
+                    + "        for x in range (paramsize):\n"
+                    + "            text += RomeFileGetAttrValue(profile,'" + r + "',x)\n"
+                    + "            if x < (paramsize-1):\n"
+                    + "                text += ', '\n"
+                    + "        text += ']'\n"
+                    + "    else:\n"
+                    + "        text = RomeFileGetAttrValue(profile, '" + r + "', 0)\n"
+                    + "    results.append(RomeFileGetAttrValue(profile, '" + r + "', 0))\n"
+                    + "    print('" + r + "=%s' % text)\n" );
+        }
+
+        // Request output for segments (seg 0 for non segmented runs)
+        pw.append( "    numflowpaths = RomeFileGetAttrSize(profile, 'NUM_FLOW_PATHS')\n"
+                + "    print('------------------------------------------------------------------------------')\n"
+                + "    print('NUMBER OF FLOWPATHS=%d' % numflowpaths)\n"
+                + "    for xx in range (numflowpaths):\n"
+                + "        print('FLOW_PATH_HORIZ:%d=%s' % (xx, RomeFileGetAttrValue(profile, 'FLOW_PATH_HORIZ', xx)))\n"
+                + "        print('HYD_ELEM_FLOW_PATH_PTR:%d=%s' % (xx, RomeFileGetAttrValue(profile, 'HYD_ELEM_FLOW_PATH_PTR', xx)))\n"
+                + "    numsegs = RomeFileGetAttrSize(profile, 'SEGMENT')\n"
+                + "    print('NUMBER OF SEGMENTS=%d' % numsegs)\n"
+                + "    for x in range (numsegs):\n"
+                + "        print('------------------------------------------------------------------------------')\n"
+                + "        print('SEGMENT:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEGMENT', x)))\n"
+                + "        print('SEG_HORIZ:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_HORIZ', x)))\n"
+                + "        print('SEG_STEEP:%d=%s' % (x,RomeFileGetAttrValue(profile, 'SEG_STEEP', x)))\n"
+                + "        print('SEG_MAN:%d=%s' % (x, RomeFileGetAttrValue(profile, 'MAN_PTR', x)))\n"
+                + "        print('SEG_SOIL:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SOIL_PTR', x)))\n"
+                + "        results.append(RomeFileGetAttrValue(profile, 'SEG_SOIL_LOSS', x))\n"
+                + "        print('SEG_SOIL_LOSS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_SOIL_LOSS', x)))\n"
+                + "        print('SEG_SOIL_LAYER %d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_SOIL_LAYER', x)))\n"
+                + "        print('SEG_MAN_LAYER %d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_MAN_LAYER', x)))\n"
+                + "        print('HYD_ELEM_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'HYD_ELEM_SYSTEM_PTR', x)))\n"
+                + "        print('STRIP_BARRIER_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'STRIP_BARRIER_SYSTEM_PTR', x)))\n"
+                + "        print('CONTOUR_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'CONTOUR_SYSTEM_PTR', x)))\n"
+                + "    print('------------------------------------------------------------------------------')\n" );
+
+        pw.append( "    numflowpaths = RomeFileGetAttrSize(profile, 'NUM_FLOW_PATHS')\n"
+                + "    print('------------------------------------------------------------------------------')\n"
+                + "    print('NUMBER OF FLOWPATHS=%d' % numflowpaths)\n"
+                + "    for xx in range (numflowpaths):\n"
+                + "        print('FLOW_PATH_HORIZ:%d=%s' % (xx, RomeFileGetAttrValue(profile, 'FLOW_PATH_HORIZ', xx)))\n"
+                + "        print('HYD_ELEM_FLOW_PATH_PTR:%d=%s' % (xx, RomeFileGetAttrValue(profile, 'HYD_ELEM_FLOW_PATH_PTR', xx)))\n"
+                + "    numsegs = RomeFileGetAttrSize(profile, 'SEGMENT')\n"
+                + "    print('NUMBER OF SEGMENTS=%d' % numsegs)\n"
+                + "    for x in range (numsegs):\n"
+                + "        print('------------------------------------------------------------------------------')\n"
+                + "        print('SEGMENT:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEGMENT', x)))\n"
+                + "        print('SEG_HORIZ:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_HORIZ', x)))\n"
+                + "        print('SEG_STEEP:%d=%s' % (x,RomeFileGetAttrValue(profile, 'SEG_STEEP', x)))\n"
+                + "        print('SEG_MAN:%d=%s' % (x, RomeFileGetAttrValue(profile, 'MAN_PTR', x)))\n"
+                + "        print('SEG_SOIL:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SOIL_PTR', x)))\n"
+                + "        results.append(RomeFileGetAttrValue(profile, 'SEG_SOIL_LOSS', x))\n"
+                + "        print('SEG_SOIL_LOSS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_SOIL_LOSS', x)))\n"
+                + "        print('SEG_SOIL_LAYER %d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_SOIL_LAYER', x)))\n"
+                + "        print('SEG_MAN_LAYER %d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_MAN_LAYER', x)))\n"
+                + "        print('HYD_ELEM_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'HYD_ELEM_SYSTEM_PTR', x)))\n"
+                + "        print('STRIP_BARRIER_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'STRIP_BARRIER_SYSTEM_PTR', x)))\n"
+                + "        print('CONTOUR_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'CONTOUR_SYSTEM_PTR', x)))\n"
+                + "    print('------------------------------------------------------------------------------')\n" );
+
+        pw.append( "    numflowpaths = RomeFileGetAttrSize(profile, 'NUM_FLOW_PATHS')\n"
+                + "    print('------------------------------------------------------------------------------')\n"
+                + "    print('NUMBER OF FLOWPATHS=%d' % numflowpaths)\n"
+                + "    for xx in range (numflowpaths):\n"
+                + "        print('FLOW_PATH_HORIZ:%d=%s' % (xx, RomeFileGetAttrValue(profile, 'FLOW_PATH_HORIZ', xx)))\n"
+                + "        print('HYD_ELEM_FLOW_PATH_PTR:%d=%s' % (xx, RomeFileGetAttrValue(profile, 'HYD_ELEM_FLOW_PATH_PTR', xx)))\n"
+                + "    numsegs = RomeFileGetAttrSize(profile, 'SEGMENT')\n"
+                + "    print('NUMBER OF SEGMENTS=%d' % numsegs)\n"
+                + "    for x in range (numsegs):\n"
+                + "        print('------------------------------------------------------------------------------')\n"
+                + "        print('SEGMENT:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEGMENT', x)))\n"
+                + "        print('SEG_HORIZ:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_HORIZ', x)))\n"
+                + "        print('SEG_STEEP:%d=%s' % (x,RomeFileGetAttrValue(profile, 'SEG_STEEP', x)))\n"
+                + "        print('SEG_MAN:%d=%s' % (x, RomeFileGetAttrValue(profile, 'MAN_PTR', x)))\n"
+                + "        print('SEG_SOIL:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SOIL_PTR', x)))\n"
+                + "        results.append(RomeFileGetAttrValue(profile, 'SEG_SOIL_LOSS', x))\n"
+                + "        print('SEG_SOIL_LOSS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_SOIL_LOSS', x)))\n"
+                + "        print('SEG_SOIL_LAYER %d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_SOIL_LAYER', x)))\n"
+                + "        print('SEG_MAN_LAYER %d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_MAN_LAYER', x)))\n"
+                + "        print('HYD_ELEM_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'HYD_ELEM_SYSTEM_PTR', x)))\n"
+                + "        print('STRIP_BARRIER_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'STRIP_BARRIER_SYSTEM_PTR', x)))\n"
+                + "        print('CONTOUR_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'CONTOUR_SYSTEM_PTR', x)))\n"
+                + "    print('------------------------------------------------------------------------------')\n"
+                + "    numsegs = RomeFileGetAttrSize(profile, 'SOIL_LAYER')\n"
+                + "    print('NUMBER OF SOIL SEGMENTS=%d' % numsegs)\n"
+                + "    for x in range (numsegs):\n"
+                + "        print('------------------------------------------------------------------------------')\n"
+                + "        print('SOIL_SEGMENT:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SOIL_LAYER', x)))\n"
+                + "        print('SOIL_HORIZ:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SOIL_HORIZ', x)))\n"
+                + "        print('SOIL_PTR:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SOIL_PTR', x)))\n"
+                + "    print('------------------------------------------------------------------------------')\n"
+                + "    numsegs = RomeFileGetAttrSize(profile, 'MAN_LAYER')\n"
+                + "    print('NUMBER OF MAN SEGMENTS=%d' % numsegs)\n"
+                + "    for x in range (numsegs):\n"
+                + "        print('------------------------------------------------------------------------------')\n"
+                + "        print('MAN_SEGMENT:%d=%s' % (x, RomeFileGetAttrValue(profile, 'MAN_LAYER', x)))\n"
+                + "        print('MAN_HORIZ:%d=%s' % (x, RomeFileGetAttrValue(profile, 'MAN_HORIZ', x)))\n"
+                + "        print('MAN_PTR:%d=%s' % (x, RomeFileGetAttrValue(profile, 'MAN_PTR', x)))\n"
+                + "    print('------------------------------------------------------------------------------')\n"
+                + "    numsegs = RomeFileGetAttrSize(profile, 'TOPO_LAYER')\n"
+                + "    print('NUMBER OF TOPO SEGMENTS=%d' % numsegs)\n"
+                + "    for x in range (numsegs):\n"
+                + "        print('------------------------------------------------------------------------------')\n"
+                + "        print('TOPO_SEGMENT:%d=%s' % (x, RomeFileGetAttrValue(profile, 'TOPO_LAYER', x)))\n"
+                + "        print('TOPO_HORIZ:%d=%s' % (x, RomeFileGetAttrValue(profile, 'TOPO_HORIZ', x)))\n"
+                + "        print('TOPO_HORIZ_COMPOSITE:%d=%s' % (x, RomeFileGetAttrValue(profile, 'TOPO_HORIZ_COMPOSITE', x)))\n"
+                + "        print('TOPO_STEEP:%d=%s' % (x, RomeFileGetAttrValue(profile, 'TOPO_STEEP', x)))\n"
+                + "        print('TOPO_STEEP_COMPOSITE:%d=%s' % (x, RomeFileGetAttrValue(profile, 'TOPO_STEEP_COMPOSITE', x)))\n"
+                + "    print('------------------------------------------------------------------------------')\n"
+                + "    exec(open(\"" + REPORT_PY_FILENAME + "\").read())\n"
+                + "    RomeFileClose(profile)\n"
+                + "    return results\n\n"
+                + "if __name__ == \"__main__\":\n"
+                + "    #inputs\n"
+                + "    save = False\n"
+                + "    #Run simulation\n"
+                + "    romeDLL = RomeInit('pyrome /DirRoot=" + resources().getFile( ROMEDLL ).getParent().replace( '\\', '/' ) + "/')\n"
+                + "    database = RomeGetDatabase(romeDLL)\n" );
+
+        // prints all outputs in single array
+        // Specify the nginx server
+        if ( !parameter().has( KEY_ALT_R2DB ) ) {
+            pw.append( "    RomeDatabaseOpen(database,'" + r2db + "')\n" );
+        } else {
+            String altr2db = r2db.substring( 0, r2db.lastIndexOf( "/" ) ) + "/model-data/" + parameter().getString( KEY_ALT_R2DB );
+            pw.append( "    RomeDatabaseOpen(database,'" + altr2db + "')\n" );
+        }
+
+        pw.append( "    results = linearTest(save)\n"
+                + "    RomeDatabaseClose(database)\n"
+                + "    RomeExit(romeDLL)\n"
+                + "    exit()\n"
+        );
+        pw.close();
+
+        // prepare individual contour system, strip barrier system, hyd elem sys, if not provided in an array
+        if ( parameter().has( KEY_CONTOUR_SYSTEM_PTR ) ) {
+            String contourHttpPtr = r2db + "/" + contourSystem.replace( "\\", "/" ) + ".xml";
+            r2run.prepareFileJ( contourHttpPtr, getWorkspaceFile( "contour_file0.xml" ), "", "contour-systems", "", true );
+        }
+        if ( parameter().has( KEY_STRIP_BARRIER_SYSTEM_PTR ) ) {
+            String stripbarrHttpPtr = r2db + "/" + stripBarrierSystem.replace( "\\", "/" ) + ".xml";
+            r2run.prepareFileJ( stripbarrHttpPtr, getWorkspaceFile( "stripbarr_file0.xml" ), "", "strip-barrier-systems", "", true );
+        }
+        if ( parameter().has( KEY_HYD_ELEM_SYSTEM_PTR ) ) {
+            String hydelemHttpPtr = r2db + "/" + hydElemSystem.replace( "\\", "/" ) + ".xml";
+            r2run.prepareHydraulicElementFlowPathJ( hydelemHttpPtr, r2db, getWorkspaceFile( "hydelemflowpath_file.xml" ) );
+        }
+
+        // prepare climate file
+        r2run.prepareFileJ( climatePtr, getWorkspaceFile( "cli_file0.xml" ), "CLIMATE", "climates", "", true );
+
+        // Unpack the report rsh file in the work space dir
+        FileUtils.copyFileToDirectory( resources().getFile( REPORT_PY_FILENAME ), getWorkspaceDir() );
+
+        climate = climatePtr;
+        soil = soilPtr[0];
+        mgmt = managementFormalName[0];
     }
 
-    // Get erosion for segments
-    if (parameter().has(KEY_TOPO_LENGTH)) {
-      JSONArray aTopoLength = JSONUtils.getJSONArrayParam(getParamMap(), KEY_TOPO_LENGTH);
-      if (aTopoLength.length() > 0) {
-        JSONArray aSoilLoss = new JSONArray(r2run.getResultPyromeArray("SEG_SOIL_LOSS", false, false, true));
-        results().put("SEG_SOIL_LOSS", aSoilLoss);
-        results().put(KEY_CLIMATES, climate);
-        if (LOG.isLoggable(Level.INFO)) {
-          LOG.info("\n\n\n\n\n\nSEG SOIL OUTPUT=" + r2run.getResultPyromeArray("SEG_SOIL", true, true, true) + "\n\n\n\n");
-          LOG.info("\n\n\n\n\n\nSEG SOIL OUTPUT=" + r2run.getResultPyromeArray("SEG_MAN", true, true, true) + "\n\n\n\n");
+    private String[] getSoilFiles ( JSONArray cokeys ) throws JSONException, Exception {
+        String soilPtr[] = new String[( cokeys.length() )];
+        JSONObject soilsRequest = new JSONObject();
+        JSONObject meta = new JSONObject();
+        JSONArray paramObj = new JSONArray();
+        JSONObject cokeyObj = new JSONObject();
+
+        soilsRequest.put( KEY_METAINFO, meta );
+        soilsRequest.put( KEY_PARAMETER, paramObj );
+        paramObj.put( cokeyObj );
+
+        for ( int i = 0; i < cokeys.length(); i++ ) {
+            String cokey = cokeys.getString( i );
+            paramObj.put( 0, cokeyObj );
+            cokeyObj.put( KEY_NAME, KEY_COKEY );
+            cokeyObj.put( KEY_VALUE, cokey );
+            JSONObject soilsResponse = new Client().doPOST( Config.getString( "r2.soils", "http://csip.engr.colostate.edu:8092/csip-soils/d/soilsXML/1.0" ), soilsRequest );
+            if ( LOG.isLoggable( Level.INFO ) ) {
+                LOG.info( "SOILS Response: " + soilsResponse.toString() );
+            }
+            JSONObject responseMeta = soilsResponse.getJSONObject( KEY_METAINFO );
+            if ( !responseMeta.getString( KEY_STATUS ).equalsIgnoreCase( "Failed" ) ) {
+                JSONArray resultArr = soilsResponse.getJSONArray( KEY_RESULT );
+                JSONObject soilObj = resultArr.getJSONObject( 0 );
+                String soilFilePath = soilObj.getString( KEY_VALUE );
+
+                new Client().doGET( soilFilePath, getWorkspaceFile( "soils_file" + i + ".xml" ) );
+
+                soilPtr[i] = getSoilFilePath( getWorkspaceFile( "soils_file" + i + ".xml" ) ).replace( "/", "\\" );
+                if ( LOG.isLoggable( Level.INFO ) ) {
+                    LOG.info( "THE SOIL IS =" + soilPtr[i] + "\n\n\n\n" );
+                }
+            } else {
+                String error = responseMeta.getString( ERROR );
+                throw new ServiceException( "Soil service error: " + error );
+            }
         }
-        results().put(KEY_SOILS, new JSONArray(r2run.getResultPyromeArray("SEG_SOIL", true, true, true)));
-        results().put(KEY_MANAGEMENTS, new JSONArray(r2run.getResultPyromeArray("SEG_MAN", true, true, true)));
-        if (parameter().has(KEY_DIVERSIONS)) {
-          results().put(KEY_DIVERSIONS, r2run.getResultPyromeArray("HYD_ELEM_SYS", true, true, true));
-        }
-        if (parameter().has(KEY_STRIP_BARRIER_SYSTEMS)) {
-          results().put(KEY_STRIP_BARRIER_SYSTEMS, r2run.getResultPyromeArray("STRIP_BARRIER_SYS", true, true, true));
-        }
-      }
-    } else {
-      results().put(KEY_CLIMATES, climate);
-      results().put(KEY_SOILS, new JSONArray(r2run.getResultPyromeArray("SEG_SOIL", true, true, true)));
-      results().put(KEY_MANAGEMENTS, new JSONArray(r2run.getResultPyromeArray("SEG_MAN", true, true, true)));
-    }
-  }
-
-
-  private void createInputFile(File file, JSONObject metainfo, Map<String, JSONObject> param)
-      throws Exception {
-
-    double steepness = parameter().getDouble(KEY_STEEPNESS, 0.0);
-    double length = parameter().getDouble(KEY_LENGTH, 0.0);
-    boolean resolveLoc = parameter().getBoolean(KEY_RESOLVE_LOCATION, false);
-    double latitude = parameter().getDouble(KEY_LATITUDE, 0.0);
-    double longitude = parameter().getDouble(KEY_LONGITUDE, 0.0);
-    double simpleRockCoverPercent = 0.0;
-
-    LOG.info("Rock cover read by service is=" + simpleRockCoverPercent);
-
-    JSONArray aRockCover = JSONUtils.getJSONArrayParam(param, KEY_SIMPLE_ROCK_COVER);
-    for (int i = 0; i < aRockCover.length(); i++) {
-      LOG.info("Rock cover [" + i + "]=" + aRockCover.getDouble(i));
-      // this is temporary, since R2 will be using slope segments soon
-      if (i == 0) {
-        simpleRockCoverPercent = aRockCover.getDouble(i);
-      }
+        return soilPtr;
     }
 
-    JSONArray aSoils = JSONUtils.getJSONArrayParam(param, KEY_SOILS);
-    if (LOG.isLoggable(Level.INFO)) {
-      for (int i = 0; i < aSoils.length(); i++) {
-        LOG.info("soil [" + i + "]=" + aSoils.getInt(i));
-      }
+    private String getSoilFilePath ( File soilFile ) throws ParserConfigurationException, SAXException, IOException {
+        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+        DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+        Document document = documentBuilder.parse( soilFile );
+        String path = document.getElementsByTagName( "Filename" ).item( 0 ).getTextContent();
+        return path;
     }
 
-    // scalar variables for non-segmented runs
-    String contourSystem = "";
-    String stripBarrierSystem = "";
-    String hydElemSystem = "";
+    private String getClimateFilePath ( double lat, double lon ) throws JSONException, Exception {
+        JSONObject climateReq = new JSONObject();
+        JSONObject meta = new JSONObject();
+        JSONArray param = new JSONArray();
+        JSONObject jlat = new JSONObject();
+        JSONObject jlong = new JSONObject();
+        String climatePath = "";
 
-    // Get the Contour System if not default
-    if (parameter().has(KEY_CONTOUR_SYSTEM_PTR)) {
-      contourSystem = parameter().getString(KEY_CONTOUR_SYSTEM_PTR, "");
+        climateReq.put( KEY_METAINFO, meta );
+        climateReq.put( KEY_PARAMETER, param );
+
+        param.put( jlat );
+        param.put( jlong );
+
+        jlat.put( KEY_NAME, KEY_LATITUDE );
+        jlat.put( KEY_VALUE, lat );
+
+        jlong.put( KEY_NAME, KEY_LONGITUDE );
+        jlong.put( KEY_VALUE, lon );
+
+        JSONObject climateResponse = new Client().doPOST( Config.getString( "r2.climate", "http://csip.engr.colostate.edu:8092/csip-misc/d/r2climate/2.0" ), climateReq );
+        if ( LOG.isLoggable( Level.INFO ) ) {
+            LOG.info( "CLIMATE Response: " + climateResponse.toString() );
+        }
+        JSONObject responseMeta = climateResponse.getJSONObject( KEY_METAINFO );
+        if ( !responseMeta.getString( KEY_STATUS ).equalsIgnoreCase( "Failed" ) ) {
+            JSONArray resultArr = climateResponse.getJSONArray( KEY_RESULT );
+            JSONObject cliObj = JSONUtils.preprocess( resultArr ).get( KEY_CLIMATE_URL );
+            climatePath = cliObj.getString( KEY_VALUE );
+        }
+        return climatePath;
     }
 
-    // Get the Strip Barrier System
-    if (parameter().has(KEY_STRIP_BARRIER_SYSTEM_PTR)) {
-      stripBarrierSystem = parameter().getString(KEY_STRIP_BARRIER_SYSTEM_PTR, "");
+    @Override
+    protected void doReport () throws Exception {
+        String sReportJSON = FileUtils.readFileToString( resources().getFile( REPORT_JSON_TEMPLATE_FILENAME ) );
+        JSONArray reportItemsFromTemplate = new JSONArray( sReportJSON );
+        for ( int i = 0; i < reportItemsFromTemplate.length(); i++ ) {
+            JSONObject obj = ( JSONObject ) reportItemsFromTemplate.get( i );
+            String itemName = obj.getString( REPORT_NAME );
+            String dimension = JSONUtils.getJSONString( obj, REPORT_DIM, null );
+            String type = JSONUtils.getJSONString( obj, REPORT_TYPE, "" );
+            String units = JSONUtils.getJSONString( obj, REPORT_UNITS, null );
+            String desc = JSONUtils.getJSONString( obj, REPORT_DESC, null );
+            if ( LOG.isLoggable( Level.INFO ) ) {
+                LOG.info( "--------------------PROCESSING ELEMENT:" );
+                LOG.info( "VAR NAME:" + itemName );
+                LOG.info( "---------------------------------------" );
+            }
+
+            //String value = r2run.getResultPyrome(itemName);
+            String value = r2run.getResult( "\"" + itemName + "\"" );
+            LOG.info( "the value='" + value + "'" );
+            if ( ( value != null ) && ( value.equals( "null" ) ) ) {
+                report().put( itemName, ( String ) null, desc, units );
+                // if there is no value, then item should be removed from the array
+            } else {
+                if ( ( dimension != null ) && ( dimension.length() > 0 ) && ( value != null ) && ( !value.equals( "null" ) ) ) {
+                    try {
+                        report().put( itemName, new JSONArray( value ), desc, units );
+                    }
+                    catch ( JSONException je ) {
+                        processReportElement( itemName, dimension, units, desc, type, value );
+                    }
+                } else {
+                    processReportElement( itemName, dimension, units, desc, type, value );
+                }
+            }
+            if ( dimension != null ) {
+                report().putMetaInfo( itemName, REPORT_DIM, new JSONArray( dimension ) );
+            }
+        }
     }
 
-    // Get the Hydraylic Element System Pointer  
-    if (parameter().has(KEY_HYD_ELEM_SYSTEM_PTR)) {
-      hydElemSystem = parameter().getString(KEY_HYD_ELEM_SYSTEM_PTR, "");
+    // This is a gross signiture but due to csip report changes this is the easiest way to change it without losing Wes's logic.
+    private void processReportElement ( String itemName, String dim, String units, String desc, String type, String value ) throws Exception {
+        if ( LOG.isLoggable( Level.INFO ) ) {
+            LOG.info( "------------------------------------PROCESSING ELEMENT:\n\n" );
+            LOG.info( "TYPE:" + type );
+            LOG.info( "VALUE:" + value );
+            LOG.info( "------------------------------------\n\n" );
+        }
+        if ( ( type.equals( "TEXT" ) ) || ( type.equals( "FILENAME" ) ) || ( type.equals( "DATE" ) ) ) {
+            // because the RomeShell returns escaped strings, and the JSONObject in Java re-escapes them
+            // we have to remove one level of "escaping" !!!
+            String newString = StringEscapeUtils.unescapeJava( value );
+            //String newString=value;
+            report().put( itemName, removeFirstLastChar( newString ), desc, units );
+        }
+        if ( type.equals( "INTEGER" ) && ( value != null ) && ( !value.equals( "null" ) ) && ( !value.equals( "\"\"" ) ) ) {
+            // trim off quotes
+            value = removeFirstLastChar( value );
+            report().put( itemName, new Double( value ).intValue(), desc, units );
+        }
+        if ( type.equals( "REAL" ) && ( value != null ) ) {
+            if ( ( !value.equals( "null" ) ) && ( !value.equals( "\"\"" ) ) ) {
+                // trim off quotes
+                value = removeFirstLastChar( value );
+                report().put( itemName, Double.parseDouble( value ), desc, units );
+            }
+            if ( value.equals( "\"\"" ) ) {
+                report().put( itemName, new Double( 0 ), desc, units );
+            }
+        }
+        if ( type.equals( "" ) ) {
+            report().put( itemName, value, desc, units );
+        }
     }
-
-    JSONArray aTopoLength = new JSONArray();
-    JSONArray aTopoSteepness = new JSONArray();
-    JSONArray aSoilIdx = new JSONArray();
-    JSONArray aManIdx = new JSONArray();
-    JSONArray aManLength = new JSONArray();
-
-    if (parameter().has(KEY_TOPO_LENGTH)) {
-      aTopoLength = JSONUtils.getJSONArrayParam(param, KEY_TOPO_LENGTH);
-      if (LOG.isLoggable(Level.INFO)) {
-        for (int i = 0; i < aTopoLength.length(); i++) {
-          LOG.info("Topo Length [" + i + "]=" + aTopoLength.getDouble(i));
-        }
-      }
-    }
-
-    if (parameter().has(KEY_TOPO_STEEPNESS)) {
-      aTopoSteepness = JSONUtils.getJSONArrayParam(param, KEY_TOPO_STEEPNESS);
-      if (LOG.isLoggable(Level.INFO)) {
-        for (int i = 0; i < aTopoSteepness.length(); i++) {
-          LOG.info("Topo Steepness [" + i + "]=" + aTopoSteepness.getDouble(i));
-        }
-      }
-    }
-
-    if (parameter().has(KEY_SOIL_INDEX)) {
-      aSoilIdx = JSONUtils.getJSONArrayParam(param, KEY_SOIL_INDEX);
-      if (LOG.isLoggable(Level.INFO)) {
-        for (int i = 0; i < aSoilIdx.length(); i++) {
-          LOG.info("Soil Index [" + i + "]=" + aSoilIdx.getInt(i));
-        }
-      }
-    }
-
-    if (parameter().has(KEY_MAN_INDEX)) {
-      aManIdx = JSONUtils.getJSONArrayParam(param, KEY_MAN_INDEX);
-      if (LOG.isLoggable(Level.INFO)) {
-        for (int i = 0; i < aManIdx.length(); i++) {
-          LOG.info("Man Index [" + i + "]=" + aManIdx.getInt(i));
-        }
-      }
-    }
-
-    if (parameter().has(KEY_MAN_LENGTH)) {
-      aManLength = JSONUtils.getJSONArrayParam(param, KEY_MAN_LENGTH);
-      for (int i = 0; i < aManLength.length(); i++) {
-        LOG.info("Man Length [" + i + "]=" + aManLength.getInt(i));
-      }
-    }
-
-    if (parameter().has(KEY_TOPO_LENGTH)) {
-      if (aTopoLength.length() != aTopoSteepness.length()) {
-        throw new ServiceException("RUSLE2 SEGMENT RUN ERROR! SEGMENT ARRAYS FOR TOPO LENGTH AND TOPO STEEPNESS MUST BE OF EQUAL SIZE!");
-      }
-    }
-
-    if (parameter().has(KEY_MAN_INDEX)) {
-      if (aManLength.length() != aManIdx.length()) {
-        throw new ServiceException("RUSLE2 SEGMENT RUN ERROR! SEGMENT ARRAYS FOR MGMT LENGTH AND MGMT INDEX MUST BE OF EQUAL SIZE!");
-      }
-    }
-
-    // management conversion
-    // Make file line separator unix compatible. ???? not sure if needed.
-    System.setProperty("line.separator", "\n");
-
-    JSONArray managements = JSONUtils.getJSONArrayParam(param, KEY_MGMTS);
-
-    LOG.info("managements array=" + managements.toString());
-    String[] managementFormalName = new String[managements.length()];
-
-    for (int i = 0; i < managements.length(); i++) {
-      LOG.info("management #" + i);
-
-      JSONObject lmod = (JSONObject) managements.get(i);
-      if (LOG.isLoggable(Level.INFO)) {
-        LOG.info(lmod.toString());
-      }
-
-      Rusle2Translator translator = new Rusle2Translator();
-      translator.readJsonString(lmod.toString());
-
-      boolean success = translator.Translate();
-      LOG.info("translation successful =" + success);
-
-      Document r2_xml = translator.getDocument();
-
-      if (LOG.isLoggable(Level.INFO)) {
-        LOG.info("R2 XML FILE from translator:\n\n" + translator.getRusle2Xml());
-      }
-
-      if ((r2_xml != null) && (r2_xml.getElementsByTagName("Filename") != null)) {
-        NodeList nl = r2_xml.getElementsByTagName("Filename");
-        for (int ii = 0; ii < nl.getLength(); ii++) {
-          if (LOG.isLoggable(Level.INFO)) {
-            LOG.info("filename node=" + nl.item(ii).getTextContent());
-          }
-          managementFormalName[i] = nl.item(ii).getTextContent();
-        }
-      }
-
-      translator.writeRusle2Xml(getWorkspaceDir().toString(), "lmod_file" + i + ".xml");
-      operations = translator.getOperationFiles();
-      vegetations = translator.getVegetationFiles();
-      residues = translator.getResidueFiles();
-
-      if (LOG.isLoggable(Level.INFO)) {
-        operations.forEach((operation) -> {
-          LOG.info("operation=" + operation);
-        });
-        vegetations.forEach((vege) -> {
-          LOG.info("vegetation=" + vege);
-        });
-        residues.forEach((residue) -> {
-          LOG.info("residue=" + residue);
-        });
-      }
-    }
-
-    // If this is a Lat/Lng request, then we need to make a DB lookup
-    // to obtain the Climate and Soil information and ignore whatever
-    // may have been passed in
-    LOG.info("Rulse 2 model request resolveLocation=" + resolveLoc);
-
-    // Sub-service calls.
-    String climatePtr = getClimateFilePath(latitude, longitude);
-    String[] soilPtr = getSoilFiles(aSoils);
-
-    PrintWriter pw = new PrintWriter(file);
-    pw.append("import sys\n"
-        // could rewrite this line based on the OS, but python is interpretting it ok on windows
-        + "sys.path.append('" + resources().getFile(PYROMESRC).getParent().replace('\\', '/') + "')\n"
-        + "from pyrome import *\n"
-        + "\n"
-        + "def linearTest(save = False, openFlags = RX_FILESOPEN_TEMP):\n"
-        + "    romeDLL = RomeInit('')\n"
-        + "    files = RomeGetFiles(romeDLL)\n"
-        + "    engine = RomeGetEngine(romeDLL)\n"
-        + "    RomeEngineSetAutorun(engine,RX_FALSE)\n"
-        + "    #Inputs\n");
-
-    if (aTopoLength.length() > 1) {
-      String text = "    slopes=[";
-      for (int i = 0; i < aTopoSteepness.length(); i++) {
-        text += "'" + aTopoSteepness.getInt(i) + "'";
-        text += (i == aTopoSteepness.length() - 1) ? "]\n" : ",";
-      }
-      pw.append(text);
-      text = "    lengths=[";
-      for (int i = 0; i < aTopoLength.length(); i++) {
-        text += "'" + aTopoLength.getInt(i) + "'";
-        text += (i == aTopoLength.length() - 1) ? "]\n" : ",";
-      }
-      pw.append(text);
-      if ((aSoilIdx != null) && (aSoilIdx.length() > 0)) {
-        text = "    soilIndex=[";
-        for (int i = 0; i < aSoilIdx.length(); i++) {
-          text += aSoilIdx.getInt(i) + "";
-          text += (i == aSoilIdx.length() - 1) ? "]\n" : ",";
-        }
-        pw.append(text);
-      }
-      text = "    manIndex=[";
-      for (int i = 0; i < aManIdx.length(); i++) {
-        text += aManIdx.getInt(i) + "";
-        text += (i == aManIdx.length() - 1) ? "]\n" : ",";
-      }
-      pw.append(text);
-    } else {
-      pw.append("    slopes=['" + steepness + "']\n"
-          + "    lengths=['" + length + "']\n"
-          + "    soilIndex=[0]\n"
-          + "    manIndex=[0]\n");
-    }
-
-    pw.append("    results = list()\n"
-        + "    #Run a simple profile\n"
-        + "    profile = RomeFilesOpen(files,'profiles\\\\csippyrome',openFlags)\n");
-
-    // Open all of the mgmt files...
-    for (int i = 0; i < managements.length(); i++) {
-      pw.append("    mgmt = RomeFilesOpen(files, '#XML:lmod_file" + i + ".xml',0)\n");
-    }
-    pw.append("    cli = RomeFilesOpen(files, '#XML:cli_file0.xml',0)\n");
-    for (int i = 0; i < aSoils.length(); i++) {
-      pw.append("    soil" + i + " = RomeFilesOpen(files, '#XML:soils_file" + i + ".xml',0)\n");
-    }
-    pw.append("    # SET SLOPE\n"
-        + "    RomeFileSetAttrValue(profile, 'SLOPE_HORIZ', '" + length + "', 0)\n"
-        + "    RomeFileSetAttrValue(profile, 'SLOPE_STEEP', '" + steepness + "', 0)\n"
-        + "    # SET CLIMATE_PTR\n"
-        + "    RomeFileSetAttrValue(profile, 'CLIMATE_PTR','climates\\\\aaa',0)\n"
-        + "    print('CLIMATE_PTR=%s' % RomeFileGetAttrValue(profile, 'CLIMATE_PTR', 0))\n");
-
-    pw.append("    # SET TOPO LAYER\n");
-    if (aTopoLength.length() > 0) {
-      pw.append("    RomeFileSetAttrSize(profile, 'TOPO_LAYER', " + aTopoLength.length() + ")\n");
-      for (int i = 0; i < aTopoLength.length(); i++) {
-        pw.append("    RomeFileSetAttrValue(profile, 'TOPO_HORIZ', '" + aTopoLength.getString(i) + "', " + i + ")\n"
-            + "    RomeFileSetAttrValue(profile, 'TOPO_STEEP', '" + aTopoSteepness.getString(i) + "', " + i + ")\n");
-      }
-    }
-
-    // Presently we do not support multiple soils
-    pw.append("    # SET SOIL LAYER\n");
-    if (aSoils.length() > 0) {
-      pw.append("    RomeFileSetAttrSize(profile, 'SOIL_LAYER', " + aSoils.length() + ")\n"
-          + "    RomeFileSetAttrValue(profile, 'SOIL_HORIZ', '" + length + "', 0)\n"
-          + "    RomeFileSetAttrValue(profile, 'SOIL_PTR', '" + StringEscapeUtils.escapeJava(soilPtr[0]) + "', " + 0 + ")\n");
-    }
-
-    // Must be after set soils or the soils code resets it...sometimes
-    if (parameter().has(KEY_SIMPLE_ROCK_COVER)) {
-      pw.append("    RomeFileSetAttrValue(profile, 'SIMPLE_ROCK_COVER', '" + simpleRockCoverPercent + "' ,0)\n");
-    }
-    pw.append("    # SET MAN LAYER\n");
-    if (aManIdx.length() > 0) {
-      pw.append("    RomeFileSetAttrSize(profile, 'MAN_LAYER', " + aManIdx.length() + ")\n");
-      for (int i = 0; i < aManIdx.length(); i++) {
-        pw.append("    RomeFileSetAttrValue(profile, 'MAN_HORIZ', '" + aManLength.getString(i) + "', " + i + ")\n");
-        if (LOG.isLoggable(Level.INFO)) {
-          LOG.info("escapeJava test=" + StringEscapeUtils.escapeJava("simple / test"));
-          LOG.info("escapeJava test=" + StringEscapeUtils.escapeJavaScript("simple / test"));
-          LOG.info("\n\n\n********************--- escapeJava man name=" + StringEscapeUtils.escapeJava(managementFormalName[aManIdx.getInt(i)]));
-          LOG.info("********************--- escapeJavaScript man name=" + StringEscapeUtils.escapeJavaScript(managementFormalName[aManIdx.getInt(i)]));
-          LOG.info("********************--- escapeHtml man name=" + StringEscapeUtils.escapeHtml(managementFormalName[aManIdx.getInt(i)]));
-          LOG.info("********************--- escapeSql man name=" + StringEscapeUtils.escapeSql(managementFormalName[aManIdx.getInt(i)]));
-          LOG.info("********************--- escapeXml man name=" + StringEscapeUtils.escapeXml(managementFormalName[aManIdx.getInt(i)]));
-          LOG.info("********************--- raw Value is=" + managementFormalName[aManIdx.getInt(i)]);
-        }
-        pw.append("    RomeFileSetAttrValue(profile, 'MAN_PTR', '" + R2Run.escapeJavaNoFwdSlash(managementFormalName[aManIdx.getInt(i)]) + "', " + i + ")\n");
-      }
-    } else {
-      // IF no max_idx array provided, defaulting to single mgmt
-      pw.append("    RomeFileSetAttrSize(profile, 'MAN_LAYER', 1)\n"
-          + "    RomeFileSetAttrValue(profile, 'MAN_HORIZ', '" + length + "', 0)\n");
-
-      if (LOG.isLoggable(Level.INFO)) {
-        LOG.info("escapeJava test=" + StringEscapeUtils.escapeJava("simple / test"));
-        LOG.info("escapeJava test=" + StringEscapeUtils.escapeJavaScript("simple / test"));
-        LOG.info("\n\n\n********************--- escapeJava man name=" + StringEscapeUtils.escapeJava(managementFormalName[0]));
-        LOG.info("********************--- escapeJavaScript man name=" + StringEscapeUtils.escapeJavaScript(managementFormalName[0]));
-        LOG.info("********************--- escapeHtml man name=" + StringEscapeUtils.escapeHtml(managementFormalName[0]));
-        LOG.info("********************--- escapeSql man name=" + StringEscapeUtils.escapeSql(managementFormalName[0]));
-        LOG.info("********************--- escapeXml man name=" + StringEscapeUtils.escapeXml(managementFormalName[0]));
-        LOG.info("********************--- raw Value is=" + managementFormalName[0]);
-      }
-      pw.append("    RomeFileSetAttrValue(profile, 'MAN_PTR', '" + R2Run.escapeJavaNoFwdSlash(managementFormalName[0]) + "', 0)\n");
-    }
-    pw.append("    print('SOIL_PTR=%s' % RomeFileGetAttrValue(profile, 'SOIL_PTR', 0))\n");
-
-    if ((contourSystem != null) && (contourSystem.length() > 1)) {
-      // Contour Systems can simply point to the nginx XML file - no need to prefetch because of no special
-      // characters in the file name
-      pw.append("    RomeFileSetAttrValue(profile, 'CONTOUR_SYSTEM_PTR', '" + StringEscapeUtils.escapeJava(contourSystem) + "', 0)\n");
-    }
-
-    // To prevent issues with pyrome converting special chars in filenames to invalid chars for web server retrieval,
-    // we prefetch the file, insert a dummy name, and point to it here
-    if ((stripBarrierSystem != null) && (stripBarrierSystem.length() > 1)) {
-      // for some reason, must reset SLOPE_HORIZ & SLOPE_STEEP immediately before setting a strip and barrier !!! R2 BUG
-      // This is required for the internal Rusle2 wizard to calculate proper slope segment lengths
-      pw.append("    stripbarr = RomeFilesOpen(files, '#XML:stripbarr_file0.xml',0)\n"
-          + "    RomeFileSetAttrValue(profile, 'STRIP_BARRIER_SYSTEM_PTR', 'strip-barrier-systems\\\\aaa', 0)\n");
-    }
-
-    // Runs with a Hydraulic Element System, use a hydraulic element flow path
-    if ((hydElemSystem != null) && (hydElemSystem.length() > 1)) {
-      // Load the hyd elem flow path into the workspace
-      pw.append("    hydelem = RomeFilesOpen(files, '#XML:hydelemflowpath_file.xml',0)\n");
-      int numFlowPaths = r2run.determineNumberOfFlowPaths(hydElemSystem);
-      pw.append("    RomeFileSetAttrSize(profile, 'NUM_FLOW_PATHS', " + numFlowPaths + ")\n");
-      double offsets[] = r2run.determineFlowPathDistribution(hydElemSystem);
-      for (int i = 0; i < numFlowPaths; i++) {
-        pw.append("    RomeFileSetAttrValue(profile, 'FLOW_PATH_HORIZ', '" + length * offsets[i] + "', " + i + ")\n");
-        if (i < (numFlowPaths - 1)) {
-          pw.append("    RomeFileSetAttrValue(profile, 'HYD_ELEM_FLOW_PATH_PTR', 'hydraulic-element-flow-paths\\hydelemflowpath1', " + i + ")\n");
-        } else {
-          // last flow path is always the default
-          pw.append("    RomeFileSetAttrValue(profile, 'HYD_ELEM_FLOW_PATH_PTR', 'hydraulic-element-flow-paths\\default', " + i + ")\n");
-        }
-      }
-    }
-
-    pw.append("    RomeFileSave(profile)\n"
-        + "    RomeEngineRun(engine)\n");
-
-    // Request specific outputs from Rusle2
-    for (String r : JSONUtils.getRequestedResults(metainfo)) {
-      pw.append("    paramsize = RomeFileGetAttrSize(profile,'" + r + "')\n"
-          + "    if paramsize > 1:\n"
-          + "        text = '['\n"
-          + "        for x in range (paramsize):\n"
-          + "            text += RomeFileGetAttrValue(profile,'" + r + "',x)\n"
-          + "            if x < (paramsize-1):\n"
-          + "                text += ', '\n"
-          + "        text += ']'\n"
-          + "    else:\n"
-          + "        text = RomeFileGetAttrValue(profile, '" + r + "', 0)\n"
-          + "    results.append(RomeFileGetAttrValue(profile, '" + r + "', 0))\n"
-          + "    print('" + r + "=%s' % text)\n");
-    }
-
-    // Request output for segments (seg 0 for non segmented runs)
-    pw.append("    numflowpaths = RomeFileGetAttrSize(profile, 'NUM_FLOW_PATHS')\n"
-        + "    print('------------------------------------------------------------------------------')\n"
-        + "    print('NUMBER OF FLOWPATHS=%d' % numflowpaths)\n"
-        + "    for xx in range (numflowpaths):\n"
-        + "        print('FLOW_PATH_HORIZ:%d=%s' % (xx, RomeFileGetAttrValue(profile, 'FLOW_PATH_HORIZ', xx)))\n"
-        + "        print('HYD_ELEM_FLOW_PATH_PTR:%d=%s' % (xx, RomeFileGetAttrValue(profile, 'HYD_ELEM_FLOW_PATH_PTR', xx)))\n"
-        + "    numsegs = RomeFileGetAttrSize(profile, 'SEGMENT')\n"
-        + "    print('NUMBER OF SEGMENTS=%d' % numsegs)\n"
-        + "    for x in range (numsegs):\n"
-        + "        print('------------------------------------------------------------------------------')\n"
-        + "        print('SEGMENT:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEGMENT', x)))\n"
-        + "        print('SEG_HORIZ:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_HORIZ', x)))\n"
-        + "        print('SEG_STEEP:%d=%s' % (x,RomeFileGetAttrValue(profile, 'SEG_STEEP', x)))\n"
-        + "        print('SEG_MAN:%d=%s' % (x, RomeFileGetAttrValue(profile, 'MAN_PTR', x)))\n"
-        + "        print('SEG_SOIL:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SOIL_PTR', x)))\n"
-        + "        results.append(RomeFileGetAttrValue(profile, 'SEG_SOIL_LOSS', x))\n"
-        + "        print('SEG_SOIL_LOSS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_SOIL_LOSS', x)))\n"
-        + "        print('SEG_SOIL_LAYER %d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_SOIL_LAYER', x)))\n"
-        + "        print('SEG_MAN_LAYER %d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_MAN_LAYER', x)))\n"
-        + "        print('HYD_ELEM_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'HYD_ELEM_SYSTEM_PTR', x)))\n"
-        + "        print('STRIP_BARRIER_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'STRIP_BARRIER_SYSTEM_PTR', x)))\n"
-        + "        print('CONTOUR_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'CONTOUR_SYSTEM_PTR', x)))\n"
-        + "    print('------------------------------------------------------------------------------')\n");
-
-    pw.append("    numflowpaths = RomeFileGetAttrSize(profile, 'NUM_FLOW_PATHS')\n"
-        + "    print('------------------------------------------------------------------------------')\n"
-        + "    print('NUMBER OF FLOWPATHS=%d' % numflowpaths)\n"
-        + "    for xx in range (numflowpaths):\n"
-        + "        print('FLOW_PATH_HORIZ:%d=%s' % (xx, RomeFileGetAttrValue(profile, 'FLOW_PATH_HORIZ', xx)))\n"
-        + "        print('HYD_ELEM_FLOW_PATH_PTR:%d=%s' % (xx, RomeFileGetAttrValue(profile, 'HYD_ELEM_FLOW_PATH_PTR', xx)))\n"
-        + "    numsegs = RomeFileGetAttrSize(profile, 'SEGMENT')\n"
-        + "    print('NUMBER OF SEGMENTS=%d' % numsegs)\n"
-        + "    for x in range (numsegs):\n"
-        + "        print('------------------------------------------------------------------------------')\n"
-        + "        print('SEGMENT:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEGMENT', x)))\n"
-        + "        print('SEG_HORIZ:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_HORIZ', x)))\n"
-        + "        print('SEG_STEEP:%d=%s' % (x,RomeFileGetAttrValue(profile, 'SEG_STEEP', x)))\n"
-        + "        print('SEG_MAN:%d=%s' % (x, RomeFileGetAttrValue(profile, 'MAN_PTR', x)))\n"
-        + "        print('SEG_SOIL:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SOIL_PTR', x)))\n"
-        + "        results.append(RomeFileGetAttrValue(profile, 'SEG_SOIL_LOSS', x))\n"
-        + "        print('SEG_SOIL_LOSS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_SOIL_LOSS', x)))\n"
-        + "        print('SEG_SOIL_LAYER %d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_SOIL_LAYER', x)))\n"
-        + "        print('SEG_MAN_LAYER %d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_MAN_LAYER', x)))\n"
-        + "        print('HYD_ELEM_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'HYD_ELEM_SYSTEM_PTR', x)))\n"
-        + "        print('STRIP_BARRIER_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'STRIP_BARRIER_SYSTEM_PTR', x)))\n"
-        + "        print('CONTOUR_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'CONTOUR_SYSTEM_PTR', x)))\n"
-        + "    print('------------------------------------------------------------------------------')\n");
-
-    pw.append("    numflowpaths = RomeFileGetAttrSize(profile, 'NUM_FLOW_PATHS')\n"
-        + "    print('------------------------------------------------------------------------------')\n"
-        + "    print('NUMBER OF FLOWPATHS=%d' % numflowpaths)\n"
-        + "    for xx in range (numflowpaths):\n"
-        + "        print('FLOW_PATH_HORIZ:%d=%s' % (xx, RomeFileGetAttrValue(profile, 'FLOW_PATH_HORIZ', xx)))\n"
-        + "        print('HYD_ELEM_FLOW_PATH_PTR:%d=%s' % (xx, RomeFileGetAttrValue(profile, 'HYD_ELEM_FLOW_PATH_PTR', xx)))\n"
-        + "    numsegs = RomeFileGetAttrSize(profile, 'SEGMENT')\n"
-        + "    print('NUMBER OF SEGMENTS=%d' % numsegs)\n"
-        + "    for x in range (numsegs):\n"
-        + "        print('------------------------------------------------------------------------------')\n"
-        + "        print('SEGMENT:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEGMENT', x)))\n"
-        + "        print('SEG_HORIZ:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_HORIZ', x)))\n"
-        + "        print('SEG_STEEP:%d=%s' % (x,RomeFileGetAttrValue(profile, 'SEG_STEEP', x)))\n"
-        + "        print('SEG_MAN:%d=%s' % (x, RomeFileGetAttrValue(profile, 'MAN_PTR', x)))\n"
-        + "        print('SEG_SOIL:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SOIL_PTR', x)))\n"
-        + "        results.append(RomeFileGetAttrValue(profile, 'SEG_SOIL_LOSS', x))\n"
-        + "        print('SEG_SOIL_LOSS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_SOIL_LOSS', x)))\n"
-        + "        print('SEG_SOIL_LAYER %d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_SOIL_LAYER', x)))\n"
-        + "        print('SEG_MAN_LAYER %d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_MAN_LAYER', x)))\n"
-        + "        print('HYD_ELEM_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'HYD_ELEM_SYSTEM_PTR', x)))\n"
-        + "        print('STRIP_BARRIER_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'STRIP_BARRIER_SYSTEM_PTR', x)))\n"
-        + "        print('CONTOUR_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'CONTOUR_SYSTEM_PTR', x)))\n"
-        + "    print('------------------------------------------------------------------------------')\n"
-        + "    numsegs = RomeFileGetAttrSize(profile, 'SOIL_LAYER')\n"
-        + "    print('NUMBER OF SOIL SEGMENTS=%d' % numsegs)\n"
-        + "    for x in range (numsegs):\n"
-        + "        print('------------------------------------------------------------------------------')\n"
-        + "        print('SOIL_SEGMENT:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SOIL_LAYER', x)))\n"
-        + "        print('SOIL_HORIZ:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SOIL_HORIZ', x)))\n"
-        + "        print('SOIL_PTR:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SOIL_PTR', x)))\n"
-        + "    print('------------------------------------------------------------------------------')\n"
-        + "    numsegs = RomeFileGetAttrSize(profile, 'MAN_LAYER')\n"
-        + "    print('NUMBER OF MAN SEGMENTS=%d' % numsegs)\n"
-        + "    for x in range (numsegs):\n"
-        + "        print('------------------------------------------------------------------------------')\n"
-        + "        print('MAN_SEGMENT:%d=%s' % (x, RomeFileGetAttrValue(profile, 'MAN_LAYER', x)))\n"
-        + "        print('MAN_HORIZ:%d=%s' % (x, RomeFileGetAttrValue(profile, 'MAN_HORIZ', x)))\n"
-        + "        print('MAN_PTR:%d=%s' % (x, RomeFileGetAttrValue(profile, 'MAN_PTR', x)))\n"
-        + "    print('------------------------------------------------------------------------------')\n"
-        + "    numsegs = RomeFileGetAttrSize(profile, 'TOPO_LAYER')\n"
-        + "    print('NUMBER OF TOPO SEGMENTS=%d' % numsegs)\n"
-        + "    for x in range (numsegs):\n"
-        + "        print('------------------------------------------------------------------------------')\n"
-        + "        print('TOPO_SEGMENT:%d=%s' % (x, RomeFileGetAttrValue(profile, 'TOPO_LAYER', x)))\n"
-        + "        print('TOPO_HORIZ:%d=%s' % (x, RomeFileGetAttrValue(profile, 'TOPO_HORIZ', x)))\n"
-        + "        print('TOPO_HORIZ_COMPOSITE:%d=%s' % (x, RomeFileGetAttrValue(profile, 'TOPO_HORIZ_COMPOSITE', x)))\n"
-        + "        print('TOPO_STEEP:%d=%s' % (x, RomeFileGetAttrValue(profile, 'TOPO_STEEP', x)))\n"
-        + "        print('TOPO_STEEP_COMPOSITE:%d=%s' % (x, RomeFileGetAttrValue(profile, 'TOPO_STEEP_COMPOSITE', x)))\n"
-        + "    print('------------------------------------------------------------------------------')\n"
-        + "    exec(open(\"" + REPORT_PY_FILENAME + "\").read())\n"
-        + "    RomeFileClose(profile)\n"
-        + "    return results\n\n"
-        + "if __name__ == \"__main__\":\n"
-        + "    #inputs\n"
-        + "    save = False\n"
-        + "    #Run simulation\n"
-        + "    romeDLL = RomeInit('pyrome /DirRoot=" + resources().getFile(ROMEDLL).getParent().replace('\\', '/') + "/')\n"
-        + "    database = RomeGetDatabase(romeDLL)\n");
-
-    // prints all outputs in single array
-    // Specify the nginx server
-    if (!parameter().has(KEY_ALT_R2DB)) {
-      pw.append("    RomeDatabaseOpen(database,'" + r2db + "')\n");
-    } else {
-      String altr2db = r2db.substring(0, r2db.lastIndexOf("/")) + "/model-data/" + parameter().getString(KEY_ALT_R2DB);
-      pw.append("    RomeDatabaseOpen(database,'" + altr2db + "')\n");
-    }
-
-    pw.append("    results = linearTest(save)\n"
-        + "    RomeDatabaseClose(database)\n"
-        + "    RomeExit(romeDLL)\n"
-        + "    exit()\n"
-    );
-    pw.close();
-
-    // prepare individual contour system, strip barrier system, hyd elem sys, if not provided in an array
-    if (parameter().has(KEY_CONTOUR_SYSTEM_PTR)) {
-      String contourHttpPtr = r2db + "/" + contourSystem.replace("\\", "/") + ".xml";
-      r2run.prepareFileJ(contourHttpPtr, getWorkspaceFile("contour_file0.xml"), "", "contour-systems", "", true);
-    }
-    if (parameter().has(KEY_STRIP_BARRIER_SYSTEM_PTR)) {
-      String stripbarrHttpPtr = r2db + "/" + stripBarrierSystem.replace("\\", "/") + ".xml";
-      r2run.prepareFileJ(stripbarrHttpPtr, getWorkspaceFile("stripbarr_file0.xml"), "", "strip-barrier-systems", "", true);
-    }
-    if (parameter().has(KEY_HYD_ELEM_SYSTEM_PTR)) {
-      String hydelemHttpPtr = r2db + "/" + hydElemSystem.replace("\\", "/") + ".xml";
-      r2run.prepareHydraulicElementFlowPathJ(hydelemHttpPtr, r2db, getWorkspaceFile("hydelemflowpath_file.xml"));
-    }
-
-    // prepare climate file
-    r2run.prepareFileJ(climatePtr, getWorkspaceFile("cli_file0.xml"), "CLIMATE", "climates", "", true);
-
-    // Unpack the report rsh file in the work space dir 
-    FileUtils.copyFileToDirectory(resources().getFile(REPORT_PY_FILENAME), getWorkspaceDir());
-
-    climate = climatePtr;
-    soil = soilPtr[0];
-    mgmt = managementFormalName[0];
-  }
-
-
-  private String[] getSoilFiles(JSONArray cokeys) throws JSONException, Exception {
-    String soilPtr[] = new String[(cokeys.length())];
-    JSONObject soilsRequest = new JSONObject();
-    JSONObject meta = new JSONObject();
-    JSONArray paramObj = new JSONArray();
-    JSONObject cokeyObj = new JSONObject();
-
-    soilsRequest.put(KEY_METAINFO, meta);
-    soilsRequest.put(KEY_PARAMETER, paramObj);
-    paramObj.put(cokeyObj);
-
-    for (int i = 0; i < cokeys.length(); i++) {
-      String cokey = cokeys.getString(i);
-      paramObj.put(0, cokeyObj);
-      cokeyObj.put(KEY_NAME, KEY_COKEY);
-      cokeyObj.put(KEY_VALUE, cokey);
-      JSONObject soilsResponse = new Client().doPOST(Config.getString("r2.soils", "http://csip.engr.colostate.edu:8092/csip-soils/d/soilsXML/1.0"), soilsRequest);
-      if (LOG.isLoggable(Level.INFO)) {
-        LOG.info("SOILS Response: " + soilsResponse.toString());
-      }
-      JSONObject responseMeta = soilsResponse.getJSONObject(KEY_METAINFO);
-      if (!responseMeta.getString(KEY_STATUS).equalsIgnoreCase("Failed")) {
-        JSONArray resultArr = soilsResponse.getJSONArray(KEY_RESULT);
-        JSONObject soilObj = resultArr.getJSONObject(0);
-        String soilFilePath = soilObj.getString(KEY_VALUE);
-
-        new Client().doGET(soilFilePath, getWorkspaceFile("soils_file" + i + ".xml"));
-
-        soilPtr[i] = getSoilFilePath(getWorkspaceFile("soils_file" + i + ".xml")).replace("/", "\\");
-        if (LOG.isLoggable(Level.INFO)) {
-          LOG.info("THE SOIL IS =" + soilPtr[i] + "\n\n\n\n");
-        }
-      } else {
-        String error = responseMeta.getString(ERROR);
-        throw new ServiceException("Soil service error: " + error);
-      }
-    }
-    return soilPtr;
-  }
-
-
-  private String getSoilFilePath(File soilFile) throws ParserConfigurationException, SAXException, IOException {
-    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
-    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
-    Document document = documentBuilder.parse(soilFile);
-    String path = document.getElementsByTagName("Filename").item(0).getTextContent();
-    return path;
-  }
-
-
-  private String getClimateFilePath(double lat, double lon) throws JSONException, Exception {
-    JSONObject climateReq = new JSONObject();
-    JSONObject meta = new JSONObject();
-    JSONArray param = new JSONArray();
-    JSONObject jlat = new JSONObject();
-    JSONObject jlong = new JSONObject();
-    String climatePath = "";
-
-    climateReq.put(KEY_METAINFO, meta);
-    climateReq.put(KEY_PARAMETER, param);
-
-    param.put(jlat);
-    param.put(jlong);
-
-    jlat.put(KEY_NAME, KEY_LATITUDE);
-    jlat.put(KEY_VALUE, lat);
-
-    jlong.put(KEY_NAME, KEY_LONGITUDE);
-    jlong.put(KEY_VALUE, lon);
-
-    JSONObject climateResponse = new Client().doPOST(Config.getString("r2.climate", "http://csip.engr.colostate.edu:8092/csip-misc/d/r2climate/2.0"), climateReq);
-    if (LOG.isLoggable(Level.INFO)) {
-      LOG.info("CLIMATE Response: " + climateResponse.toString());
-    }
-    JSONObject responseMeta = climateResponse.getJSONObject(KEY_METAINFO);
-    if (!responseMeta.getString(KEY_STATUS).equalsIgnoreCase("Failed")) {
-      JSONArray resultArr = climateResponse.getJSONArray(KEY_RESULT);
-      JSONObject cliObj = JSONUtils.preprocess(resultArr).get(KEY_CLIMATE_URL);
-      climatePath = cliObj.getString(KEY_VALUE);
-    }
-    return climatePath;
-  }
-
-
-  @Override
-  protected void doReport() throws Exception {
-    String sReportJSON = FileUtils.readFileToString(resources().getFile(REPORT_JSON_TEMPLATE_FILENAME));
-    JSONArray reportItemsFromTemplate = new JSONArray(sReportJSON);
-    for (int i = 0; i < reportItemsFromTemplate.length(); i++) {
-      JSONObject obj = (JSONObject) reportItemsFromTemplate.get(i);
-      String itemName = obj.getString(REPORT_NAME);
-      String dimension = JSONUtils.getJSONString(obj, REPORT_DIM, null);
-      String type = JSONUtils.getJSONString(obj, REPORT_TYPE, "");
-      String units = JSONUtils.getJSONString(obj, REPORT_UNITS, null);
-      String desc = JSONUtils.getJSONString(obj, REPORT_DESC, null);
-      if (LOG.isLoggable(Level.INFO)) {
-        LOG.info("--------------------PROCESSING ELEMENT:");
-        LOG.info("VAR NAME:" + itemName);
-        LOG.info("---------------------------------------");
-      }
-
-      //String value = r2run.getResultPyrome(itemName);
-      String value = r2run.getResult("\"" + itemName + "\"");
-      LOG.info("the value='" + value + "'");
-      if ((value != null) && (value.equals("null"))) {
-        report().put(itemName, (String) null, desc, units);
-        // if there is no value, then item should be removed from the array
-      } else {
-        if ((dimension != null) && (dimension.length() > 0) && (value != null) && (!value.equals("null"))) {
-          try {
-            report().put(itemName, new JSONArray(value), desc, units);
-          } catch (JSONException je) {
-            processReportElement(itemName, dimension, units, desc, type, value);
-          }
-        } else {
-          processReportElement(itemName, dimension, units, desc, type, value);
-        }
-      }
-      if (dimension != null) {
-        report().putMetaInfo(itemName, REPORT_DIM, new JSONArray(dimension));
-      }
-    }
-  }
-
-
-  // This is a gross signiture but due to csip report changes this is the easiest way to change it without losing Wes's logic.
-  private void processReportElement(String itemName, String dim, String units, String desc, String type, String value) throws Exception {
-    if (LOG.isLoggable(Level.INFO)) {
-      LOG.info("------------------------------------PROCESSING ELEMENT:\n\n");
-      LOG.info("TYPE:" + type);
-      LOG.info("VALUE:" + value);
-      LOG.info("------------------------------------\n\n");
-    }
-    if ((type.equals("TEXT")) || (type.equals("FILENAME")) || (type.equals("DATE"))) {
-      // because the RomeShell returns escaped strings, and the JSONObject in Java re-escapes them
-      // we have to remove one level of "escaping" !!! 
-      String newString = StringEscapeUtils.unescapeJava(value);
-      //String newString=value;
-      report().put(itemName, Services.removeFirstLastChar(newString), desc, units);
-    }
-    if (type.equals("INTEGER") && (value != null) && (!value.equals("null")) && (!value.equals("\"\""))) {
-      // trim off quotes
-      value = Services.removeFirstLastChar(value);
-      report().put(itemName, new Double(value).intValue(), desc, units);
-    }
-    if (type.equals("REAL") && (value != null)) {
-      if ((!value.equals("null")) && (!value.equals("\"\""))) {
-        // trim off quotes
-        value = Services.removeFirstLastChar(value);
-        report().put(itemName, Double.parseDouble(value), desc, units);
-      }
-      if (value.equals("\"\"")) {
-        report().put(itemName, new Double(0), desc, units);
-      }
-    }
-    if (type.equals("")) {
-      report().put(itemName, value, desc, units);
-    }
-  }
 }

src/java/m/rusle2/V3_0.java

@@ -14,61 +14,69 @@
 import csip.Client;
 import csip.Config;
 import csip.Executable;
-import csip.ServiceException;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.util.*;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.codehaus.jettison.json.JSONArray;
-import org.codehaus.jettison.json.JSONObject;
-import org.codehaus.jettison.json.JSONException;
-import org.w3c.dom.Document;
-import org.w3c.dom.NodeList;
 import csip.ModelDataService;
+import static csip.ModelDataService.ERROR;
+import static csip.ModelDataService.KEY_METAINFO;
+import static csip.ModelDataService.KEY_NAME;
+import static csip.ModelDataService.KEY_PARAMETER;
 import static csip.ModelDataService.KEY_REQUEST_RESULTS;
+import static csip.ModelDataService.KEY_RESULT;
+import static csip.ModelDataService.KEY_STATUS;
+import static csip.ModelDataService.KEY_VALUE;
+import static csip.ModelDataService.REPORT_DESC;
 import static csip.ModelDataService.REPORT_DIM;
 import static csip.ModelDataService.REPORT_NAME;
 import static csip.ModelDataService.REPORT_TYPE;
+import static csip.ModelDataService.REPORT_UNITS;
 import static csip.ModelDataService.VALUE;
+import csip.ServiceException;
+import static csip.Utils.removeFirstLastChar;
 import csip.annotations.*;
 import static csip.annotations.ResourceType.ARCHIVE;
 import static csip.annotations.ResourceType.FILE;
 import static csip.annotations.ResourceType.REFERENCE;
 import static csip.annotations.State.RELEASED;
-import static util.Constants.*;
-
 import csip.utils.JSONUtils;
-import csip.utils.Services;
+import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.util.*;
 import java.util.logging.Level;
 import javax.ws.rs.Path;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 import static m.rusle2.V3_0.*;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
+import static util.Constants.*;
 
 /**
  * REST Web Service. Front end callable.
  *
  * @author wlloyd, od
  */
-@Name("Rusle2")
-@Description("IET / pyrome version of RomeDLL 2.6.8.4; references NRCS Soil Data Mart")
-@VersionInfo("3.0")
-@State(RELEASED)
-@Path("m/rusle2/3.0")
-@Polling(first = 1000, next = 1000)
+@Name( "Rusle2" )
+@Description( "IET / pyrome version of RomeDLL 2.6.8.4; references NRCS Soil Data Mart" )
+@VersionInfo( "3.0" )
+@State( RELEASED )
+@Path( "m/rusle2/3.0" )
+@Polling( first = 1000, next = 1000 )
 
-@Resource(type = FILE, file = "/bin/win-x86/2.6.8.4/RomeDLL.dll", id = ROMEDLL)
-@Resource(type = FILE, file = "/bin/win-x86/2.6.8.4/pyrome.py", id = PYROMESRC)
-@Resource(type = FILE, file = "/bin/win-x86/2.6.8.4/_pyrome.pyd", id = PYROME)
-@Resource(type = ARCHIVE, file = "/bin/win-x86/Python34.zip", id = PYTHONZIP)
-@Resource(type = REFERENCE, file = "${csip.dir}/bin/win-x86/Python34/python.exe", wine = true, id = PYTHON)
+@Resource( type = FILE, file = "/bin/win-x86/2.6.8.4/RomeDLL.dll", id = ROMEDLL )
+@Resource( type = FILE, file = "/bin/win-x86/2.6.8.4/pyrome.py", id = PYROMESRC )
+@Resource( type = FILE, file = "/bin/win-x86/2.6.8.4/_pyrome.pyd", id = PYROME )
+@Resource( type = ARCHIVE, file = "/bin/win-x86/Python34.zip", id = PYTHONZIP )
+@Resource( type = REFERENCE, file = "${csip.dir}/bin/win-x86/Python34/python.exe", wine = true, id = PYTHON )
 
-@Resource(type = FILE, file = "/bin/win-x86/rusle2_report.py", id = REPORT_PY_FILENAME)
-@Resource(type = FILE, file = "/bin/win-x86/Rusle2_Report.json", id = REPORT_JSON_TEMPLATE_FILENAME)
+@Resource( type = FILE, file = "/bin/win-x86/rusle2_report.py", id = REPORT_PY_FILENAME )
+@Resource( type = FILE, file = "/bin/win-x86/Rusle2_Report.json", id = REPORT_JSON_TEMPLATE_FILENAME )
 
 public class V3_0 extends ModelDataService {
 
@@ -91,7 +99,7 @@
      * The R2 Run
      */
     final R2Run r2run = new R2Run();
-    static final List<String> potResults = Collections.unmodifiableList(Arrays.asList(
+    static final List<String> potResults = Collections.unmodifiableList( Arrays.asList(
             RES_SLOPE_DELIVERY,
             RES_SLOPE_T_VALUE,
             RES_SLOPE_DEGRAD,
@@ -107,7 +115,7 @@
             RES_SURF_RES_OUTPUTS_SURF_COV_AT_OP,
             RES_SOIL_COND_INDEX_OM_SUBFACTOR,
             RES_SOIL_COND_INDEX_FO_SUBFACTOR,
-            RES_SOIL_COND_INDEX_ER_SUBFACTOR));
+            RES_SOIL_COND_INDEX_ER_SUBFACTOR ) );
     //
     String climate;
     String soil;
@@ -124,158 +132,158 @@
     protected String climatePtr;
 
     //
+    @Override
+    protected void preProcess () throws Exception {
+        // check for requested output.
+        r2run.setLogger( LOG );
+        try {
+            LOG.info( "\n\n\n\n\nMETAINFO:" );
+            LOG.info( "\n" + getMetainfo().toString() );
+            LOG.info( "\n\n\n" );
+            JSONUtils.checkValidResultRequest( getMetainfo(), potResults );
+        }
+        catch ( ServiceException se ) {
+            LOG.severe( "\n\n\nERROR!!!\n\n\n" + se.toString() );
+            LOG.warning( "No Rusle2 return parameters requested! Will use defaults: SLOPE_DELIVERY, SLOPE_T_VALUE, SLOPE_DEGRAD" );
+            List<String> params = new LinkedList<String>();
+            params.add( RES_SLOPE_DELIVERY );
+            params.add( RES_SLOPE_T_VALUE );
+            params.add( RES_SLOPE_DEGRAD );
+
+            // check if these are being set
+            if ( JSONUtils.checkKeyExistsB( getParamMap(), KEY_CONTOUR_SYSTEM_PTR ) ) {
+                params.add( "CONTOUR_SYSTEM_PTR" );
+            }
+
+            if ( JSONUtils.checkKeyExistsB( getParamMap(), KEY_STRIP_BARRIER_SYSTEM_PTR ) ) {
+                params.add( "STRIP_BARRIER_SYSTEM_PTR" );
+            }
+
+            if ( JSONUtils.checkKeyExistsB( getParamMap(), KEY_HYD_ELEM_SYSTEM_PTR ) ) {
+                params.add( "HYD_ELEM_SYSTEM_PTR" );
+            }
+            getMetainfo().put( KEY_REQUEST_RESULTS, params );
+        }
+
+        JSONUtils.checkKeyExists( getParamMap(), KEY_SOILS );
+        JSONUtils.checkKeyExists( getParamMap(), KEY_LENGTH );
+        JSONUtils.checkKeyExists( getParamMap(), KEY_STEEPNESS );
+        JSONUtils.checkKeyExists( getParamMap(), KEY_MGMTS );
+
+        if ( !r2run.isUrlReachable( "climates/default.xml" ) ) {
+            throw new ServiceException( "R2 file server unreachable at: " + Config.getString( "r2.db", "http://oms-db.engr.colostate.edu/r2" ) );
+        }
+
+        File r2script = new File( getWorkspaceDir(), R2_TMP_FILENAME + R2_TMP_FILEEXT );
+        createInputFile( r2script, getMetainfo(), getParamMap() );
+    }
 
     @Override
-    protected void preProcess() throws Exception {
-        // check for requested output.
-        r2run.setLogger(LOG);
+    protected void doProcess () throws Exception {
         try {
-            LOG.info("\n\n\n\n\nMETAINFO:");
-            LOG.info("\n" + getMetainfo().toString());
-            LOG.info("\n\n\n");
-            JSONUtils.checkValidResultRequest(getMetainfo(), potResults);
-        } catch (ServiceException se) {
-            LOG.severe("\n\n\nERROR!!!\n\n\n" + se.toString());
-            LOG.warning("No Rusle2 return parameters requested! Will use defaults: SLOPE_DELIVERY, SLOPE_T_VALUE, SLOPE_DEGRAD");
-            List<String> params = new LinkedList<String>();
-            params.add(RES_SLOPE_DELIVERY);
-            params.add(RES_SLOPE_T_VALUE);
-            params.add(RES_SLOPE_DEGRAD);
-
-            // check if these are being set
-            if (JSONUtils.checkKeyExistsB(getParamMap(), KEY_CONTOUR_SYSTEM_PTR)) {
-                params.add("CONTOUR_SYSTEM_PTR");
-            }
-
-            if (JSONUtils.checkKeyExistsB(getParamMap(), KEY_STRIP_BARRIER_SYSTEM_PTR)) {
-                params.add("STRIP_BARRIER_SYSTEM_PTR");
-            }
-
-            if (JSONUtils.checkKeyExistsB(getParamMap(), KEY_HYD_ELEM_SYSTEM_PTR)) {
-                params.add("HYD_ELEM_SYSTEM_PTR");
-            }
-            getMetainfo().put(KEY_REQUEST_RESULTS, params);
+            Executable python = resources().getExe( V3_0.PYTHON );
+            LOG.log( Level.INFO, "EXECUTING PYROME FROM doProcess()..." );
+            int result = r2run.executePyrome( new File( getWorkspaceDir(), R2_TMP_FILENAME + R2_TMP_FILEEXT ), python );
         }
-
-        JSONUtils.checkKeyExists(getParamMap(), KEY_SOILS);
-        JSONUtils.checkKeyExists(getParamMap(), KEY_LENGTH);
-        JSONUtils.checkKeyExists(getParamMap(), KEY_STEEPNESS);
-        JSONUtils.checkKeyExists(getParamMap(), KEY_MGMTS);
-        
-        if(!r2run.isUrlReachable("climates/default.xml"))
-            throw new ServiceException("R2 file server unreachable at: " + Config.getString("r2.db", "http://oms-db.engr.colostate.edu/r2"));
-
-        File r2script = new File(getWorkspaceDir(), R2_TMP_FILENAME + R2_TMP_FILEEXT);
-        createInputFile(r2script, getMetainfo(), getParamMap());
-    }
-
-
-    @Override
-    protected void doProcess() throws Exception {
-        try {
-            Executable python = resources().getExe(V3_0.PYTHON);
-            LOG.log(Level.INFO, "EXECUTING PYROME FROM doProcess()...");
-            int result = r2run.executePyrome(new File(getWorkspaceDir(), R2_TMP_FILENAME + R2_TMP_FILEEXT), python);
-        } catch (Exception e) {
-            LOG.log(Level.SEVERE, "ERROR EXECUTING PYTHON-RUSLE2", e);
+        catch ( Exception e ) {
+            LOG.log( Level.SEVERE, "ERROR EXECUTING PYTHON-RUSLE2", e );
             throw e;
         }
     }
 
-
     @Override
-    protected void postProcess() throws Exception {
+    protected void postProcess () throws Exception {
         int errors = 0;
-        for (int i = 0; i < operations.size(); i++) {
-            String op = operations.get(i);
-            if (r2run.isFileUrlReachable(op)) {
-                results().put("OPERATION_" + (i + 1), op, "operation is valid");
+        for ( int i = 0; i < operations.size(); i++ ) {
+            String op = operations.get( i );
+            if ( r2run.isFileUrlReachable( op ) ) {
+                results().put( "OPERATION_" + ( i + 1 ), op, "operation is valid" );
             } else {
-                results().put("OPERATION_INVALID_" + (i + 1), op, "OPERATION IS MISSING!");
+                results().put( "OPERATION_INVALID_" + ( i + 1 ), op, "OPERATION IS MISSING!" );
                 errors++;
             }
         }
-        for (int i = 0; i < vegetations.size(); i++) {
-            String vege = vegetations.get(i);
-            if (r2run.isFileUrlReachable(vege)) {
-                results().put("VEGETATION_" + (i + 1),vege,"vegetation is valid");
+        for ( int i = 0; i < vegetations.size(); i++ ) {
+            String vege = vegetations.get( i );
+            if ( r2run.isFileUrlReachable( vege ) ) {
+                results().put( "VEGETATION_" + ( i + 1 ), vege, "vegetation is valid" );
             } else {
-                results().put("VEGETATION_INVALID_" + (i + 1), vege, "VEGETATION IS MISSING");
+                results().put( "VEGETATION_INVALID_" + ( i + 1 ), vege, "VEGETATION IS MISSING" );
                 errors++;
             }
         }
-        for (int i = 0; i < residues.size(); i++) {
-            String res = residues.get(i);
-            if (r2run.isFileUrlReachable(res)) {
-                results().put("RESIDUE_" + (i + 1), res, "residue is valid");
+        for ( int i = 0; i < residues.size(); i++ ) {
+            String res = residues.get( i );
+            if ( r2run.isFileUrlReachable( res ) ) {
+                results().put( "RESIDUE_" + ( i + 1 ), res, "residue is valid" );
             } else {
-                results().put("RESIDUE_INVALID_" + (i + 1), res, "RESIDUE IS MISSING");
+                results().put( "RESIDUE_INVALID_" + ( i + 1 ), res, "RESIDUE IS MISSING" );
                 errors++;
             }
         }
 
 //      results.put(JSONUtils.data(KEY_SLOPE_DELIVERY, 3.0));
-        for (String r : JSONUtils.getRequestedResults(getMetainfo())) {
-            if ((errors > 0) && (r.equals(RES_SLOPE_DEGRAD))) {
-                results().put(r, r2run.getResultPyrome(r), R2_MISSING_XML_FILES_WARNING_MSG);
+        for ( String r : JSONUtils.getRequestedResults( getMetainfo() ) ) {
+            if ( ( errors > 0 ) && ( r.equals( RES_SLOPE_DEGRAD ) ) ) {
+                results().put( r, r2run.getResultPyrome( r ), R2_MISSING_XML_FILES_WARNING_MSG );
             } else {
-                results().put(r, r2run.getResultPyrome(r));
+                results().put( r, r2run.getResultPyrome( r ) );
             }
         }
 
-         // Get erosion for segments
-        if (JSONUtils.checkKeyExistsB(getParamMap(), KEY_TOPO_LENGTH)) {
-            JSONArray aTopoLength = JSONUtils.getJSONArrayParam(getParamMap(), KEY_TOPO_LENGTH);
-            if (aTopoLength.length() > 0) {
-                JSONArray aSoilLoss = new JSONArray(r2run.getResultPyromeArray("SEG_SOIL_LOSS", false, false, true));
-                results().put("SEG_SOIL_LOSS", aSoilLoss);
-                results().put(KEY_CLIMATES, climate);
-                LOG.info("\n\n\n\n\n\nSEG SOIL OUTPUT=" + r2run.getResultPyromeArray("SEG_SOIL", true, true, true) + "\n\n\n\n");
-                LOG.info("\n\n\n\n\n\nSEG SOIL OUTPUT=" + r2run.getResultPyromeArray("SEG_MAN", true, true, true) + "\n\n\n\n");
-                results().put(KEY_SOILS, new JSONArray(r2run.getResultPyromeArray("SEG_SOIL", true, true, true)));
-                results().put(KEY_MANAGEMENTS, new JSONArray(r2run.getResultPyromeArray("SEG_MAN", true, true, true)));
-                if (JSONUtils.checkKeyExistsB(getParamMap(), KEY_DIVERSIONS)) 
-                    results().put(KEY_DIVERSIONS, r2run.getResultPyromeArray("HYD_ELEM_SYS", true, true, true));
-                
-                if (JSONUtils.checkKeyExistsB(getParamMap(), KEY_STRIP_BARRIER_SYSTEMS)) {
-                    results().put(KEY_STRIP_BARRIER_SYSTEMS, r2run.getResultPyromeArray("STRIP_BARRIER_SYS", true, true, true));
+        // Get erosion for segments
+        if ( JSONUtils.checkKeyExistsB( getParamMap(), KEY_TOPO_LENGTH ) ) {
+            JSONArray aTopoLength = JSONUtils.getJSONArrayParam( getParamMap(), KEY_TOPO_LENGTH );
+            if ( aTopoLength.length() > 0 ) {
+                JSONArray aSoilLoss = new JSONArray( r2run.getResultPyromeArray( "SEG_SOIL_LOSS", false, false, true ) );
+                results().put( "SEG_SOIL_LOSS", aSoilLoss );
+                results().put( KEY_CLIMATES, climate );
+                LOG.info( "\n\n\n\n\n\nSEG SOIL OUTPUT=" + r2run.getResultPyromeArray( "SEG_SOIL", true, true, true ) + "\n\n\n\n" );
+                LOG.info( "\n\n\n\n\n\nSEG SOIL OUTPUT=" + r2run.getResultPyromeArray( "SEG_MAN", true, true, true ) + "\n\n\n\n" );
+                results().put( KEY_SOILS, new JSONArray( r2run.getResultPyromeArray( "SEG_SOIL", true, true, true ) ) );
+                results().put( KEY_MANAGEMENTS, new JSONArray( r2run.getResultPyromeArray( "SEG_MAN", true, true, true ) ) );
+                if ( JSONUtils.checkKeyExistsB( getParamMap(), KEY_DIVERSIONS ) ) {
+                    results().put( KEY_DIVERSIONS, r2run.getResultPyromeArray( "HYD_ELEM_SYS", true, true, true ) );
+                }
+
+                if ( JSONUtils.checkKeyExistsB( getParamMap(), KEY_STRIP_BARRIER_SYSTEMS ) ) {
+                    results().put( KEY_STRIP_BARRIER_SYSTEMS, r2run.getResultPyromeArray( "STRIP_BARRIER_SYS", true, true, true ) );
                 }
             }
         } else {
-            results().put(KEY_CLIMATES, climate);
-            results().put(KEY_SOILS, new JSONArray(r2run.getResultPyromeArray("SEG_SOIL", true, true, true)));
-            results().put(KEY_MANAGEMENTS, new JSONArray(r2run.getResultPyromeArray("SEG_MAN", true, true, true)));
+            results().put( KEY_CLIMATES, climate );
+            results().put( KEY_SOILS, new JSONArray( r2run.getResultPyromeArray( "SEG_SOIL", true, true, true ) ) );
+            results().put( KEY_MANAGEMENTS, new JSONArray( r2run.getResultPyromeArray( "SEG_MAN", true, true, true ) ) );
         }
     }
 
-
-    protected void createInputFile(File file, JSONObject metainfo, Map<String, JSONObject> param)
+    protected void createInputFile ( File file, JSONObject metainfo, Map<String, JSONObject> param )
             throws Exception {
 
-        steepness = JSONUtils.getDoubleParam(param, KEY_STEEPNESS, 0.0);
-        length = JSONUtils.getDoubleParam(param, KEY_LENGTH, 0.0);
-        boolean resolveLoc = JSONUtils.getBooleanParam(param, KEY_RESOLVE_LOCATION, false);
-        double latitude = JSONUtils.getDoubleParam(param, KEY_LATITUDE, 0.0);
-        double longitude = JSONUtils.getDoubleParam(param, KEY_LONGITUDE, 0.0);
-        double simpleRockCoverPercent = JSONUtils.getDoubleParam(param, KEY_SIMPLE_ROCK_COVER, 0.0);
+        steepness = JSONUtils.getDoubleParam( param, KEY_STEEPNESS, 0.0 );
+        length = JSONUtils.getDoubleParam( param, KEY_LENGTH, 0.0 );
+        boolean resolveLoc = JSONUtils.getBooleanParam( param, KEY_RESOLVE_LOCATION, false );
+        double latitude = JSONUtils.getDoubleParam( param, KEY_LATITUDE, 0.0 );
+        double longitude = JSONUtils.getDoubleParam( param, KEY_LONGITUDE, 0.0 );
+        double simpleRockCoverPercent = JSONUtils.getDoubleParam( param, KEY_SIMPLE_ROCK_COVER, 0.0 );
 
-        LOG.info("Rock cover read by service is=" + simpleRockCoverPercent);
+        LOG.info( "Rock cover read by service is=" + simpleRockCoverPercent );
 
-        JSONArray aRockCover = JSONUtils.getJSONArrayParam(param, KEY_SIMPLE_ROCK_COVER);
-        for (int i = 0; i < aRockCover.length(); i++) {
-            LOG.info("Rock cover [" + i + "]=" + aRockCover.getDouble(i));
+        JSONArray aRockCover = JSONUtils.getJSONArrayParam( param, KEY_SIMPLE_ROCK_COVER );
+        for ( int i = 0; i < aRockCover.length(); i++ ) {
+            LOG.info( "Rock cover [" + i + "]=" + aRockCover.getDouble( i ) );
             // this is temporary, since R2 will be using slope segments soon
-            if (i == 0) {
-                simpleRockCoverPercent = aRockCover.getDouble(i);
+            if ( i == 0 ) {
+                simpleRockCoverPercent = aRockCover.getDouble( i );
             }
         }
 
-        climatePtr = JSONUtils.getStringParam(param, KEY_CLIMATES, "");
+        climatePtr = JSONUtils.getStringParam( param, KEY_CLIMATES, "" );
 
-        aSoils = JSONUtils.getJSONArrayParam(param, KEY_SOILS);
-        String soilPtr[] = new String[(aSoils.length())];
-        for (int i = 0; i < aSoils.length(); i++) {
-            LOG.info("soil [" + i + "]=" + aSoils.getInt(i));
+        aSoils = JSONUtils.getJSONArrayParam( param, KEY_SOILS );
+        String soilPtr[] = new String[( aSoils.length() )];
+        for ( int i = 0; i < aSoils.length(); i++ ) {
+            LOG.info( "soil [" + i + "]=" + aSoils.getInt( i ) );
             // this is temporary, since R2 will be using slope segments soon
 //            if (i==0)
 //                soilPtr = Integer.toString(aSoils.getInt(i));
@@ -290,18 +298,18 @@
         String hydElemSystem = "";
 
         // Get the Contour System if not default
-        if (JSONUtils.checkKeyExistsB(param, KEY_CONTOUR_SYSTEM_PTR)) {
-            contourSystem = JSONUtils.getStringParam(param, KEY_CONTOUR_SYSTEM_PTR, "");
+        if ( JSONUtils.checkKeyExistsB( param, KEY_CONTOUR_SYSTEM_PTR ) ) {
+            contourSystem = JSONUtils.getStringParam( param, KEY_CONTOUR_SYSTEM_PTR, "" );
         }
 
         // Get the Strip Barrier System
-        if (JSONUtils.checkKeyExistsB(param, KEY_STRIP_BARRIER_SYSTEM_PTR)) {
-            stripBarrierSystem = JSONUtils.getStringParam(param, KEY_STRIP_BARRIER_SYSTEM_PTR, "");
+        if ( JSONUtils.checkKeyExistsB( param, KEY_STRIP_BARRIER_SYSTEM_PTR ) ) {
+            stripBarrierSystem = JSONUtils.getStringParam( param, KEY_STRIP_BARRIER_SYSTEM_PTR, "" );
         }
 
-        // Get the Hydraylic Element System Pointer  
-        if (JSONUtils.checkKeyExistsB(param, KEY_HYD_ELEM_SYSTEM_PTR)) {
-            hydElemSystem = JSONUtils.getStringParam(param, KEY_HYD_ELEM_SYSTEM_PTR, "");
+        // Get the Hydraylic Element System Pointer
+        if ( JSONUtils.checkKeyExistsB( param, KEY_HYD_ELEM_SYSTEM_PTR ) ) {
+            hydElemSystem = JSONUtils.getStringParam( param, KEY_HYD_ELEM_SYSTEM_PTR, "" );
         }
 
         JSONArray aTopoLength = new JSONArray();
@@ -312,10 +320,10 @@
 //        JSONArray aDiversionIdx = new JSONArray();
 //        JSONArray aContourIdx = new JSONArray();
 //        JSONArray aStripBarrierIdx = new JSONArray();
-        if (JSONUtils.checkKeyExistsB(param, KEY_TOPO_LENGTH)) {
-            aTopoLength = JSONUtils.getJSONArrayParam(param, KEY_TOPO_LENGTH);
-            for (int i = 0; i < aTopoLength.length(); i++) {
-                LOG.info("Topo Length [" + i + "]=" + aTopoLength.getDouble(i));
+        if ( JSONUtils.checkKeyExistsB( param, KEY_TOPO_LENGTH ) ) {
+            aTopoLength = JSONUtils.getJSONArrayParam( param, KEY_TOPO_LENGTH );
+            for ( int i = 0; i < aTopoLength.length(); i++ ) {
+                LOG.info( "Topo Length [" + i + "]=" + aTopoLength.getDouble( i ) );
 //                // this is temporary, since R2 will be using slope segments soon
 //                if (i == 0) {
 //                    length = aTopoLength.getDouble(i);
@@ -323,38 +331,38 @@
             }
         }
 
-        if (JSONUtils.checkKeyExistsB(param, KEY_TOPO_STEEPNESS)) {
-            aTopoSteepness = JSONUtils.getJSONArrayParam(param, KEY_TOPO_STEEPNESS);
-            for (int i = 0; i < aTopoSteepness.length(); i++) {
-                LOG.info("Topo Steepness [" + i + "]=" + aTopoSteepness.getDouble(i));
+        if ( JSONUtils.checkKeyExistsB( param, KEY_TOPO_STEEPNESS ) ) {
+            aTopoSteepness = JSONUtils.getJSONArrayParam( param, KEY_TOPO_STEEPNESS );
+            for ( int i = 0; i < aTopoSteepness.length(); i++ ) {
+                LOG.info( "Topo Steepness [" + i + "]=" + aTopoSteepness.getDouble( i ) );
 //                if (i == 0) {
 //                    steepness = aTopoSteepness.getDouble(i);
 //                }
             }
         }
 
-        if (JSONUtils.checkKeyExistsB(param, KEY_SOIL_INDEX)) {
-            aSoilIdx = JSONUtils.getJSONArrayParam(param, KEY_SOIL_INDEX);
-            for (int i = 0; i < aSoilIdx.length(); i++) {
-                LOG.info("Soil Index [" + i + "]=" + aSoilIdx.getInt(i));
+        if ( JSONUtils.checkKeyExistsB( param, KEY_SOIL_INDEX ) ) {
+            aSoilIdx = JSONUtils.getJSONArrayParam( param, KEY_SOIL_INDEX );
+            for ( int i = 0; i < aSoilIdx.length(); i++ ) {
+                LOG.info( "Soil Index [" + i + "]=" + aSoilIdx.getInt( i ) );
                 //            if (i==0)
                 //                steepness = aSoilIdx.getInt(i);
             }
         }
 
-        if (JSONUtils.checkKeyExistsB(param, KEY_MAN_INDEX)) {
-            aManIdx = JSONUtils.getJSONArrayParam(param, KEY_MAN_INDEX);
-            for (int i = 0; i < aManIdx.length(); i++) {
-                LOG.info("Man Index [" + i + "]=" + aManIdx.getInt(i));
+        if ( JSONUtils.checkKeyExistsB( param, KEY_MAN_INDEX ) ) {
+            aManIdx = JSONUtils.getJSONArrayParam( param, KEY_MAN_INDEX );
+            for ( int i = 0; i < aManIdx.length(); i++ ) {
+                LOG.info( "Man Index [" + i + "]=" + aManIdx.getInt( i ) );
                 //            if (i==0)
                 //                steepness = aTopoSteepness.getDouble(i);
             }
         }
 
-        if (JSONUtils.checkKeyExistsB(param, KEY_MAN_LENGTH)) {
-            aManLength = JSONUtils.getJSONArrayParam(param, KEY_MAN_LENGTH);
-            for (int i = 0; i < aManLength.length(); i++) {
-                LOG.info("Man Length [" + i + "]=" + aManLength.getInt(i));
+        if ( JSONUtils.checkKeyExistsB( param, KEY_MAN_LENGTH ) ) {
+            aManLength = JSONUtils.getJSONArrayParam( param, KEY_MAN_LENGTH );
+            for ( int i = 0; i < aManLength.length(); i++ ) {
+                LOG.info( "Man Length [" + i + "]=" + aManLength.getInt( i ) );
             }
         }
 
@@ -376,20 +384,20 @@
 //                LOG.info("Strip Barrier Index [" + i + "]=" + aStripBarrierIdx.getInt(i));
 //            }
 //        }
-        if (JSONUtils.checkKeyExistsB(param, KEY_TOPO_LENGTH)) {
-            if (!allEqual(aTopoLength.length(), aTopoSteepness.length())) {
-                throw new ServiceException("RUSLE2 SEGMENT RUN ERROR! SEGMENT ARRAYS FOR TOPO LENGTH AND TOPO STEEPNESS MUST BE OF EQUAL SIZE!");
+        if ( JSONUtils.checkKeyExistsB( param, KEY_TOPO_LENGTH ) ) {
+            if ( !allEqual( aTopoLength.length(), aTopoSteepness.length() ) ) {
+                throw new ServiceException( "RUSLE2 SEGMENT RUN ERROR! SEGMENT ARRAYS FOR TOPO LENGTH AND TOPO STEEPNESS MUST BE OF EQUAL SIZE!" );
             }
         }
 
-        if (JSONUtils.checkKeyExistsB(param, KEY_MAN_INDEX)) {
-            if (!allEqual(aManLength.length(), aManIdx.length())) {
-                throw new ServiceException("RUSLE2 SEGMENT RUN ERROR! SEGMENT ARRAYS FOR MGMT LENGTH AND MGMT INDEX MUST BE OF EQUAL SIZE!");
+        if ( JSONUtils.checkKeyExistsB( param, KEY_MAN_INDEX ) ) {
+            if ( !allEqual( aManLength.length(), aManIdx.length() ) ) {
+                throw new ServiceException( "RUSLE2 SEGMENT RUN ERROR! SEGMENT ARRAYS FOR MGMT LENGTH AND MGMT INDEX MUST BE OF EQUAL SIZE!" );
             }
         }
 
         //soilPtr = JSONUtils.getStringParam(param, KEY_SOILS, "");
-        String managementFormalName[] = new String[]{};
+        String managementFormalName[] = new String[] {};
 
 //        String mgmtPtr = JSONUtils.getStringParam(param, KEY_MANAGEMENTS, "");
 //        if (!mgmtPtr.startsWith("managements\\")) {
@@ -397,24 +405,24 @@
 //        }
         // management conversion
         // Make file line separator unix compatible. ???? not sure if needed.
-        System.setProperty("line.separator", "\n");
+        System.setProperty( "line.separator", "\n" );
         //
-        managements = JSONUtils.getJSONArrayParam(param, KEY_MGMTS);
+        managements = JSONUtils.getJSONArrayParam( param, KEY_MGMTS );
 
-        LOG.info("managements array=" + managements.toString());
+        LOG.info( "managements array=" + managements.toString() );
         managementFormalName = new String[managements.length()];
 
-        for (int i = 0; i < managements.length(); i++) {
-            LOG.info("management #" + i);
+        for ( int i = 0; i < managements.length(); i++ ) {
+            LOG.info( "management #" + i );
 
-            JSONObject lmod = (JSONObject) managements.get(i);
-            LOG.info(lmod.toString());
+            JSONObject lmod = ( JSONObject ) managements.get( i );
+            LOG.info( lmod.toString() );
 
-            LOG.info("creating Jim's translator.");
+            LOG.info( "creating Jim's translator." );
             lmod2rusle2.Rusle2Translator translator = new lmod2rusle2.Rusle2Translator();
-            LOG.info("trying to put in the lmod json");
-            translator.readJsonString(lmod.toString());
-            LOG.info("trying to translate=" + translator.Translate());
+            LOG.info( "trying to put in the lmod json" );
+            translator.readJsonString( lmod.toString() );
+            LOG.info( "trying to translate=" + translator.Translate() );
 
 //            // extract the element as JSON
 //            Document lmod_xml = Lmod2Rusle2.readJSON(lmod, false);
@@ -422,47 +430,47 @@
 //            Document r2_xml = Lmod2Rusle2.LmodXmlToRusle2Xml(lmod_xml, "F");
             Document r2_xml = translator.getDocument();
 
-            LOG.info("R2 XML FILE from trhe translator:\n\n" + translator.getRusle2Xml());
-            LOG.info("R2 XML FILE:\n\n" + translator.getRusle2Xml());
+            LOG.info( "R2 XML FILE from trhe translator:\n\n" + translator.getRusle2Xml() );
+            LOG.info( "R2 XML FILE:\n\n" + translator.getRusle2Xml() );
             //LOG.info("LMOD XML FILE:\n\n" + lmod_xml.getTextContent());
 
 //            if ((lmod_xml != null) && (lmod_xml.getElementById("Filename") != null))
 //                managementFormalName[i] = lmod_xml.getElementById("Filename").getTextContent();
-            if ((r2_xml != null) && (r2_xml.getElementsByTagName("Filename") != null)) {
-                NodeList nl = r2_xml.getElementsByTagName("Filename");
-                for (int ii = 0; ii < nl.getLength(); ii++) {
-                    LOG.info("filename node=" + nl.item(ii).getTextContent());
-                    managementFormalName[i] = nl.item(ii).getTextContent();
+            if ( ( r2_xml != null ) && ( r2_xml.getElementsByTagName( "Filename" ) != null ) ) {
+                NodeList nl = r2_xml.getElementsByTagName( "Filename" );
+                for ( int ii = 0; ii < nl.getLength(); ii++ ) {
+                    LOG.info( "filename node=" + nl.item( ii ).getTextContent() );
+                    managementFormalName[i] = nl.item( ii ).getTextContent();
                 }
             }
-            translator.writeRusle2Xml(getWorkspaceDir().toString(), "lmod_file" + i + ".xml");
+            translator.writeRusle2Xml( getWorkspaceDir().toString(), "lmod_file" + i + ".xml" );
             operations = translator.getOperationFiles();
             vegetations = translator.getVegetationFiles();
             residues = translator.getResidueFiles();
 
-            for (String operation : translator.getOperationFiles()) {
-                System.out.println("operation=" + operation);
+            for ( String operation : translator.getOperationFiles() ) {
+                System.out.println( "operation=" + operation );
             }
-            for (String vege : translator.getVegetationFiles()) {
-                System.out.println("vegetation=" + vege);
+            for ( String vege : translator.getVegetationFiles() ) {
+                System.out.println( "vegetation=" + vege );
             }
-            for (String residue : translator.getResidueFiles()) {
-                System.out.println("residue=" + residue);
+            for ( String residue : translator.getResidueFiles() ) {
+                System.out.println( "residue=" + residue );
             }
         }
 
         String altR2db = null;
-        if (param.get(KEY_ALT_R2DB) != null) {
-            altR2db = param.get(KEY_ALT_R2DB).getString(VALUE);
+        if ( param.get( KEY_ALT_R2DB ) != null ) {
+            altR2db = param.get( KEY_ALT_R2DB ).getString( VALUE );
         }
 
         // If this is a Lat/Lng request, then we need to make a DB lookup
         // to obtain the Climate and Soil information and ignore whatever
         // may have been passed in
-        LOG.info("Rulse 2 model request resolveLocation=" + resolveLoc);
+        LOG.info( "Rulse 2 model request resolveLocation=" + resolveLoc );
         //if (resolveLoc) {
 
-        climatePtr = getClimateFilePath(latitude, longitude);
+        climatePtr = getClimateFilePath( latitude, longitude );
 //            // to do
 //            // use only the first soil for now - later we need to use all of them
 //            sString cokey = soilPtr.replace(",", " ");
@@ -477,53 +485,53 @@
 //                }
 //            }
 
-        soilPtr = getSoilFiles(aSoils);
+        soilPtr = getSoilFiles( aSoils );
 
         //}
-        FileOutputStream fos = new FileOutputStream(file);
+        FileOutputStream fos = new FileOutputStream( file );
 
-        fos.write("import sys\n".getBytes());
+        fos.write( "import sys\n".getBytes() );
         // could rewrite this line based on the OS, but python is interpretting it ok on windows
-        fos.write(("sys.path.append('"+ resources().getFile(PYROMESRC).getParent().replace('\\','/')+"')\n").getBytes());
+        fos.write( ( "sys.path.append('" + resources().getFile( PYROMESRC ).getParent().replace( '\\', '/' ) + "')\n" ).getBytes() );
 
-        fos.write("from pyrome import *\n".getBytes());
-        fos.write("from time import sleep\n".getBytes());
+        fos.write( "from pyrome import *\n".getBytes() );
+        fos.write( "from time import sleep\n".getBytes() );
 
-        fos.write("def linearTest(save = False, openFlags = RX_FILESOPEN_TEMP):\n".getBytes());
-        fos.write("    romeDLL = RomeInit('')\n".getBytes());
-        fos.write("    files = RomeGetFiles(romeDLL)\n".getBytes());
-        fos.write("    engine = RomeGetEngine(romeDLL)\n".getBytes());
-        fos.write("    RomeEngineSetAutorun(engine,RX_FALSE)\n".getBytes());
+        fos.write( "def linearTest(save = False, openFlags = RX_FILESOPEN_TEMP):\n".getBytes() );
+        fos.write( "    romeDLL = RomeInit('')\n".getBytes() );
+        fos.write( "    files = RomeGetFiles(romeDLL)\n".getBytes() );
+        fos.write( "    engine = RomeGetEngine(romeDLL)\n".getBytes() );
+        fos.write( "    RomeEngineSetAutorun(engine,RX_FALSE)\n".getBytes() );
 
-        fos.write("    #Inputs\n".getBytes());
+        fos.write( "    #Inputs\n".getBytes() );
 
-        if (aTopoLength.length() > 1) {
+        if ( aTopoLength.length() > 1 ) {
             String text = "    slopes=[";
-            for (int i = 0; i < aTopoSteepness.length(); i++) {
-                text += "'" + aTopoSteepness.getInt(i) + "'";
-                text += (i == aTopoSteepness.length() - 1) ? "]\n" : ",";
+            for ( int i = 0; i < aTopoSteepness.length(); i++ ) {
+                text += "'" + aTopoSteepness.getInt( i ) + "'";
+                text += ( i == aTopoSteepness.length() - 1 ) ? "]\n" : ",";
             }
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
             text = "    lengths=[";
-            for (int i = 0; i < aTopoLength.length(); i++) {
-                text += "'" + aTopoLength.getInt(i) + "'";
-                text += (i == aTopoLength.length() - 1) ? "]\n" : ",";
+            for ( int i = 0; i < aTopoLength.length(); i++ ) {
+                text += "'" + aTopoLength.getInt( i ) + "'";
+                text += ( i == aTopoLength.length() - 1 ) ? "]\n" : ",";
             }
-            fos.write(text.getBytes());
-            if ((aSoilIdx != null) && (aSoilIdx.length() > 0)) {
+            fos.write( text.getBytes() );
+            if ( ( aSoilIdx != null ) && ( aSoilIdx.length() > 0 ) ) {
                 text = "    soilIndex=[";
-                for (int i = 0; i < aSoilIdx.length(); i++) {
-                    text += aSoilIdx.getInt(i) + "";
-                    text += (i == aSoilIdx.length() - 1) ? "]\n" : ",";
+                for ( int i = 0; i < aSoilIdx.length(); i++ ) {
+                    text += aSoilIdx.getInt( i ) + "";
+                    text += ( i == aSoilIdx.length() - 1 ) ? "]\n" : ",";
                 }
-                fos.write(text.getBytes());
+                fos.write( text.getBytes() );
             }
             text = "    manIndex=[";
-            for (int i = 0; i < aManIdx.length(); i++) {
-                text += aManIdx.getInt(i) + "";
-                text += (i == aManIdx.length() - 1) ? "]\n" : ",";
+            for ( int i = 0; i < aManIdx.length(); i++ ) {
+                text += aManIdx.getInt( i ) + "";
+                text += ( i == aManIdx.length() - 1 ) ? "]\n" : ",";
             }
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
 //            if ((aDiversionIdx != null) && (aDiversionIdx.length() > 0)) {
 //                text = "    diversionIndex=[";
 //                for (int i = 0; i < aDiversionIdx.length(); i++) {
@@ -535,29 +543,29 @@
 
         } else {
             String text = "    slopes=['" + steepness + "']\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
             text = "    lengths=['" + length + "']\n";
-            fos.write(text.getBytes());
-            fos.write("    soilIndex=[0]\n".getBytes());
-            fos.write("    manIndex=[0]\n".getBytes());
+            fos.write( text.getBytes() );
+            fos.write( "    soilIndex=[0]\n".getBytes() );
+            fos.write( "    manIndex=[0]\n".getBytes() );
         }
 
-        fos.write("    results = list()\n".getBytes());
+        fos.write( "    results = list()\n".getBytes() );
 
-        fos.write("    #Run a simple profile\n".getBytes());
-        fos.write("    profile = RomeFilesOpen(files,'profiles\\\\csippyrome',openFlags)\n".getBytes());
+        fos.write( "    #Run a simple profile\n".getBytes() );
+        fos.write( "    profile = RomeFilesOpen(files,'profiles\\\\csippyrome',openFlags)\n".getBytes() );
 
         // Open all of the mgmt files...
-        for (int i = 0; i < managements.length(); i++) {
+        for ( int i = 0; i < managements.length(); i++ ) {
             String text = "    mgmt = RomeFilesOpen(files, '#XML:lmod_file" + i + ".xml',0)\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
         }
 
-        fos.write("    cli = RomeFilesOpen(files, '#XML:cli_file0.xml',0)\n".getBytes());
+        fos.write( "    cli = RomeFilesOpen(files, '#XML:cli_file0.xml',0)\n".getBytes() );
 
-        for (int i = 0; i < aSoils.length(); i++) {
+        for ( int i = 0; i < aSoils.length(); i++ ) {
             String text = "    soil" + i + " = RomeFilesOpen(files, '#XML:soils_file" + i + ".xml',0)\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
         }
 
 //// need to set these elements based on array settings
@@ -579,86 +587,86 @@
 ////            text = "    RomeFileSetAttrValue(profile, 'CONTOUR_SYSTEM_PTR', 'contour-systems\\\\aaa" + i + "', 0)\n";
 ////            fos.write(text.getBytes());
 //        }
-        fos.write("    # SET SLOPE\n".getBytes());
+        fos.write( "    # SET SLOPE\n".getBytes() );
         String text = "    RomeFileSetAttrValue(profile, 'SLOPE_HORIZ', '" + length + "', 0)\n";
-        fos.write(text.getBytes());
+        fos.write( text.getBytes() );
         text = "    RomeFileSetAttrValue(profile, 'SLOPE_STEEP', '" + steepness + "', 0)\n";
-        fos.write(text.getBytes());
+        fos.write( text.getBytes() );
 
-        fos.write("    # SET CLIMATE_PTR\n".getBytes());
-        fos.write("    RomeFileSetAttrValue(profile, 'CLIMATE_PTR','climates\\\\aaa',0)\n".getBytes());
-        fos.write("    print('CLIMATE_PTR=%s' % RomeFileGetAttrValue(profile, 'CLIMATE_PTR', 0))\n".getBytes());
+        fos.write( "    # SET CLIMATE_PTR\n".getBytes() );
+        fos.write( "    RomeFileSetAttrValue(profile, 'CLIMATE_PTR','climates\\\\aaa',0)\n".getBytes() );
+        fos.write( "    print('CLIMATE_PTR=%s' % RomeFileGetAttrValue(profile, 'CLIMATE_PTR', 0))\n".getBytes() );
 
-        fos.write("    # SET TOPO LAYER\n".getBytes());
-        if (aTopoLength.length() > 0) {
+        fos.write( "    # SET TOPO LAYER\n".getBytes() );
+        if ( aTopoLength.length() > 0 ) {
             text = "    RomeFileSetAttrSize(profile, 'TOPO_LAYER', " + aTopoLength.length() + ")\n";
-            fos.write(text.getBytes());
-            for (int i = 0; i < aTopoLength.length(); i++) {
-                text = "    RomeFileSetAttrValue(profile, 'TOPO_HORIZ', '" + aTopoLength.getString(i) + "', " + i + ")\n";
-                fos.write(text.getBytes());
-                text = "    RomeFileSetAttrValue(profile, 'TOPO_STEEP', '" + aTopoSteepness.getString(i) + "', " + i + ")\n";
-                fos.write(text.getBytes());
+            fos.write( text.getBytes() );
+            for ( int i = 0; i < aTopoLength.length(); i++ ) {
+                text = "    RomeFileSetAttrValue(profile, 'TOPO_HORIZ', '" + aTopoLength.getString( i ) + "', " + i + ")\n";
+                fos.write( text.getBytes() );
+                text = "    RomeFileSetAttrValue(profile, 'TOPO_STEEP', '" + aTopoSteepness.getString( i ) + "', " + i + ")\n";
+                fos.write( text.getBytes() );
             }
         }
 
         // Presently we do not support multiple soils
-        fos.write("    # SET SOIL LAYER\n".getBytes());
-        if (aSoils.length() > 0) {
+        fos.write( "    # SET SOIL LAYER\n".getBytes() );
+        if ( aSoils.length() > 0 ) {
             text = "    RomeFileSetAttrSize(profile, 'SOIL_LAYER', " + aSoils.length() + ")\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
             text = "    RomeFileSetAttrValue(profile, 'SOIL_HORIZ', '" + length + "', 0)\n";
-            fos.write(text.getBytes());
-            text = "    RomeFileSetAttrValue(profile, 'SOIL_PTR', '" + StringEscapeUtils.escapeJava(soilPtr[0]) + "', " + 0 + ")\n";
-            fos.write(text.getBytes());
-        }
-        
-        // Must be after set soils or the soils code resets it...sometimes
-        if (JSONUtils.checkKeyExistsB(param, KEY_SIMPLE_ROCK_COVER)) {
-            text = "    RomeFileSetAttrValue(profile, 'SIMPLE_ROCK_COVER', '" + simpleRockCoverPercent + "' ,0)\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
+            text = "    RomeFileSetAttrValue(profile, 'SOIL_PTR', '" + StringEscapeUtils.escapeJava( soilPtr[0] ) + "', " + 0 + ")\n";
+            fos.write( text.getBytes() );
         }
 
-        fos.write("    # SET MAN LAYER\n".getBytes());
-        if (aManIdx.length() > 0) {
+        // Must be after set soils or the soils code resets it...sometimes
+        if ( JSONUtils.checkKeyExistsB( param, KEY_SIMPLE_ROCK_COVER ) ) {
+            text = "    RomeFileSetAttrValue(profile, 'SIMPLE_ROCK_COVER', '" + simpleRockCoverPercent + "' ,0)\n";
+            fos.write( text.getBytes() );
+        }
+
+        fos.write( "    # SET MAN LAYER\n".getBytes() );
+        if ( aManIdx.length() > 0 ) {
             text = "    RomeFileSetAttrSize(profile, 'MAN_LAYER', " + aManIdx.length() + ")\n";
-            fos.write(text.getBytes());
-            for (int i = 0; i < aManIdx.length(); i++) {
-                text = "    RomeFileSetAttrValue(profile, 'MAN_HORIZ', '" + aManLength.getString(i) + "', " + i + ")\n";
-                fos.write(text.getBytes());
-                LOG.info("escapeJava test=" + StringEscapeUtils.escapeJava("simple / test"));
-                LOG.info("escapeJava test=" + StringEscapeUtils.escapeJavaScript("simple / test"));
-                LOG.info("\n\n\n********************--- escapeJava man name=" + StringEscapeUtils.escapeJava(managementFormalName[aManIdx.getInt(i)]));
-                LOG.info("********************--- escapeJavaScript man name=" + StringEscapeUtils.escapeJavaScript(managementFormalName[aManIdx.getInt(i)]));
-                LOG.info("********************--- escapeHtml man name=" + StringEscapeUtils.escapeHtml(managementFormalName[aManIdx.getInt(i)]));
-                LOG.info("********************--- escapeSql man name=" + StringEscapeUtils.escapeSql(managementFormalName[aManIdx.getInt(i)]));
-                LOG.info("********************--- escapeXml man name=" + StringEscapeUtils.escapeXml(managementFormalName[aManIdx.getInt(i)]));
-                LOG.info("********************--- raw Value is=" + managementFormalName[aManIdx.getInt(i)]);
+            fos.write( text.getBytes() );
+            for ( int i = 0; i < aManIdx.length(); i++ ) {
+                text = "    RomeFileSetAttrValue(profile, 'MAN_HORIZ', '" + aManLength.getString( i ) + "', " + i + ")\n";
+                fos.write( text.getBytes() );
+                LOG.info( "escapeJava test=" + StringEscapeUtils.escapeJava( "simple / test" ) );
+                LOG.info( "escapeJava test=" + StringEscapeUtils.escapeJavaScript( "simple / test" ) );
+                LOG.info( "\n\n\n********************--- escapeJava man name=" + StringEscapeUtils.escapeJava( managementFormalName[aManIdx.getInt( i )] ) );
+                LOG.info( "********************--- escapeJavaScript man name=" + StringEscapeUtils.escapeJavaScript( managementFormalName[aManIdx.getInt( i )] ) );
+                LOG.info( "********************--- escapeHtml man name=" + StringEscapeUtils.escapeHtml( managementFormalName[aManIdx.getInt( i )] ) );
+                LOG.info( "********************--- escapeSql man name=" + StringEscapeUtils.escapeSql( managementFormalName[aManIdx.getInt( i )] ) );
+                LOG.info( "********************--- escapeXml man name=" + StringEscapeUtils.escapeXml( managementFormalName[aManIdx.getInt( i )] ) );
+                LOG.info( "********************--- raw Value is=" + managementFormalName[aManIdx.getInt( i )] );
                 //text = "    RomeFileSetAttrValue(profile, 'MAN_PTR', '" + managementFormalName[aManIdx.getInt(i)] + "', " + i + ")\n";
-                text = "    RomeFileSetAttrValue(profile, 'MAN_PTR', '" + R2Run.escapeJavaNoFwdSlash(managementFormalName[aManIdx.getInt(i)]) + "', " + i + ")\n";
-                fos.write(text.getBytes());
+                text = "    RomeFileSetAttrValue(profile, 'MAN_PTR', '" + R2Run.escapeJavaNoFwdSlash( managementFormalName[aManIdx.getInt( i )] ) + "', " + i + ")\n";
+                fos.write( text.getBytes() );
             }
         } else {
             // IF no max_idx array provided, defaulting to single mgmt
             text = "    RomeFileSetAttrSize(profile, 'MAN_LAYER', 1)\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
             text = "    RomeFileSetAttrValue(profile, 'MAN_HORIZ', '" + length + "', 0)\n";
-            fos.write(text.getBytes());
-            LOG.info("escapeJava test=" + StringEscapeUtils.escapeJava("simple / test"));
-            LOG.info("escapeJava test=" + StringEscapeUtils.escapeJavaScript("simple / test"));
-            LOG.info("\n\n\n********************--- escapeJava man name=" + StringEscapeUtils.escapeJava(managementFormalName[0]));
-            LOG.info("********************--- escapeJavaScript man name=" + StringEscapeUtils.escapeJavaScript(managementFormalName[0]));
-            LOG.info("********************--- escapeHtml man name=" + StringEscapeUtils.escapeHtml(managementFormalName[0]));
-            LOG.info("********************--- escapeSql man name=" + StringEscapeUtils.escapeSql(managementFormalName[0]));
-            LOG.info("********************--- escapeXml man name=" + StringEscapeUtils.escapeXml(managementFormalName[0]));
-            LOG.info("********************--- raw Value is=" + managementFormalName[0]);
-            text = "    RomeFileSetAttrValue(profile, 'MAN_PTR', '" + R2Run.escapeJavaNoFwdSlash(managementFormalName[0]) + "', 0)\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
+            LOG.info( "escapeJava test=" + StringEscapeUtils.escapeJava( "simple / test" ) );
+            LOG.info( "escapeJava test=" + StringEscapeUtils.escapeJavaScript( "simple / test" ) );
+            LOG.info( "\n\n\n********************--- escapeJava man name=" + StringEscapeUtils.escapeJava( managementFormalName[0] ) );
+            LOG.info( "********************--- escapeJavaScript man name=" + StringEscapeUtils.escapeJavaScript( managementFormalName[0] ) );
+            LOG.info( "********************--- escapeHtml man name=" + StringEscapeUtils.escapeHtml( managementFormalName[0] ) );
+            LOG.info( "********************--- escapeSql man name=" + StringEscapeUtils.escapeSql( managementFormalName[0] ) );
+            LOG.info( "********************--- escapeXml man name=" + StringEscapeUtils.escapeXml( managementFormalName[0] ) );
+            LOG.info( "********************--- raw Value is=" + managementFormalName[0] );
+            text = "    RomeFileSetAttrValue(profile, 'MAN_PTR', '" + R2Run.escapeJavaNoFwdSlash( managementFormalName[0] ) + "', 0)\n";
+            fos.write( text.getBytes() );
         }
 
         // This segment implementation is currently commented out in favor of populating the
         // individual topo, soil, and man layers above for now...
 //        if (aTopoLength.length() > 1) {
-//            
+//
 //            text = "    RomeFileSetAttrSize(profile, 'SEGMENT', " + aTopoLength.length() + ")\n";
 //            fos.write(text.getBytes());
 //            text = "    RomeFileSetAttrValue(profile, 'SOIL_LAYER', '#INSERT', 1)\n";
@@ -711,22 +719,22 @@
         //fos.write("    # Set SOIL_PTR\n".getBytes());
         //text = "    RomeFileSetAttrValue(profile, 'SOIL_PTR', '" + StringEscapeUtils.escapeJava(soilPtr[0]) + ".xml',0)\n";
         //fos.write(text.getBytes());
-        fos.write("    print('SOIL_PTR=%s' % RomeFileGetAttrValue(profile, 'SOIL_PTR', 0))\n".getBytes());
+        fos.write( "    print('SOIL_PTR=%s' % RomeFileGetAttrValue(profile, 'SOIL_PTR', 0))\n".getBytes() );
 
 //        fos.write("    # Set MAN_PTR\n".getBytes());
 //        text = "    RomeFileSetAttrValue(profile, 'MAN_PTR', '" + StringEscapeUtils.escapeJava(managementFormalName[0]) + "',0)\n";
 //        fos.write(text.getBytes());
 //        fos.write("    print('MAN_PTR=%s' % RomeFileGetAttrValue(profile, 'MAN_PTR', 0))\n".getBytes());
-        if ((contourSystem != null) && (contourSystem.length() > 1)) {
+        if ( ( contourSystem != null ) && ( contourSystem.length() > 1 ) ) {
             // Contour Systems can simply point to the nginx XML file - no need to prefetch because of no special
             // characters in the file name
-            text = "    RomeFileSetAttrValue(profile, 'CONTOUR_SYSTEM_PTR', '" + StringEscapeUtils.escapeJava(contourSystem) + "', 0)\n";
-            fos.write(text.getBytes());
+            text = "    RomeFileSetAttrValue(profile, 'CONTOUR_SYSTEM_PTR', '" + StringEscapeUtils.escapeJava( contourSystem ) + "', 0)\n";
+            fos.write( text.getBytes() );
         }
 
         // To prevent issues with pyrome converting special chars in filenames to invalid chars for web server retrieval,
         // we prefetch the file, insert a dummy name, and point to it here
-        if ((stripBarrierSystem != null) && (stripBarrierSystem.length() > 1)) {
+        if ( ( stripBarrierSystem != null ) && ( stripBarrierSystem.length() > 1 ) ) {
             // for some reason, must reset SLOPE_HORIZ & SLOPE_STEEP immediately before setting a strip and barrier !!! R2 BUG
             // This is required for the internal Rusle2 wizard to calculate proper slope segment lengths
 //            text = "    RomeFileSetAttrValue(profile, 'SLOPE_HORIZ', '" + length + "', 0)\n";
@@ -734,31 +742,31 @@
 //            text = "    RomeFileSetAttrValue(profile, 'SLOPE_STEEP', '" + steepness + "', 0)\n";
 //            fos.write(text.getBytes());
 
-            fos.write("    stripbarr = RomeFilesOpen(files, '#XML:stripbarr_file0.xml',0)\n".getBytes());
+            fos.write( "    stripbarr = RomeFilesOpen(files, '#XML:stripbarr_file0.xml',0)\n".getBytes() );
             text = "    RomeFileSetAttrValue(profile, 'STRIP_BARRIER_SYSTEM_PTR', 'strip-barrier-systems\\\\aaa', 0)\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
         }
 
         // Runs with a Hydraulic Element System, use a hydraulic element flow path
-        if ((hydElemSystem != null) && (hydElemSystem.length() > 1)) {
+        if ( ( hydElemSystem != null ) && ( hydElemSystem.length() > 1 ) ) {
             // Load the hyd elem flow path into the workspace
-            fos.write("    hydelem = RomeFilesOpen(files, '#XML:hydelemflowpath_file.xml',0)\n".getBytes());
+            fos.write( "    hydelem = RomeFilesOpen(files, '#XML:hydelemflowpath_file.xml',0)\n".getBytes() );
 //            String r2db = Config.getString("r2.db", "http://oms-db.engr.colostate.edu/r2");
 //            String hydelemHttpPtr = r2db + "/" + hydElemSystem.replace("\\", "/") + ".xml";
-            int numFlowPaths = r2run.determineNumberOfFlowPaths(hydElemSystem);
+            int numFlowPaths = r2run.determineNumberOfFlowPaths( hydElemSystem );
             text = "    RomeFileSetAttrSize(profile, 'NUM_FLOW_PATHS', " + numFlowPaths + ")\n";
-            fos.write(text.getBytes());
-            double offsets[] = r2run.determineFlowPathDistribution(hydElemSystem);
-            for (int i = 0; i < numFlowPaths; i++) {
+            fos.write( text.getBytes() );
+            double offsets[] = r2run.determineFlowPathDistribution( hydElemSystem );
+            for ( int i = 0; i < numFlowPaths; i++ ) {
                 text = "    RomeFileSetAttrValue(profile, 'FLOW_PATH_HORIZ', '" + length * offsets[i] + "', " + i + ")\n";
-                fos.write(text.getBytes());
-                if (i < (numFlowPaths - 1)) {
+                fos.write( text.getBytes() );
+                if ( i < ( numFlowPaths - 1 ) ) {
                     text = "    RomeFileSetAttrValue(profile, 'HYD_ELEM_FLOW_PATH_PTR', 'hydraulic-element-flow-paths\\hydelemflowpath1', " + i + ")\n";
-                    fos.write(text.getBytes());
+                    fos.write( text.getBytes() );
                 } else {
                     // last flow path is always the default
                     text = "    RomeFileSetAttrValue(profile, 'HYD_ELEM_FLOW_PATH_PTR', 'hydraulic-element-flow-paths\\default', " + i + ")\n";
-                    fos.write(text.getBytes());
+                    fos.write( text.getBytes() );
                 }
             }
         }
@@ -767,93 +775,93 @@
 //            text = "    RomeFileSetAttrValue(profile, 'CONTOUR_SYSTEM_PTR', '" + contourSystem + "',0)\n";
 //            fos.write(text.getBytes());
 //        }
-        fos.write("    RomeFileSave(profile)\n".getBytes());
-        fos.write("    RomeEngineRun(engine)\n".getBytes());
+        fos.write( "    RomeFileSave(profile)\n".getBytes() );
+        fos.write( "    RomeEngineRun(engine)\n".getBytes() );
 //        fos.write("    results.append(RomeFileGetAttrValue(profile, 'SLOPE_SOIL_LOSS', 0))\n".getBytes());
 //        fos.write("    results.append(RomeFileGetAttrValue(profile, 'SLOPE_DELIVERY', 0))\n".getBytes());
 //        fos.write("    results.append(RomeFileGetAttrValue(profile, 'SLOPE_DEGRAD', 0))\n".getBytes());
 
         // Request specific outputs from Rusle2
-        for (String r : JSONUtils.getRequestedResults(metainfo)) {
+        for ( String r : JSONUtils.getRequestedResults( metainfo ) ) {
             text = "    paramsize = RomeFileGetAttrSize(profile,'" + r + "')\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
             text = "    if paramsize > 1:\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
             text = "        text = '['\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
             text = "        for x in range (paramsize):\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
             text = "            text += RomeFileGetAttrValue(profile,'" + r + "',x)\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
             text = "            if x < (paramsize-1):\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
             text = "                text += ', '\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
             text = "        text += ']'\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
             text = "    else:\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
             text = "        text = RomeFileGetAttrValue(profile, '" + r + "', 0)\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
             text = "    results.append(RomeFileGetAttrValue(profile, '" + r + "', 0))\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
             text = "    print('" + r + "=%s' % text)\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
         }
 
         // Request output for segments (seg 0 for non segmented runs)
-        fos.write("    numflowpaths = RomeFileGetAttrSize(profile, 'NUM_FLOW_PATHS')\n".getBytes());
-        fos.write("    print('------------------------------------------------------------------------------')\n".getBytes());
-        fos.write("    print('NUMBER OF FLOWPATHS=%d' % numflowpaths)\n".getBytes());
-        fos.write("    for xx in range (numflowpaths):\n".getBytes());
-        fos.write("        print('FLOW_PATH_HORIZ:%d=%s' % (xx, RomeFileGetAttrValue(profile, 'FLOW_PATH_HORIZ', xx)))\n".getBytes());
-        fos.write("        print('HYD_ELEM_FLOW_PATH_PTR:%d=%s' % (xx, RomeFileGetAttrValue(profile, 'HYD_ELEM_FLOW_PATH_PTR', xx)))\n".getBytes());
-        fos.write("    numsegs = RomeFileGetAttrSize(profile, 'SEGMENT')\n".getBytes());
-        fos.write("    print('NUMBER OF SEGMENTS=%d' % numsegs)\n".getBytes());
-        fos.write("    for x in range (numsegs):\n".getBytes());
-        fos.write("        print('------------------------------------------------------------------------------')\n".getBytes());
-        fos.write("        print('SEGMENT:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEGMENT', x)))\n".getBytes());
-        fos.write("        print('SEG_HORIZ:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_HORIZ', x)))\n".getBytes());
-        fos.write("        print('SEG_STEEP:%d=%s' % (x,RomeFileGetAttrValue(profile, 'SEG_STEEP', x)))\n".getBytes());
-        fos.write("        print('SEG_MAN:%d=%s' % (x, RomeFileGetAttrValue(profile, 'MAN_PTR', x)))\n".getBytes());
-        fos.write("        print('SEG_SOIL:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SOIL_PTR', x)))\n".getBytes());
-        fos.write("        results.append(RomeFileGetAttrValue(profile, 'SEG_SOIL_LOSS', x))\n".getBytes());
-        fos.write("        print('SEG_SOIL_LOSS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_SOIL_LOSS', x)))\n".getBytes());
-        fos.write("        print('SEG_SOIL_LAYER %d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_SOIL_LAYER', x)))\n".getBytes());
-        fos.write("        print('SEG_MAN_LAYER %d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_MAN_LAYER', x)))\n".getBytes());
-        fos.write("        print('HYD_ELEM_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'HYD_ELEM_SYSTEM_PTR', x)))\n".getBytes());
-        fos.write("        print('STRIP_BARRIER_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'STRIP_BARRIER_SYSTEM_PTR', x)))\n".getBytes());
-        fos.write("        print('CONTOUR_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'CONTOUR_SYSTEM_PTR', x)))\n".getBytes());
-        fos.write("    print('------------------------------------------------------------------------------')\n".getBytes());
+        fos.write( "    numflowpaths = RomeFileGetAttrSize(profile, 'NUM_FLOW_PATHS')\n".getBytes() );
+        fos.write( "    print('------------------------------------------------------------------------------')\n".getBytes() );
+        fos.write( "    print('NUMBER OF FLOWPATHS=%d' % numflowpaths)\n".getBytes() );
+        fos.write( "    for xx in range (numflowpaths):\n".getBytes() );
+        fos.write( "        print('FLOW_PATH_HORIZ:%d=%s' % (xx, RomeFileGetAttrValue(profile, 'FLOW_PATH_HORIZ', xx)))\n".getBytes() );
+        fos.write( "        print('HYD_ELEM_FLOW_PATH_PTR:%d=%s' % (xx, RomeFileGetAttrValue(profile, 'HYD_ELEM_FLOW_PATH_PTR', xx)))\n".getBytes() );
+        fos.write( "    numsegs = RomeFileGetAttrSize(profile, 'SEGMENT')\n".getBytes() );
+        fos.write( "    print('NUMBER OF SEGMENTS=%d' % numsegs)\n".getBytes() );
+        fos.write( "    for x in range (numsegs):\n".getBytes() );
+        fos.write( "        print('------------------------------------------------------------------------------')\n".getBytes() );
+        fos.write( "        print('SEGMENT:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEGMENT', x)))\n".getBytes() );
+        fos.write( "        print('SEG_HORIZ:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_HORIZ', x)))\n".getBytes() );
+        fos.write( "        print('SEG_STEEP:%d=%s' % (x,RomeFileGetAttrValue(profile, 'SEG_STEEP', x)))\n".getBytes() );
+        fos.write( "        print('SEG_MAN:%d=%s' % (x, RomeFileGetAttrValue(profile, 'MAN_PTR', x)))\n".getBytes() );
+        fos.write( "        print('SEG_SOIL:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SOIL_PTR', x)))\n".getBytes() );
+        fos.write( "        results.append(RomeFileGetAttrValue(profile, 'SEG_SOIL_LOSS', x))\n".getBytes() );
+        fos.write( "        print('SEG_SOIL_LOSS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_SOIL_LOSS', x)))\n".getBytes() );
+        fos.write( "        print('SEG_SOIL_LAYER %d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_SOIL_LAYER', x)))\n".getBytes() );
+        fos.write( "        print('SEG_MAN_LAYER %d=%s' % (x, RomeFileGetAttrValue(profile, 'SEG_MAN_LAYER', x)))\n".getBytes() );
+        fos.write( "        print('HYD_ELEM_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'HYD_ELEM_SYSTEM_PTR', x)))\n".getBytes() );
+        fos.write( "        print('STRIP_BARRIER_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'STRIP_BARRIER_SYSTEM_PTR', x)))\n".getBytes() );
+        fos.write( "        print('CONTOUR_SYS:%d=%s' % (x, RomeFileGetAttrValue(profile, 'CONTOUR_SYSTEM_PTR', x)))\n".getBytes() );
+        fos.write( "    print('------------------------------------------------------------------------------')\n".getBytes() );
 
-        fos.write("    numsegs = RomeFileGetAttrSize(profile, 'SOIL_LAYER')\n".getBytes());
-        fos.write("    print('NUMBER OF SOIL SEGMENTS=%d' % numsegs)\n".getBytes());
-        fos.write("    for x in range (numsegs):\n".getBytes());
-        fos.write("        print('------------------------------------------------------------------------------')\n".getBytes());
-        fos.write("        print('SOIL_SEGMENT:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SOIL_LAYER', x)))\n".getBytes());
-        fos.write("        print('SOIL_HORIZ:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SOIL_HORIZ', x)))\n".getBytes());
-        fos.write("        print('SOIL_PTR:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SOIL_PTR', x)))\n".getBytes());
-        fos.write("    print('------------------------------------------------------------------------------')\n".getBytes());
+        fos.write( "    numsegs = RomeFileGetAttrSize(profile, 'SOIL_LAYER')\n".getBytes() );
+        fos.write( "    print('NUMBER OF SOIL SEGMENTS=%d' % numsegs)\n".getBytes() );
+        fos.write( "    for x in range (numsegs):\n".getBytes() );
+        fos.write( "        print('------------------------------------------------------------------------------')\n".getBytes() );
+        fos.write( "        print('SOIL_SEGMENT:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SOIL_LAYER', x)))\n".getBytes() );
+        fos.write( "        print('SOIL_HORIZ:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SOIL_HORIZ', x)))\n".getBytes() );
+        fos.write( "        print('SOIL_PTR:%d=%s' % (x, RomeFileGetAttrValue(profile, 'SOIL_PTR', x)))\n".getBytes() );
+        fos.write( "    print('------------------------------------------------------------------------------')\n".getBytes() );
 
-        fos.write("    numsegs = RomeFileGetAttrSize(profile, 'MAN_LAYER')\n".getBytes());
-        fos.write("    print('NUMBER OF MAN SEGMENTS=%d' % numsegs)\n".getBytes());
-        fos.write("    for x in range (numsegs):\n".getBytes());
-        fos.write("        print('------------------------------------------------------------------------------')\n".getBytes());
-        fos.write("        print('MAN_SEGMENT:%d=%s' % (x, RomeFileGetAttrValue(profile, 'MAN_LAYER', x)))\n".getBytes());
-        fos.write("        print('MAN_HORIZ:%d=%s' % (x, RomeFileGetAttrValue(profile, 'MAN_HORIZ', x)))\n".getBytes());
-        fos.write("        print('MAN_PTR:%d=%s' % (x, RomeFileGetAttrValue(profile, 'MAN_PTR', x)))\n".getBytes());
-        fos.write("    print('------------------------------------------------------------------------------')\n".getBytes());
+        fos.write( "    numsegs = RomeFileGetAttrSize(profile, 'MAN_LAYER')\n".getBytes() );
+        fos.write( "    print('NUMBER OF MAN SEGMENTS=%d' % numsegs)\n".getBytes() );
+        fos.write( "    for x in range (numsegs):\n".getBytes() );
+        fos.write( "        print('------------------------------------------------------------------------------')\n".getBytes() );
+        fos.write( "        print('MAN_SEGMENT:%d=%s' % (x, RomeFileGetAttrValue(profile, 'MAN_LAYER', x)))\n".getBytes() );
+        fos.write( "        print('MAN_HORIZ:%d=%s' % (x, RomeFileGetAttrValue(profile, 'MAN_HORIZ', x)))\n".getBytes() );
+        fos.write( "        print('MAN_PTR:%d=%s' % (x, RomeFileGetAttrValue(profile, 'MAN_PTR', x)))\n".getBytes() );
+        fos.write( "    print('------------------------------------------------------------------------------')\n".getBytes() );
 
-        fos.write("    numsegs = RomeFileGetAttrSize(profile, 'TOPO_LAYER')\n".getBytes());
-        fos.write("    print('NUMBER OF TOPO SEGMENTS=%d' % numsegs)\n".getBytes());
-        fos.write("    for x in range (numsegs):\n".getBytes());
-        fos.write("        print('------------------------------------------------------------------------------')\n".getBytes());
-        fos.write("        print('TOPO_SEGMENT:%d=%s' % (x, RomeFileGetAttrValue(profile, 'TOPO_LAYER', x)))\n".getBytes());
-        fos.write("        print('TOPO_HORIZ:%d=%s' % (x, RomeFileGetAttrValue(profile, 'TOPO_HORIZ', x)))\n".getBytes());
-        fos.write("        print('TOPO_HORIZ_COMPOSITE:%d=%s' % (x, RomeFileGetAttrValue(profile, 'TOPO_HORIZ_COMPOSITE', x)))\n".getBytes());
-        fos.write("        print('TOPO_STEEP:%d=%s' % (x, RomeFileGetAttrValue(profile, 'TOPO_STEEP', x)))\n".getBytes());
-        fos.write("        print('TOPO_STEEP_COMPOSITE:%d=%s' % (x, RomeFileGetAttrValue(profile, 'TOPO_STEEP_COMPOSITE', x)))\n".getBytes());
-        fos.write("    print('------------------------------------------------------------------------------')\n".getBytes());
+        fos.write( "    numsegs = RomeFileGetAttrSize(profile, 'TOPO_LAYER')\n".getBytes() );
+        fos.write( "    print('NUMBER OF TOPO SEGMENTS=%d' % numsegs)\n".getBytes() );
+        fos.write( "    for x in range (numsegs):\n".getBytes() );
+        fos.write( "        print('------------------------------------------------------------------------------')\n".getBytes() );
+        fos.write( "        print('TOPO_SEGMENT:%d=%s' % (x, RomeFileGetAttrValue(profile, 'TOPO_LAYER', x)))\n".getBytes() );
+        fos.write( "        print('TOPO_HORIZ:%d=%s' % (x, RomeFileGetAttrValue(profile, 'TOPO_HORIZ', x)))\n".getBytes() );
+        fos.write( "        print('TOPO_HORIZ_COMPOSITE:%d=%s' % (x, RomeFileGetAttrValue(profile, 'TOPO_HORIZ_COMPOSITE', x)))\n".getBytes() );
+        fos.write( "        print('TOPO_STEEP:%d=%s' % (x, RomeFileGetAttrValue(profile, 'TOPO_STEEP', x)))\n".getBytes() );
+        fos.write( "        print('TOPO_STEEP_COMPOSITE:%d=%s' % (x, RomeFileGetAttrValue(profile, 'TOPO_STEEP_COMPOSITE', x)))\n".getBytes() );
+        fos.write( "    print('------------------------------------------------------------------------------')\n".getBytes() );
 
 //        // request erosion by segment, if a segmented run
 //        if (aTopoLength.length() > 1) {
@@ -895,38 +903,38 @@
 //            fos.write(text.getBytes());
 //            text = "    print('SEG_MAN:0" + "=%s' % RomeFileGetAttrValue(profile, 'MAN_PTR', " + 0 + "))\n";
 //            fos.write(text.getBytes());
-//            // 
+//            //
 //        }
 //        fos.write("    print('SLOPE_DELIVERY=%s' % RomeFileGetAttrValue(profile, 'SLOPE_DELIVERY', 0))\n".getBytes());
 //        fos.write("    print('SLOPE_T_VALUE=%s' % RomeFileGetAttrValue(profile, 'SLOPE_T_VALUE', 0))\n".getBytes());
 //        fos.write("    print('SLOPE_DEGRAD=%s' % RomeFileGetAttrValue(profile, 'SLOPE_DEGRAD', 0))\n".getBytes());
         text = "    exec(open(\"" + REPORT_PY_FILENAME + "\").read())\n";
-        fos.write(text.getBytes());
-        fos.write("    RomeFileClose(profile)\n".getBytes());
-        fos.write("    return results\n".getBytes());
+        fos.write( text.getBytes() );
+        fos.write( "    RomeFileClose(profile)\n".getBytes() );
+        fos.write( "    return results\n".getBytes() );
 
-        fos.write("if __name__ == \"__main__\":\n".getBytes());
-        fos.write("    #inputs\n".getBytes());
-        fos.write("    save = False\n".getBytes());
-        fos.write("    #Run simulation\n".getBytes());
-        fos.write(("    romeDLL = RomeInit('pyrome /DirRoot="+ resources().getFile(ROMEDLL).getParent().replace('\\','/')+"/')\n").getBytes());
-        fos.write("    database = RomeGetDatabase(romeDLL)\n".getBytes());
+        fos.write( "if __name__ == \"__main__\":\n".getBytes() );
+        fos.write( "    #inputs\n".getBytes() );
+        fos.write( "    save = False\n".getBytes() );
+        fos.write( "    #Run simulation\n".getBytes() );
+        fos.write( ( "    romeDLL = RomeInit('pyrome /DirRoot=" + resources().getFile( ROMEDLL ).getParent().replace( '\\', '/' ) + "/')\n" ).getBytes() );
+        fos.write( "    database = RomeGetDatabase(romeDLL)\n".getBytes() );
         // prints all outputs in single array
         //fos.write("    print(results[:])\n".getBytes());
 
         // Specify the nginx server
-        String r2db = Config.getString("r2.db", "http://oms-db.engr.colostate.edu/r2");
-        if (altR2db == null) {
+        String r2db = Config.getString( "r2.db", "http://oms-db.engr.colostate.edu/r2" );
+        if ( altR2db == null ) {
             text = "    RomeDatabaseOpen(database,'" + r2db + "')\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
         } else {
-            String altr2db = r2db.substring(0, r2db.lastIndexOf("/")) + "/model-data/" + altR2db;
+            String altr2db = r2db.substring( 0, r2db.lastIndexOf( "/" ) ) + "/model-data/" + altR2db;
             text = "    RomeDatabaseOpen(database,'" + altr2db + "')\n";
-            fos.write(text.getBytes());
+            fos.write( text.getBytes() );
         }
-        fos.write("    results = linearTest(save)\n".getBytes());
-        fos.write("    RomeDatabaseClose(database)\n".getBytes());
-        fos.write("    RomeExit(romeDLL)\n".getBytes());
+        fos.write( "    results = linearTest(save)\n".getBytes() );
+        fos.write( "    RomeDatabaseClose(database)\n".getBytes() );
+        fos.write( "    RomeExit(romeDLL)\n".getBytes() );
 
 //        for (int i = 0; i < contoursytems.length(); i++) {
 //            String contourSys = contoursytems.getString(i);
@@ -944,23 +952,23 @@
 //            r2run.prepareFile(hydelemHttpPtr, new File(getWorkspaceDir(), "hydelem_file" + i + ".xml"), "hydraulic-element", "hydraulic-element-systems", Integer.toString(i));
 //        }
         // prepare individual contour system, strip barrier system, hyd elem sys, if not provided in an array
-        if (JSONUtils.checkKeyExistsB(param, KEY_CONTOUR_SYSTEM_PTR)) {
-            String contourHttpPtr = r2db + "/" + contourSystem.replace("\\", "/") + ".xml";
-            r2run.prepareFileJ(contourHttpPtr, new File(getWorkspaceDir(), "contour_file0.xml"), "", "contour-systems", "", true);
+        if ( JSONUtils.checkKeyExistsB( param, KEY_CONTOUR_SYSTEM_PTR ) ) {
+            String contourHttpPtr = r2db + "/" + contourSystem.replace( "\\", "/" ) + ".xml";
+            r2run.prepareFileJ( contourHttpPtr, new File( getWorkspaceDir(), "contour_file0.xml" ), "", "contour-systems", "", true );
         }
-        if (JSONUtils.checkKeyExistsB(param, KEY_STRIP_BARRIER_SYSTEM_PTR)) {
-            String stripbarrHttpPtr = r2db + "/" + stripBarrierSystem.replace("\\", "/") + ".xml";
-            r2run.prepareFileJ(stripbarrHttpPtr, new File(getWorkspaceDir(), "stripbarr_file0.xml"), "", "strip-barrier-systems", "", true);
+        if ( JSONUtils.checkKeyExistsB( param, KEY_STRIP_BARRIER_SYSTEM_PTR ) ) {
+            String stripbarrHttpPtr = r2db + "/" + stripBarrierSystem.replace( "\\", "/" ) + ".xml";
+            r2run.prepareFileJ( stripbarrHttpPtr, new File( getWorkspaceDir(), "stripbarr_file0.xml" ), "", "strip-barrier-systems", "", true );
         }
-        if (JSONUtils.checkKeyExistsB(param, KEY_HYD_ELEM_SYSTEM_PTR)) {
-            String hydelemHttpPtr = r2db + "/" + hydElemSystem.replace("\\", "/") + ".xml";
-            r2run.prepareHydraulicElementFlowPathJ(hydelemHttpPtr, r2db, new File(getWorkspaceDir(), "hydelemflowpath_file.xml"));
+        if ( JSONUtils.checkKeyExistsB( param, KEY_HYD_ELEM_SYSTEM_PTR ) ) {
+            String hydelemHttpPtr = r2db + "/" + hydElemSystem.replace( "\\", "/" ) + ".xml";
+            r2run.prepareHydraulicElementFlowPathJ( hydelemHttpPtr, r2db, new File( getWorkspaceDir(), "hydelemflowpath_file.xml" ) );
             //r2run.prepareFileJ(hydelemHttpPtr, new File(getWorkspaceDir(), "hydelemflowpath_file.xml"), climate, text, r2db);
         }
 
         // prepare climate file
         //r2run.prepareClimateFileJ(cliHttpPtr, new File(getWorkspaceDir(), "cli_file0.xml"));
-        r2run.prepareFileJ(climatePtr, new File(getWorkspaceDir(), "cli_file0.xml"), "CLIMATE", "climates", "", true);
+        r2run.prepareFileJ( climatePtr, new File( getWorkspaceDir(), "cli_file0.xml" ), "CLIMATE", "climates", "", true );
         //r2run.prepareClimateFile(cliHttpPtr, new File(getWorkspaceDir(), "cli_file0.xml"));
 
         // to do
@@ -969,20 +977,19 @@
         //fos.write("READ \"rusle2_report.rsh\"\n".getBytes());
         fos.close();
 
-        // Unpack the report rsh file in the work space dir 
+        // Unpack the report rsh file in the work space dir
 //        Binaries.unpackResourceAbsolute("/bin/win-x86/" + REPORT_PY_FILENAME, getWorkspaceDir().toString() + "/" + REPORT_PY_FILENAME);
-        FileUtils.copyFileToDirectory(resources().getFile(REPORT_PY_FILENAME), getWorkspaceDir());
+        FileUtils.copyFileToDirectory( resources().getFile( REPORT_PY_FILENAME ), getWorkspaceDir() );
 
         climate = climatePtr;
         soil = soilPtr[0];
         mgmt = managementFormalName[0];
 
-        LOG.info("R2 script: " + file.toString());
+        LOG.info( "R2 script: " + file.toString() );
     }
 
-
-    private String[] getSoilFiles(JSONArray cokeys) throws JSONException, Exception {
-        String soilPtr[] = new String[(cokeys.length())];
+    private String[] getSoilFiles ( JSONArray cokeys ) throws JSONException, Exception {
+        String soilPtr[] = new String[( cokeys.length() )];
         JSONObject soilsRequest = new JSONObject();
         JSONObject meta = new JSONObject();
         JSONArray paramObj = new JSONArray();
@@ -993,52 +1000,50 @@
         JSONObject soilObj;
         String soilFilePath;
 
-        soilsRequest.put(KEY_METAINFO, meta);
-        soilsRequest.put(KEY_PARAMETER, paramObj);
-        paramObj.put(cokeyObj);
+        soilsRequest.put( KEY_METAINFO, meta );
+        soilsRequest.put( KEY_PARAMETER, paramObj );
+        paramObj.put( cokeyObj );
 
-        for (int i = 0; i < cokeys.length(); i++) {
-            cokey = cokeys.getString(i);
-            paramObj.put(0, cokeyObj);
-            cokeyObj.put(KEY_NAME, KEY_COKEY);
-            cokeyObj.put(KEY_VALUE, cokey);
-            LOG.info("SOILS Request: " + soilsRequest.toString());
-            JSONObject soilsResponse = new Client().doPOST(Config.getString("r2.soils", "http://csip.engr.colostate.edu:8092/csip-soils/d/soilsXML/1.0"), soilsRequest);
-            LOG.info("SOILS Response: " + soilsResponse.toString());
-            responseMeta = soilsResponse.getJSONObject(KEY_METAINFO);
-            if (!responseMeta.getString(KEY_STATUS).equalsIgnoreCase("Failed")) {
-                resultArr = soilsResponse.getJSONArray(KEY_RESULT);
-                soilObj = resultArr.getJSONObject(0);
-                soilFilePath = soilObj.getString(KEY_VALUE);
+        for ( int i = 0; i < cokeys.length(); i++ ) {
+            cokey = cokeys.getString( i );
+            paramObj.put( 0, cokeyObj );
+            cokeyObj.put( KEY_NAME, KEY_COKEY );
+            cokeyObj.put( KEY_VALUE, cokey );
+            LOG.info( "SOILS Request: " + soilsRequest.toString() );
+            JSONObject soilsResponse = new Client().doPOST( Config.getString( "r2.soils", "http://csip.engr.colostate.edu:8092/csip-soils/d/soilsXML/1.0" ), soilsRequest );
+            LOG.info( "SOILS Response: " + soilsResponse.toString() );
+            responseMeta = soilsResponse.getJSONObject( KEY_METAINFO );
+            if ( !responseMeta.getString( KEY_STATUS ).equalsIgnoreCase( "Failed" ) ) {
+                resultArr = soilsResponse.getJSONArray( KEY_RESULT );
+                soilObj = resultArr.getJSONObject( 0 );
+                soilFilePath = soilObj.getString( KEY_VALUE );
 
-                new Client().doGET(soilFilePath, getWorkspaceFile("soils_file" + i + ".xml"));
+                new Client().doGET( soilFilePath, getWorkspaceFile( "soils_file" + i + ".xml" ) );
 
-                soilPtr[i] = getSoilFilePath(getWorkspaceFile("soils_file" + i + ".xml")).replace("/", "\\");
-                LOG.info("THE SOIL IS =" + soilPtr[i] + "\n\n\n\n");
+                soilPtr[i] = getSoilFilePath( getWorkspaceFile( "soils_file" + i + ".xml" ) ).replace( "/", "\\" );
+                LOG.info( "THE SOIL IS =" + soilPtr[i] + "\n\n\n\n" );
 
-            }  else {
-                String error = responseMeta.getString(ERROR);
-                throw new ServiceException("Soil service error: " + error);
+            } else {
+                String error = responseMeta.getString( ERROR );
+                throw new ServiceException( "Soil service error: " + error );
             }
         }
         return soilPtr;
     }
 
-
-    private String getSoilFilePath(File soilFile) throws ParserConfigurationException, SAXException, IOException {
+    private String getSoilFilePath ( File soilFile ) throws ParserConfigurationException, SAXException, IOException {
         String path = "";
         DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
         DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
 
-        Document document = documentBuilder.parse(soilFile);
+        Document document = documentBuilder.parse( soilFile );
 
-        path = document.getElementsByTagName("Filename").item(0).getTextContent();
+        path = document.getElementsByTagName( "Filename" ).item( 0 ).getTextContent();
 
         return path;
     }
 
-
-    private String getClimateFilePath(double lat, double lon) throws JSONException, Exception {
+    private String getClimateFilePath ( double lat, double lon ) throws JSONException, Exception {
         JSONObject climateReq = new JSONObject();
         JSONObject meta = new JSONObject();
         JSONArray param = new JSONArray();
@@ -1049,133 +1054,130 @@
         JSONObject cliObj;
         String climatePath = "";
 
-        climateReq.put(KEY_METAINFO, meta);
-        climateReq.put(KEY_PARAMETER, param);
+        climateReq.put( KEY_METAINFO, meta );
+        climateReq.put( KEY_PARAMETER, param );
 
-        param.put(jlat);
-        param.put(jlong);
+        param.put( jlat );
+        param.put( jlong );
 
-        jlat.put(KEY_NAME, KEY_LATITUDE);
-        jlat.put(KEY_VALUE, lat);
+        jlat.put( KEY_NAME, KEY_LATITUDE );
+        jlat.put( KEY_VALUE, lat );
 
-        jlong.put(KEY_NAME, KEY_LONGITUDE);
-        jlong.put(KEY_VALUE, lon);
+        jlong.put( KEY_NAME, KEY_LONGITUDE );
+        jlong.put( KEY_VALUE, lon );
 
-        LOG.info("CLIMATE Request: " + climateReq.toString());
-        JSONObject climateResponse = new Client().doPOST(Config.getString("r2.climate", "http://csip.engr.colostate.edu:8092/csip-misc/d/r2climate/2.0"), climateReq);
-        LOG.info("CLIMATE Response: " + climateResponse.toString());
-        responseMeta = climateResponse.getJSONObject(KEY_METAINFO);
-        if (!responseMeta.getString(KEY_STATUS).equalsIgnoreCase("Failed")) {
-            resultArr = climateResponse.getJSONArray(KEY_RESULT);
-            cliObj = JSONUtils.preprocess(resultArr).get(KEY_CLIMATE_URL);
-            climatePath = cliObj.getString(KEY_VALUE);
+        LOG.info( "CLIMATE Request: " + climateReq.toString() );
+        JSONObject climateResponse = new Client().doPOST( Config.getString( "r2.climate", "http://csip.engr.colostate.edu:8092/csip-misc/d/r2climate/2.0" ), climateReq );
+        LOG.info( "CLIMATE Response: " + climateResponse.toString() );
+        responseMeta = climateResponse.getJSONObject( KEY_METAINFO );
+        if ( !responseMeta.getString( KEY_STATUS ).equalsIgnoreCase( "Failed" ) ) {
+            resultArr = climateResponse.getJSONArray( KEY_RESULT );
+            cliObj = JSONUtils.preprocess( resultArr ).get( KEY_CLIMATE_URL );
+            climatePath = cliObj.getString( KEY_VALUE );
         }
 
         return climatePath;
     }
 
-
-    private String getFilenumber(String filename) {
-        return filename.substring(R2_TMP_FILENAME.length(), filename.length() - R2_TMP_FILEEXT.length());
+    private String getFilenumber ( String filename ) {
+        return filename.substring( R2_TMP_FILENAME.length(), filename.length() - R2_TMP_FILEEXT.length() );
     }
 
-
     @Override
-    protected void doReport() throws Exception {
+    protected void doReport () throws Exception {
 //        String sessionWorkDir = getWorkspaceDir().toString();
 //        String reportJSON = Binaries.unpackResourceAbsolute("/bin/win-x86/" + REPORT_JSON_TEMPLATE_FILENAME, sessionWorkDir + "/" + REPORT_JSON_TEMPLATE_FILENAME).toString();
 //        File reportTemplate = new File(sessionWorkDir + "/" + REPORT_JSON_TEMPLATE_FILENAME);
-        File reportTemplate = resources().getFile(REPORT_JSON_TEMPLATE_FILENAME);
-        
-        String sReportJSON = FileUtils.readFileToString(reportTemplate);
-        JSONArray reportItemsFromTemplate = new JSONArray(sReportJSON);
+        File reportTemplate = resources().getFile( REPORT_JSON_TEMPLATE_FILENAME );
 
-        for (int i = 0; i < reportItemsFromTemplate.length(); i++) {
-            JSONObject obj = (JSONObject) reportItemsFromTemplate.get(i);
-            String itemName = obj.getString(REPORT_NAME);
-            String dimension = JSONUtils.getJSONString(obj, REPORT_DIM, null);
-            String type = JSONUtils.getJSONString(obj, REPORT_TYPE, "");
-            String units = JSONUtils.getJSONString(obj, REPORT_UNITS, null);
-            String desc = JSONUtils.getJSONString(obj, REPORT_DESC, null);
+        String sReportJSON = FileUtils.readFileToString( reportTemplate );
+        JSONArray reportItemsFromTemplate = new JSONArray( sReportJSON );
+
+        for ( int i = 0; i < reportItemsFromTemplate.length(); i++ ) {
+            JSONObject obj = ( JSONObject ) reportItemsFromTemplate.get( i );
+            String itemName = obj.getString( REPORT_NAME );
+            String dimension = JSONUtils.getJSONString( obj, REPORT_DIM, null );
+            String type = JSONUtils.getJSONString( obj, REPORT_TYPE, "" );
+            String units = JSONUtils.getJSONString( obj, REPORT_UNITS, null );
+            String desc = JSONUtils.getJSONString( obj, REPORT_DESC, null );
             //LOG.info("Attempting to fetch results for:" + itemName);
-            System.out.println("------------------------------------------------------------------------PROCESSING ELEMENT:");
-            System.out.println("VAR NAME:" + itemName);
-            System.out.println("-------------------------------------------------------------------------------------------");
+            System.out.println( "------------------------------------------------------------------------PROCESSING ELEMENT:" );
+            System.out.println( "VAR NAME:" + itemName );
+            System.out.println( "-------------------------------------------------------------------------------------------" );
 
             //String value = r2run.getResultPyrome(itemName);
-            String value = r2run.getResult("\"" + itemName + "\"");
-            LOG.info("the value='" + value + "'");
-            if ((value != null) && (value.equals("null"))) {
-                report().put(itemName, (String) null, desc, units);
+            String value = r2run.getResult( "\"" + itemName + "\"" );
+            LOG.info( "the value='" + value + "'" );
+            if ( ( value != null ) && ( value.equals( "null" ) ) ) {
+                report().put( itemName, ( String ) null, desc, units );
                 // if there is no value, then item should be removed from the array
             } else {
-                if ((dimension != null) && (dimension.length() > 0) && (value != null) && (!value.equals("null"))) {
+                if ( ( dimension != null ) && ( dimension.length() > 0 ) && ( value != null ) && ( !value.equals( "null" ) ) ) {
                     try {
-                        report().put(itemName, new JSONArray(value), desc, units);
-                    } catch (JSONException je) {
-                        processReportElement(itemName,dimension,units,desc, type, value);
+                        report().put( itemName, new JSONArray( value ), desc, units );
+                    }
+                    catch ( JSONException je ) {
+                        processReportElement( itemName, dimension, units, desc, type, value );
                     }
                 } else {
-                    processReportElement(itemName,dimension,units,desc, type, value);
+                    processReportElement( itemName, dimension, units, desc, type, value );
                 }
 
             }
-            if(dimension != null)
-                report().putMetaInfo(itemName,REPORT_DIM,new JSONArray(dimension));
-        }     
+            if ( dimension != null ) {
+                report().putMetaInfo( itemName, REPORT_DIM, new JSONArray( dimension ) );
+            }
+        }
     }
 
-
-    private void prepareHydraulicFlowElementFile() {
+    private void prepareHydraulicFlowElementFile () {
         // Given a Hydraulic Element Pointer, parse the XML and return a Hydraulic Flow Element
     }
 
+    // This is a gross signiture but due to csip report changes this is the easiest way to change it without losing Wes's logic.
+    private void processReportElement ( String itemName, String dim, String units, String desc, String type, String value ) throws Exception {
+        System.out.println( "------------------------------------------------------------------------PROCESSING ELEMENT:\n\n" );
+        System.out.println( "TYPE:" + type );
+        System.out.println( "VALUE:" + value );
+        System.out.println( "-------------------------------------------------------------------------------------------\n\n" );
 
-    // This is a gross signiture but due to csip report changes this is the easiest way to change it without losing Wes's logic.
-    private void processReportElement(String itemName, String dim, String units, String desc, String type, String value) throws Exception {
-        System.out.println("------------------------------------------------------------------------PROCESSING ELEMENT:\n\n");
-        System.out.println("TYPE:" + type);
-        System.out.println("VALUE:" + value);
-        System.out.println("-------------------------------------------------------------------------------------------\n\n");
+        if ( ( type.equals( "TEXT" ) ) || ( type.equals( "FILENAME" ) ) || ( type.equals( "DATE" ) ) ) {
+            // because the RomeShell returns escaped strings, and the JSONObject in Java re-escapes them
+            // we have to remove one level of "escaping" !!!
 
-        if ((type.equals("TEXT")) || (type.equals("FILENAME")) || (type.equals("DATE"))) {
-            // because the RomeShell returns escaped strings, and the JSONObject in Java re-escapes them
-            // we have to remove one level of "escaping" !!! 
-
-            String newString = StringEscapeUtils.unescapeJava(value);
+            String newString = StringEscapeUtils.unescapeJava( value );
             //String newString=value;
-            report().put(itemName, Services.removeFirstLastChar(newString), desc, units);
+            report().put( itemName, removeFirstLastChar( newString ), desc, units );
         }
-        if (type.equals("INTEGER") && (value != null) && (!value.equals("null")) && (!value.equals("\"\""))) {
+        if ( type.equals( "INTEGER" ) && ( value != null ) && ( !value.equals( "null" ) ) && ( !value.equals( "\"\"" ) ) ) {
             // trim off quotes
-            value = Services.removeFirstLastChar(value);
-            System.out.println("VALUE:" + value);
-            report().put(itemName, new Double(value).intValue(), desc, units);
+            value = removeFirstLastChar( value );
+            System.out.println( "VALUE:" + value );
+            report().put( itemName, new Double( value ).intValue(), desc, units );
         }
-        if (type.equals("REAL") && (value != null)) {
-            if ((!value.equals("null")) && (!value.equals("\"\""))) {
+        if ( type.equals( "REAL" ) && ( value != null ) ) {
+            if ( ( !value.equals( "null" ) ) && ( !value.equals( "\"\"" ) ) ) {
                 // trim off quotes
-                value = Services.removeFirstLastChar(value);
-                System.out.println("VALUE:" + value);
-                report().put(itemName, Double.parseDouble(value), desc, units);
+                value = removeFirstLastChar( value );
+                System.out.println( "VALUE:" + value );
+                report().put( itemName, Double.parseDouble( value ), desc, units );
             }
-            if (value.equals("\"\"")) {
-                report().put(itemName, new Double(0), desc, units);
+            if ( value.equals( "\"\"" ) ) {
+                report().put( itemName, new Double( 0 ), desc, units );
             }
         }
-        if (type.equals("")) {
-            report().put(itemName, value, desc, units);
+        if ( type.equals( "" ) ) {
+            report().put( itemName, value, desc, units );
         }
     }
 
-
-    private boolean allEqual(int... vals) {
-        if (vals.length < 2) {
+    private boolean allEqual ( int... vals ) {
+        if ( vals.length < 2 ) {
             return true;
         }
         int a = vals[0];
-        for (int i = 0; i < vals.length; i++) {
-            if (vals[i] != a) {
+        for ( int i = 0; i < vals.length; i++ ) {
+            if ( vals[i] != a ) {
                 return false;
             }
         }

web/WEB-INF/csip-defaults.json

@@ -1,5 +1,5 @@
 { 
-    "csip-r2.version": "$version: 2.11.8.10 93182438fa0e 2019-10-31 Shaun Case, built at 2019-11-12 16:39 by od$",
+    "csip-r2.version": "$version: 2.11.8.11 default 81 24eb0cf5c794 2019-11-12 od, built at 2021-05-10 10:42 by Lucas$",
     "lmod.db": "jdbc:sqlserver:\/\/129.82.20.242:1433;databaseName=lmod_temp;user=lmod-rw;password=?",
     "sdmONLINE":"true",
     "csip.session.ttl": "PT1M",