Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r5389 - in branches/new-structure-with-base2/ps-mdm-web-admin: ant src/main/java/org/perfsonar/webadmin/base2/config src/main/java/org/perfsonar/webadmin/base2/servlet src/main/java/org/perfsonar/webadmin/base2/servlet/util src/main/java/org/perfsonar/webadmin/base2/util src/main/java/org/perfsonar/webadmin/base2/xupdate tomcat

Subject: perfsonar development work

List archive

perfsonar: r5389 - in branches/new-structure-with-base2/ps-mdm-web-admin: ant src/main/java/org/perfsonar/webadmin/base2/config src/main/java/org/perfsonar/webadmin/base2/servlet src/main/java/org/perfsonar/webadmin/base2/servlet/util src/main/java/org/perfsonar/webadmin/base2/util src/main/java/org/perfsonar/webadmin/base2/xupdate tomcat


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r5389 - in branches/new-structure-with-base2/ps-mdm-web-admin: ant src/main/java/org/perfsonar/webadmin/base2/config src/main/java/org/perfsonar/webadmin/base2/servlet src/main/java/org/perfsonar/webadmin/base2/servlet/util src/main/java/org/perfsonar/webadmin/base2/util src/main/java/org/perfsonar/webadmin/base2/xupdate tomcat
  • Date: Wed, 9 Dec 2009 05:29:43 -0500

Author: trzaszcz
Date: 2009-12-09 05:29:43 -0500 (Wed, 09 Dec 2009)
New Revision: 5389

Added:

branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/xupdate/XObjectImpl.java

branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/xupdate/XPathQueryImpl.java
Removed:

branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/servlet/BasicConfiguration.java

branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/servlet/util/Abstraction.java
Modified:
branches/new-structure-with-base2/ps-mdm-web-admin/ant/build.xml
branches/new-structure-with-base2/ps-mdm-web-admin/ant/tomcat.properties

branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/config/HTMLGenerator.java

branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/config/ObjectMap.java

branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/HTMLUtil.java

branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/NSContext.java

branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/StringOutputStream.java

branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/WAXMLReader.java

branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/WAXMLWriter.java

branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/XMLUtil.java

branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/xupdate/XPathQueryFactoryImpl.java
branches/new-structure-with-base2/ps-mdm-web-admin/tomcat/web.xml
Log:
code refactoring

Modified: branches/new-structure-with-base2/ps-mdm-web-admin/ant/build.xml
===================================================================
--- branches/new-structure-with-base2/ps-mdm-web-admin/ant/build.xml
2009-12-09 09:36:04 UTC (rev 5388)
+++ branches/new-structure-with-base2/ps-mdm-web-admin/ant/build.xml
2009-12-09 10:29:43 UTC (rev 5389)
@@ -1,118 +1,86 @@
<?xml version="1.0"?>

-<project name="WebAdmin" basedir="..">
+<project name="WebAdmin" basedir="..">


-<property file="${basedir}/ant/const.properties"/>
-<property file="${basedir}/ant/tomcat.properties"/>
+ <property file="${basedir}/ant/const.properties" />
+ <property file="${basedir}/ant/tomcat.properties" />

-<!-- ======================= download.lib =================== -->
-<taskdef resource="net/sf/antcontrib/antlib.xml"
- uri="antlib:net.sf.antcontrib">
- <classpath>
- <pathelement location="${antcontrib.jar}"/>
- </classpath>
-</taskdef>
+ <!-- ======================= download.lib =================== -->
+ <taskdef resource="net/sf/antcontrib/antlib.xml"
uri="antlib:net.sf.antcontrib">
+ <classpath>
+ <pathelement location="${antcontrib.jar}" />
+ </classpath>
+ </taskdef>

-<property name="maven.jar"
-
value="${basedir}/lib/maven-artifact-ant-2.0.4-dep.jar"/>
+ <property name="maven.jar"
value="${basedir}/lib/maven-artifact-ant-2.0.4-dep.jar" />

-<macrodef name="init-lib-dependencies-macro"
- xmlns:artifact="urn:maven-artifact-ant">
+ <macrodef name="init-lib-dependencies-macro"
xmlns:artifact="urn:maven-artifact-ant">

- <attribute name="localRepositoryPath"/>
- <attribute name="remoteRepositoryUri1"/>
- <attribute name="remoteRepositoryUri2"/>
+ <attribute name="localRepositoryPath" />
+ <attribute name="remoteRepositoryUri1" />
+ <attribute name="remoteRepositoryUri2" />

- <sequential>
- <path id="maven.classpath">
- <pathelement location="${maven.jar}" />
- </path>
- <typedef resource="org/apache/maven/artifact/ant/antlib.xml"
- uri="urn:maven-artifact-ant">
- <classpath refid="maven.classpath"/>
- </typedef>
- <artifact:localRepository
- id="local.repository"
- location="${basedir}/@{localRepositoryPath}"
- layout="default"/>
-
- <artifact:remoteRepository id="remote.repository"
-
url="@{remoteRepositoryUri1}"/>
- <artifact:remoteRepository id="remote.repository.2"
- url="@{remoteRepositoryUri2}"/>
- </sequential>
-</macrodef>
+ <sequential>
+ <path id="maven.classpath">
+ <pathelement location="${maven.jar}" />
+ </path>
+ <typedef
resource="org/apache/maven/artifact/ant/antlib.xml"
uri="urn:maven-artifact-ant">
+ <classpath refid="maven.classpath" />
+ </typedef>
+ <artifact:localRepository id="local.repository"
location="${basedir}/@{localRepositoryPath}" layout="default" />

+ <artifact:remoteRepository id="remote.repository"
url="@{remoteRepositoryUri1}" />
+ <artifact:remoteRepository id="remote.repository.2"
url="@{remoteRepositoryUri2}" />
+ </sequential>
+ </macrodef>

-<target name="init-urnmaven">
- <path id="maven.classpath">
- <pathelement location="${maven.jar}" />
- </path>
- <typedef resource="org/apache/maven/artifact/ant/antlib.xml"
- uri="urn:maven-artifact-ant">
- <classpath refid="maven.classpath"/>
- </typedef>
-</target>

-<target name="init-lib-dependencies"
- depends="init-urnmaven">
- <init-lib-dependencies-macro
- localRepositoryPath="lib/repository"
-
remoteRepositoryUri1="http://anonsvn.internet2.edu/svn/perfsonar/trunk/jar-repository/";
- remoteRepositoryUri2="http://www.ibiblio.org/maven2"/>
-</target>
+ <target name="init-urnmaven">
+ <path id="maven.classpath">
+ <pathelement location="${maven.jar}" />
+ </path>
+ <typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="urn:maven-artifact-ant">
+ <classpath refid="maven.classpath" />
+ </typedef>
+ </target>

-<target name="get-repo"
- depends="init-lib-dependencies"
- xmlns:artifact="urn:maven-artifact-ant" >
- <artifact:dependencies>
- <dependency groupId="tomcat"
- artifactId="servlet-api"
- version="5.0.28"/>
- <dependency groupId="Validation"
- artifactId="msv"
- version="1.0"/>
- <dependency groupId="Validation"
- artifactId="xsdlib"
- version="1.0"/>
- <dependency groupId="Validation"
- artifactId="isorelax"
- version="1.0"/>
- <dependency groupId="Validation"
- artifactId="relaxngDatatype"

- version="1.0"/>
- <dependency groupId="xerces"
- artifactId="xercesImpl"
- version="2.8.0"/>
- <dependency groupId="xalan"
- artifactId="xalan"
- version="2.7.0"/>
- <localRepository refid="local.repository"/>
- <remoteRepository refid="remote.repository"/>
- </artifact:dependencies>
-</target>
+ <target name="init-lib-dependencies" depends="init-urnmaven">
+ <init-lib-dependencies-macro
localRepositoryPath="lib/repository"
remoteRepositoryUri1="http://anonsvn.internet2.edu/svn/perfsonar/trunk/jar-repository/";
remoteRepositoryUri2="http://www.ibiblio.org/maven2"; />
+ </target>

-<!-- ======================= generate schema-based stubs ===================
-->
-<target name="waschema">
- <!--
+ <target name="get-repo" depends="init-lib-dependencies"
xmlns:artifact="urn:maven-artifact-ant">
+ <artifact:dependencies>
+ <dependency groupId="tomcat" artifactId="servlet-api"
version="5.0.28" />
+ <dependency groupId="Validation" artifactId="msv"
version="1.0" />
+ <dependency groupId="Validation" artifactId="xsdlib"
version="1.0" />
+ <dependency groupId="Validation"
artifactId="isorelax" version="1.0" />
+ <dependency groupId="Validation"
artifactId="relaxngDatatype" version="1.0" />
+ <dependency groupId="xerces" artifactId="xercesImpl"
version="2.8.0" />
+ <dependency groupId="xalan" artifactId="xalan"
version="2.7.0" />
+ <localRepository refid="local.repository" />
+ <remoteRepository refid="remote.repository" />
+ </artifact:dependencies>
+ </target>
+
+ <!-- ======================= generate schema-based stubs
=================== -->
+ <target name="waschema">
+ <!--
Set up the classpath for the generation task.
Include all the standard jaxme jars.
-->
<path id="generate.class.path">
<pathelement
location="${lib}/jaxme2/jaxme2-${jaxme.version}.jar" />
- <pathelement
location="${lib}/jaxme2/jaxmeapi-${jaxme.version}.jar" />
- <pathelement
location="${libext}/jaxme2/jaxmejs-${jaxme.version}.jar" />
- <pathelement
location="${lib}/jaxme2/jaxmexs-${jaxme.version}.jar" />
+ <pathelement
location="${lib}/jaxme2/jaxmeapi-${jaxme.version}.jar" />
+ <pathelement
location="${libext}/jaxme2/jaxmejs-${jaxme.version}.jar" />
+ <pathelement
location="${lib}/jaxme2/jaxmexs-${jaxme.version}.jar" />
</path>

- <!--
+ <!--
Defines the generation task using that classpath.
-->
- <taskdef name="xjc"
- classname="org.apache.ws.jaxme.generator.XJCTask"
- classpathref="generate.class.path"/>
- <!--
+ <taskdef name="xjc"
classname="org.apache.ws.jaxme.generator.XJCTask"
classpathref="generate.class.path" />
+ <!--
Generate source code.
The 'schema' attribute gives the path to the schema the sources
will be generated from.
@@ -120,10 +88,8 @@
will be generated into. Sources will be created in subdirectories
corresponding to the package structure.
-->
- <xjc
- schema="${schema}/xsd/wa.xsd"
- target="${src}">
- <!--
+ <xjc schema="${schema}/xsd/wa.xsd" target="${src}">
+ <!--
The source files being created. The xjc task uses these for
a check, whether they are uptodate. If so, the generation is
skipped, for improved speed.
@@ -132,256 +98,211 @@
written files or files created by another generator or xjc call.
If so, these need to be excluded from the uptodate check.
-->
- <produces
includes="org/perfsonar/webadmin/base2/waschema/v20090201/*.java"/>
- </xjc>
+ <produces
includes="org/perfsonar/webadmin/base2/waschema/v20090201/*.java" />
+ </xjc>
</target>

-<!-- ======================= create WA jar =================== -->
+ <!-- ======================= create WA jar =================== -->
<target name="build-web-admin" depends="compile,cleanjar">

<fileset id="resources" dir="${src}">
- <include
name="org/perfsonar/webadmin/base2/waschema/v${wa.version}/jaxb.properties"/>
- <include
name="org/perfsonar/webadmin/base2/waschema/v${wa.version}/Configuration.xml"/>
- </fileset>
- <jar jarfile="${build}/${jarfilename}-${version}.jar"
- basedir="${build}/class" > <!-- manifest="Manifest"-->
- <fileset refid="resources"/>
- </jar>
- </target>
+ <include
name="org/perfsonar/webadmin/base2/waschema/v${wa.version}/jaxb.properties" />
+ <include
name="org/perfsonar/webadmin/base2/waschema/v${wa.version}/Configuration.xml"
/>
+ </fileset>
+ <jar jarfile="${build}/${jarfilename}-${version}.jar"
basedir="${build}/class">
+ <!-- manifest="Manifest"-->
+ <fileset refid="resources" />
+ </jar>
+ </target>

- <target name="cleanjar">
- <delete>
- <fileset dir="${build}" includes="${jarfilename}-*.jar" />
- </delete>
- </target>
-
- <target name="compile" depends="waschema">
- <path id="lib.path">
+ <target name="cleanjar">
+ <delete>
+ <fileset dir="${build}"
includes="${jarfilename}-*.jar" />
+ </delete>
+ </target>
+
+ <target name="compile" depends="waschema">
+ <path id="lib.path">
<fileset dir="${lib}">
- <include name="**/*.jar"/>
+ <include name="**/*.jar" />
</fileset>
<fileset dir="${servlet.dir}">
- <include name="*.jar"/>
+ <include name="*.jar" />
</fileset>
<pathelement location="${xalan.jar}" />
- </path>
-
- <tstamp/>
+ </path>

- <mkdir dir="${build}/dependencies"/>
- <depend srcdir="${src}"
- destdir="${build}/class"
- cache="${build}/dependencies"
- closure="true"/>
+ <tstamp />

- <mkdir dir="${build}/class"/>
- <javac srcdir="${src}"
- destdir="${build}/class"
- classpathref="lib.path"
- debug="on"/>
- </target>
+ <mkdir dir="${build}/dependencies" />
+ <depend srcdir="${src}" destdir="${build}/class"
cache="${build}/dependencies" closure="true" />

-<!-- ======================= Validation stuff =================== -->
- <target name="validatewa">
- <path id="validwa.lib.path">
+ <mkdir dir="${build}/class" />
+ <javac srcdir="${src}" destdir="${build}/class"
classpathref="lib.path" debug="on" />
+ </target>
+
+ <!-- ======================= Validation stuff =================== -->
+ <target name="validatewa">
+ <path id="validwa.lib.path">
<pathelement location="${msv.jar}" />
<pathelement location="${xerces.jar}" />
<pathelement location="${isorelax.jar}" />
<pathelement location="${relaxngDatatype.jar}" />
<pathelement location="${xsdlib.jar}" />
</path>
- <java classpathref="validwa.lib.path"
- classname ="com.sun.msv.driver.textui.Driver"
- >
- <arg value="http://www.w3.org/2001/XMLSchema.xsd"/>
- <arg value="${basedir}/schema/xsd/wa.xsd"/>
- </java>
- </target>
+ <java classpathref="validwa.lib.path"
classname="com.sun.msv.driver.textui.Driver">
+ <arg value="http://www.w3.org/2001/XMLSchema.xsd"; />
+ <arg value="${basedir}/schema/xsd/wa.xsd" />
+ </java>
+ </target>

- <target name="validatefile">
- <path id="validwa.lib.path">
- <pathelement location="${msv.jar}" />
+ <target name="validatefile">
+ <path id="validwa.lib.path">
+ <pathelement location="${msv.jar}" />
<pathelement location="${xerces.jar}" />
<pathelement location="${isorelax.jar}" />
<pathelement location="${relaxngDatatype.jar}" />
<pathelement location="${xsdlib.jar}" />
</path>
- <java classpathref="validwa.lib.path"
- classname ="com.sun.msv.driver.textui.Driver"
- >
- <arg value="${basedir}/schema/xsd/wa.xsd"/>
- <arg value="${xml.file}"/>
- </java>
- </target>
+ <java classpathref="validwa.lib.path"
classname="com.sun.msv.driver.textui.Driver">
+ <arg value="${basedir}/schema/xsd/wa.xsd" />
+ <arg value="${xml.file}" />
+ </java>
+ </target>

-<!-- ======================= Generate RNG from XSD =================== -->
- <target name="xsd2rng" >
- <path id="validwa.lib.path">
- <pathelement location="${msv.jar}" />
+ <!-- ======================= Generate RNG from XSD
=================== -->
+ <target name="xsd2rng">
+ <path id="validwa.lib.path">
+ <pathelement location="${msv.jar}" />
<pathelement location="${xerces.jar}" />
<pathelement location="${isorelax.jar}" />
<pathelement location="${relaxngDatatype.jar}" />
<pathelement location="${xsdlib.jar}" />
<pathelement location="${rngconv.jar}" />
</path>
- <mkdir dir="${basedir}/schema/rng"/>
- <java classpathref="validwa.lib.path"
- classname ="com.sun.msv.writer.relaxng.Driver"
- >
- <arg value="${schema}/xsd/wa.xsd"/>
- <redirector output="${basedir}/schema/rng/wa.rng" />
- </java>
+ <mkdir dir="${basedir}/schema/rng" />
+ <java classpathref="validwa.lib.path"
classname="com.sun.msv.writer.relaxng.Driver">
+ <arg value="${schema}/xsd/wa.xsd" />
+ <redirector output="${basedir}/schema/rng/wa.rng" />
+ </java>
</target>

-<!-- ======================= Generate RNC from RNG =================== -->
- <target name="rng2rnc" depends="xsd2rng" >
- <path id="rng2rnc.lib.path">
+ <!-- ======================= Generate RNC from RNG
=================== -->
+ <target name="rng2rnc" depends="xsd2rng">
+ <path id="rng2rnc.lib.path">
<fileset dir="${libext}/trang">
- <include name="trang.jar"/>
- </fileset>
- <!--<fileset dir="${lib}/saxon">
+ <include name="trang.jar" />
+ </fileset>
+ <!--<fileset dir="${lib}/saxon">
<include name="saxon.jar"/>
</fileset>-->
<pathelement location="${xerces.jar}" />
</path>
- <mkdir dir="${basedir}/schema/rnc"/>
- <java classpathref="rng2rnc.lib.path"
- classname
="com.thaiopensource.relaxng.translate.Driver"
- >
- <arg value="-I"/>
- <arg value="rng"/>
- <arg value="-O"/>
- <arg value="rnc"/>
- <arg value="${basedir}/schema/rng/wa.rng"/>
- <arg value="${basedir}/schema/rnc/wa.rnc"/>
- </java>
- </target>
+ <mkdir dir="${basedir}/schema/rnc" />
+ <java classpathref="rng2rnc.lib.path"
classname="com.thaiopensource.relaxng.translate.Driver">
+ <arg value="-I" />
+ <arg value="rng" />
+ <arg value="-O" />
+ <arg value="rnc" />
+ <arg value="${basedir}/schema/rng/wa.rng" />
+ <arg value="${basedir}/schema/rnc/wa.rnc" />
+ </java>
+ </target>

-<!-- ======================= JavaDoc =================== -->
- <target name="doc">
- <javadoc packagenames="org.perfsonar.*"
- sourcepath="${src}"
- defaultexcludes="yes"
- destdir="${basedir}/tmp/doc/api"
- author="true"
- version="true"
- use="true"
- linksource="yes"
- windowtitle="Test API"/>
-



+ <!-- ======================= JavaDoc =================== -->
+ <target name="doc">
+ <javadoc packagenames="org.perfsonar.*" sourcepath="${src}"
defaultexcludes="yes" destdir="${basedir}/tmp/doc/api" author="true"
version="true" use="true" linksource="yes" windowtitle="Test API" />
+
</target>
-<!-- ======================= WAR creation =================== -->
- <target name="war">
+ <!-- ======================= WAR creation =================== -->
+ <target name="war" depends="build-web-admin">

- <mkdir dir="${build}/flatten"/>
- <copy todir="${build}/flatten" flatten="true">
- <fileset dir="${lib}">
- <exclude name="jaxme2" />
- <exclude name="saxon" />
- <exclude name="xalan" />
- <exclude name="xmldb" />
- </fileset>
- </copy>
-
- <war destfile="${build}/${warfilename}.war"
- webxml="${temp.dir.web-inf}/web.xml"
- excludes="${lib}/servlet/*">
- <fileset dir="${pages.dir}"/>
- <metainf dir="${metainf.dir}"/>
- <lib dir="${build}/flatten">
- <exclude name="${lib}/servlet/*"/>
- </lib>
- <lib file="${build}/${jarfilename}-${version}.jar"/>
- <classes dir="${classes.dir}" />
- <zipfileset dir="${graphics.dir}"
- prefix="graphics"/>
- </war>
- </target>
-
-<!-- ======================= tomcat deployment =================== -->
+ <mkdir dir="${build}/flatten" />
+ <copy todir="${build}/flatten" flatten="true">
+ <fileset dir="${lib}">
+ <exclude name="jaxme2" />
+ <exclude name="saxon" />
+ <exclude name="xalan" />
+ <exclude name="xmldb" />
+ </fileset>
+ </copy>

- <path id="tomcat.deployer.classpath">
+ <war destfile="${build}/${warfilename}.war"
webxml="${temp.dir.web-inf}/web.xml" excludes="${lib}/servlet/*">
+ <fileset dir="${pages.dir}" />
+ <metainf dir="${metainf.dir}" />
+ <lib dir="${build}/flatten">
+ <exclude name="${lib}/servlet/*" />
+ </lib>
+ <lib file="${build}/${jarfilename}-${version}.jar" />
+ <classes dir="${classes.dir}" />
+ <zipfileset dir="${graphics.dir}" prefix="graphics" />
+ </war>
+ </target>
+
+ <target name="war-deploy" depends="war">
+ <delete dir="${tomcat.dir}/webapps/${warfilename}"
includes="**/*.*" includeemptydirs="true"/>
+ <delete file="${tomcat.dir}/webapps/${warfilename}.war"/>
+ <copy todir="${tomcat.dir}/webapps/"
file="build/${warfilename}.war"/>
+ </target>
+
+
+
+ <!-- ======================= tomcat deployment =================== -->
+
+ <path id="tomcat.deployer.classpath">
<fileset dir="${tomcat.deployer.dir}">
- <include name="*.jar"/>
- </fileset>
- </path>
+ <include name="*.jar" />
+ </fileset>
+ </path>

- <taskdef resource="org/apache/catalina/ant/catalina.tasks"
- classpathref="tomcat.deployer.classpath"/>
+ <taskdef resource="org/apache/catalina/ant/catalina.tasks"
classpathref="tomcat.deployer.classpath" />

-<target name="deploy" description="Deploy web application">
- <deploy url="${tomcat.manager.url}"
- username="${tomcat.username}"
- password="${tomcat.password}"
- path="/${webapp.name}"
-
war="file://${build}/${warfilename}-${version}.war"
- update="true" />
- </target>
+ <target name="deploy" description="Deploy web application">
+ <deploy url="${tomcat.manager.url}"
username="${tomcat.username}" password="${tomcat.password}"
path="/${webapp.name}" war="file://${build}/${warfilename}-${version}.war"
update="true" />
+ </target>

- <target name="undeploy" description="Undeploy web application">
- <undeploy
- url="${tomcat.manager.url}"
- username="${tomcat.username}"
- password="${tomcat.password}"
- path="/${webapp.name}"
- />
- </target>
+ <target name="undeploy" description="Undeploy web application">
+ <undeploy url="${tomcat.manager.url}"
username="${tomcat.username}" password="${tomcat.password}"
path="/${webapp.name}" />
+ </target>

- <!-- Webapp lifecycle control -->
- <target name="start" description="Start web application">
- <start
- url="${tomcat.manager.url}"
- username="${tomcat.username}"
- password="${tomcat.password}"
- path="/${webapp.name}"
- />
- </target>
- <target name="reload" description="Reload web application">
- <reload
- url="${tomcat.manager.url}"
- username="${tomcat.username}"
- password="${tomcat.password}"
- path="/${webapp.name}"
- />
- </target>
+ <!-- Webapp lifecycle control -->
+ <target name="start" description="Start web application">
+ <start url="${tomcat.manager.url}"
username="${tomcat.username}" password="${tomcat.password}"
path="/${webapp.name}" />
+ </target>
+ <target name="reload" description="Reload web application">
+ <reload url="${tomcat.manager.url}"
username="${tomcat.username}" password="${tomcat.password}"
path="/${webapp.name}" />
+ </target>

- <target name="stop" description="Stop web application">
- <stop
- url="${tomcat.manager.url}"
- username="${tomcat.username}"
- password="${tomcat.password}"
- path="/${webapp.name}"
- />
- </target>
+ <target name="stop" description="Stop web application">
+ <stop url="${tomcat.manager.url}"
username="${tomcat.username}" password="${tomcat.password}"
path="/${webapp.name}" />
+ </target>

-<!-- ======================= Clean =================== -->
- <target name="clean">
- <delete dir="${build}/class"/>
- <delete dir="${build}/dependencies"/>
- <delete dir="${build}/flatten"/>
- </target>
+ <!-- ======================= Clean =================== -->
+ <target name="clean">
+ <delete dir="${build}/class" />
+ <delete dir="${build}/dependencies" />
+ <delete dir="${build}/flatten" />
+ </target>

- <target name="distclean" depends="clean">
- <delete file="${build}/${jarfilename}-${version}.jar"/>
- <delete file="${build}/${warfilename}-${version}.war"/>
- </target>
+ <target name="distclean" depends="clean">
+ <delete file="${build}/${jarfilename}-${version}.jar" />
+ <delete file="${build}/${warfilename}-${version}.war" />
+ </target>

-<!-- ======================= TESTING =================== -->
+ <!-- ======================= TESTING =================== -->

-<!-- ======================= Run a WA class =================== -->
- <target name="runwa">
- <path id="runwa.lib.path">
+ <!-- ======================= Run a WA class =================== -->
+ <target name="runwa">
+ <path id="runwa.lib.path">
<fileset dir="${lib}">
- <include name="**/*.jar"/>
+ <include name="**/*.jar" />
</fileset>
<pathelement
location="${build}/${jarfilename}-${version}.jar" />
<pathelement location="${xalan.jar}" />
<pathelement location="${xerces.jar}" />
</path>
- <java classpathref="runwa.lib.path"
- classname ="${runwa.class}"
- >
- <arg value="${runwa.arg1}"/>
- </java>
+ <java classpathref="runwa.lib.path"
classname="${runwa.class}">
+ <arg value="${runwa.arg1}" />
+ </java>
</target>
</project>

Modified:
branches/new-structure-with-base2/ps-mdm-web-admin/ant/tomcat.properties
===================================================================
--- branches/new-structure-with-base2/ps-mdm-web-admin/ant/tomcat.properties
2009-12-09 09:36:04 UTC (rev 5388)
+++ branches/new-structure-with-base2/ps-mdm-web-admin/ant/tomcat.properties
2009-12-09 10:29:43 UTC (rev 5389)
@@ -1,6 +1,12 @@
# Properties for Tomcat Server
+
+
+tomcat.dir=/usr/local/tomcat/
tomcat.server=127.0.0.1
tomcat.manager.url=http://127.0.0.1:8080/manager
tomcat.username=tomcat
tomcat.password=tomcat
webapp.name=wa
+
+
+

Modified:
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/config/HTMLGenerator.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/config/HTMLGenerator.java
2009-12-09 09:36:04 UTC (rev 5388)
+++
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/config/HTMLGenerator.java
2009-12-09 10:29:43 UTC (rev 5389)
@@ -1,421 +1,378 @@
package org.perfsonar.webadmin.base2.config;

-import org.perfsonar.webadmin.base2.waschema.v20090201.*;
-
import java.io.PrintStream;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.HashSet;

-import org.perfsonar.webadmin.base2.util.WAXMLReader;
-import org.perfsonar.webadmin.base2.util.StringOutputStream;
-import org.perfsonar.webadmin.base2.util.XMLUtil;
+import org.perfsonar.webadmin.base2.util.HTMLUtil;
import org.perfsonar.webadmin.base2.util.NSContext;
+import org.perfsonar.webadmin.base2.util.StringOutputStream;
import org.perfsonar.webadmin.base2.util.Tuple;
-import org.perfsonar.webadmin.base2.util.HTMLUtil;
-
-import javax.xml.bind.JAXBContext;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.Document;
+import org.perfsonar.webadmin.base2.util.XMLUtil;
+import org.perfsonar.webadmin.base2.waschema.v20090201.BaseType;
+import org.perfsonar.webadmin.base2.waschema.v20090201.BaseUIType;
+import org.perfsonar.webadmin.base2.waschema.v20090201.ComplexGroupUIType;
+import org.perfsonar.webadmin.base2.waschema.v20090201.ComplexUIType;
+import org.perfsonar.webadmin.base2.waschema.v20090201.GroupsType;
+import org.perfsonar.webadmin.base2.waschema.v20090201.LinkType;
+import org.perfsonar.webadmin.base2.waschema.v20090201.PageType;
+import org.perfsonar.webadmin.base2.waschema.v20090201.PlainType;
+import org.perfsonar.webadmin.base2.waschema.v20090201.WebAdminInterface;
import org.w3c.dom.NodeList;

-public class HTMLGenerator
-{
- public enum UIType
- {
- DROPDOWN,
- RADIO,
- RADIOGROUP,
- TEXTBOX;
- public static UIType fromString( String s )
- {
- s = s.toLowerCase();
- if( s.equals("dropdown")) return DROPDOWN;
- else if( s.equals("radio")) return RADIO;
- else if( s.equals("radiogroup")) return RADIOGROUP;
- else if( s.equals("textbox")) return TEXTBOX;
- else throw new RuntimeException("Bad string");
- }
- public String toString()
- {
- switch(this)
- {
- case DROPDOWN: return "dropdown";
- case RADIO: return "radio";
- case RADIOGROUP: return "radiogroup";
- case TEXTBOX: return "textbox";
- }
- return "";
- }
+public class HTMLGenerator {
+ public enum UIType {
+ DROPDOWN, RADIO, RADIOGROUP, TEXTBOX;
+ public static UIType fromString(String s) {
+ s = s.toLowerCase();
+ if (s.equals("dropdown"))
+ return DROPDOWN;
+ else if (s.equals("radio"))
+ return RADIO;
+ else if (s.equals("radiogroup"))
+ return RADIOGROUP;
+ else if (s.equals("textbox"))
+ return TEXTBOX;
+ else
+ throw new RuntimeException("Bad string");
+ }
+
+ public String toString() {
+ switch (this) {
+ case DROPDOWN:
+ return "dropdown";
+ case RADIO:
+ return "radio";
+ case RADIOGROUP:
+ return "radiogroup";
+ case TEXTBOX:
+ return "textbox";
+ }
+ return "";
+ }
};

private PrintStream out = null;
private String url = "";
private boolean plainContext = true;
- private ObjectMap omap=null;
- private HTMLUtil html=null;
+ private ObjectMap omap = null;
+ private HTMLUtil html = null;

- private void println( String s ) { if( out != null ) out.println(s); }
+ private void println(String s) {
+ if (out != null)
+ out.println(s);
+ }

- public HTMLGenerator(){}
+ public HTMLGenerator() {
+ }

- public void translate( WebAdminInterface wai )
- {
- if( wai == null ) return;
+ public void translate(WebAdminInterface wai) {
+ if (wai == null)
+ return;
List page = wai.getPage();
- if( page != null )
- for( int i=0, sz = page.size(); i < sz ; i++ )
- translate((PageType) page.get(i));

+ if (page != null)
+ for (int i = 0, sz = page.size(); i < sz; i++)
+ translate((PageType) page.get(i));
}

- private static String makeLinkList( List blist, boolean big, boolean
advanced )
- {
+ private static String makeLinkList(List blist, boolean big, boolean
advanced) {
String basic = "";
- String cls = advanced?"configheadinglavender":"configheading";
- if(big)
- for( Object o : blist )
- {
- LinkType l = (LinkType) o;
- basic = HTMLUtil.tag("tr",
- HTMLUtil.tag("td",HTMLUtil.att("class",cls),
- HTMLUtil.tag("p",
- HTMLUtil.tag("a",
-
HTMLUtil.att("href","config?page="+l.getUrl())+
-
HTMLUtil.att("target","_self")
-
,l.getTitle())
- ) +
- HTMLUtil.tag("p","&nbsp")+
- HTMLUtil.tag("p","&nbsp")
- )
- ) + "\n";
- }
- else
- {
- for( Object o : blist )
- {
- LinkType l = (LinkType) o;
- basic = HTMLUtil.tag("a",
-
HTMLUtil.att("href","config?page="+l.getUrl())+
-
HTMLUtil.att("target","_self")
-
,l.getTitle()) + "<br/>";
+ String cls = advanced ? "configheadinglavender" :
"configheading";
+ if (big)
+ for (Object o : blist) {
+ LinkType l = (LinkType) o;
+ basic = HTMLUtil.tag("tr", HTMLUtil.tag("td",
HTMLUtil.att(
+ "class", cls),
HTMLUtil.tag("p",
+ HTMLUtil
+ .tag("a",
HTMLUtil.att("href", "config?page="
+
+ l.getUrl())
+
+ HTMLUtil.att("target", "_self"), l
+
.getTitle()))
+ + HTMLUtil.tag("p", "&nbsp")
+ + HTMLUtil.tag("p", "&nbsp")))
+ + "\n";
}
- if( basic.equals("") ) return "";
- return "<p><span class=\"navtex\">"+
- basic + "</span> </p>";
+ else {
+ for (Object o : blist) {
+ LinkType l = (LinkType) o;
+ basic = HTMLUtil.tag("a",
HTMLUtil.att("href", "config?page="
+ + l.getUrl())
+ + HTMLUtil.att("target",
"_self"), l.getTitle())
+ + "<br/>";
+ }
+ if (basic.equals(""))
+ return "";
+ return "<p><span class=\"navtex\">" + basic +
"</span> </p>";
}
return basic;
}

- public static String[] makeLinks( ObjectMap o , boolean b)
- {
+ public static String[] makeLinks(ObjectMap o, boolean b) {
WebAdminInterface wai;
- if( o == null )
+ if (o == null)
throw new RuntimeException("Null object map");
- else if( (wai=o.getWA()) == null )
+ else if ((wai = o.getWA()) == null)
throw new RuntimeException("Null web admin
interface");
- return new String[]{ makeLinkList(wai.getBasiclink(),b,false),
-
makeLinkList(wai.getAdvancedlink(),b,true)
- };
+ return new String[] { makeLinkList(wai.getBasiclink(), b,
false),
+ makeLinkList(wai.getAdvancedlink(), b, true)
};
}

- public boolean translate( String url , ObjectMap o, PrintStream o1 )
- {
+ public boolean translate(String url, ObjectMap o, PrintStream o1) {
omap = o;
WebAdminInterface wai = omap.getWA();
out = o1;
html = new HTMLUtil(out);
- if( wai == null ) return false;
+ if (wai == null)
+ return false;
List page = wai.getPage();
- if( page != null )
- for( int i=0, sz = page.size(); i < sz ; i++ )
- {
- PageType pt = (PageType) page.get(i);
- if( raw(getData(pt.getUrl())).equals(url) )
- {
- translate(pt);
- return true;
- }
+ if (page != null)
+ for (int i = 0, sz = page.size(); i < sz; i++) {
+ PageType pt = (PageType) page.get(i);
+ if (raw(getData(pt.getUrl())).equals(url)) {
+ translate(pt);
+ return true;
+ }
}
- return false;
+ return false;
}

- public void translate( PageType pg )
- {
- if( pg == null ) return;
- //String u = pg.getUrl();
- //if( u != null ) url = u;
+ public void translate(PageType pg) {
+ if (pg == null)
+ return;
+ // String u = pg.getUrl();
+ // if( u != null ) url = u;
List plain = pg.getPlain();
GroupsType groups = pg.getGroups();
- if( groups != null )
- {
+ if (groups != null) {
boolean oldContext = plainContext;
plainContext = false;
translate(groups);
plainContext = oldContext;
- }
- else if( plain != null )
- {
+ } else if (plain != null) {
boolean oldContext = plainContext;
plainContext = true;
- for( int i=0, sz = plain.size(); i < sz ; i++ )
- translate((PlainType) plain.get(i));

+ for (int i = 0, sz = plain.size(); i < sz; i++)
+ translate((PlainType) plain.get(i));
plainContext = oldContext;
- }
- else throw new RuntimeException("Unexpected page type.");
+ } else
+ throw new RuntimeException("Unexpected page type.");
}

- public void translate( GroupsType g )
- {
+ public void translate(GroupsType g) {
}

- public void translate( PlainType p )
- {
- if( p == null ) return;
- if( p.getTextbox() != null )
translateBaseUI(p.getTextbox(),UIType.TEXTBOX);
- else if( p.getRadiogroup() != null )
translate(p.getRadiogroup(),UIType.RADIOGROUP);
- else if( p.getRadio() != null )
translate(p.getRadio(),UIType.RADIO);
- else if( p.getDropdown() != null)
translate(p.getDropdown(),UIType.DROPDOWN);
- else throw new RuntimeException("Unexpected UI type.");
+ public void translate(PlainType p) {
+ if (p == null)
+ return;
+ if (p.getTextbox() != null)
+ translateBaseUI(p.getTextbox(), UIType.TEXTBOX);
+ else if (p.getRadiogroup() != null)
+ translate(p.getRadiogroup(), UIType.RADIOGROUP);
+ else if (p.getRadio() != null)
+ translate(p.getRadio(), UIType.RADIO);
+ else if (p.getDropdown() != null)
+ translate(p.getDropdown(), UIType.DROPDOWN);
+ else
+ throw new RuntimeException("Unexpected UI type.");
}

- public void translateBaseUI( BaseUIType b , UIType u )
- {
- switch(u)
- {
- case TEXTBOX:
- drawTextBox( getRawData(b.getTitle()),
-
getSingleData(b.getDefault())
- );
- break;
- default:
- throw new RuntimeException("Unexpected
BaseUI type.");
+ public void translateBaseUI(BaseUIType b, UIType u) {
+ switch (u) {
+ case TEXTBOX:
+ drawTextBox(getRawData(b.getTitle()),
getSingleData(b.getDefault()));
+ break;
+ default:
+ throw new RuntimeException("Unexpected BaseUI type.");
}
}

- public void translate( ComplexGroupUIType cgui , UIType u )
- {
- switch(u)
- {
- case RADIOGROUP:
- List plains = cgui.getPlain();
- if( plains == null ) return;
- PrintStream oldOut = out;
- StringOutputStream sos = new
StringOutputStream();
- out = new PrintStream(sos);
- for( int i=0,sz=plains.size() ; i < sz ; i++ )
translate((PlainType)plains.get(i));
- out = oldOut;
-
drawRadiogroup(getData(cgui.getValues()),sos.toString());
- break;
- default:
- throw new RuntimeException("Unexpected
ComplexGroupUI type.");
+ public void translate(ComplexGroupUIType cgui, UIType u) {
+ switch (u) {
+ case RADIOGROUP:
+ List plains = cgui.getPlain();
+ if (plains == null)
+ return;
+ PrintStream oldOut = out;
+ StringOutputStream sos = new StringOutputStream();
+ out = new PrintStream(sos);
+ for (int i = 0, sz = plains.size(); i < sz; i++)
+ translate((PlainType) plains.get(i));
+ out = oldOut;
+ drawRadiogroup(getData(cgui.getValues()),
sos.toString());
+ break;
+ default:
+ throw new RuntimeException("Unexpected ComplexGroupUI
type.");
}
}

- public void translate( ComplexUIType cui , UIType u )
- {
- Tuple<Integer,String[]> def = getData(cui.getDefault());
- Tuple<Integer,String[]> all = getData(cui.getValues());
+ public void translate(ComplexUIType cui, UIType u) {
+ Tuple<Integer, String[]> def = getData(cui.getDefault());
+ Tuple<Integer, String[]> all = getData(cui.getValues());
String[] alls = all.second()[0].split(",");
- Set<String> set = new HashSet<String>
-
(def.second().length+all.second().length);
-
- for( String s : alls) set.add(s);
+ Set<String> set = new HashSet<String>(def.second().length
+ + all.second().length);
+
+ for (String s : alls)
+ set.add(s);
HashSet<String> singleton = new HashSet<String>(1);
singleton.add(def.second()[0]);
set.removeAll(singleton);

- String[] rets = new String[set.size()+1];
+ String[] rets = new String[set.size() + 1];
rets[0] = def.second()[0];
- int i=rets.length-1;
- for( Object o : set ) rets[i--] = (String) o;
+ int i = rets.length - 1;
+ for (Object o : set)
+ rets[i--] = (String) o;

- Tuple<Integer,String[]> ret =
- new
Tuple<Integer,String[]>(def.first(),
-
rets);
+ Tuple<Integer, String[]> ret = new Tuple<Integer, String[]>(
+ def.first(), rets);

- switch(u)
- {
- case RADIO:
- drawRadio(getSingleData(cui.getTitle()),
- ret);
- break;
- case DROPDOWN:
- drawDropdown(getSingleData(cui.getTitle()),
- ret);
- break;
- default:
- throw new RuntimeException("Unexpected
ComplexUI type.");
+ switch (u) {
+ case RADIO:
+ drawRadio(getSingleData(cui.getTitle()), ret);
+ break;
+ case DROPDOWN:
+ drawDropdown(getSingleData(cui.getTitle()), ret);
+ break;
+ default:
+ throw new RuntimeException("Unexpected ComplexUI
type.");
}
}

- private static String raw( Tuple<Integer,String[]> t )
- { return (t.second())[0]; }
+ private static String raw(Tuple<Integer, String[]> t) {
+ return (t.second())[0];
+ }

- private static Tuple<Integer,String> single( Tuple<Integer,String[]>
t)
- { return new Tuple<Integer,String>(t.first(),raw(t)); }
+ private static Tuple<Integer, String> single(Tuple<Integer, String[]>
t) {
+ return new Tuple<Integer, String>(t.first(), raw(t));
+ }

- private Tuple<Integer,String> getSingleData( BaseType b )
- { return single(getData(b)); }
+ private Tuple<Integer, String> getSingleData(BaseType b) {
+ return single(getData(b));
+ }

- private String getRawData( BaseType b )
- { return raw(getData(b)); }
- //////////////////////////////////////////////////////
- private Tuple<Integer,String[]> getData( BaseType b ) //FIXME
+ private String getRawData(BaseType b) {
+ return raw(getData(b));
+ }
+
+ // ////////////////////////////////////////////////////
+ private Tuple<Integer, String[]> getData(BaseType b) // FIXME
{
- if( b.getText() != null && !b.getText().equals("") )
- return new Tuple<Integer,String[]>(
-
omap.registerObject(b),
- new String[] {
b.getText().trim()}); //maybe a list
- else
- {
- Tuple<String,String> t =
XMLUtil.parseXPath(b.getXpath());
+ if (b.getText() != null && !b.getText().equals(""))
+ return new Tuple<Integer,
String[]>(omap.registerObject(b),
+ new String[] { b.getText().trim() });
// maybe a list
+ else {
+ Tuple<String, String> t =
XMLUtil.parseXPath(b.getXpath());
NSContext ns = omap.getMap();
- try
- {
- NodeList nl = XMLUtil.query(ns,
-
t.second(),
-
omap.getDocument(t.first()));
+ try {
+ NodeList nl = XMLUtil.query(ns, t.second(),
omap.getDocument(t
+ .first()));
int sz = nl.getLength();
String[] lst = new String[sz];
- for(int i = 0 ; i < sz ; i++ )
- lst[i] = nl.item(i).getNodeValue();
- return new Tuple<Integer,String[]>
-
(omap.registerObject(nl),lst);
- }
- catch( Exception e )
- {
- e.printStackTrace();
- return new Tuple<Integer,String[]>(0,new
String[]{""});
- }
+ for (int i = 0; i < sz; i++)
+ lst[i] = nl.item(i).getNodeValue();
+ return new Tuple<Integer,
String[]>(omap.registerObject(nl),
+ lst);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return new Tuple<Integer, String[]>(0, new
String[] { "" });
+ }
}

}
- //////////////////////////////////////////////////////
- //TODO: External HTMLUtil.java -> HTML tags and so on
- public void drawTextBox( String title, Tuple<Integer,String> t )
- {
- System.out.println("WA --- Drawing a box : title: \"" +
title +
- "\" value :
\"" + t.second() + "\"" );
- try
- {
+
+ // ////////////////////////////////////////////////////
+ // TODO: External HTMLUtil.java -> HTML tags and so on
+ public void drawTextBox(String title, Tuple<Integer, String> t) {
+ System.out.println("WA --- Drawing a box : title: \"" + title
+ + "\" value : \"" + t.second() + "\"");
+ try {
html.singlerow_begin(20);
- html.textbox(t.first() + "",title,t.second());
+ html.textbox(t.first() + "", title, t.second());
html.singlerow_end();
- }
- catch( Exception e )
- {
+ } catch (Exception e) {
e.printStackTrace();
}
}

- public void drawRadio( Tuple<Integer,String> title,
-
Tuple<Integer,String[]> values )
- {
- System.out.println("WA --- Drawing a radio : title: \"" +
title.second()+"\"" ) ;
- //for( String s : values.second() ) println("\nradio value :
" + s);
- try
- {
+ public void drawRadio(Tuple<Integer, String> title,
+ Tuple<Integer, String[]> values) {
+ System.out.println("WA --- Drawing a radio : title: \""
+ + title.second() + "\"");
+ // for( String s : values.second() ) println("\nradio value :
" + s);
+ try {
html.singlerow_begin(20);
- html.radio(values.first() + ""
,title.second(),values.second());
+ html.radio(values.first() + "", title.second(),
values.second());
html.singlerow_end();
- }
- catch( Exception e )
- {
+ } catch (Exception e) {
e.printStackTrace();
}
}

- public void drawDropdown( Tuple<Integer,String> title,
-
Tuple<Integer,String[]> values )
- {
- System.out.println("WA --- Drawing a drop-down : title: \""
+ title.second()+ "\"");
- //for( String s : values.second() ) println("\ndrop-down
value : " + s);
- try
- {
+ public void drawDropdown(Tuple<Integer, String> title,
+ Tuple<Integer, String[]> values) {
+ System.out.println("WA --- Drawing a drop-down : title: \""
+ + title.second() + "\"");
+ // for( String s : values.second() ) println("\ndrop-down
value : " +
+ // s);
+ try {
html.singlerow_begin(20);
- html.dropdown(values.first() + ""
,title.second(),values.second());
+ html.dropdown(values.first() + "", title.second(),
values.second());
html.singlerow_end();
- }
- catch( Exception e )
- {
+ } catch (Exception e) {
e.printStackTrace();
}

}

- public void drawRadiogroup( Tuple<Integer,String[]> values,
-
String innerHTML )
- {
- System.out.println("WA --- Drawing a group radio: " );
+ public void drawRadiogroup(Tuple<Integer, String[]> values, String
innerHTML) {
+ System.out.println("WA --- Drawing a group radio: ");
boolean enabled = false;
- //FIXME: Hardcoded values
- try
- {
+ // FIXME: Hardcoded values
+ try {
html.singlerow_begin(20);
- html.radiogroup_begin("key3","Grouped box",
-
"yes","no",enabled);
+ html.radiogroup_begin("key3", "Grouped box", "yes",
"no", enabled);
println(innerHTML);
- html.radiogroup_end();
+ html.radiogroup_end();
html.singlerow_end();
- }
- catch( Exception e )
- {
+ } catch (Exception e) {
e.printStackTrace();
}
- //for( String s : values.second() )
System.out.println("\ngroup radio value : " + s);
- //System.out.println("group radio inner code:\n" + innerHTML);
- //System.out.println("end radio group");
+ // for( String s : values.second() )
+ // System.out.println("\ngroup radio value : " + s);
+ // System.out.println("group radio inner code:\n" +
innerHTML);
+ // System.out.println("end radio group");
}

- /////////////////////////////////////
- public static void main( String args[] )
- throws Exception
- {
-// Tuple<WebAdminInterface,JAXBContext>
-// wai = WAXMLReader.parseFile(args[0]);
- // HTMLGenerator gen = new HTMLGenerator(System.out,args[0]);
- // gen.translate(wai);
-// gen.registerObject(wai);
+ // ///////////////////////////////////
+ public static void main(String args[]) throws Exception {
+ // Tuple<WebAdminInterface,JAXBContext>
+ // wai = WAXMLReader.parseFile(args[0]);
+ // HTMLGenerator gen = new HTMLGenerator(System.out,args[0]);
+ // gen.translate(wai);
+ // gen.registerObject(wai);
}
- //// REMOVE THIS
- // //public HTMLGenerator( PrintStream out, String configFile )
- //throws Exception
- //{ this.out = out; omap = new ObjectMap(configFile); }
+ // // REMOVE THIS
+ // //public HTMLGenerator( PrintStream out, String configFile )
+ // throws Exception
+ // { this.out = out; omap = new ObjectMap(configFile); }

-// public HTMLGenerator(String basePath,
-// String
confPath,
-// String
configFile )
-// throws Exception
-// { omap = new ObjectMap(basePath,confPath,configFile); }
+ // public HTMLGenerator(String basePath,
+ // String confPath,
+ // String configFile )
+ // throws Exception
+ // { omap = new ObjectMap(basePath,confPath,configFile); }

/*
- public synchronized void setOutput( PrintStream out0, ObjectMap o )
- {
- if( out != null )
- {
- try
- {
- do{ wait(); } while( out != null );
- }
- catch(InterruptedException e)
- {
- System.out.println("InterruptedException
caught");
- }
- }
- out = out0;
- omap = o;
- html = new HTMLUtil(out);
- }
+ * public synchronized void setOutput( PrintStream out0, ObjectMap o
) { if(
+ * out != null ) { try { do{ wait(); } while( out != null ); }
+ * catch(InterruptedException e) {
+ * System.out.println("InterruptedException caught"); } } out = out0;
omap =
+ * o; html = new HTMLUtil(out); }
+ *
+ * public synchronized void done() { omap = null; html = null; out =
null;
+ * notifyAll(); }
+ */

- public synchronized void done()
- {
- omap = null;
- html = null;
- out = null;
- notifyAll();
- }
- */
-
};
-

Modified:
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/config/ObjectMap.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/config/ObjectMap.java
2009-12-09 09:36:04 UTC (rev 5388)
+++
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/config/ObjectMap.java
2009-12-09 10:29:43 UTC (rev 5389)
@@ -1,226 +1,190 @@
package org.perfsonar.webadmin.base2.config;

import java.util.Hashtable;
+import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.Vector;
-import java.util.Iterator;
import java.util.Map.Entry;
-import java.util.List;

-import org.perfsonar.webadmin.base2.waschema.v20090201.*;
+import javax.xml.bind.JAXBContext;

-import org.perfsonar.webadmin.base2.util.Tuple;
import org.perfsonar.webadmin.base2.util.NSContext;
-import org.perfsonar.webadmin.base2.util.WAXMLWriter;
+import org.perfsonar.webadmin.base2.util.Tuple;
import org.perfsonar.webadmin.base2.util.WAXMLReader;
+import org.perfsonar.webadmin.base2.util.WAXMLWriter;
import org.perfsonar.webadmin.base2.util.XMLUtil;
-
+import org.perfsonar.webadmin.base2.waschema.v20090201.BaseType;
+import org.perfsonar.webadmin.base2.waschema.v20090201.NsMap;
+import org.perfsonar.webadmin.base2.waschema.v20090201.WebAdminInterface;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
- import org.w3c.dom.Node;
-import javax.xml.bind.JAXBContext;
-
-public class ObjectMap extends Hashtable<Integer,Object>
-{
- Tuple<WebAdminInterface,JAXBContext> waconfig;
+
+public class ObjectMap extends Hashtable<Integer, Object> {
+ Tuple<WebAdminInterface, JAXBContext> waconfig;
String waconfigfile = "";
- Hashtable<String,Document> file2doc = new
-
Hashtable<String,Document>();
+ Hashtable<String, Document> file2doc = new Hashtable<String,
Document>();
String basePath = "";
- String confPath = ""; //TODO: unused field
+ String confPath = ""; // TODO: unused field
NSContext namespaces;
boolean sync = false;

- public ObjectMap( String basePath, String confPath, String file)
- throws Exception
- {
- //TODO: Unix paths
- waconfigfile = basePath + "/" + confPath + "/" + file;
+ public ObjectMap(String basePath, String confPath, String file)
+ throws Exception {
+ // TODO: Unix paths
+ waconfigfile = basePath + "/" + confPath + "/" + file;
waconfig = WAXMLReader.parseFile(waconfigfile);
this.basePath = basePath;
this.confPath = confPath;
makeMap();
}

- private void makeMap()
- {
+ private void makeMap() {
NSContext nsc = new NSContext();
- List map = getWA().getMap();
+ List map = getWA().getMap();
NsMap ns;
- for( Object o : map )
- {
+ for (Object o : map) {
ns = (NsMap) o;
- nsc.put(ns.getNs(),ns.getUrl());
+ nsc.put(ns.getNs(), ns.getUrl());
}
namespaces = nsc;
}

- public NSContext getMap()
- {
+ public NSContext getMap() {
return namespaces;
}

- public WebAdminInterface getWA()
- {
+ public WebAdminInterface getWA() {
return waconfig.first();
}
- private int _registerObject( Object ui )
- {
- int id = ((Object)ui).hashCode();
- put(id,ui);
- return id;

+ private int _registerObject(Object ui) {
+ int id = ((Object) ui).hashCode();
+ put(id, ui);
+ return id;
+
}

- private boolean saveWA()
- {
- try
- {
- WAXMLWriter.writeToFile(waconfig.second(),
-
waconfig.first(),
-
waconfigfile);
- }
- catch( Exception e )
- {
+ private boolean saveWA() {
+ try {
+ WAXMLWriter.writeToFile(waconfig.second(),
waconfig.first(),
+ waconfigfile);
+ } catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}

- private boolean saveExternal()
- {
-
- try
- {
- Set<Entry<String,Document>> entrySet =
file2doc.entrySet();
- for( Entry<String,Document> o : entrySet )
- {
- try
- {
- XMLUtil.
- writeXml(
- o.getValue(),
- new
java.io.FileOutputStream(basePath+"/"+o.getKey())
- );
- }
- catch( Exception e )
- {
+ private boolean saveExternal() {
+
+ try {
+ Set<Entry<String, Document>> entrySet =
file2doc.entrySet();
+ for (Entry<String, Document> o : entrySet) {
+ try {
+ XMLUtil.writeXml(o.getValue(),
+ new
java.io.FileOutputStream(basePath + "/"
+ +
o.getKey()));
+ } catch (Exception e) {
e.printStackTrace();
return false;
}
}
- }
- catch( Exception e )
- {
+ } catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}

- public synchronized boolean save()
- {
- boolean b= saveExternal() && saveWA();
- if(b) sync = false;
- return b;
+ public synchronized boolean save() {
+ boolean b = saveExternal() && saveWA();
+ if (b)
+ sync = false;
+ return b;
}

- public synchronized int registerObject( BaseType ui )
- {
+ public synchronized int registerObject(BaseType ui) {
return _registerObject(ui);
}

- public synchronized int registerObject( NodeList n )
- {
-// Document doc = t.first().getOwnerDocument();
-// Document old = file2doc.get(t.second())) == doc
+ public synchronized int registerObject(NodeList n) {
+ // Document doc = t.first().getOwnerDocument();
+ // Document old = file2doc.get(t.second())) == doc
return _registerObject(n);
}

- public synchronized Document getDocument( String uri ) throws Exception
- {
+ public synchronized Document getDocument(String uri) throws Exception
{
Document ret = file2doc.get(uri);
- if( ret != null ) return ret;
- String path = basePath + "/" + uri;
- System.out.println("WA --- Attempting to locate URI : \"" +
path + "\"");
- file2doc.put(uri, (ret=XMLUtil.readDocument(path)));
+ if (ret != null)
+ return ret;
+ String path = basePath + "/" + uri;
+ System.out
+ .println("WA --- Attempting to locate URI :
\"" + path + "\"");
+ file2doc.put(uri, (ret = XMLUtil.readDocument(path)));
return ret;
- }
+ }

- public synchronized void updateObjects( Map pmap ) throws Exception
- {
+ public synchronized void updateObjects(Map pmap) throws Exception {
Set entrySet = pmap.entrySet();
- Object myobj = null;
+ Object myobj = null;
Entry e;
- for( Object o : entrySet )
- {
+ for (Object o : entrySet) {
e = (Entry) o;
- try
- {
- myobj=
get(Integer.parseInt((String)e.getKey()));
- if( myobj == null )
- {
- String err = "Could not find object
for key: \""+
-
(String)e.getKey() + "\"" ;
+ try {
+ myobj = get(Integer.parseInt((String)
e.getKey()));
+ if (myobj == null) {
+ String err = "Could not find object
for key: \""
+ + (String) e.getKey()
+ "\"";
System.out.println("WA --- " + err);
throw new Exception(err);
}
- if( myobj instanceof BaseType )
- updateBase((BaseType)myobj,(String[])
e.getValue() );
- else if( myobj instanceof NodeList )
- updateNodeList((NodeList) myobj,
(String[]) e.getValue() );
- else
+ if (myobj instanceof BaseType)
+ updateBase((BaseType) myobj,
(String[]) e.getValue());
+ else if (myobj instanceof NodeList)
+ updateNodeList((NodeList) myobj,
(String[]) e.getValue());
+ else
throw new Exception("Unknown type");
+ } catch (Exception ee) {
+ System.out.println("WA --- Key \"" + (String)
e.getKey()
+ + "\" will not be updated.");
}
- catch( Exception ee )
- {
- System.out.println("WA --- Key \"" +
(String)e.getKey() +
-
"\" will not be updated.");
- }
}
sync = true;
- }
+ }

- public synchronized boolean needSync()
- {
+ public synchronized boolean needSync() {
return sync;
}

- private void updateBase( BaseType o , String[] v )
- {
+ private void updateBase(BaseType o, String[] v) {
System.out.println("WA --- Should update base type");
- if ( v.length < 1 )
- {
+ if (v.length < 1) {
System.out.println("WA --- Empty value list ---
Internal error");
return;
}
String s = v[0];
- for( int i = 1 ; i < v.length ; i++ ) s += "," + v[i];
- //NOTE:Assuming that this is a text element (not xpath)
- o.setText(s);
+ for (int i = 1; i < v.length; i++)
+ s += "," + v[i];
+ // NOTE:Assuming that this is a text element (not xpath)
+ o.setText(s);
System.out.println("WA --- Updated base type");
}

- private void updateNodeList( NodeList t , String[] v )
- {
- if( t.getLength() < 1 )
- {
- System.out.println("WA --- EMPTY NODE LIST ---" +
-
" This possibly indicates a bad xpath " +
-
"element in WA configuration file.");
+ private void updateNodeList(NodeList t, String[] v) {
+ if (t.getLength() < 1) {
+ System.out.println("WA --- EMPTY NODE LIST ---"
+ + " This possibly indicates a bad
xpath "
+ + "element in WA configuration
file.");
return;
- }
- else if ( v.length < 1 )
- {
+ } else if (v.length < 1) {
System.out.println("WA --- Empty value list ---
Internal error");
return;
}
Node n = t.item(0);
String s = v[0];
- for( int i = 1 ; i < v.length ; i++ ) s += "," + v[i];
+ for (int i = 1; i < v.length; i++)
+ s += "," + v[i];
n.setNodeValue(s);
System.out.println("WA --- Updated node list");
}

Deleted:
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/servlet/BasicConfiguration.java

Deleted:
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/servlet/util/Abstraction.java

Modified:
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/HTMLUtil.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/HTMLUtil.java
2009-12-09 09:36:04 UTC (rev 5388)
+++
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/HTMLUtil.java
2009-12-09 10:29:43 UTC (rev 5389)
@@ -5,158 +5,204 @@
import java.io.File;
import java.io.FileOutputStream;

-public class HTMLUtil
-{
+public class HTMLUtil {
private PrintStream out = null;
- private int colspan = 3;
- public HTMLUtil( PrintStream out ) { this.out = out; }
+ private int colspan = 3;

- public void println( String s ) { if( out != null ) out.println(s); }
+ public HTMLUtil(PrintStream out) {
+ this.out = out;
+ }

- public static String tag( String name , String attr, String body )
- {
- return "<" + name + attr + ">" + body + "</" + name + ">\n";
+ public void println(String s) {
+ if (out != null)
+ out.println(s);
}

- public static String tag( String name , String body )
- {
- return "<" + name + ">" + body + "</" + name + ">\n";
+ public static String tag(String name, String attr, String body) {
+ return "<" + name + attr + ">" + body + "</" + name + ">\n";
}

- public static String atag( String name , String attr )
- {
- return "<" + name + attr + "/>\n";
+ public static String tag(String name, String body) {
+ return "<" + name + ">" + body + "</" + name + ">\n";
}

- public static String tag( String name )
- {
+ public static String atag(String name, String attr) {
+ return "<" + name + attr + "/>\n";
+ }
+
+ public static String tag(String name) {
return "<" + name + "/>\n";
}

- public static String btag( String name , String body , String ...
atts )
- {
+ public static String btag(String name, String body, String... atts) {
String ret = "<" + name + " ";
- if( atts != null && atts.length > 0 )
- {
- for( String s : atts ) ret += s + " ";
+ if (atts != null && atts.length > 0) {
+ for (String s : atts)
+ ret += s + " ";
}
- return ret + ">" + body + "</" + name + ">\n";
+ return ret + ">" + body + "</" + name + ">\n";
}

- public static String att( String attr, String val )
- {
- if( val == null ) return "";
- else return " " + attr + " = \"" + val + "\" ";
+ public static String att(String attr, String val) {
+ if (val == null)
+ return "";
+ else
+ return " " + attr + " = \"" + val + "\" ";
}

- public static String table( boolean b , String body )
- { return
btag("table",body,att("center",(b?"center":null))); }
+ public static String table(boolean b, String body) {
+ return btag("table", body, att("center", (b ? "center" :
null)));
+ }

- public static String div( String cls , String id , String align,
String style , String body )
- { return
btag("div",body,att("class",cls),att("id",id),att("align",align),att("style",style));
}
+ public static String div(String cls, String id, String align, String
style,
+ String body) {
+ return btag("div", body, att("class", cls), att("id", id),
att("align",
+ align), att("style", style));
+ }

- public static String form( String action, String name , String method
, String onsubmit ,String body )
- { return
btag("form",body,att("action",action),att("name",name),att("method",method),att("onsubmit",onsubmit));
}
+ public static String form(String action, String name, String method,
+ String onsubmit, String body) {
+ return btag("form", body, att("action", action), att("name",
name),
+ att("method", method), att("onsubmit",
onsubmit));
+ }

- public static String p( String cls, String body ) {
return btag("p",body,att("class",cls)); }
+ public static String p(String cls, String body) {
+ return btag("p", body, att("class", cls));
+ }

- public static String input( String type , String name , String value
, String onClick , String body )
- { return
btag("input",body,att("type",type),att("name",name),att("value",value),att("onClick",onClick));
}
+ public static String input(String type, String name, String value,
+ String onClick, String body) {
+ return btag("input", body, att("type", type), att("name",
name), att(
+ "value", value), att("onClick", onClick));
+ }

- public static String radio_chk( String type , String name , String
value , String onClick , String body )
- { return
btag("input",body,att("type",type),att("name",name),att("value",value),att("onClick",onClick),att("checked","true"));
}
+ public static String radio_chk(String type, String name, String value,
+ String onClick, String body) {
+ return btag("input", body, att("type", type), att("name",
name), att(
+ "value", value), att("onClick", onClick),
+ att("checked", "true"));
+ }

- public static String input_id( String type , String id , String value
, String onClick , String body )
- { return
btag("input",body,att("type",type),att("id",id),att("value",value),att("onClick",onClick));
}
+ public static String input_id(String type, String id, String value,
+ String onClick, String body) {
+ return btag("input", body, att("type", type), att("id", id),
att(
+ "value", value), att("onClick", onClick));
+ }

- public static String html( String body ) { return btag("html",body); }
- public static String body( String bd ) { return btag("body",bd); }
- public static String head( String bd ) { return btag("head",bd); }
- public static String title( String bd ) { return btag("title",bd); }
- public static String ul( String bd ) { return btag("ul",bd); }
- public static String li( String bd ) { return btag("li",bd); }
- public static String h1( String bd ) { return btag("h1",bd); }
- public static String a( String href, String bd ) { return
btag("a",bd,att("href",href)); }
- public static String br( String body ){ return
btag("br",body); }
- public static String tr( String body ){ return
btag("tr",body); }
- public static String td( String body ){ return
btag("td",body); }
- public static String td_col( String body ){ return
btag("td",body,att("colspan","2")); }
- public static String span( String cls, String body ){ return
btag("span",body,att("class",cls)); }
+ public static String html(String body) {
+ return btag("html", body);
+ }

- public static String colouredtext( String text, String colour )
- {
- return tag("font",att("color",colour),text);
+ public static String body(String bd) {
+ return btag("body", bd);
}

- public static String greenasterisk()
- {
+ public static String head(String bd) {
+ return btag("head", bd);
+ }
+
+ public static String title(String bd) {
+ return btag("title", bd);
+ }
+
+ public static String ul(String bd) {
+ return btag("ul", bd);
+ }
+
+ public static String li(String bd) {
+ return btag("li", bd);
+ }
+
+ public static String h1(String bd) {
+ return btag("h1", bd);
+ }
+
+ public static String a(String href, String bd) {
+ return btag("a", bd, att("href", href));
+ }
+
+ public static String br(String body) {
+ return btag("br", body);
+ }
+
+ public static String tr(String body) {
+ return btag("tr", body);
+ }
+
+ public static String td(String body) {
+ return btag("td", body);
+ }
+
+ public static String td_col(String body) {
+ return btag("td", body, att("colspan", "2"));
+ }
+
+ public static String span(String cls, String body) {
+ return btag("span", body, att("class", cls));
+ }
+
+ public static String colouredtext(String text, String colour) {
+ return tag("font", att("color", colour), text);
+ }
+
+ public static String greenasterisk() {
return "<span class=\"greenasterisk\" >*</span>";
}
- private static final String doctype =
- "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01"+
- " Transitional//EN\"
\"http://www.w3.org/TR/html4/loose.dtd\";> ";
+
+ private static final String doctype = "<!DOCTYPE HTML PUBLIC
\"-//W3C//DTD HTML 4.01"
+ + " Transitional//EN\"
\"http://www.w3.org/TR/html4/loose.dtd\";> ";
private static final String cssFile = "default.css";
- private static final String onClickAttribute =
-
" onclick=\"checkIt(this);\" ";
- private static final String nbsp = "&nbsp;";
+ private static final String onClickAttribute = "
onclick=\"checkIt(this);\" ";
+ private static final String nbsp = "&nbsp;";
private static final String checkedAttribute = " checked =\"true\" ";
//
- private static final String blockedAttribute =
-
" style=\"display:block;\" ";
- private static final String unblockedAttribute =
-
" style=\"display:none;\" ";
+ private static final String blockedAttribute = "
style=\"display:block;\" ";
+ private static final String unblockedAttribute = "
style=\"display:none;\" ";

- private static String times(int i )
- {
- String ret="";
- for(int j = 0 ; j < i ; j++ ) ret += nbsp;
+ private static String times(int i) {
+ String ret = "";
+ for (int j = 0; j < i; j++)
+ ret += nbsp;
return ret;
}

- private String getCSS()
- {
+ private String getCSS() {
String css = "<link rel=\"stylesheet\" type=\"text/css\"
href=\""
+ cssFile + "\"/>";
return css;
}
-
- private String getScript() //FIXME Vl_ stuff
+
+ private String getScript() // FIXME Vl_ stuff
{
- return "<script src=\"Service_Admin.js\">"
+ return "<script src=\"Service_Admin.js\">"
+ "</script>\n"
+ "<script src=\"wz_tooltip.js\">"
+ "</script>\n"
- +"<script src=\"Service_Admin.js\">"
+ + "<script src=\"Service_Admin.js\">"
+ "</script>\n"
+ "<script type=\"text/javascript\">\n"
+ "function checkIt(el) {\n"
// el = clicked element
// el.value = value attribute of clicked
element el
- // el.name = name attribute of clicked
element el
+ // el.name = name attribute of clicked
element el
// if the clicked element's value is the same
// as the hidden tag's (whose id=Vl_ + name
clicked elt)
- // default value then
- // disable all elements whose id is the same
as the
+ // default value then
+ // disable all elements whose id is the same
as the
// clicked element's name
- // + "document.write(el.value
+\"\\n\"+document.getElementById(\"Vl_\"+el.name).value+\"\\n\"+document.getElementById(el.name).style.display)\n"
- + "if (el.value == "
+ // +
+ // "document.write(el.value
+\"\\n\"+document.getElementById(\"Vl_\"+el.name).value+\"\\n\"+document.getElementById(el.name).style.display)\n"
+ + "if (el.value == "
+
"document.getElementById(\"Vl_\"+el.name).value) {\n"
+
"document.getElementById(el.name).style.display = "
- + "\"block\";\n"
- + "}\n"
- + "else {\n"
+ + "\"block\";\n" + "}\n" + "else {\n"
+
"document.getElementById(el.name).style.display ="
- + " \"none\";\n"
- + "}\n"
- + "}\n"
- + "</script>\n";
+ + " \"none\";\n" + "}\n" + "}\n" +
"</script>\n";
}

-
- public void preamble() throws IOException
- {
+ public void preamble() throws IOException {
println(doctype);
println("<html>");
- println("<head>" + getCSS() + "</head>" );
+ println("<head>" + getCSS() + "</head>");
println("<title>");
println("perfSONAR services configuration wizard");
println("</title>");
@@ -165,289 +211,207 @@
println("<div class=\"main\">");
}

- public void postscript() throws IOException
- {
+ public void postscript() throws IOException {
println("</div>");
println("</body>");
println("</html>");
}

// Specification:
- //for each grouped radio elt
- //there exists a hidden tag
- // whose
- // id = Vl_+name attr of radio elt
- // and
- // name denotes the disabled value
- //there exist other elements
- // whose
- // id = name attr of radio elt

+ // for each grouped radio elt
+ // there exists a hidden tag
+ // whose
+ // id = Vl_+name attr of radio elt
+ // and
+ // name denotes the disabled value
+ // there exist other elements
+ // whose
+ // id = name attr of radio elt

- public void radiogroup_begin(String id,
-
String title,
-
String yesval,
-
String noval,
-
boolean enabled
-
)
- throws IOException
- {
- println
- (
- //att("align","center"),
- tag
- ("tr",
- tag("td",title) +
//,att("colspan",""+3)
- times(13) +
- tag
- ("td",
- atag
- ("input",
att("type","hidden") +
- att("value",yesval)
+
- att("id","Vl_" + id)
- )

- +
- tag
- ("input",
- att("type","radio") +
- att("name",id)
+
- att("value",yesval) +
- onClickAttribute +
-
(enabled?checkedAttribute:""),
- times(2) + yesval + nbsp
- )
+
- tag
- ("input",
- att("type","radio") +
- att("name",id) +
- att("value",noval) +
- onClickAttribute
+
-
(!enabled?checkedAttribute:""),
- times(2) + noval + times(14)
- )
- )
- )
- );
- println( "<tr><td>"+ "<div "+ att("id",id) +
- att("class","inner_properties") +
- (
!enabled?unblockedAttribute:blockedAttribute)+ " > "
- );//+ "<div "+
att("class","properties") + " >");
+ public void radiogroup_begin(String id, String title, String yesval,
+ String noval, boolean enabled) throws IOException {
+ println(
+ // att("align","center"),
+ tag("tr", tag("td", title)
+ + // ,att("colspan",""+3)
+ times(13)
+ + tag("td", atag("input", att("type",
"hidden")
+ + att("value", yesval) +
att("id", "Vl_" + id))
+ + tag("input", att("type",
"radio") + att("name", id)
+ +
att("value", yesval) + onClickAttribute
+ + (enabled ?
checkedAttribute : ""), times(2)
+ + yesval +
nbsp)
+ + tag("input", att("type",
"radio") + att("name", id)
+ +
att("value", noval) + onClickAttribute
+ + (!enabled ?
checkedAttribute : ""), times(2)
+ + noval +
times(14)))));
+ println("<tr><td>" + "<div " + att("id", id)
+ + att("class", "inner_properties")
+ + (!enabled ? unblockedAttribute :
blockedAttribute) + " > ");// +
+

// "<div "+
+

// att("class","properties")
+

// +
+

// " >");
table_begin();
}

- public void radiogroup_end()
- {
+ public void radiogroup_end() {
table_end();

println("</div></td></tr>");
}

- private void generictextbox(String type,
-
String key,
-
String title,
-
String val )
- throws IOException
- {
+ private void generictextbox(String type, String key, String title,
+ String val) throws IOException {

final int size = 30;
- println(
- tag("tr",
-
tag("td",att("colspan",""+colspan),title) +
-
tag("td",att("align","left")
- ,
- atag("input",
-
att("class","input_style")+
-
att("type",type)+
-
att("name",key)+
-
att("size",""+size)+
-
att("value",val)
-
)
- )
- )
-
- );
+ println(tag("tr", tag("td", att("colspan", "" + colspan),
title)
+ + tag("td", att("align", "left"),
atag("input", att("class",
+ "input_style")
+ + att("type", type)
+ + att("name", key)
+ + att("size", "" + size) +
att("value", val))))
+
+ );
}

- public void textbox( String key, String title , String val )
- throws IOException
- {
- generictextbox("text",key,title,val);
+ public void textbox(String key, String title, String val)
+ throws IOException {
+ generictextbox("text", key, title, val);
}

- public void passtextbox( String key, String title , String val )
- throws IOException
- {
- generictextbox("password",key,title,val);
+ public void passtextbox(String key, String title, String val)
+ throws IOException {
+ generictextbox("password", key, title, val);
}

// assumes keys.length = vals.length
- public void radio(String key, String title, String[] vals )
- throws IOException
- {
+ public void radio(String key, String title, String[] vals)
+ throws IOException {
String opts = "";
- for( int i = 0 ; i < vals.length ; i++ )
- {
- opts += tag
- ("input",
- att("type","radio") +
- att("name",key)
+
- att("value",vals[i]) +
- (i==0?checkedAttribute:""),
- times(2) + vals[i] + nbsp
- ) ;
+ for (int i = 0; i < vals.length; i++) {
+ opts += tag("input", att("type", "radio") +
att("name", key)
+ + att("value", vals[i]) + (i == 0 ?
checkedAttribute : ""),
+ times(2) + vals[i] + nbsp);
}
- println(
tag("tr",tag("td",att("colspan",""+colspan),title)
- +tag("td",opts)));
+ println(tag("tr", tag("td", att("colspan", "" + colspan),
title)
+ + tag("td", opts)));
}
-
- public void dropdown(String key, String title, String[] vals )
- {
+
+ public void dropdown(String key, String title, String[] vals) {
String opts = "";
- for( int i = 0 ; i < vals.length ; i++ )
- opts += tag("option",att("value",vals[i]),vals[i]) ;
- println(
tag("tr",tag("td",att("colspan",""+colspan),title) +
-
tag("td",att("align","left"),tag("select",att("name",key),opts))));
+ for (int i = 0; i < vals.length; i++)
+ opts += tag("option", att("value", vals[i]), vals[i]);
+ println(tag("tr", tag("td", att("colspan", "" + colspan),
title)
+ + tag("td", att("align", "left"),
tag("select",
+ att("name", key), opts))));
}

- public void form_begin(String key,String val, String url , int
spacing )
- throws IOException
- {
- println( "<div " + att("class","properties") + " > " +
- //"<center>" +
- "<form action=\""+url+"\"
method=\"POST\">\n"+
- "<input type=\"hidden\" name=\"" +
key + "\" value=\"" +
- val + "\">\n" +
- "<table align=\"center\" " +
- att("cellspacing",spacing+"%") + " >"
- );
+ public void form_begin(String key, String val, String url, int
spacing)
+ throws IOException {
+ println("<div "
+ + att("class", "properties")
+ + " > "
+ +
+ // "<center>" +
+ "<form action=\"" + url + "\"
method=\"POST\">\n"
+ + "<input type=\"hidden\" name=\"" + key +
"\" value=\"" + val
+ + "\">\n" + "<table align=\"center\" "
+ + att("cellspacing", spacing + "%") + " >");
}

- public void form_begin(String key, String val, String url )
- throws IOException
- {
- form_begin(key,val,url,10);
+ public void form_begin(String key, String val, String url)
+ throws IOException {
+ form_begin(key, val, url, 10);
}

- public void form_end()
- throws IOException
- {
- println(
- tag("tr",
- tag("td",nbsp)+
- tag("td",att("align","right")+
-
att("colspan",""+colspan),
- atag("input",
-
att("type","submit")+
-
att("name","submit")+
-
att("value","Submit"))))+
- "</table><p/>\n" +
- "</form>"+
- //"</center>"+
- "</div>");
+ public void form_end() throws IOException {
+ println(tag("tr", tag("td", nbsp)
+ + tag("td", att("align", "right")
+ + att("colspan", "" +
colspan), atag("input", att(
+ "type", "submit")
+ + att("name", "submit") +
att("value", "Submit"))))
+ + "</table><p/>\n" + "</form>" +
+ // "</center>"+
+ "</div>");
}

+ public void singlerow_begin(int spacing, int span) {

- public void singlerow_begin(int spacing, int span)
- {
-
- println("<tr><td " + att("colspan",""+span) + " >");
+ println("<tr><td " + att("colspan", "" + span) + " >");
table_begin(spacing);
}

- public void singlerow_begin(int spacing)
- {
- singlerow_begin(spacing,1);
+ public void singlerow_begin(int spacing) {
+ singlerow_begin(spacing, 1);
}
- public void singlerow_end()
- {
+
+ public void singlerow_end() {
table_end();
println("</td></tr>");
}

-
- public void table_begin()
- {
- //println("<center><table align=\"center\">");
+ public void table_begin() {
+ // println("<center><table align=\"center\">");
table_begin(10);
}

- public void table_begin(int spacing)
- {
- println("<div " + att("class","properties") + " > " +
- "<center><table align=\"left\" " +
- att("cellspacing",spacing+"%") + ">");
+ public void table_begin(int spacing) {
+ println("<div " + att("class", "properties") + " > "
+ + "<center><table align=\"left\" "
+ + att("cellspacing", spacing + "%") + ">");
}

- public void table_end()
- {
+ public void table_end() {
println("</table></center></div>");
}

-
- public void lineoftext( String text, String colour , int fill )
- {
- singlerow_begin(1,2);
- println(tag("tr",
- tag("td"
- ,
-
colouredtext(text+times(fill),colour)
- )));
+ public void lineoftext(String text, String colour, int fill) {
+ singlerow_begin(1, 2);
+ println(tag("tr", tag("td", colouredtext(text + times(fill),
colour))));
singlerow_end();
}

- public void simplelineoftext( String text, String colour )
- { //+ att("colspan",""+span)
- println("<tr><td " + " >\n"+
- tag("tr",
- tag("td",
-
tag("p",colouredtext(text,colour))
- )) +
- "</td></tr>"
- );
+ public void simplelineoftext(String text, String colour) { // +
+
// att("colspan",""+span)
+ println("<tr><td " + " >\n"
+ + tag("tr", tag("td", tag("p",
colouredtext(text, colour))))
+ + "</td></tr>");
}

- public void simplelineoftext(String span, String text, String colour
)
- { //
- println("<tr><td " + att("colspan",""+span) + " >\n"+
- tag("tr",
- tag("td",
-
tag("p",colouredtext(text,colour))
- )) +
- "</td></tr>"
- );
+ public void simplelineoftext(String span, String text, String colour)
{ //
+ println("<tr><td " + att("colspan", "" + span) + " >\n"
+ + tag("tr", tag("td", tag("p",
colouredtext(text, colour))))
+ + "</td></tr>");
}

//
- public static void main( String[] args ) throws Exception
- {
- PrintStream p = new PrintStream(
- new FileOutputStream(
- new File(args[0])));
+ public static void main(String[] args) throws Exception {
+ PrintStream p = new PrintStream(new FileOutputStream(new
File(args[0])));
HTMLUtil u = new HTMLUtil(p);
//
u.preamble();
- u.form_begin("fkey","keyval","lalala",1);
- u.lineoftext("Please fill in the following
fields:","green",20);
+ u.form_begin("fkey", "keyval", "lalala", 1);
+ u.lineoftext("Please fill in the following fields:", "green",
20);

- u.simplelineoftext("eXist configuration","green");
+ u.simplelineoftext("eXist configuration", "green");
u.singlerow_begin(20);
- u.dropdown("key1","This is a drop down list",
- new String
[]{"Val1","Val2","Val3"});
+ u.dropdown("key1", "This is a drop down list", new String[] {
"Val1",
+ "Val2", "Val3" });
u.singlerow_end();
-
+
u.singlerow_begin(20);
- u.textbox("key2","This is a textbox","default text");
- u.radio("key1","Radio",new String[]{"true","false"});
+ u.textbox("key2", "This is a textbox", "default text");
+ u.radio("key1", "Radio", new String[] { "true", "false" });
u.singlerow_end();

-
boolean enabled = false;
u.singlerow_begin(20);
- u.radiogroup_begin("key3","Grouped box",
-
"yes","no",enabled);
- u.textbox("key6","This is a textbox","default hidden text");
- u.dropdown("key7","This is a drop down list",
- new String
[]{"Val1","Val2","Val3"});
- u.radiogroup_end();
+ u.radiogroup_begin("key3", "Grouped box", "yes", "no",
enabled);
+ u.textbox("key6", "This is a textbox", "default hidden text");
+ u.dropdown("key7", "This is a drop down list", new String[] {
"Val1",
+ "Val2", "Val3" });
+ u.radiogroup_end();
u.singlerow_end();

u.form_end();

Modified:
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/NSContext.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/NSContext.java
2009-12-09 09:36:04 UTC (rev 5388)
+++
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/NSContext.java
2009-12-09 10:29:43 UTC (rev 5389)
@@ -5,32 +5,28 @@
import javax.xml.*;
import java.util.Iterator;

-public class NSContext
- extends HashMap<String,String>
- implements NamespaceContext
-{
- // private myurl = "";
- public NSContext()
- {
- put("xml",XMLConstants.XML_NS_URI);
- }
+public class NSContext extends HashMap<String, String> implements
+ NamespaceContext {
+ // private myurl = "";
+ public NSContext() {
+ put("xml", XMLConstants.XML_NS_URI);
+ }

- public String getNamespaceURI(String prefix)
- {
- if (prefix == null) throw new NullPointerException("Null prefix");
- String s = get(prefix);
- return ( s == null )? XMLConstants.NULL_NS_URI:s;
- }
+ public String getNamespaceURI(String prefix) {
+ if (prefix == null)
+ throw new NullPointerException("Null prefix");
+ String s = get(prefix);
+ return (s == null) ? XMLConstants.NULL_NS_URI : s;
+ }

- // This method isn't necessary for XPath processing.
- public String getPrefix(String uri)
- {
- throw new UnsupportedOperationException();
- }
- // This method isn't necessary for XPath processing either.
- //
- public Iterator getPrefixes(String uri)
- {
- throw new UnsupportedOperationException();
- }
+ // This method isn't necessary for XPath processing.
+ public String getPrefix(String uri) {
+ throw new UnsupportedOperationException();
+ }
+
+ // This method isn't necessary for XPath processing either.
+ //
+ public Iterator getPrefixes(String uri) {
+ throw new UnsupportedOperationException();
+ }
};

Modified:
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/StringOutputStream.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/StringOutputStream.java
2009-12-09 09:36:04 UTC (rev 5388)
+++
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/StringOutputStream.java
2009-12-09 10:29:43 UTC (rev 5389)
@@ -1,36 +1,47 @@
package org.perfsonar.webadmin.base2.util;
-import java.io.OutputStream;
-import java.io.Serializable;

- public class StringOutputStream extends OutputStream implements
Serializable {
- protected StringBuffer buf = null;
- public StringOutputStream() {
- super();
- buf = new StringBuffer();
- }
- public String toString() {
- return buf.toString();
- }
- public void close() { buf = null; }
- public void write(byte[] bytes) {
- char[] carr = new char[bytes.length];
- for (int i = 0; i < bytes.length; i++) carr[i] = (char) bytes[i];
- buf.append(carr);
- }
- public void write(byte[] b, int off, int len) {
- if ((off < 0) || (len < 0) || (off + len) > b.length) {
- throw new IndexOutOfBoundsException("Out of bounds");
- }
- byte[] bytes = new byte[len];
- for (int i = 0; i < len; i++) {
- bytes[i] = b[off];
- off++;
- }
- char[] carr = new char[bytes.length];
- for (int i = 0; i < bytes.length; i++) carr[i] = (char) bytes[i];
- buf.append(carr);
- }
- public void write(int b) {
- buf.append((char)b);
- }
- }
+import java.io.OutputStream;
+import java.io.Serializable;
+
+public class StringOutputStream extends OutputStream implements Serializable
{
+ protected StringBuffer buf = null;
+
+ public StringOutputStream() {
+ super();
+ buf = new StringBuffer();
+ }
+
+ public String toString() {
+ return buf.toString();
+ }
+
+ public void close() {
+ buf = null;
+ }
+
+ public void write(byte[] bytes) {
+ char[] carr = new char[bytes.length];
+ for (int i = 0; i < bytes.length; i++)
+ carr[i] = (char) bytes[i];
+ buf.append(carr);
+ }
+
+ public void write(byte[] b, int off, int len) {
+ if ((off < 0) || (len < 0) || (off + len) > b.length) {
+ throw new IndexOutOfBoundsException("Out of bounds");
+ }
+ byte[] bytes = new byte[len];
+ for (int i = 0; i < len; i++) {
+ bytes[i] = b[off];
+ off++;
+ }
+ char[] carr = new char[bytes.length];
+ for (int i = 0; i < bytes.length; i++)
+ carr[i] = (char) bytes[i];
+ buf.append(carr);
+ }
+
+ public void write(int b) {
+ buf.append((char) b);
+ }
+}

Modified:
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/WAXMLReader.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/WAXMLReader.java
2009-12-09 09:36:04 UTC (rev 5388)
+++
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/WAXMLReader.java
2009-12-09 10:29:43 UTC (rev 5389)
@@ -2,19 +2,14 @@

import java.io.File;
import java.io.FileInputStream;
-import java.io.StringWriter;
-
import java.util.List;

import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;

+import org.perfsonar.webadmin.base2.waschema.v20090201.WebAdminInterface;
import org.xml.sax.InputSource;

-import org.perfsonar.webadmin.base2.waschema.v20090201.*;
-
public class WAXMLReader {
private final static String CLASS_NAME =
// FIXME: Should read this from JAXB xml file

Modified:
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/WAXMLWriter.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/WAXMLWriter.java
2009-12-09 09:36:04 UTC (rev 5388)
+++
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/WAXMLWriter.java
2009-12-09 10:29:43 UTC (rev 5389)
@@ -1,27 +1,21 @@
package org.perfsonar.webadmin.base2.util;

-import java.io.File;
import java.io.IOException;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;

+import org.perfsonar.webadmin.base2.waschema.v20090201.WebAdminInterface;

-import org.perfsonar.webadmin.base2.waschema.v20090201.*;
-
-public class WAXMLWriter
-{
- public static void writeToFile( JAXBContext pContext,
- WebAdminInterface pObject,
- String pFileName)
- throws JAXBException, IOException
- {
- java.io.FileOutputStream fos = new java.io.FileOutputStream(pFileName);
- Marshaller marshaller = pContext.createMarshaller();
- marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
- marshaller.marshal(pObject, fos);
- fos.close();
- }
+public class WAXMLWriter {
+ public static void writeToFile(JAXBContext pContext,
+ WebAdminInterface pObject, String pFileName) throws
JAXBException,
+ IOException {
+ java.io.FileOutputStream fos = new
java.io.FileOutputStream(pFileName);
+ Marshaller marshaller = pContext.createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
+ marshaller.marshal(pObject, fos);
+ fos.close();
+ }
};

Modified:
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/XMLUtil.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/XMLUtil.java
2009-12-09 09:36:04 UTC (rev 5388)
+++
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/util/XMLUtil.java
2009-12-09 10:29:43 UTC (rev 5389)
@@ -1,161 +1,150 @@
package org.perfsonar.webadmin.base2.util;

-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.FileInputStream;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;

-import org.w3c.dom.*;
-import org.xml.sax.SAXException;
-import javax.xml.parsers.*;
-import javax.xml.xpath.*;
-
-
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
-import javax.xml.transform.Source;
+import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;

-public class XMLUtil
-{
- public static String readFile(String fname ) throws Exception
- {
- java.io.File file = new File(fname);
- String ret = "";
- FileInputStream fis = null;
- BufferedInputStream bis = null;
- DataInputStream dis = null;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;

- if( file == null )
- throw new Exception("Invalid file name " + fname ) ;
- else if ( !file.exists() )
- throw new Exception("File " + fname + " does not exist " );
- else
- {
- try
- {
- fis = new FileInputStream(file);
- bis = new BufferedInputStream(fis);
- dis = new DataInputStream(bis);
- while (dis.available() != 0) ret += dis.readLine();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- finally{
- if( fis != null ) fis.close();
- if( bis != null ) bis.close();
- if( dis != null ) dis.close();
- }
+public class XMLUtil {
+ public static String readFile(String fname) throws Exception {
+ java.io.File file = new File(fname);
+ String ret = "";
+ FileInputStream fis = null;
+ BufferedInputStream bis = null;
+ DataInputStream dis = null;
+
+ if (file == null)
+ throw new Exception("Invalid file name " + fname);
+ else if (!file.exists())
+ throw new Exception("File " + fname + " does not
exist ");
+ else {
+ try {
+ fis = new FileInputStream(file);
+ bis = new BufferedInputStream(fis);
+ dis = new DataInputStream(bis);
+ while (dis.available() != 0)
+ ret += dis.readLine();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ if (fis != null)
+ fis.close();
+ if (bis != null)
+ bis.close();
+ if (dis != null)
+ dis.close();
+ }
+ }
+ return ret;
}
- return ret;
- }

- public static Document readDocument( String uri )
- throws Exception
- {
- DocumentBuilderFactory domFactory =
-
DocumentBuilderFactory.newInstance();
- domFactory.setNamespaceAware(true); // never forget
this!
- DocumentBuilder builder = domFactory.newDocumentBuilder();
- return builder.parse(uri);
- }
+ public static Document readDocument(String uri) throws Exception {
+ DocumentBuilderFactory domFactory = DocumentBuilderFactory
+ .newInstance();
+ domFactory.setNamespaceAware(true); // never forget this!
+ DocumentBuilder builder = domFactory.newDocumentBuilder();
+ return builder.parse(uri);
+ }

- public static NodeList query( NSContext ns,
-
String q,
-
Document doc
- )
- throws ParserConfigurationException, SAXException,
- IOException, XPathExpressionException,
-
javax.xml.xpath.XPathFactoryConfigurationException
- {
- System.setProperty("javax.xml.xpath.XPathFactory" + ":"+
javax.xml.xpath.XPathFactory.DEFAULT_OBJECT_MODEL_URI,
-
"org.apache.xpath.jaxp.XPathFactoryImpl");
- XPathFactory factory =
XPathFactory.newInstance(javax.xml.xpath.XPathFactory.DEFAULT_OBJECT_MODEL_URI);
- XPath xpath = factory.newXPath();
- if( ns != null ) xpath.setNamespaceContext(ns);
- XPathExpression expr = xpath.compile(q);
- Object result = expr.evaluate(doc, XPathConstants.NODESET);
- NodeList nodes = (NodeList) result;
- return nodes;
- }
+ public static NodeList query(NSContext ns, String q, Document doc)
+ throws ParserConfigurationException, SAXException,
IOException,
+ XPathExpressionException,
+ javax.xml.xpath.XPathFactoryConfigurationException {
+ System.setProperty("javax.xml.xpath.XPathFactory" + ":"
+ +
javax.xml.xpath.XPathFactory.DEFAULT_OBJECT_MODEL_URI,
+ "org.apache.xpath.jaxp.XPathFactoryImpl");
+ XPathFactory factory = XPathFactory
+
.newInstance(javax.xml.xpath.XPathFactory.DEFAULT_OBJECT_MODEL_URI);
+ XPath xpath = factory.newXPath();
+ if (ns != null)
+ xpath.setNamespaceContext(ns);
+ XPathExpression expr = xpath.compile(q);
+ Object result = expr.evaluate(doc, XPathConstants.NODESET);
+ NodeList nodes = (NodeList) result;
+ return nodes;
+ }

- public static void writeXml(Document document,
-
java.io.OutputStream file ) throws Exception
- {
- try {
- if( document == null )
- {
- System.out.println("WA -- Cann't write XML to file -
Null doc");
- return;
- }
- // Prepare the DOM document for writing
- Source source = new DOMSource(document);
+ public static void writeXml(Document document, java.io.OutputStream
file)
+ throws Exception {
+ try {
+ if (document == null) {
+ System.out.println("WA -- Cann't write XML to
file - Null doc");
+ return;
+ }
+ // Prepare the DOM document for writing
+ Source source = new DOMSource(document);

- // Prepare the output file
- Result result = new StreamResult(file);
+ // Prepare the output file
+ Result result = new StreamResult(file);

- // Write the DOM document to the file
- // Get Transformer
- Transformer xformer =
TransformerFactory.newInstance().newTransformer();
- xformer.setOutputProperty(javax.xml.transform.OutputKeys.INDENT,
"yes");
- //xformer.getOutputProperties().store(System.out,"");
- // Write to a file
- xformer.transform(source, result);
- } catch (TransformerConfigurationException e) {
- System.out.println("TransformerConfigurationException: " + e);
- } catch (TransformerException e) {
- System.out.println("TransformerException: " + e);
- }
- }
+ // Write the DOM document to the file
+ // Get Transformer
+ Transformer xformer = TransformerFactory.newInstance()
+ .newTransformer();
+
xformer.setOutputProperty(javax.xml.transform.OutputKeys.INDENT,
+ "yes");
+ // xformer.getOutputProperties().store(System.out,"");
+ // Write to a file
+ xformer.transform(source, result);
+ } catch (TransformerConfigurationException e) {
+
System.out.println("TransformerConfigurationException: " + e);
+ } catch (TransformerException e) {
+ System.out.println("TransformerException: " + e);
+ }
+ }

- public static Tuple<String,String> parseXPath( String query )
- {
- query = query.trim();
- int i =0;
- String[] qtoken = query.split("\\s+");
- query = "";
- for( String tk : qtoken ) query+= tk;
- String filename = "";
+ public static Tuple<String, String> parseXPath(String query) {
+ query = query.trim();
+ int i = 0;
+ String[] qtoken = query.split("\\s+");
+ query = "";
+ for (String tk : qtoken)
+ query += tk;
+ String filename = "";

- if( query.length() < 8 ||
- query.startsWith("doc(\"") == false )
- {
- throw new RuntimeException("Did not find
\"doc\" at the beggining of query");
- }
- else if( (i=query.indexOf("\"",5)) > 3)
- {
- if( i+2 >= query.length() )
- {
- throw new RuntimeException("Invalid query");
- }
- filename = query.substring(5,i);
- query = query.substring(i+2);
- }
- else
- throw new RuntimeException("Invalid query");
- return new Tuple<String,String>(filename,query);
- }
+ if (query.length() < 8 || query.startsWith("doc(\"") ==
false) {
+ throw new RuntimeException(
+ "Did not find \"doc\" at the
beggining of query");
+ } else if ((i = query.indexOf("\"", 5)) > 3) {
+ if (i + 2 >= query.length()) {
+ throw new RuntimeException("Invalid query");
+ }
+ filename = query.substring(5, i);
+ query = query.substring(i + 2);
+ } else
+ throw new RuntimeException("Invalid query");
+ return new Tuple<String, String>(filename, query);
+ }

- public static void main(String[] args)
- throws ParserConfigurationException, SAXException,
- IOException, XPathExpressionException,
-
javax.xml.xpath.XPathFactoryConfigurationException
- {
- String
prefix="http://service.perfsonar.org/ns/config/base/0.9/";;
- String q =
"doc(\"tmp/configls.xml\")//ns1:configuration/ns1:service[@name=\"SimpleService\"]/ns1:lookupInformation/ns1:option[@name=\"accessPoint\"]/@value";
- }
+ public static void main(String[] args) throws
ParserConfigurationException,
+ SAXException, IOException, XPathExpressionException,
+ javax.xml.xpath.XPathFactoryConfigurationException {
+ String prefix =
"http://service.perfsonar.org/ns/config/base/0.9/";;
+ String q =
"doc(\"tmp/configls.xml\")//ns1:configuration/ns1:service[@name=\"SimpleService\"]/ns1:lookupInformation/ns1:option[@name=\"accessPoint\"]/@value";
+ }
};

Added:
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/xupdate/XObjectImpl.java

Modified:
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/xupdate/XPathQueryFactoryImpl.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/xupdate/XPathQueryFactoryImpl.java
2009-12-09 09:36:04 UTC (rev 5388)
+++
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/xupdate/XPathQueryFactoryImpl.java
2009-12-09 10:29:43 UTC (rev 5389)
@@ -16,143 +16,11 @@
*/
package org.perfsonar.webadmin.base2.xupdate;

-import org.apache.xpath.objects.XObject;
-import org.apache.xpath.XPath;
-import org.apache.xml.utils.PrefixResolver;
-import org.apache.xml.utils.PrefixResolverDefault;
-import org.apache.xpath.XPath; // ??
-import org.apache.xpath.XPathContext;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.traversal.NodeFilter;
-
-
import org.xmldb.common.xml.queries.XPathQuery;
-import org.xmldb.common.xml.queries.XPathQueryFactory;
import org.xmldb.common.xml.queries.XPathQueryConfigurationException;
+import org.xmldb.common.xml.queries.XPathQueryFactory;

-final class XObjectImpl implements org.xmldb.common.xml.queries.XObject {

- private XObject _xobj = null;
-
- /**
- * Creates a new XObject to wrap a Xalan XObject
- *
- * @param xobj xalan's XObject that should be wrapped.
- * @exception IllegalArgumentException If the given XObject was null.
- */
- public XObjectImpl(XObject xobj) throws IllegalArgumentException {
- if (xobj == null) {
- throw new IllegalArgumentException("XalanXObject(): Argument was
null!");
- }
- _xobj = xobj;
- }
-
- public int getType() {
- return _xobj.getType();
- }
-
- public boolean bool() throws Exception {
- return _xobj.bool();
- }
-
- public double num() throws Exception {
- return _xobj.num();
- }
-
- public String str() {
- return _xobj.str();
- }
-
- // this works like the old xalan1 nodset()
- public NodeList nodeset() throws Exception {
- return _xobj.nodelist();
- }
-
- public DocumentFragment rtree() {
- return _xobj.rtree();
- }
-}
-
-final class XPathQueryImpl implements XPathQuery {
- private String qstring;
- private Node rootNode;
- private Node namespace;
- private NodeFilter filter;
- private XPath xpath;
-
- /**
- * Sets the QString attribute of the XPathQueryImpl object
- *
- * @param qstring The new QString value
- * @exception Exception Description of Exception
- */
- public void setQString(String qstring) throws Exception {
- this.qstring = qstring;
- }
-
- /**
- * Sets the Namespace attribute of the XPathQueryImpl object
- *
- * @param namespace The new Namespace value
- * @exception Exception Description of Exception
- */
- public void setNamespace(Node namespace) throws Exception {
- this.namespace = namespace;
- }
-
- /**
- * Sets the NodeFilter attribute of the XPathQueryImpl object
- *
- * @param filter The new NodeFilter value
- * @exception Exception Description of Exception
- */
- public void setNodeFilter(NodeFilter filter) throws Exception {
- this.filter = filter;
- }
-
- /**
- * Execute the xpath.
- *
- * @param rootNode The node from which the query should start or null.
- * @return The XObject insulating the query result.
- * @exception Exception
- */
- public org.xmldb.common.xml.queries.XObject
- execute(Node rootNode) throws Exception {
- if (rootNode.getNodeType() == Node.DOCUMENT_NODE) {
- rootNode = ((Document) rootNode).getDocumentElement();
- }
-
- this.rootNode = rootNode;
-
- // Since we don't have a XML Parser involved here, install some
default
- // support for things like namespaces, etc.
- XPathContext xpathSupport = new XPathContext();
-
- PrefixResolver prefixResolver = null;
- // Create an object to resolve namespace prefixes.
- if (namespace != null) {
- if (namespace.getNodeType() == Node.DOCUMENT_NODE) {
- namespace = ((Document) namespace).getDocumentElement();
- }
-
- prefixResolver = new PrefixResolverDefault(namespace);
- } else {
- prefixResolver = new PrefixResolverDefault(rootNode);
- }
-
- // Create the XPath object.
- xpath = new XPath(qstring, null, prefixResolver, XPath.SELECT, null);
-
- // execute the XPath query on the specified root node
- return new XObjectImpl(xpath.execute(xpathSupport, rootNode,
prefixResolver));
- }
-}
-
public final class XPathQueryFactoryImpl extends XPathQueryFactory
{


Added:
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/xupdate/XPathQueryImpl.java

Modified: branches/new-structure-with-base2/ps-mdm-web-admin/tomcat/web.xml
===================================================================
--- branches/new-structure-with-base2/ps-mdm-web-admin/tomcat/web.xml
2009-12-09 09:36:04 UTC (rev 5388)
+++ branches/new-structure-with-base2/ps-mdm-web-admin/tomcat/web.xml
2009-12-09 10:29:43 UTC (rev 5389)
@@ -100,7 +100,7 @@
BasicConfiguration
</servlet-name>
<servlet-class>
- org.perfsonar.webadmin.base2.servlet.BasicConfiguration
+
org.perfsonar.webadmin.base2.servlet.BasicConfigurationServlet
</servlet-class>
</servlet>




  • perfsonar: r5389 - in branches/new-structure-with-base2/ps-mdm-web-admin: ant src/main/java/org/perfsonar/webadmin/base2/config src/main/java/org/perfsonar/webadmin/base2/servlet src/main/java/org/perfsonar/webadmin/base2/servlet/util src/main/java/org/perfsonar/webadmin/base2/util src/main/java/org/perfsonar/webadmin/base2/xupdate tomcat, svnlog, 12/09/2009

Archive powered by MHonArc 2.6.16.

Top of Page