Changeset 9874


Ignore:
Timestamp:
2005-05-16T11:02:50+12:00 (16 years ago)
Author:
kjdon
Message:

merged from branch ant-install-branch: merge 1

Location:
trunk
Files:
26 added
40 deleted
132 edited

Legend:

Unmodified
Added
Removed
  • trunk/greenstone3-extensions/gsdl-as/build.xml

    r8738 r9874  
    147147-->
    148148
    149   <taskdef name="install" classname="org.apache.catalina.ant.InstallTask"/>
    150   <taskdef name="list"    classname="org.apache.catalina.ant.ListTask"/>
    151   <taskdef name="reload"  classname="org.apache.catalina.ant.ReloadTask"/>
    152   <taskdef name="remove"  classname="org.apache.catalina.ant.RemoveTask"/>
     149  <taskdef name="install" classname="org.apache.catalina.ant.InstallTask"
     150    classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
     151  <taskdef name="list"    classname="org.apache.catalina.ant.ListTask"
     152    classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
     153  <taskdef name="reload"  classname="org.apache.catalina.ant.ReloadTask"
     154    classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
     155  <taskdef name="remove"  classname="org.apache.catalina.ant.RemoveTask"
     156    classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
    153157
    154158
     
    220224        <include name="*.jar"/>
    221225    </fileset>
    222 
     226    <!-- include greenstone files -->
     227    <fileset dir="../../lib/java">
     228      <include name="*.jar"/>
     229    </fileset>
    223230    <!-- Include all elements that Tomcat exposes to applications -->
    224231    <pathelement location="${catalina.home}/common/classes"/>
  • trunk/greenstone3-extensions/gsdl-as/src/org/greenstone/gsdlas/AlertingService.java

    r8888 r9874  
    8686            String title = "Unknown action";
    8787            String message = "I don't know how to " + action;
    88             String details = "The only actions I know are " + Arrays.toString(actions);
     88            String details = "The only actions I know are " + ArrayHelper.toString(actions);
    8989            return showError(context, message, details);
    9090        }
  • trunk/greenstone3-extensions/gsdl-as/src/org/greenstone/gsdlas/EventStore.java

    r8888 r9874  
    101101     */
    102102    private String encodeSpecialChars(String string) {
    103         String encodedString = string.replace("&", "&amp;");
    104         encodedString = encodedString.replace("<", "&lt;");
    105         encodedString = encodedString.replace(">", "&gt;");
    106         encodedString = encodedString.replace("'", "&apos;");
    107         encodedString = encodedString.replace("\"", "&quot;");
     103        String encodedString = string.replaceAll("&", "&amp;");
     104        encodedString = encodedString.replaceAll("<", "&lt;");
     105        encodedString = encodedString.replaceAll(">", "&gt;");
     106        encodedString = encodedString.replaceAll("\'", "&apos;");
     107        encodedString = encodedString.replaceAll("\"", "&quot;");
    108108        return encodedString;
    109109    }
  • trunk/greenstone3-extensions/gsdl-as/src/org/greenstone/gsdlas/GreenstoneCommunicator.java

    r8874 r9874  
    2121import org.w3c.dom.*;
    2222
     23import org.greenstone.gsdlas.util.ArrayHelper;
    2324
    2425/**
     
    7071        }
    7172       
    72         System.out.println(Arrays.toString(result));
     73    System.out.println(ArrayHelper.toString(result));
    7374       
    7475        return result;
  • trunk/greenstone3-extensions/gsdl-as/src/org/greenstone/gsdlas/NotificationStore.java

    r8738 r9874  
    5454            String key = (String) iter.next();
    5555            String value = (String) event.get(key);
    56             String encodedValue = value.replace("&", "&amp;");
    57             encodedValue = encodedValue.replace("<", "&lt;");
    58             encodedValue = encodedValue.replace(">", "&gt;");
    59             encodedValue = encodedValue.replace("'", "&apos;");
    60             encodedValue = encodedValue.replace("\"", "&quot;");
     56            String encodedValue = value.replaceAll("&", "&amp;");
     57            encodedValue = encodedValue.replaceAll("<", "&lt;");
     58            encodedValue = encodedValue.replaceAll(">", "&gt;");
     59            encodedValue = encodedValue.replaceAll("\'", "&apos;");
     60            encodedValue = encodedValue.replaceAll("\"", "&quot;");
    6161           
    6262            event.put(key, encodedValue);
  • trunk/greenstone3-extensions/gsdl-as/src/org/greenstone/gsdlas/util/ArrayHelper.java

    r8775 r9874  
    2626        return index > -1 && index <= array.length;
    2727    }
     28
     29    static public String toString(String [] array) {
     30    StringBuffer buffer = new StringBuffer();
     31    buffer.append("[");
     32    for (int i=0; i<array.length; i++) {
     33        buffer.append((String)array[i]);
     34        buffer.append(",");
     35    }
     36    buffer.append("]");
     37    return buffer.toString();
     38
     39    }
    2840}
  • trunk/greenstone3-extensions/vishnu/README

    r8412 r9874  
    55If you want to run it standalone:
    66
    7 The environment variable JAVA_HOME needs to be set.
     7You need to have Java 1.4 or higher and Ant installed. The environment variable JAVA_HOME needs to be set.
    88You need to have MG installed - this should be the version from Greenstone, and you need the mg.jar file in your CLASSPATH and the libmgjni.so in your LD_LIBRARY_PATH.
    99You need the lucene 1.4 or higher jar file in your CLASSPATH.
    10 Other jar files needed in CLASSPATH: xercesImpl.jar, servlet.jar.
     10Other jar files needed in CLASSPATH: xercesImpl.jar, servlet-api.jar.
    1111These jar files all come as part of the Greenstone download. Some in gsdl3/lib/java, and servlet.jar in gsdl3/comms/jakarta/tomcat/lib (when unpacked).
    1212
    13 Edit the src/vishnu Makefile/winMake.bat and uncomment the prefix for stand-alone vishnu.
     13Edit the build.xml file and change the prefix property to be the current directory.
    1414
    15 Then run the following (on both linux or windows)
    16 
    17 make
    18 make install
     15Then run 'ant' (or "ant all').
    1916
    2017
     
    7067We have provided an example configuration for use with Tomcat (version 4.1).
    7168
    72 Set the prefix in the src/vishnu Makefile to be ../.., then the servlet class and jar files will be installed in the correct places.
    7369The vishnu/web directory is setup to be the context directory for vishnu in Tomcat.
    7470You need to edit Tomcat's conf/server.xml file, and add in the context for vishnu. Add the following element after the tomcat root context element:
  • trunk/gsdl3/README.txt

    r8428 r9874  
    44This is free software, and you are welcome to redistribute it
    55
    6 |--------|
    7 | Linux: |
    8 |--------|
    9 
    10 Installing Greenstone from a binary distribution:
    11 -------------------------------------------------
     6Installing Greenstone from a binary distribution (Linux):
     7---------------------------------------------------------
    128
    139Download the gsdl3-x.xx-linux executable file, and run it. Follow the instructions given.
    1410
    15 Installing Greenstone from a CVS checkout:
    16 ------------------------------------------
     11Installing Greenstone from a binary distribution (Windows):
     12-----------------------------------------------------------
    1713
    18 (cvs co gsdl3) (if not already done)
    19 cd gsdl3
    20 ./gs3-install.sh
     14Download the gsdl3-x.xx-win32.exe executable file, and double click on it.
     15Follow the instructions given.
    2116
    22 If you change the source and want to compile it again later, you can run 'make' then 'make install' from this directory.
    2317
    24 If you want to compile the test servlet, (useful is you are unsure whether Tomcat is working properly), go to gsdl3/web/WEB-INF/classes, and run 'javac TestServlet.java'.
     18Installing Greenstone from a CVS checkout (Linux and Windows):
     19--------------------------------------------------------------
    2520
    26 Greenstone requires Java 1.4.
     21Checkout the code:
     22
     23cvs -d :pserver:cvs_anon@cvs.scms.waikato.ac.nz:2402/usr/local/global-cvs/gsdl-src co gsdl3
     24
     25Build and install:
     26
     27Greenstone is built and installed using Ant (Apache's Java based build tool,
     28http://ant.apache.org). You will need a Java Development
     29Environment (1.4 or higher), and Ant installed to use Greenstone. You can download Ant from http://ant.apache.org/bindownload.cgi.
     30
     31In the gsdl3 directory, you can run 'ant' which will give you a help message.
     32Running 'ant -projecthelp' gives a list of the targets that you can run - these
     33do various things like compile the source code, startup the server etc.
     34
     35For a first time install, run 'ant install'.
     36
     37The file build.properties contains various parameters that can be set by the user. Please check these settings before running 'ant install'. The install process will ask you if you accept the properties before starting.
     38For a  non-interactive version of the install, run
     39ant -Dproperties.accepted=yes install
     40
     41To log the output in build.log, run
     42ant -Dproperties.accepted=yes -logfile build.log install
     43
     44Under Linux, Java and C/C++ compilation is carried out. For windows, since Visual Studio is not a standard component, only Java compilation is carried out. Pre-compiled binaries are provided for the C/C++ components (packages and Greenstone 2 style building). If you have Visual Studio installed (version 6), you can run the compile-windows-c++ targets to compile the code locally. (Don't forget to setup the Visual Studio environment first, by running, e.g. C:/Program Files/Microsoft Visual Studio/VC98/Bin/VCVARS32.BAT or equivalent.)
    2745
    2846Running Greenstone:
    2947-------------------
    3048
    31 Run the script gs3-launch.sh from the gsdl3 directory. This starts up a Tomcat web server and a mysql database server. To shutdown, run gs3-launch.sh -shutdown
     49To startup the servers, run 'ant start'. 'ant restart' and 'ant stop' restarts and shuts down the servers. To start or stop just Tomcat or MYSQL, use the start-tomcat, start-mysql, stop-tomcat, stop-mysql targets.
    3250
    33 Using SOAP:
    34 ------------
     51On Windows, if you have installed a binary version, you can also start Greenstone by selecting Greenstone 3 Digital Library from the Start menu.
    3552
    36 Greenstone comes setup to use SOAP. SOAP runs as a servlet inside Tomcat, and is disabled by default. To enable it, run
    37 ./gs3-enable-soap.sh
    38 Then re-launch Greenstone:
    39 ./gs3-launch.sh -shutdown
    40 ./gs3-launch.sh
     53Greenstone will be available in a browser at "http://localhost:8080/gsdl3".
    4154
    42 A SOAP server for localsite comes predeployed.
    43 You should be able to see all localsite's collections through the gateway servlet.
     55Using SOAP (Linux and Windows):
     56-------------------------------
     57
     58Greenstone comes with Apache Axis installed as a webapp in Tomcat.  A SOAP server on localsite is deployed during installation. You should be able to see all localsite's collections through the gateway servlet.
    4459
    4560To set up a SOAP server on a new site, run
    46 gs3-soap-deploy-site.sh <sitename> <siteURI>
    47 where the sitename is the directory name of the site, and siteURI is a unique
    48 identifier for the sites 'web service'.
     61ant soap-deploy-site
     62This will prompt you for the sitename (the directory name), and the site uri - this should be a unique identifier for the site's web service.
    4963
     64For a non-interactive version, run
     65ant -Daxis.sitename=xxx -Daxis.siteuri=yyy soap-deploy-site
    5066
     67Building Collections:
     68-----------------------
    5169
    52 |----------|
    53 | Windows: |
    54 |----------|
     70You can build collections using either Greenstone 2 style building, or native Greenstone 3 style.
    5571
    56 Installing Greenstone from a binary distribution:
    57 -------------------------------------------------
     72Greenstone 2:
    5873
    59 Download the gsdl3-x.xx-win32.exe executable file, and double click on it.
     74You need to have Perl installed and on your PATH.
     75run  'ant gli", or cd to gsdl3/gli and run gli4gs3.sh/bat. This is a graphical tool for building collections.
    6076
    61 To run Greenstone, select Greenstone 3 Digital Library from the Start menu.
     77Greenstone 3:
    6278
    63 Installing Greenstone from a CVS checkout:
    64 ------------------------------------------
     79In the gsdl3 directory, run: 'source gs3-setup.sh' (linux) or 'gs3-setup' (windows).
     80To create a new collection, run 'gs3-mkcol.sh/bat <sitename> <collname>'
     81Put documents in the import directory (gsdl3/web/sites/<sitename>/collect/<collname>/import), edit the collection configuration file (gsdl3/web/sites/<sitename>/collect/<collname>/etc/collectionConfig.xml), and run 'gs3-build.sh <sitename> <collname>'
     82Rename the building directory to index (in gsdl3/web/sites/<sitename>/collect/<collname>) and reload the collection in Tomcat (?a=s&sa=a&st=collection&sn=<collname>), or restart Tomcat.
    6583
    66 (cvs co gsdl3) (if not already done)
    67 cd gsdl3
    68 gs3-install
     84See the manual for more details about both styles of collection building.
    6985
    70 To run Greenstone, run
    71 gs3-launch
    72 This starts up the Tomcat web server and mysql database server.
    73 
    74 Using SOAP:
    75 ------------
    76 
    77 Greenstone comes setup to use SOAP. SOAP runs as a servlet inside Tomcat, and is disabled by default. To enable it, run
    78 gs3-enable-soap
    79 Then shutdown and restart Greenstone.
    80 
    81 A SOAP server for localsite comes predeployed.
    82 You should be able to see all localsite's collections through the gateway servlet.
    83 
    84 To set up a SOAP server on a new site, run
    85 gs3-soap-deploy-site <sitename> <siteURI>
    86 where the sitename is the directory name of the site, and siteURI is a unique
    87 identifier for the sites 'web service'.
    88 
    89 |--------------|
    90 | Other notes: |
    91 |--------------|
     86Other Notes:
     87---------------
    9288
    9389See gsdl3/docs/manual/manual.pdf for more details about the software and installation etc.
    9490
     91Under Linux, Tomcat logs output in gsdl3/comms/jakarta/tomcat/logs/catalina.out.
     92
    9593To prevent Tomcat showing directory listings, edit the gsdl3/comms/jakarta/tomcat/conf/web.xml file and set the value of the "listings" servlet parameter to false.
    9694
     95ant can't seem to do cvs using authenticated cvs on windows:
     96there were some classes missing - www.ibiblio.org/maven/jsch/jars/jsch-0.1.17.jar
     97many ssh processes seemed to be started up - all waiting in the background for password??
     98So should only use anonymous cvs.
     99
  • trunk/gsdl3/bin/script/convert_coll_from_gs2.pl

    r8967 r9874  
    103103    my $buildwriter = new XML::Writer(OUTPUT => $buildoutput, NEWLINES => 1);
    104104   
    105     $buildwriter->startTag('buildConfig', 'xmlns:gsf'=>"http://www.greenstone.org/configformat");
     105    $buildwriter->startTag('buildConfig', 'xmlns:gsf'=>"http://www.greenstone.org/greenstone3/schema/ConfigFormat");
    106106   
    107107    my $colloutput = new IO::File(">$colloutfile");
    108108    my $collwriter = new XML::Writer(OUTPUT => $colloutput, NEWLINES => 1);
    109109   
    110     $collwriter->startTag('collectionConfig', 'xmlns:gsf'=>"http://www.greenstone.org/configformat", 'xmlns:xsl'=>'http://www.w3.org/1999/XSL/Transform');
     110    $collwriter->startTag('collectionConfig', 'xmlns:gsf'=>"http://www.greenstone.org/greenstone3/schema/ConfigFormat", 'xmlns:xsl'=>'http://www.w3.org/1999/XSL/Transform');
    111111   
    112112    #output the collection metadata to the collectionConfig file
  • trunk/gsdl3/build.xml

    r8424 r9874  
    11<?xml version="1.0"?>
     2
    23<!-- ======================================================================
    3      Oct 11, 2004 1:54:59 AM                                                       
    4 
    5      GSDL3 build script for rebuilding gsdl3.jar
     4     March 2005                                                   
     5
     6     GSDL3 build and install script
    67                   
    7      schweer                                                               
     8     kjdon                                                               
    89     ====================================================================== -->
    9 <project name="gsdl3" default="build">
    10 
    11     <property name="src" value="src/java"/>
    12     <property name="build" value="classes"/>
    13     <property name="lib" value="lib/java"/>
    14     <property name="weblib" value="web/lib"/>
    15     <property name="javadocs" value="docs/javadoc"/>
    16 
    17     <description>
    18         GSDL3 build script for rebuilding gsdl3.jar
    19     </description>
    20 
    21     <target name="init">
    22         <tstamp/>
    23         <mkdir dir="${build}"/>
    24     </target>
    25 
    26     <target name="build" depends="init" description="build the java code">
    27         <javac debug="true" destdir="${build}" extdirs="${lib}:comms/jakarta/tomcat/common/lib/servlet.jar" optimize="false" srcdir="${src}" excludes="org/greenstone/testing/** org/greenstone/applet/** "/>
    28     </target>
    29 
    30     <target name="jar" depends="build" description="re-create gsdl3.jar">
    31         <jar destfile="${lib}/gsdl3.jar">
    32             <fileset dir="${build}" excludes="org/greenstone/testing/**" />
    33             <manifest>
    34                 <attribute name="Built-By" value="${user.name}" />
    35             </manifest>
    36         </jar>
    37     </target>
    38 
    39     <target name="install" depends="jar" description="copy gsdl3.jar to where it's supposed to be">
    40         <copy file="${lib}/gsdl3.jar" todir="${weblib}"/>
    41     </target>
    42 
    43 
    44     <target name="javadocs" depends="init" description="create javadocs">
    45         <javadoc author="true" destdir="${javadocs}" extdirs="${lib}" failonerror="true" private="true" source="1.4" sourcepath="${src}" version="true">
    46             <packageset dir="${src}" excludes="org/greenstone/testing/** org/greenstone/applet/** org/greenstone/gdbm/**"/>
    47         </javadoc>
    48     </target>
     10<project name="gsdl3" default="usage" basedir=".">
     11
     12 <!-- ============ self defined tasks =================== -->
     13
     14  <taskdef name="mysetproxy" classname="org.greenstone.anttasks.MySetProxy" classpath="${basedir}/lib/java/anttasks.jar"/>
     15  <taskdef name="getuserandpassword" classname="org.greenstone.anttasks.MyGetUserAndPassword" classpath="${basedir}/lib/java/anttasks.jar"/>
     16
     17
     18
     19<!-- ===================== Property Definitions =========================== -->
     20
     21<!--
     22
     23  Each of the following properties are used in the build script.
     24  Values for these properties are set by the first place they are
     25  defined, from the following list:
     26
     27  * Definitions on the "ant" command line (ant -Dfoo=bar compile).
     28
     29  * Definitions from a "build.properties" file in the top level
     30    source directory of this application.
     31
     32  * Definitions from a "build.properties" file in the user's
     33    home directory.
     34
     35  * Default definitions in this build.xml file.
     36
     37  You will note below that property values can be composed based on the
     38  contents of previously defined properties.  This is a powerful technique
     39  that helps you minimize the number of changes required when your development
     40  environment is modified.  Note that property composition is allowed within
     41  "build.properties" files as well as in the "build.xml" script.
     42
     43-->
     44
     45  <property file="build.properties"/>
     46  <property file="${user.home}/build.properties"/>
     47
     48  <!-- get properties from the environment -->
     49  <property environment="env"/>
     50  <property name="src.home" value="${basedir}/src/java"/>
     51  <property name="build.home" value="${basedir}/build"/>
     52  <property name="packages.home" value="${basedir}/packages"/>
     53  <property name="javalib" value="${basedir}/lib/java"/>
     54  <property name="web.home" value="${basedir}/web"/>
     55  <property name="web.lib" value="${web.home}/lib"/>
     56  <property name="web.classes" value="${web.home}/WEB-INF/classes"/>
     57 
     58  <property name="javadocs" value="${basedir}/docs/javadoc"/>
     59
     60  <property name="app.name"      value="gsdl3"/>
     61  <property name="app.path"      value="/${app.name}"/>
     62  <property name="app.version"   value="3.00alpha"/>
     63  <property name="catalina.home" value="${basedir}/comms/jakarta/tomcat"/>
     64 
     65  <property name="os.linux" value="Linux"/> <!-- mac??-->
     66  <property name="os.windows" value="Windows 95,Windows 98,Windows 2000,Windows XP, Windows NT,Windows ME"/> <!-- check this!!!-->
     67
     68  <condition property="current.os.islinux">
     69    <os family="unix"/>
     70  </condition>
     71  <condition property="current.os.iswindows">
     72    <os family="windows"/>
     73  </condition>
     74  <!-- ============= Base dirs for each package and component ============ -->
     75  <property name="applet.home" value="${src.home}/org/greenstone/applet"/>
     76  <property name="gsdl3.home" value="${src.home}/org/greenstone/gsdl3"/>
     77  <property name="anttasks.home" value="${src.home}/org/greenstone/anttasks"/>
     78  <property name="gs2build.home" value="${basedir}/gs2build"/>
     79  <property name="gli.home" value="${basedir}/gli"/>
     80  <property name="vishnu.home" value="${packages.home}/vishnu"/>
     81  <property name="mg.home" value="${packages.home}/mg"/>
     82  <property name="mgpp.home" value="${packages.home}/mgpp"/>
     83  <property name="mysql.home" value="${packages.home}/mysql"/>
     84  <property name="gsdl-as.home" value="${packages.home}/gsdl-as"/>
     85
     86<!--  ==================== Compilation Control Options ==================== -->
     87
     88<!--
     89
     90  These properties control option settings on the Javac compiler when it
     91  is invoked using the <javac> task.
     92
     93  compile.debug        Should compilation include the debug option?
     94
     95  compile.deprecation  Should compilation include the deprecation option?
     96
     97  compile.optimize     Should compilation include the optimize option?
     98
     99-->
     100
     101  <property name="compile.debug"       value="true"/>
     102  <property name="compile.deprecation" value="true"/>
     103  <property name="compile.optimize"    value="true"/>
     104
     105<!--
     106
     107  Rather than relying on the CLASSPATH environment variable, Ant includes
     108  features that makes it easy to dynamically construct the classpath you
     109  need for each compilation.  The example below constructs the compile
     110  classpath to include the servlet.jar file, as well as the other components
     111  that Tomcat makes available to web applications automatically, plus anything
     112  that you explicitly added.
     113
     114-->
     115
     116  <path id="compile.classpath">
     117    <!-- Include all jar files in our lib directory -->
     118    <pathelement location="${javalib}"/>
     119    <fileset dir="${javalib}">
     120      <include name="*.jar"/>
     121    </fileset>
     122    <!-- Include the resources directory -->
     123    <pathelement location="${basedir}/resources/java"/>
     124    <pathelement location="${basedir}/resources/dtd"/>
     125   
     126    <!-- Include the axis jar files -->
     127    <fileset dir="${basedir}/comms/soap/axis/lib">
     128      <include name="*.jar"/>
     129    </fileset>
     130   
     131    <!-- include the jar files from the packages -->
     132    <!-- mg and mgpp get installed into lib/java but they may not be there yet -->
     133    <pathelement location="${javalib}/mg.jar"/>
     134    <pathelement location="${javalib}/mgpp.jar"/>
     135    <pathelement location="${vishnu.home}/build/vishnu.jar"/>
     136   
     137    <!-- Include all elements that Tomcat exposes to applications -->
     138    <pathelement location="${catalina.home}/common/classes"/>
     139    <fileset dir="${catalina.home}/common/endorsed">
     140      <include name="*.jar"/>
     141    </fileset>
     142    <fileset dir="${catalina.home}/common/lib">
     143      <include name="*.jar"/>
     144    </fileset>
     145    <pathelement location="${catalina.home}/shared/classes"/>
     146    <fileset dir="${catalina.home}/shared/lib">
     147      <include name="*.jar"/>
     148    </fileset>
     149  </path>
     150
     151  <path id="running.path">
     152    <pathelement location="${mysql.home}/bin"/>
     153    <pathelement location="${basedir}/bin/script"/>
     154    <pathelement location="${basedir}/bin"/>
     155    <pathelement location="${basedir}/lib"/>
     156    <pathelement path="${env.PATH}"/>
     157    <pathelement path="${env.Path}"/>
     158  </path>
     159
     160  <path id="ld.library.path">
     161    <pathelement path="${env.LD_LIBRARY_PATH}"/>
     162    <pathelement location="${basedir}/lib"/>
     163    <pathelement location="${mysql.home}/lib/mysql"/>
     164  </path>
     165
     166<!-- ==================== Primary and Global Targets ============================= -->
     167
     168  <!-- add comments about using xxx-core, xxx-packages if only want certain parts?? -->
     169
     170  <target name="install" depends="accept-properties,init,prepare,cvsupdate,configure,clean,compile,deploy-localsite"
     171    description="Install Greenstone 3. Use this when you first checkout the code. Also running this target later on will reinstall Greenstone. Most things will be reset back to their defaults, except for code changes."/>
     172
     173  <target name="prepare" depends="init,prepare-core,prepare-packages,prepare-gs2building,prepare-tomcat,prepare-axis,prepare-mysql,prepare-collections,prepare-extra"/>
     174
     175  <target name="cvsupdate" depends="init,cvsupdate-packages,cvsupdate-core,cvsupdate-gs2building"
     176    description="Do a cvs update for all sources. Doesn't reompile the code."/>
     177
     178    <target name="configure" depends="init,configure-tomcat,configure-files,configure-packages,configure-core,configure-gs2building"
     179    description="Configure the installation. Includes setting up config files and configuring the C/C++ packages. This is called from install and update. Should be re-run if you change the build.properties file."/>
     180
     181  <target name="clean" depends="init,clean-packages,clean-core,clean-gs2building"
     182    description="Remove all old compiled code. Includes core, packages and gs2building if necessary"/>
     183  <target name="clean-windows-c++" depends="init,clean-windows-c++-gs2building,clean-windows-c++-packages"
     184    description="Remove C++ compiled code for Windows. Requires Microsoft Visual Studio"/>
     185  <target name="compile" depends="init,compile-extra,compile-packages,compile-core,compile-gs2building"
     186    description="Compile all the source code, includes core, packages and gs2building if necessary. Copy jar files and executables to their correct places."/>
     187  <target name="compile-windows-c++" depends="init,compile-windows-c++-gs2building,compile-windows-c++-packages"
     188    description="Compile the C/C++ code for Windows. Requires Microsoft Visual Studio"/>
     189  <target name="update" depends="init,update-packages,update-core,update-gs2building"
     190    description="Update (thru CVS) all the source (including core, packages and gs2building) and recompile. Similar to install but doesn't reinstall components such as Tomcat and axis."/>
     191
     192  <target name="start" depends="init,start-mysql,start-tomcat"
     193    description="Startup the (local) Greenstone servers (tomcat,mysql...)" />
     194
     195  <target name="stop" depends="init,stop-tomcat,stop-mysql"
     196    description="Shutdown the (local) Greenstone servers."/>
     197 
     198  <target name="restart" description="Shutdown and restart the Greenstone servers" depends="init,stop,start"/>
     199
     200
     201<!-- =========== Help targets ===================================  -->
     202 
     203  <target name="usage" description="Print a help message">
     204    <echo message="  Execute 'ant -projecthelp' for a list of targets."/>
     205    <echo message="  Execute 'ant -help' for Ant help."/>
     206    <echo>To install Greenstone, run 'ant [options] install'.
     207There are properties defined in build.properties. The install process will ask you if these properties are set correctly. To avoid this prompt, use the '-Dproperties.accepted=yes' option.
     208To log the output, use the '-logfile build.log' option.
     209    </echo>
     210  </target>
     211 
     212  <target name="help" depends="usage" description="Print a help message"/>
     213 
     214  <target name="debug" depends="init" description="Display all the currently used properties">
     215    <echoproperties/>
     216  </target>
     217
     218<!-- ====== initialization and setup targets ================== -->
     219
     220  <target name="accept-properties" unless="properties.accepted">
     221    <input addproperty="properties.ok" validargs="y,n">The following properties (among others) are being used from a build.properties file found in this directory:
     222tomcat.server=${tomcat.server}
     223tomcat.port=${tomcat.port}
     224tomcat.installed.path=${tomcat.installed.path} (this is the location of Tomcat's base dir if it is already installed)
     225gsdl2.installed.path=${gsdl2.installed.path} (this is the location of Greenstone 2 if you have it)
     226proxy.host=${proxy.host}
     227proxy.port=${proxy.port}
     228mysql.installed.path=${mysql.installed.path} (this is the location of mysql if it is already installed)
     229mysql.admin.user=${mysql.admin.user}
     230mysql.port=${mysql.port}
     231If these are not acceptable, please change them and rerun this target. Continue [y/n]?" />
     232    </input>
     233    <condition property="do.abort">
     234      <equals arg1="n" arg2="${properties.ok}"/>
     235    </condition>
     236    <fail if="do.abort">Build aborted by user. Please change your properties settings and re-run the target</fail>
     237  </target>
     238
     239  <target name="check-cvsroot">
     240    <condition property="cvsroot.notset">
     241      <or>
     242    <not>
     243      <isset property="env.CVSROOT"/>
     244    </not>
     245    <equals arg1="" arg2="${env.CVSROOT}"/>
     246      </or>
     247    </condition>
     248    <fail if="cvsroot.notset" message="You need to set the CVSROOT variable"/>
     249  </target>
     250  <!-- this sets up some initial properties -->
     251  <target name="init">
     252
     253    <condition property="java.too.old">
     254      <or>
     255    <equals arg1="1.1" arg2="${ant.java.version}"/>
     256    <equals arg1="1.2" arg2="${ant.java.version}"/>
     257    <equals arg1="1.3" arg2="${ant.java.version}"/>
     258      </or>
     259    </condition>
     260    <fail if="java.too.old" message="You need Java 1.4 or greater to run Greenstone 3"/>
     261   
     262    <available file="${basedir}/packages/mgpp/text" property="mgpp.present"/>
     263    <available file="${basedir}/packages/mysql/bin" property="mysql.present"/>
     264    <available file="${basedir}/gli" property="gli.present"/>
     265    <available file="${basedir}/gs2build" property="gs2build.present"/>
     266    <available file="${basedir}/comms/soap/axis" property="axis.present"/>
     267    <available file="${basedir}/comms/jakarta/tomcat/webapps/axis" property="axis.installed"/>
     268    <condition property="gsdl2.islocal">
     269      <or>
     270    <not>
     271      <isset property="gsdl2.installed.path"/>
     272    </not>
     273    <equals arg1="" arg2="${gsdl2.installed.path}"/>
     274      </or>
     275    </condition>
     276    <condition property="mysql.islocal">
     277      <or>
     278    <not>
     279      <isset property="mysql.installed.path"/>
     280    </not>
     281    <equals arg1="" arg2="${mysql.installed.path}"/>
     282      </or>
     283    </condition>
     284    <condition property="tomcat.islocal">
     285      <or>
     286    <not>
     287      <isset property="tomcat.installed.path"/>
     288    </not>
     289    <equals arg1="" arg2="${tomcat.installed.path}"/>
     290      </or>
     291    </condition>
     292   
     293      <echo>tomcat.port:${tomcat.port}, gli.present:${gli.present} gsdlislocal=${gsdl2.islocal} gs2build.present=${gs2build.present} gsdl2.installed.path = ${gsdl2.installed.path}</echo>
     294    <condition property="proxy.present">
     295      <and>
     296    <isset property="proxy.host"/>
     297    <not>
     298      <equals arg1="" arg2="${proxy.host}"/>
     299    </not>
     300      </and>
     301    </condition>
     302  </target>
     303
     304  <target name="setup-proxy" depends="init" if="proxy.present">
     305    <condition property="ask.user">
     306      <or>
     307    <equals arg1="" arg2="${proxy.user}"/>
     308    <equals arg1="" arg2="${proxy.password}"/>
     309      </or>
     310    </condition>
     311    <getuserandpassword message="Using proxy: ${proxy.host}:${proxy.port}" if="ask.user" username="${proxy.user}"/>
     312    <mysetproxy proxyhost="${proxy.host}" proxyport="${proxy.port}" proxyuser="${proxy.user}" proxypassword="${proxy.password}"/>
     313  </target>
     314
     315 <!-- ========== Miscellaneous Targets ================================ -->
     316 
     317  <target name="prepare-collections">
     318    <property name="collect.dir" value="${basedir}/web/sites/localsite/collect"/>
     319    <!-- gs3mgdemo -->
     320    <unzip src="${collect.dir}/gs3mgdemo/import.zip"
     321      dest="${collect.dir}/gs3mgdemo"/>
     322    <unzip src="${collect.dir}/gs3mgdemo/archives.zip"
     323      dest="${collect.dir}/gs3mgdemo"/>
     324    <unzip src="${collect.dir}/gs3mgdemo/index/index.zip"
     325      dest="${collect.dir}/gs3mgdemo/index"/>
     326    <!-- gs2mgdemo -->
     327    <unzip src="${collect.dir}/gs2mgdemo/import.zip"
     328      dest="${collect.dir}/gs2mgdemo"/>
     329    <unzip src="${collect.dir}/gs2mgdemo/metadata.zip"
     330      dest="${collect.dir}/gs2mgdemo"/>
     331    <unzip src="${collect.dir}/gs2mgdemo/index/index.zip"
     332      dest="${collect.dir}/gs2mgdemo/index"/>
     333    <!-- gs2mgppdemo -->
     334    <unzip src="${collect.dir}/gs2mgppdemo/import.zip"
     335      dest="${collect.dir}/gs2mgppdemo"/>
     336    <unzip src="${collect.dir}/gs2mgppdemo/metadata.zip"
     337      dest="${collect.dir}/gs2mgppdemo"/>
     338    <unzip src="${collect.dir}/gs2mgppdemo/index/index.zip"
     339      dest="${collect.dir}/gs2mgppdemo/index"/>
     340    <!-- gberg -->
     341    <unzip src="${collect.dir}/gberg/index/index.zip"
     342      dest="${collect.dir}/gberg/index"/>
     343  </target>
     344
     345  <target name="prepare-extra" depends="init">
     346    <!--  copy some jar files to web/lib for the phind applet -->
     347    <copy file="${catalina.home}/common/endorsed/xml-apis.jar"
     348      tofile="${basedir}/web/lib/xml-apis.jar"/>
     349    <copy file="${catalina.home}/common/endorsed/xercesImpl.jar"
     350      tofile="${basedir}/web/lib/xercesImpl.jar"/>
     351  </target>
     352
     353  <target name="configure-files" depends="configure-files-gsdl3,configure-files-server"/>
     354 
     355  <target name="configure-files-gsdl3" depends="init">
     356    <filter token="gsdl3home" value="${basedir}"/>
     357    <copy file="${basedir}/web/WEB-INF/web.xml.in" tofile="${basedir}/web/WEB-INF/web.xml" filtering="true"/>
     358    <copy file="${basedir}/resources/java/SOAPServer.cfg.in" tofile="${basedir}/resources/java/SOAPServer.cfg" filtering="true"/>
     359  </target>
     360 
     361  <target name="configure-files-server" depends="init">
     362    <filter token="port" value="${tomcat.port}"/>
     363    <filter token="hostname" value="${tomcat.server}"/>
     364    <copy file="${basedir}/web/sites/localsite/siteConfig.xml.in" tofile="${basedir}/web/sites/localsite/siteConfig.xml" filtering="true" overwrite="true"/>
     365    <copy file="${basedir}/web/sites/gateway/siteConfig.xml.in" tofile="${basedir}/web/sites/gateway/siteConfig.xml" filtering="true" overwrite="true"/>
     366  </target>
     367
     368   <target name="compile-extra" depends="init">
     369    <javac srcdir="${web.home}/WEB-INF/classes"
     370      destdir="${web.home}/WEB-INF/classes"
     371      debug="${compile.debug}"
     372      deprecation="${compile.deprecation}"
     373      optimize="${compile.optimize}">
     374      <classpath>
     375    <path refid="compile.classpath"/>
     376      </classpath>
     377    </javac>
     378  </target>
     379
     380 
     381
     382
     383<!-- ======================= Tomcat Targets ========================== -->
     384
     385  <!-- this target sets up tomcat for the first time, or resets it any subsequent times -->
     386  <target name="prepare-tomcat" depends="init,setup-proxy" if="tomcat.islocal">
     387    <get src="http://www.greenstone.org/gs3files/jakarta-tomcat-5.5.7.zip"
     388      dest="${basedir}/comms/jakarta/jakarta-tomcat-5.5.7.zip"
     389      usetimestamp="true"/>
     390    <delete dir="${basedir}/comms/jakarta/tomcat.bak"/>
     391    <move todir="${basedir}/comms/jakarta/tomcat.bak" failonerror="false">
     392      <fileset dir="${basedir}/comms/jakarta/tomcat"/>
     393    </move>
     394    <unzip src="${basedir}/comms/jakarta/jakarta-tomcat-5.5.7.zip"
     395      dest="${basedir}/comms/jakarta"/>
     396    <condition property="need.tomcat.compat">
     397      <equals arg1="1.4" arg2="${ant.java.version}"/>
     398    </condition>
     399    <antcall target="prepare-tomcat-compat"/>
     400    <move todir="${basedir}/comms/jakarta/tomcat">
     401      <fileset dir="${basedir}/comms/jakarta/jakarta-tomcat-5.5.7"/>
     402    </move>
     403    <!-- make sure we have execute permission for the .sh files -->
     404    <chmod dir="${basedir}/comms/jakarta/tomcat/bin" perm="ugo+rx"
     405      includes="*.sh"/>
     406    <copy file="${basedir}/comms/jakarta/setclasspath.bat"
     407      tofile="${basedir}/comms/jakarta/tomcat/bin/setclasspath.bat"
     408      overwrite="true"/>
     409  </target>
     410
     411 
     412  <target name="prepare-tomcat-compat" if="need.tomcat.compat">
     413    <get src="http://www.greenstone.org/gs3files/jakarta-tomcat-5.5.7-compat.zip"
     414      dest="${basedir}/comms/jakarta/jakarta-tomcat-5.5.7-compat.zip"
     415      usetimestamp="true"/>
     416    <unzip src="${basedir}/comms/jakarta/jakarta-tomcat-5.5.7-compat.zip"
     417      dest="${basedir}/comms/jakarta"/>
     418  </target>
     419 
     420  <target name="configure-tomcat" depends="init" if="tomcat.islocal">
     421    <!-- re-setup the server.xml file -->
     422    <copy file="${basedir}/comms/jakarta/server.xml.in" tofile="${basedir}/comms/jakarta/tomcat/conf/server.xml" overwrite="true">
     423      <filterset>
     424    <filter token="port" value="${tomcat.port}"/>
     425    <filter token="gsdl3home" value="${basedir}"/>
     426      </filterset>
     427    </copy>
     428  </target>
     429
     430  <target name="reload" description="Reload web application"
     431          depends="init,setup-catalina-ant-tasks">
     432    <reload  url="http://kanuka:7070/manager" username="admin" password="admin"
     433            path="/gsdl3"/>
     434  </target>
     435 
     436  <target name="start-tomcat" description="Startup only Tomcat" depends="init" if="tomcat.islocal">
     437    <property name="tomcat.classpath" refid="compile.classpath"/>
     438    <property name="tomcat.path" refid="running.path"/>
     439    <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx400M"/>
     440    <exec executable="${catalina.home}/bin/startup.sh" os="${os.linux}" dir="${catalina.home}/bin" spawn="false">
     441      <env key="GSDLOS" value="linux"/>
     442      <env key="GSDL3HOME" value="${basedir}"/>
     443      <env key="PATH" path="${tomcat.path}"/>
     444      <env key="CATALINA_OPTS" value="${catalina.opts}"/>
     445      <env key="CATALINA_HOME" value="${catalina.home}"/>
     446      <env key="CLASSPATH" path="${tomcat.classpath}"/>
     447      <env key="LD_LIBRARY_PATH" path="${env.LD_LIBRARY_PATH}:${basedir}/lib:${mysql.home}/lib/mysql"/>
     448    </exec>
     449    <exec executable="${catalina.home}/bin/startup.bat" os="${os.windows}" dir="${catalina.home}/bin" spawn="true">
     450      <env key="GSDLOS" value="windows"/>
     451      <env key="GSDL3HOME" value="${basedir}"/>
     452      <env key="Path" path="${tomcat.path}"/>
     453      <env key="PATH" path="${tomcat.path}"/>
     454      <env key="CATALINA_OPTS" value="${catalina.opts}"/>
     455      <env key="CLASSPATH" path="${tomcat.classpath}"/>
     456    </exec>
     457    <!-- wait for the server to startup in case other targets need it running -->
     458    <waitfor maxwait="5" maxwaitunit="second">
     459      <and>
     460    <socket server="${tomcat.server}" port="${tomcat.port}"/>
     461    <http url="http://${tomcat.server}:${tomcat.port}/gsdl3/index.html"/>
     462      </and>
     463    </waitfor>
     464  </target>
     465  <!-- windows: do we want to launch a webrowser?? -->
     466  <target name="stop-tomcat" description="Shutdown only Tomcat" depends="init" if="tomcat.islocal">
     467    <exec executable="${catalina.home}/bin/shutdown.sh" os="${os.linux}" dir="${catalina.home}/bin" spawn="false">
     468      <env key="CATALINA_HOME" value="${catalina.home}"/>
     469    </exec>
     470    <exec executable="${catalina.home}/bin/shutdown.bat" os="${os.windows}" dir="${catalina.home}/bin" spawn="false"/>
     471  </target>
     472
     473  <target name="restart-tomcat" description="Shutdown and restart only Tomcat" depends="init,stop-tomcat,start-tomcat"/>
     474
     475  <target name="setup-catalina-ant-tasks">
     476    <!-- Configure the custom Ant tasks for the Tomcat Manager application -->
     477    <taskdef name="deploy"    classname="org.apache.catalina.ant.DeployTask"
     478      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
     479    <taskdef name="list"      classname="org.apache.catalina.ant.ListTask"
     480      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
     481    <taskdef name="reload"    classname="org.apache.catalina.ant.ReloadTask"
     482      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
     483    <taskdef name="resources" classname="org.apache.catalina.ant.ResourcesTask"
     484      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
     485    <taskdef name="roles"     classname="org.apache.catalina.ant.RolesTask"
     486      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
     487    <taskdef name="start"     classname="org.apache.catalina.ant.StartTask"
     488      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
     489    <taskdef name="stop"      classname="org.apache.catalina.ant.StopTask"
     490      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
     491    <taskdef name="undeploy"  classname="org.apache.catalina.ant.UndeployTask"
     492      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
     493  </target>
     494
     495
     496<!-- ======================= Mysql Targets =========================== -->
     497
     498  <!-- this is one target that we only want to run once. -->
     499  <target name="prepare-mysql" depends="init,init-mysql-vars,install-mysql,start-mysql,setup-mysql,stop-mysql"/>
     500
     501  <target name="init-mysql-vars">
     502    <condition property="mysql.islocal.linux">
     503      <and>
     504    <isset property="mysql.islocal"/>
     505    <isset property="current.os.islinux"/>
     506      </and>
     507    </condition>
     508
     509    <condition property="mysql.islocal.windows">
     510      <and>
     511    <isset property="mysql.islocal"/>
     512    <isset property="current.os.iswindows"/>
     513      </and>
     514    </condition>
     515   </target>
     516 
     517 <target name="install-mysql" depends="init,init-mysql-vars,install-mysql-linux,install-mysql-windows"/>
     518 
     519  <!-- install and set up the database -->
     520  <target name="install-mysql-linux" depends="init,init-mysql-vars" if="mysql.islocal.linux" unless="mysql.present">
     521    <get src="http://www.greenstone.org/gs3files/mysql-standard-4.1.11-pc-linux-gnu-i686.tar.gz"
     522      dest="${packages.home}/mysql-standard-4.1.11-pc-linux-gnu-i686.tar.gz"
     523      usetimestamp="true"/>
     524    <untar src="${packages.home}/mysql-standard-4.1.11-pc-linux-gnu-i686.tar.gz"
     525      dest="${packages.home}"
     526      compression="gzip"/>
     527    <move todir="${packages.home}/mysql">
     528      <fileset dir="${packages.home}/mysql-standard-4.1.11-pc-linux-gnu-i686"/>
     529    </move>
     530    <!-- file permissions are screwed up, so make executables executable -->
     531    <chmod file="${mysql.home}/scripts/mysql_install_db" perm="a+x"/>
     532    <chmod perm="a+x">
     533      <fileset dir="${mysql.home}/bin" />
     534    </chmod>
     535    <mkdir dir="${mysql.home}/var/"/>
     536    <mkdir dir="${mysql.home}/var/log/"/>
     537    <chmod file="${mysql.home}/var/" perm="777"/>
     538    <chmod file="${mysql.home}/var/log/" perm="777"/>
     539   
     540    <exec executable="${mysql.home}/scripts/mysql_install_db" dir="${mysql.home}">
     541      <arg value="--datadir=./data"/>
     542      <arg value="--basedir=."/>
     543      <arg value="--user=root"/>
     544      <arg value="--force"/>
     545    </exec>
     546  </target>
     547
     548  <target name="install-mysql-windows" depends="init,init-mysql-vars" if="mysql.islocal.windows" unless="mysql.present">
     549    <get src="http://www.greenstone.org/gs3files/mysql-noinstall-4.1.11-win32.zip"
     550      dest="${packages.home}/mysql-noinstall-4.1.11-win32.zip"
     551      usetimestamp="true"/>
     552    <!-- can we run the installer?? -->
     553    <unzip src="${packages.home}/mysql-noinstall-4.1.11-win32.zip"
     554      dest="${packages.home}"/>
     555    <move todir="${packages.home}/mysql">
     556      <fileset dir="${packages.home}/mysql-4.1.11-win32"/>
     557    </move>
     558  </target>
     559
     560  <!-- is this just linux or both??. also we probably need to do this for external mysql -->
     561  <!-- had unless mysql.present -->
     562  <target name="setup-mysql" depends="init,init-mysql-vars" if="mysql.islocal">
     563    <exec executable="${mysql.home}/bin/mysql" dir="${mysql.home}">
     564      <arg value="--user=root"/>
     565      <arg value="--execute=GRANT SELECT,INSERT,DELETE,UPDATE,DROP,CREATE ON *.* TO gsdl3admin@localhost;"/>
     566    </exec>
     567    <exec executable="${mysql.home}/bin/mysql" dir="${mysql.home}">
     568      <arg value="--user=root"/>
     569      <arg value="--execute=GRANT SELECT,INSERT,DELETE,UPDATE,DROP,CREATE ON *.* TO gsdl3admin@'%'"/>
     570    </exec>
     571    <exec executable="${mysql.home}/bin/mysql" dir="${mysql.home}">
     572      <arg value="--user=root"/>
     573      <arg value="--execute=GRANT SELECT ON *.* TO gsdl3reader@localhost;"/>
     574    </exec>
     575    <exec executable="${mysql.home}/bin/mysql" dir="${mysql.home}">
     576      <arg value="--user=root"/>
     577      <arg value="--execute=create database localsite_gs3mgdemo;"/>
     578    </exec>
     579    <exec executable="${mysql.home}/bin/mysql" dir="${mysql.home}"
     580      input="${basedir}/web/sites/localsite/collect/gs3mgdemo/mysqldatadump.sql">
     581      <arg value="--user=root"/>
     582      <arg value="localsite_gs3mgdemo"/>
     583    </exec>
     584  </target>
     585 
     586  <target name="start-mysql" depends="init,init-mysql-vars" if="mysql.islocal"
     587    description="Startup only mysql">
     588    <exec executable="${mysql.home}/bin/mysqld_safe" dir="${mysql.home}"
     589      spawn="true" os="${os.linux}">
     590      <arg value="--user=root"/>
     591      <arg value="--datadir=./data"/>
     592      <arg value="--basedir=."/>
     593      <arg value="--pid_file=gsdl3.pid"/>
     594      <arg value="--socket=/tmp/mysql.sock"/>
     595      <arg value="--err-log=./var/log/mysql.log"/>
     596    </exec>
     597   <exec executable="${mysql.home}/bin/mysqld" dir="${mysql.home}" spawn="true" os="${os.windows}">
     598    </exec>
     599    <sleep seconds="2"/>
     600    <!-- need to test that the server has started up -->   
     601    <exec executable="${mysql.home}/bin/mysql" dir="${mysql.home}"
     602      failonerror="true" outputproperty="throw.away">
     603      <arg value="--user=root"/>
     604      <arg value="--execute=show databases;"/>
     605    </exec>
     606    <echo>MYSQL database server started successfully</echo>
     607  </target>
     608
     609    <target name="stop-mysql" depends="init" if="mysql.islocal"
     610    description="Shutdown only mysql">
     611    <exec executable="${mysql.home}/bin/mysqladmin" dir="${mysql.home}"
     612      failonerror="true" os="${os.linux}">
     613      <arg value="--user=root"/>
     614      <arg value="--socket=/tmp/mysql.sock"/>
     615      <arg value="shutdown"/>
     616    </exec>
     617    <exec executable="${mysql.home}/bin/mysqladmin" dir="${mysql.home}"
     618      failonerror="true" os="${os.windows}">
     619      <arg value="--user=root"/>
     620      <arg value="shutdown"/>
     621    </exec>
     622    <echo>MYSQL database server shutdown successfully</echo>
     623  </target>
     624
     625  <target name="restart-mysql" description="Shutdown and restart only mysql" depends="init,stop-mysql,start-mysql"/>
     626
     627
     628<!-- ======================= Axis Targets ============================ -->
     629
     630  <target name="prepare-axis" depends="init">
     631    <mkdir dir="${basedir}/comms/soap"/>
     632    <get src="http://www.greenstone.org/gs3files/axis-1_1.zip"
     633      dest="${basedir}/comms/soap/axis-1_1.zip"
     634      usetimestamp="true"/>
     635    <delete dir="${basedir}/comms/soap/axis.bak"/>
     636    <move todir="${basedir}/comms/soap/axis.bak"  failonerror="false">
     637      <fileset dir="${basedir}/comms/soap/axis"/>
     638    </move>
     639    <unzip src="${basedir}/comms/soap/axis-1_1.zip"
     640      dest="${basedir}/comms/soap/"/>
     641    <move todir="${basedir}/comms/soap/axis">
     642      <fileset dir="${basedir}/comms/soap/axis-1_1"/>
     643    </move>
     644    <!-- install the webapp into tomcat -->
     645    <copy todir="${basedir}/comms/jakarta/tomcat/webapps/axis">
     646      <fileset dir="${basedir}/comms/soap/axis/webapps/axis"/>
     647    </copy>
     648  </target>
     649
     650  <target name="soap-deploy-site" depends="get-sitename,get-siteuri,create-deployment-files,restart-tomcat"
     651    description="Deploy a SOAP web service for a local Greenstone site">
     652    <java classname="org.apache.axis.client.AdminClient">
     653      <classpath refid="compile.classpath"/>
     654      <arg value="-p"/>
     655      <arg value="${tomcat.port}"/>
     656      <arg file="${basedir}/resources/soap/${axis.sitename}.wsdd"/>
     657    </java>   
     658  </target>
     659 
     660  <target name="soap-undeploy-site" depends="get-sitename"
     661    description="Undeploy a SOAP web service for a local Greenstone site">
     662    <java classname="org.apache.axis.client.AdminClient">
     663      <classpath refid="compile.classpath"/>
     664      <arg value="-p"/>
     665      <arg value="${tomcat.port}"/>
     666      <arg file="${basedir}/resources/soap/undeploy-${axis.sitename}.wsdd"/>
     667    </java>
     668  </target>
     669
     670  <target name="deploy-localsite" depends="init">
     671    <antcall target="start-tomcat"/>
     672    <antcall target="soap-deploy-site">
     673      <param name="axis.sitename" value="localsite"/>
     674      <param name="axis.siteuri" value="localsite"/>
     675    </antcall>
     676    <antcall target="stop-tomcat"/>
     677  </target>
     678 
     679  <target name="get-sitename" unless="axis.sitename">
     680    <input addproperty="axis.sitename" message="What site? (press enter for default:localsite)" defaultvalue="localsite"/>
     681  </target>
     682
     683  <target name="get-siteuri" depends="get-sitename" unless="axis.siteuri">
     684    <input addproperty="axis.siteuri" message="What name do you want the service to have? (press enter for default:${axis.sitename})" defaultvalue="${axis.sitename}"/>
     685    <echo>${axis.sitename}, ${axis.siteuri}</echo>
     686  </target>
     687  <target name="check-deployment-files" depends="get-sitename">
     688    <condition property="deploy.exists">
     689      <available file="${basedir}/resources/soap/${axis.sitename}.wsdd"/>
     690    </condition>
     691    <condition property="undeploy.exists">
     692      <available file="${basedir}/resources/soap/undeploy-${axis.sitename}.wsdd"/>
     693    </condition>
     694    <echo>${axis.sitename}, ${deploy.exists}, ${undeploy.exists}</echo>
     695  </target>
     696  <target name="create-deployment-files" depends="get-sitename,check-deployment-files"
     697    if="axis.sitename" unless="deploy.exists">
     698    <filter token="sitename" value="${axis.sitename}"/>
     699    <filter token="siteuri" value="${axis.siteuri}"/>
     700    <copy file="${basedir}/resources/soap/site.wsdd.template"
     701      tofile="${basedir}/resources/soap/${axis.sitename}.wsdd"
     702      filtering="true"/>
     703     <copy file="${basedir}/resources/soap/undeploy-site.wsdd.template"
     704      tofile="${basedir}/resources/soap/undeploy-${axis.sitename}.wsdd"
     705      filtering="true"/>
     706    <!-- create the java files and compile them -->
     707    <copy file="${gsdl3.home}/SOAPServer.java.in"
     708      tofile="${gsdl3.home}/SOAPServer${axis.sitename}.java"
     709      filtering="true"/>
     710    <javac srcdir="${src.home}"
     711      destdir="${build.home}"
     712      debug="${compile.debug}"
     713      deprecation="${compile.deprecation}"
     714      optimize="${compile.optimize}">
     715      <classpath refid="compile.classpath"/>
     716      <include name="org/greenstone/gsdl3/SOAPServer${axis.sitename}.java" />
     717    </javac>
     718    <jar destfile="${build.home}/gsdl3.jar">
     719      <fileset dir="${build.home}">
     720    <include name="org/greenstone/gsdl3/**"/>
     721    <exclude name="**/Test.class"/>
     722      </fileset>
     723      <manifest>
     724    <attribute name="Built-By" value="${user.name}" />
     725      </manifest>
     726    </jar>
     727    <copy file="${build.home}/gsdl3.jar" todir="${javalib}"/>
     728    <copy file="${build.home}/gsdl3.jar" todir="${web.lib}"/>
     729  </target>
     730   
     731
     732<!-- ====================== Core targets ============================== -->
     733<!-- core targets refer to the core gsdl3 java src -->
     734 
     735  <target name="prepare-core">
     736    <!-- just get rid of empty directories-->
     737    <cvs command="update -P"/>
     738  </target>
     739  <target name="configure-core"/>
     740  <target name="update-core" depends="init,cvsupdate-core,clean-core,compile-core"
     741    description="Update only the Greenstone core" />
     742 
     743  <target name="cvsupdate-core">
     744    <cvs command="update -l"/>
     745    <cvs command="update -dP bin comms dist-resources docs interfaces lib resources src web winutil"/>
     746  </target>
     747
     748  <target name="clean-core"
     749    description="Clean only the Greenstone core">
     750    <delete dir="${build.home}"/>
     751  </target>
     752
     753   <target name="compile-core"
     754    description="Compile only the Greenstone core">
     755    <mkdir dir="${build.home}"/>
     756    <javac srcdir="${src.home}"
     757      destdir="${build.home}"
     758      debug="${compile.debug}"
     759      deprecation="${compile.deprecation}"
     760      optimize="${compile.optimize}">
     761      <classpath>
     762    <path refid="compile.classpath"/>
     763      </classpath>
     764    </javac>
     765    <jar destfile="${build.home}/gsdl3.jar">
     766      <fileset dir="${build.home}">
     767    <include name="org/greenstone/gsdl3/**"/>
     768    <exclude name="**/Test.class"/>
     769      </fileset>
     770      <manifest>
     771    <attribute name="Built-By" value="${user.name}" />
     772      </manifest>
     773    </jar>
     774    <copy file="${build.home}/gsdl3.jar" todir="${javalib}"/>
     775    <copy file="${build.home}/gsdl3.jar" todir="${web.lib}"/>
     776    <mkdir dir="${web.classes}/org/greenstone/gsdl3"/>
     777    <copy file="${build.home}/org/greenstone/gsdl3/LibraryServlet.class"
     778      todir="${web.classes}/org/greenstone/gsdl3"/>
     779    <jar destfile="${build.home}/phind.jar">
     780      <fileset dir="${build.home}">
     781    <include name="org/greenstone/applet/phind/**"/>
     782      </fileset>
     783      <manifest>
     784    <attribute name="Built-By" value="${user.name}" />
     785      </manifest>
     786    </jar>
     787    <copy file="${build.home}/phind.jar" todir="${javalib}"/>
     788    <copy file="${build.home}/phind.jar" todir="${web.lib}"/>
     789    <jar destfile="${build.home}/anttasks.jar">
     790      <fileset dir="${build.home}">
     791    <include name="org/greenstone/anttasks/**"/>
     792      </fileset>
     793      <manifest>
     794    <attribute name="Built-By" value="${user.name}" />
     795      </manifest>
     796    </jar>
     797    <copy file="${build.home}/anttasks.jar" todir="${javalib}"/>
     798    <jar destfile="${build.home}/gsdl3test.jar">
     799      <fileset dir="${build.home}">
     800    <include name="org/greenstone/gsdl3/**/*Test.class"/>
     801    <include name="org/greenstone/testing/**"/>
     802      </fileset>
     803      <manifest>
     804    <attribute name="Built-By" value="${user.name}" />
     805      </manifest>
     806    </jar>
     807  </target>
     808 
     809<!-- ================== Packages targets ================================ -->
     810  <!-- these targets refer to the greenstone packages - these need updating
     811  less often, so are in  separate targets to the core -->
     812  <target name="prepare-packages" depends="init,prepare-mgpp,prepare-windows"/>
     813 
     814  <target name="prepare-windows" depends="init" if="current.os.iswindows">
     815    <!-- need to download precompiled binaries for mg and mgpp -->
     816  </target>
     817  <target name="prepare-mgpp" depends="check-cvsroot,init" unless="mgpp.present">
     818    <cvs command="checkout -P" package="mgpp" dest="${basedir}/packages/"/>
     819  </target>
     820
     821  <target name="update-packages" depends="init,cvsupdate-packages,configure-packages,clean-packages,compile-packages"
     822    description="Update only the packages"/>
     823
     824  <target name="cvsupdate-packages">
     825    <cvs command="update -dP" dest="${packages.home}"/>
     826  </target>
     827 
     828  <target name="configure-packages" description="Configure only the packages.">
     829    <echo>
     830      Configuring MG
     831    </echo>
     832    <exec executable="configure" os="${os.linux}"
     833      dir="${mg.home}">
     834      <arg value="--prefix=${basedir}"/>
     835    </exec>   
     836    <echo>
     837      Configuring MGPP
     838    </echo>
     839    <exec executable="configure" os="${os.linux}"
     840      dir="${mgpp.home}">
     841      <arg value="--prefix=${basedir}"/>
     842    </exec>
     843  </target>
     844
     845  <target name="clean-packages"
     846    description="Clean only the packages">
     847    <!-- mg : just call the make target -->
     848    <exec executable="make" os="${os.linux}"
     849      dir="${mg.home}">
     850      <arg value="clean"/>
     851    </exec>
     852    <!-- mgpp -->
     853    <exec executable="make" os="${os.linux}"
     854      dir="${mg.home}">
     855      <arg value="clean"/>
     856    </exec>
     857    <!-- vishnu : just call the ant target -->
     858    <ant antfile="${vishnu.home}/build.xml" dir="${vishnu.home}"
     859      inheritall="false" target="clean"/>
     860
     861    <!-- gsdl-as : just call the ant target-->
     862    <ant antfile="${gsdl-as.home}/build.xml" dir="${gsdl-as.home}"
     863      inheritall="false" target="clean"/>
     864  </target>
     865
     866  <target name="clean-windows-c++-packages" depends="init" if="current.os.iswindows"
     867    description="Clean only the C/C++ packages">
     868    <exec executable="${mg.home}/winMake.bat" dir="${mg.home}">
     869      <arg value="clean"/>
     870    </exec>
     871    <exec executable="${mgpp.home}/winMake.bat" dir="${mgpp.home}">
     872      <arg value="clean"/>
     873    </exec>
     874  </target>   
     875
     876  <target name="compile-packages"
     877    description="Compile only the packages">
     878    <echo>Compiling MG</echo>
     879    <exec executable="make" os="${os.linux}"
     880       dir="${mg.home}">
     881    </exec>
     882    <exec executable="make" os="${os.linux}"
     883      dir="${mg.home}">
     884      <arg value="install"/>
     885    </exec>
     886    <!-- windows: just the java stuff. -->
     887    <exec executable="${mg.home}/winMake.bat" os="${os.windows}"
     888      dir="${mg.home}">
     889      <arg value="compile"/>
     890      <arg value="javaonly"/>
     891    </exec>
     892    <exec executable="${mg.home}/winMake.bat" os="${os.windows}"
     893      dir="${mg.home}">
     894      <arg value="install"/>
     895      <arg value="javaonly"/>
     896      <env key="GSDL3HOME" value="${basedir}"/>
     897    </exec>
     898   
     899    <!-- mgpp -->
     900    <echo>Compiling MGPP</echo>
     901    <exec executable="make" os="${os.linux}"
     902       dir="${mgpp.home}">
     903    </exec>
     904    <exec executable="make" os="${os.linux}"
     905      dir="${mgpp.home}">
     906      <arg value="install"/>
     907    </exec>
     908    <!-- windows: just the java stuff. -->
     909    <exec executable="${mgpp.home}/winMake.bat" os="${os.windows}"
     910      dir="${mgpp.home}">
     911      <arg value="compile"/>
     912      <arg value="javaonly"/>
     913    </exec>
     914    <exec executable="${mgpp.home}/winMake.bat" os="${os.windows}"
     915      dir="${mgpp.home}">
     916      <arg value="install"/>
     917      <arg value="javaonly"/>
     918      <env key="GSDL3HOME" value="${basedir}"/>
     919    </exec>
     920
     921    <!-- vishnu -->
     922    <echo>Compiling Vishnu</echo>
     923    <ant antfile="${vishnu.home}/build.xml" dir="${vishnu.home}"
     924      inheritall="false" target="compile"/>
     925
     926    <!-- gsdl-as -->
     927    <echo>Compiling GSDL-AS</echo>
     928    <ant antfile="${gsdl-as.home}/build.xml" dir="${gsdl-as.home}"
     929      inheritall="false" target="compile"/>
     930  </target>
     931
     932  <target name="compile-windows-c++-packages" depends="init" if="current.os.iswindows"
     933    description="Compile only the C/C++ packages">
     934    <exec executable="${mg.home}/winMake.bat" dir="${mg.home}"/>
     935    <exec executable="${mg.home}/winMake.bat" dir="${mg.home}">
     936      <arg value="install"/>
     937      <env key="GSDL3HOME" value="${basedir}"/>
     938    </exec>
     939   <exec executable="${mgpp.home}/winMake.bat" dir="${mgpp.home}"/>
     940    <exec executable="${mgpp.home}/winMake.bat" dir="${mgpp.home}">
     941      <arg value="install"/>
     942      <env key="GSDL3HOME" value="${basedir}"/>
     943    </exec>
     944  </target>   
     945 
     946  <!-- ================== gs2building targets ===============-->
     947
     948
     949  <target name="update-gs2building" if="gsdl2.islocal"
     950    depends="init,cvsupdate-gs2building,configure-gs2building,clean-gs2building,compile-gs2building"
     951    description="Update only the Greenstone 2 building components"/>
     952
     953  <target name="cvsupdate-gs2building" if="gsdl2.islocal" depends="init">
     954    <cvs command="update -dP" dest="${gli.home}"/>
     955    <!-- Note: can't do a -d update here cos it will get all of gsdl
     956     also, an update doesn't get new files, so we do a checkout instead. -->
     957    <cvs command="co gs2build" dest="${basedir}"/>
     958    <!-- rename the .gs2build files - we may have gotten changes to the main
     959    gsdl versions - make sure they are set back to the gs2build versions -->
     960    <antcall target="rename-gs2build-files"/>
     961  </target>
     962
     963  <target name="prepare-gs2building" depends="init,prepare-gs2build,prepare-gli" if="gsdl2.islocal">
     964    <echo>checking out gs2 building stuff</echo>
     965  </target>
     966
     967  <target name="prepare-gs2build" depends="check-cvsroot,init" if="gsdl2.islocal" unless="gs2build.present">
     968    <echo>checking out gs2build</echo>
     969    <cvs command="checkout -P" package="gs2build"/>
     970
     971    <!-- rename the .gs2build files -->
     972    <antcall target="rename-gs2build-files"/>
     973    <antcall target="unzip-windows-packages"/>
     974    <antcall target="get-windows-binaries"/>
     975  </target>
     976
     977  <target name="get-windows-binaries" depends="init" if="current.os.iswindows">
     978     <cvs command="checkout -P" package="winbin"/>
     979     <copy todir="${basedir}/bin">
     980       <fileset dir="${basedir}/winbin/bin" includes="mg*.exe"/>
     981     </copy>
     982     <move todir="${gs2build.home}/bin/windows" failonerror="false">
     983      <fileset dir="${basedir}/winbin/bin"/>
     984    </move>
     985    <delete dir="${basedir}/winbin"/>
     986   </target>
     987 <target name="unzip-windows-packages" depends="init"> 
     988    <unzip src="${gs2build.home}/packages/windows/gdbm/gdbm.zip"
     989    dest="${gs2build.home}/packages/windows/gdbm"/>
     990   <unzip src="${gs2build.home}/packages/windows/crypt/crypt.zip"
     991    dest="${gs2build.home}/packages/windows/crypt"/>
     992       <unzip src="${gs2build.home}/packages/windows/expat/expat.zip"
     993    dest="${gs2build.home}/packages/windows/expat"/>
     994   </target>
     995
     996  <target name="rename-gs2build-files" depends="rename-gs2build-files-linux,rename-gs2build-files-windows"/>
     997
     998  <target name="rename-gs2build-files-windows" if="current.os.iswindows">
     999    <property name="gs2build-extra.home" value="${gs2build.home}/gs2build-extra"/>
     1000   <copy file="${gs2build-extra.home}/lib.win32.mak" tofile="${gs2build.home}/lib/win32.mak"/>
     1001   <copy file="${gs2build-extra.home}/win32.mak" tofile="${gs2build.home}/win32.mak"/>
     1002   <copy file="${gs2build-extra.home}/setup.bat" tofile="${gs2build.home}/setup.bat">
     1003     <filterset>
     1004       <filter token="gsdlhome" value="${gs2build.home}"/>
     1005     </filterset>
     1006    </copy> 
     1007  </target>
     1008  <target name="rename-gs2build-files-linux" if="current.os.islinux">
     1009    <property name="gs2build-extra.home" value="${gs2build.home}/gs2build-extra"/>
     1010    <copy file="${gs2build-extra.home}/configure" tofile="${gs2build.home}/configure"/>   
     1011    <chmod file="${gs2build.home}/configure" perm="a+x"/>
     1012    <copy file="${gs2build-extra.home}/configure.in" tofile="${gs2build.home}/configure.in"/>
     1013    <copy file="${gs2build-extra.home}/Makefile.in" tofile="${gs2build.home}/Makefile.in"/> 
     1014    <copy file="${gs2build-extra.home}/packages.configure" tofile="${gs2build.home}/packages/configure"/>
     1015    <chmod file="${gs2build.home}/packages/configure" perm="a+x"/>
     1016    <copy file="${gs2build-extra.home}/packages.Makefile" tofile="${gs2build.home}/packages/Makefile"/>
     1017    <copy file="${gs2build-extra.home}/lib.Makefile.in" tofile="${gs2build.home}/lib/Makefile.in"/> 
     1018   
     1019  </target>
     1020  <target name="prepare-gli" depends="check-cvsroot,init" if="gsdl2.islocal" unless="gli.present">
     1021    <echo>checking out gli</echo>
     1022    <cvs command="checkout -P" package="gli"/>
     1023  </target>
     1024   
     1025  <target name="configure-gs2building" depends="init" if="gsdl2.islocal"
     1026    description="Configure only the Greenstone 2 building components">
     1027    <exec executable="${gs2build.home}/configure" os="${os.linux}"
     1028      dir="${gs2build.home}">
     1029      <arg value="--prefix=${gs2build.home}"/>
     1030    </exec>
     1031  </target>
     1032
     1033  <target name="clean-gs2building" depends="init" if="gsdl2.islocal"
     1034    description="Clean only the Greenstone 2 building components">
     1035    <!-- gli -->
     1036    <property name="gli.home" value="${basedir}/gli"/>
     1037    <!-- linux -->
     1038    <exec executable="clean.sh" os="${os.linux}" dir="${gli.home}"
     1039      resolveExecutable="true"/>
     1040    <!-- windows -->
     1041    <exec executable="clean.bat" os="${os.windows}" dir="${gli.home}"
     1042      resolveExecutable="true"/>
     1043    <!-- gs2build -->
     1044    <!--linux:  -->
     1045    <exec executable="make" os="${os.linux}" dir="${gs2build.home}">
     1046      <arg value="clean"/>
     1047    </exec>
     1048    <!-- windows: -->   
     1049  </target>
     1050   
     1051  <target name="clean-windows-c++-gs2building" depends="init" if="current.os.iswindows"
     1052    description="remove all object files and executables">
     1053    <!-- run the setup script -->
     1054    <exec executable="${compile.windows.c++.setup}"/>
     1055    <exec executable="nmake" dir="${gs2build.home}">
     1056     <arg value="/f"/>
     1057     <arg value="win32.mak"/>
     1058     <arg value="clean"/>
     1059    </exec>
     1060  </target> 
     1061
     1062  <target name="compile-gs2building" depends="init" if="gsdl2.islocal"
     1063    description="Compile only the Greenstone 2 building components">
     1064    <!-- gli -->
     1065    <property name="gli.home" value="${basedir}/gli"/>
     1066    <!-- linux -->
     1067    <exec executable="makegli.sh" os="${os.linux}" dir="${gli.home}"
     1068      resolveExecutable="true"/>
     1069    <!-- windows -->
     1070    <exec executable="makegli.bat" os="${os.windows}" dir="${gli.home}"
     1071      resolveExecutable="true"/>
     1072    <!-- gs2build -->
     1073    <!--linux: make, make install -->
     1074    <exec executable="make" os="${os.linux}" dir="${gs2build.home}">
     1075    </exec>
     1076    <exec executable="make" os="${os.linux}" dir="${gs2build.home}">
     1077      <arg value="install"/>
     1078    </exec>
     1079  </target>
     1080    <!-- windows: -->
     1081   <target name="compile-windows-c++-gs2building" depends="init" if="current.os.iswindows"
     1082    description="Use this if you want to compile the C++ code for the gs2build package">
     1083    <!-- run the setup script -->
     1084    <exec executable="${compile.windows.c++.setup}"/>
     1085    <exec executable="nmake" dir="${gs2build.home}">
     1086     <arg value="/f"/>
     1087     <arg value="win32.mak"/>
     1088    </exec>
     1089  </target>
     1090  <target name="gli" description="Run the Greenstone Librarian Interface" depends="gli-local,gli-external">
     1091    <echo>Running GLI from Ant means that you don't get to see any of the terminal output. If you have problems with GLI and want to see the output, please run the script gli4gs3.sh/bat from the gsdl3/gli directory.
     1092    </echo>
     1093  </target>
     1094
     1095  <target name="gli-local" depends="init" if="gsdl2.islocal">
     1096    <exec executable="${basedir}/gli/gli4gs3.sh" os="${os.linux}" dir="${basedir}/gli" spawn="true">
     1097      <env key="GSDLHOME" path="${basedir}/gs2build"/>
     1098      <env key="GSDL3HOME" value="${basedir}"/>
     1099    </exec>
     1100    <exec executable="${basedir}/gli/gli4gs3.bat" os="${os.windows}" dir="${basedir}/gli" spawn="true">
     1101      <env key="GSDLHOME" value="${basedir}/gs2build"/>
     1102      <env key="GSDL3HOME" value="${basedir}"/>
     1103    </exec>
     1104  </target>
     1105 
     1106  <target name="gli-external" depends="init" unless="gsdl2.islocal">
     1107    <exec executable="${gsdl2.installed.path}/gli/gli4gs3.sh" os="${os.linux}" dir="${gsdl2.installed.path}/gli"/>
     1108    <exec executable="${gsdl2.installed.path}/gli/gli4gs3.bat" os="${os.windows}" dir="${gsdl2.installed.path}/gli"/>
     1109  </target>
     1110
     1111
     1112<!-- ======================== TESTING Targets ========================= -->
     1113 
     1114  <target name="test" description="Run the (incomplete) JUnit test suite "
     1115    depends="init">
     1116    <mkdir dir="${basedir}/test"/>
     1117    <junit printsummary="withOutAndErr"
     1118      errorproperty="test.failed"
     1119      failureproperty="test.failed"
     1120      fork="${junit.fork}">
     1121      <formatter type="plain"/>
     1122      <classpath>
     1123    <pathelement location="${build.home}/gsdl3test.jar"/>
     1124    <path refid="compile.classpath"/>
     1125      </classpath>
     1126      <test name="${testcase}" if="testcase"/>
     1127      <batchtest todir="${basedir}/test" unless="testcase">
     1128    <fileset dir="${build.home}"
     1129      includes="**/*Test.class"
     1130      />
     1131      </batchtest>
     1132    </junit>
     1133    <echo>
     1134      *********************************************
     1135       Test output can be found in directory 'test'
     1136      *********************************************
     1137    </echo>
     1138  </target>
     1139
     1140
     1141  <target name="reconfigure-server-settings" depends="init,configure-tomcat,configure-files-server"
     1142    description="If you have changed any of the Tomcat properties in the build.properties file, run this target to update the Tomcat configuration, and any Greenstone configuration files that specify the server address">
     1143  </target>
     1144
    491145
    501146</project>
    511147
     1148
  • trunk/gsdl3/comms/jakarta/server.xml.in

    r7971 r9874  
    1 <!-- Alternate Example-less Configuration File -->
     1<!-- Example Server Configuration File -->
    22<!-- Note that component elements are nested corresponding to their
    33     parent-child relationships with each other -->
     
    1111 -->
    1212
    13 <Server port="8005" shutdown="SHUTDOWN" debug="0">
    14 
    15 
    16   <!-- Uncomment this entry to enable JMX MBeans support -->
    17 <!--
    18   <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
    19                 debug="0" port="-1" login="admin" password="admin"/>
    20 -->
    21 
     13<Server port="8005" shutdown="SHUTDOWN">
     14
     15  <!-- Comment these entries out to disable JMX MBeans support used for the
     16       administration web application -->
     17  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
     18  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
     19  <Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
     20
     21  <!-- Global JNDI resources -->
     22  <GlobalNamingResources>
     23
     24    <!-- Test entry for demonstration purposes -->
     25    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
     26
     27    <!-- Editable user database that can also be used by
     28         UserDatabaseRealm to authenticate users -->
     29    <Resource name="UserDatabase" auth="Container"
     30              type="org.apache.catalina.UserDatabase"
     31       description="User database that can be updated and saved"
     32           factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
     33          pathname="conf/tomcat-users.xml" />
     34
     35  </GlobalNamingResources>
    2236
    2337  <!-- A "Service" is a collection of one or more "Connectors" that share
     
    3145
    3246  <!-- Define the Tomcat Stand-Alone Service -->
    33   <Service name="Tomcat-Standalone">
     47  <Service name="Catalina">
    3448
    3549    <!-- A "Connector" represents an endpoint by which requests are received
     
    4155         following the instructions below and uncommenting the second Connector
    4256         entry.  SSL support requires the following steps (see the SSL Config
    43          HOWTO in the Tomcat 4.0 documentation bundle for more detailed
     57         HOWTO in the Tomcat 5 documentation bundle for more detailed
    4458         instructions):
    45          * Download and install JSSE 1.0.2 or later, and put the JAR files
    46            into "$JAVA_HOME/jre/lib/ext".
     59         * If your JDK version 1.3 or prior, download and install JSSE 1.0.2 or
     60           later, and put the JAR files into "$JAVA_HOME/jre/lib/ext".
    4761         * Execute:
    4862             %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA (Windows)
     
    6074
    6175    <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
    62     <Connector className="org.apache.catalina.connector.http.HttpConnector"
    63                port="8080" minProcessors="5" maxProcessors="75"
    64                enableLookups="true" redirectPort="8443"
    65                acceptCount="10" debug="0" connectionTimeout="60000"/>
    66     <!-- Note : To disable connection timeouts, set connectionTimeout value
    67      to -1 -->
    68 
    69     <!-- Define an SSL HTTP/1.1 Connector on port 8443 -->
     76    <Connector port="@port@"
     77               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
     78               enableLookups="false" redirectPort="8443" acceptCount="100"
     79               connectionTimeout="20000" disableUploadTimeout="true" />
     80    <!-- Note : To disable connection timeouts, set connectionTimeout value
     81     to 0 -->
     82   
     83    <!-- Note : To use gzip compression you could set the following properties :
     84   
     85               compression="on"
     86               compressionMinSize="2048"
     87               noCompressionUserAgents="gozilla, traviata"
     88               compressableMimeType="text/html,text/xml"
     89    -->
     90
     91    <!-- Define a SSL HTTP/1.1 Connector on port 8443 -->
    7092    <!--
    71     <Connector className="org.apache.catalina.connector.http.HttpConnector"
    72                port="8443" minProcessors="5" maxProcessors="75"
    73                enableLookups="true"
    74            acceptCount="10" debug="0" scheme="https" secure="true">
    75       <Factory className="org.apache.catalina.net.SSLServerSocketFactory"
    76                clientAuth="false" protocol="TLS"/>
    77     </Connector>
     93    <Connector port="8443"
     94               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
     95               enableLookups="false" disableUploadTimeout="true"
     96               acceptCount="100" scheme="https" secure="true"
     97               clientAuth="false" sslProtocol="TLS" />
    7898    -->
    7999
    80100    <!-- Define an AJP 1.3 Connector on port 8009 -->
    81     <!--
    82     <Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
    83                port="8009" minProcessors="5" maxProcessors="75"
    84                acceptCount="10" debug="0"/>
    85     -->
    86 
    87     <!-- Define a Proxied HTTP/1.1 Connector on port 8081 -->
     101    <Connector port="8009"
     102               enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
     103
     104    <!-- Define a Proxied HTTP/1.1 Connector on port 8082 -->
    88105    <!-- See proxy documentation for more information about using this. -->
    89106    <!--
    90     <Connector className="org.apache.catalina.connector.http.HttpConnector"
    91                port="8081" minProcessors="5" maxProcessors="75"
    92                enableLookups="true"
    93                acceptCount="10" debug="0" connectionTimeout="60000"
    94                proxyPort="80"/>
    95     -->
    96 
    97     <!-- Define a non-SSL HTTP/1.0 Test Connector on port 8082 -->
    98     <!--
    99     <Connector className="org.apache.catalina.connector.http10.HttpConnector"
    100                port="8082" minProcessors="5" maxProcessors="75"
    101                enableLookups="true" redirectPort="8443"
    102                acceptCount="10" debug="0"/>
     107    <Connector port="8082"
     108               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
     109               enableLookups="false" acceptCount="100" connectionTimeout="20000"
     110               proxyPort="80" disableUploadTimeout="true" />
    103111    -->
    104112
     
    108116         on to the appropriate Host (virtual host). -->
    109117
     118    <!-- You should set jvmRoute to support load-balancing via AJP ie :
     119    <Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm1">         
     120    -->
     121         
    110122    <!-- Define the top level container in our container hierarchy -->
    111     <Engine name="Standalone" defaultHost="localhost" debug="0">
     123    <Engine name="Catalina" defaultHost="localhost">
    112124
    113125      <!-- The request dumper valve dumps useful debugging information about
     
    118130           element inside the corresponding <Host> or <Context> entry instead.
    119131
    120            For a similar mechanism that is portable to all Servlet 2.3
     132           For a similar mechanism that is portable to all Servlet 2.4
    121133           containers, check out the "RequestDumperFilter" Filter in the
    122134           example application (the source for this filter may be found in
     
    129141      -->
    130142
    131       <!-- Global logger unless overridden at lower levels -->
    132       <Logger className="org.apache.catalina.logger.FileLogger"
    133               prefix="catalina_log." suffix=".txt"
    134               timestamp="true"/>
    135 
    136143      <!-- Because this Realm is here, an instance will be shared globally -->
    137144
     145      <!-- This Realm uses the UserDatabase configured in the global JNDI
     146           resources under the key "UserDatabase".  Any edits
     147           that are performed against this UserDatabase are immediately
     148           available for use by the Realm.  -->
     149      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
     150             resourceName="UserDatabase"/>
     151
     152      <!-- Comment out the old realm but leave here for now in case we
     153           need to go back quickly -->
     154      <!--
    138155      <Realm className="org.apache.catalina.realm.MemoryRealm" />
     156      -->
    139157
    140158      <!-- Replace the above Realm with one of the following to get a Realm
     
    142160
    143161      <!--
    144       <Realm  className="org.apache.catalina.realm.JDBCRealm" debug="99"
     162      <Realm  className="org.apache.catalina.realm.JDBCRealm"
    145163             driverName="org.gjt.mm.mysql.Driver"
    146164          connectionURL="jdbc:mysql://localhost/authority"
     
    151169
    152170      <!--
    153       <Realm  className="org.apache.catalina.realm.JDBCRealm" debug="99"
     171      <Realm  className="org.apache.catalina.realm.JDBCRealm"
    154172             driverName="oracle.jdbc.driver.OracleDriver"
    155173          connectionURL="jdbc:oracle:thin:@ntserver:1521:ORCL"
     
    160178
    161179      <!--
    162       <Realm  className="org.apache.catalina.realm.JDBCRealm" debug="99"
     180      <Realm  className="org.apache.catalina.realm.JDBCRealm"
    163181             driverName="sun.jdbc.odbc.JdbcOdbcDriver"
    164182          connectionURL="jdbc:odbc:CATALINA"
     
    167185      -->
    168186
    169       <!-- Define the default virtual host -->
    170       <Host name="localhost" debug="0" appBase="webapps"
    171        unpackWARs="true" autoDeploy="true">
     187      <!-- Define the default virtual host
     188           Note: XML Schema validation will not work with Xerces 2.2.
     189       -->
     190      <Host name="localhost" appBase="webapps"
     191       unpackWARs="true" autoDeploy="true"
     192       xmlValidation="false" xmlNamespaceAware="false">
     193
     194    <!-- GSDL3 Service -->
     195    <Context path="/gsdl3" docBase="@gsdl3home@/web" debug="1" reloadable="true"><Resources allowLinking='true'/></Context>
     196   
     197        <!-- Defines a cluster for this node,
     198             By defining this element, means that every manager will be changed.
     199             So when running a cluster, only make sure that you have webapps in there
     200             that need to be clustered and remove the other ones.
     201             A cluster has the following parameters:
     202
     203             className = the fully qualified name of the cluster class
     204
     205             name = a descriptive name for your cluster, can be anything
     206
     207             mcastAddr = the multicast address, has to be the same for all the nodes
     208
     209             mcastPort = the multicast port, has to be the same for all the nodes
     210             
     211             mcastBindAddr = bind the multicast socket to a specific address
     212             
     213             mcastTTL = the multicast TTL if you want to limit your broadcast
     214             
     215             mcastSoTimeout = the multicast readtimeout
     216
     217             mcastFrequency = the number of milliseconds in between sending a "I'm alive" heartbeat
     218
     219             mcastDropTime = the number a milliseconds before a node is considered "dead" if no heartbeat is received
     220
     221             tcpThreadCount = the number of threads to handle incoming replication requests, optimal would be the same amount of threads as nodes
     222
     223             tcpListenAddress = the listen address (bind address) for TCP cluster request on this host,
     224                                in case of multiple ethernet cards.
     225                                auto means that address becomes
     226                                InetAddress.getLocalHost().getHostAddress()
     227
     228             tcpListenPort = the tcp listen port
     229
     230             tcpSelectorTimeout = the timeout (ms) for the Selector.select() method in case the OS
     231                                  has a wakup bug in java.nio. Set to 0 for no timeout
     232
     233             printToScreen = true means that managers will also print to std.out
     234
     235             expireSessionsOnShutdown = true means that
     236
     237             useDirtyFlag = true means that we only replicate a session after setAttribute,removeAttribute has been called.
     238                            false means to replicate the session after each request.
     239                            false means that replication would work for the following piece of code: (only for SimpleTcpReplicationManager)
     240                            <%
     241                            HashMap map = (HashMap)session.getAttribute("map");
     242                            map.put("key","value");
     243                            %>
     244             replicationMode = can be either 'pooled', 'synchronous' or 'asynchronous'.
     245                               * Pooled means that the replication happens using several sockets in a synchronous way. Ie, the data gets replicated, then the request return. This is the same as the 'synchronous' setting except it uses a pool of sockets, hence it is multithreaded. This is the fastest and safest configuration. To use this, also increase the nr of tcp threads that you have dealing with replication.
     246                               * Synchronous means that the thread that executes the request, is also the
     247                               thread the replicates the data to the other nodes, and will not return until all
     248                               nodes have received the information.
     249                               * Asynchronous means that there is a specific 'sender' thread for each cluster node,
     250                               so the request thread will queue the replication request into a "smart" queue,
     251                               and then return to the client.
     252                               The "smart" queue is a queue where when a session is added to the queue, and the same session
     253                               already exists in the queue from a previous request, that session will be replaced
     254                               in the queue instead of replicating two requests. This almost never happens, unless there is a
     255                               large network delay.
     256        -->             
     257        <!--
     258            When configuring for clustering, you also add in a valve to catch all the requests
     259            coming in, at the end of the request, the session may or may not be replicated.
     260            A session is replicated if and only if all the conditions are met:
     261            1. useDirtyFlag is true or setAttribute or removeAttribute has been called AND
     262            2. a session exists (has been created)
     263            3. the request is not trapped by the "filter" attribute
     264
     265            The filter attribute is to filter out requests that could not modify the session,
     266            hence we don't replicate the session after the end of this request.
     267            The filter is negative, ie, anything you put in the filter, you mean to filter out,
     268            ie, no replication will be done on requests that match one of the filters.
     269            The filter attribute is delimited by ;, so you can't escape out ; even if you wanted to.
     270
     271            filter=".*\.gif;.*\.js;" means that we will not replicate the session after requests with the URI
     272            ending with .gif and .js are intercepted.
     273           
     274            The deployer element can be used to deploy apps cluster wide.
     275            Currently the deployment only deploys/undeploys to working members in the cluster
     276            so no WARs are copied upons startup of a broken node.
     277            The deployer watches a directory (watchDir) for WAR files when watchEnabled="true"
     278            When a new war file is added the war gets deployed to the local instance,
     279            and then deployed to the other instances in the cluster.
     280            When a war file is deleted from the watchDir the war is undeployed locally
     281            and cluster wide
     282        -->
     283       
     284        <!--
     285        <Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
     286                 managerClassName="org.apache.catalina.cluster.session.DeltaManager"
     287                 expireSessionsOnShutdown="false"
     288                 useDirtyFlag="true"
     289                 notifyListenersOnReplication="true">
     290
     291            <Membership
     292                className="org.apache.catalina.cluster.mcast.McastService"
     293                mcastAddr="228.0.0.4"
     294                mcastPort="45564"
     295                mcastFrequency="500"
     296                mcastDropTime="3000"/>
     297
     298            <Receiver
     299                className="org.apache.catalina.cluster.tcp.ReplicationListener"
     300                tcpListenAddress="auto"
     301                tcpListenPort="4001"
     302                tcpSelectorTimeout="100"
     303                tcpThreadCount="6"/>
     304
     305            <Sender
     306                className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
     307                replicationMode="pooled"
     308                ackTimeout="15000"/>
     309
     310            <Valve className="org.apache.catalina.cluster.tcp.ReplicationValve"
     311                   filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/>
     312                   
     313            <Deployer className="org.apache.catalina.cluster.deploy.FarmWarDeployer"
     314                      tempDir="/tmp/war-temp/"
     315                      deployDir="/tmp/war-deploy/"
     316                      watchDir="/tmp/war-listen/"
     317                      watchEnabled="false"/>
     318        </Cluster>
     319        -->       
     320
     321
    172322
    173323        <!-- Normally, users must authenticate themselves to each web app
     
    178328             in this virtual host. -->
    179329        <!--
    180         <Valve className="org.apache.catalina.authenticator.SingleSignOn"
    181                    debug="0"/>
     330        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
    182331        -->
    183332
     
    188337             (to $CATALINA_HOME) or absolute path to the desired directory.
    189338        -->
     339        <!--
    190340        <Valve className="org.apache.catalina.valves.AccessLogValve"
    191341                 directory="logs"  prefix="localhost_access_log." suffix=".txt"
    192                  pattern="common"/>
    193 
    194         <!-- Logger shared by all Contexts related to this virtual host.  By
    195              default (when using FileLogger), log files are created in the "logs"
    196              directory relative to $CATALINA_HOME.  If you wish, you can specify
    197              a different directory with the "directory" attribute.  Specify either a
    198              relative (to $CATALINA_HOME) or absolute path to the desired
    199              directory.-->
    200         <Logger className="org.apache.catalina.logger.FileLogger"
    201                  directory="logs"  prefix="localhost_log." suffix=".txt"
    202             timestamp="true"/>
    203 
    204         <!-- Define properties for each web application.  This is only needed
    205              if you want to set non-default properties, or have web application
    206              document roots in places other than the virtual host's appBase
    207              directory.  -->
    208 
    209         <!-- Tomcat Root Context -->
    210         <!--
    211           <Context path="" docBase="ROOT" debug="0"/>
    212         -->
    213 
    214     <!-- GSDL3 Service -->
    215         <Context path="/gsdl3" docBase="@gsdl3home@/web" debug="1" reloadable="true">
    216       <Resources allowLinking='true'/>
    217         </Context>
    218 
    219     <!-- SOAP Service -->
    220     <Context path="/soap" docBase="@gsdl3home@/comms/soap/soap/webapps/soap" debug="1" reloadable="true"/>
     342                 pattern="common" resolveHosts="false"/>
     343        -->
     344
     345        <!-- Access log processes all requests for this virtual host.  By
     346             default, log files are created in the "logs" directory relative to
     347             $CATALINA_HOME.  If you wish, you can specify a different
     348             directory with the "directory" attribute.  Specify either a relative
     349             (to $CATALINA_HOME) or absolute path to the desired directory.
     350             This access log implementation is optimized for maximum performance,
     351             but is hardcoded to support only the "common" and "combined" patterns.
     352        -->
     353        <!--
     354        <Valve className="org.apache.catalina.valves.FastCommonAccessLogValve"
     355                 directory="logs"  prefix="localhost_access_log." suffix=".txt"
     356                 pattern="common" resolveHosts="false"/>
     357        -->
     358        <!-- Access log processes all requests for this virtual host.  By
     359             default, log files are created in the "logs" directory relative to
     360             $CATALINA_HOME.  If you wish, you can specify a different
     361             directory with the "directory" attribute.  Specify either a relative
     362             (to $CATALINA_HOME) or absolute path to the desired directory.
     363             This access log implementation is optimized for maximum performance,
     364             but is hardcoded to support only the "common" and "combined" patterns.
     365
     366             This valve use NIO direct Byte Buffer to asynchornously store the
     367             log.
     368        -->
     369        <!--
     370        <Valve className="org.apache.catalina.valves.ByteBufferAccessLogValve"
     371                 directory="logs"  prefix="localhost_access_log." suffix=".txt"
     372                 pattern="common" resolveHosts="false"/>
     373        -->
    221374
    222375      </Host>
     
    226379  </Service>
    227380
    228   <!-- The MOD_WEBAPP connector is used to connect Apache 1.3 with Tomcat 4.0
    229        as its servlet container. Please read the README.txt file coming with
    230        the WebApp Module distribution on how to build it.
    231        (Or check out the "jakarta-tomcat-connectors/webapp" CVS repository)
    232 
    233        To configure the Apache side, you must ensure that you have the
    234        "ServerName" and "Port" directives defined in "httpd.conf".  Then,
    235        lines like these to the bottom of your "httpd.conf" file:
    236 
    237          LoadModule webapp_module libexec/mod_webapp.so
    238          WebAppConnection warpConnection warp localhost:8008
    239          WebAppDeploy examples warpConnection /examples/
    240 
    241        The next time you restart Apache (after restarting Tomcat, if needed)
    242        the connection will be established, and all applications you make
    243        visible via "WebAppDeploy" directives can be accessed through Apache.
    244   -->
    245 
    246   <!-- Define an Apache-Connector Service -->
    247   <Service name="Tomcat-Apache">
    248 
    249     <Connector className="org.apache.catalina.connector.warp.WarpConnector"
    250      port="8008" minProcessors="5" maxProcessors="75"
    251      enableLookups="true"
    252      acceptCount="10" debug="0"/>
    253 
    254     <!-- Replace "localhost" with what your Apache "ServerName" is set to -->
    255     <Engine className="org.apache.catalina.connector.warp.WarpEngine"
    256      name="Apache" debug="0" appBase="webapps">
    257 
    258       <!-- Global logger unless overridden at lower levels -->
    259       <Logger className="org.apache.catalina.logger.FileLogger"
    260               prefix="apache_log." suffix=".txt"
    261               timestamp="true"/>
    262 
    263       <!-- Because this Realm is here, an instance will be shared globally -->
    264       <Realm className="org.apache.catalina.realm.MemoryRealm" />
    265 
    266     </Engine>
    267 
    268   </Service>
    269 
    270381</Server>
    271 
  • trunk/gsdl3/docs/manual/manual.tex

    r9445 r9874  
    6666This section covers where to get \gsiii\  from, how to install it and how to run it. The standard method of running \gsiii\  is as a Java servlet. We provide the Tomcat servlet container to run the servlet. Standard web servers may  be able to be configured to provide servlet support, and thereby remove the need to use Tomcat. Please see your web server documentation for this. This documentation assumes that you are using Tomcat. To access \gsiii, Tomcat must be started up, and then it can be accessed via a web browser.
    6767
     68Ant (Java's XML based build tool) is used for compilation, installation and running Greenstone. The build.xml file is the configuration file for the Greenstone project, and build.properties contains parameters that can be altered by the user.
    6869
    6970\subsection{Get and install \gs\ }
     
    7576\subsubsection{Linux}
    7677
    77 Download the latest version of the installer, \gst{gsdl3-x.xx-linux}, and run it in a shell (\gst{./gsdl3-x.xx-linux}). The installation process will prompt you for the installation directory, the name of your computer and what port to run Tomcat on (the defaults being \gst{localhost} and \gst{8080}).  Once \gsiii\  has been installed, you can start the library  by running \gst{.gs3-launch.sh} from the gsdl3 directory, and opening up a browser pointing to \gst{http://localhost:8080/gsdl3} (substituting your chosen name and port if necessary).
     78Download the latest version of the installer, \gst{gsdl3-x.xx-linux}, and run it in a shell (\gst{./gsdl3-x.xx-linux}). The installation process will prompt you for the installation directory, the name of your computer and what port to run Tomcat on (defaults are \gst{localhost} and \gst{8080}). Once \gsiii\  has been installed, you can start the library by running \gst{ant start} from the gsdl3 directory, and opening up a browser pointing to \gst{http://localhost:8080/gsdl3} (substituting your chosen name and port if necessary).
    7879
    7980\subsubsection{Windows}
    8081
    81 Download the latest Windows installer, \gst{gsdl3-x.xx-win32.exe}, and double click it to start the installation. You will be prompted for the installation directory, installation type, your computer name and the port number to run Tomcat on (defaults are \gst{localhost} and \gst{8080}). Once \gsiii\  is installed, you can access the library by selecting \gst{Greenstone Digital Library 3} in the Start menu.
     82Download the latest Windows installer, \gst{gsdl3-x.xx-win32.exe}, and double click it to start the installation. You will be prompted for the installation directory, installation type, your computer name and the port number to run Tomcat on (defaults are \gst{localhost} and \gst{8080}). Once \gsiii\  is installed, you can access the library by selecting \gst{Greenstone Digital Library 3} in the Start menu (or by running \gst{ant start} in the gsdl3 directory).
    8283
    8384\subsubsection{Accessing the library in a browser}\label{sec:browser-access}
     
    9394\subsubsection{Restarting the library}
    9495
    95 The library program (actually Tomcat) can be restarted in Windows by closing the window, and restarting it from the Start menu. In Linux, you need to go to the gsdl3 directory, and run \gst{./gs3-launch.sh -shutdown}, then \gst{./gs3-launch.sh}.
     96The library program (actually Tomcat) can be restarted in Windows by closing the window, and restarting it from the Start menu. In Linux, you need to go to the gsdl3 directory, and run \gst{ant restart}.
    9697
    9798
     
    366367\begin{figure}[h]
    367368  \centering
    368   \includegraphics[width=4in]{pagebanner} %5.8
     369  \includegraphics[width=4in]{pagebanner.ps} %5.8
    369370  \caption{A sample collection page banner}
    370371  \label{fig:page-banner}
     
    389390
    390391To create the director
    391 Building native \gsiii\  collections is done using the \gst{gs3-build.sh} script, with the \gst{collectionConfig.xml} file controlling how the building is done.  There are a number of considerations in building a collection:  what documents appear in the collection, how they are indexed for searching, which classifications are used for browsing, etc.
     392Building native \gsiii\  collections is done using the \gst{gs3-build.sh/bat} script, with the \gst{collectionConfig.xml} file controlling how the building is done.  There are a number of considerations in building a collection:  what documents appear in the collection, how they are indexed for searching, which classifications are used for browsing, etc.
    392393
    393394Firstly, the documents that comprise the collection should be placed in the import subdirectory.  At present, only documents in this directory will appear in the collection. Documents can be organised into sub folders inside the import directory.
     
    453454The collectionConfig.xml file controls the all of these options for collection building, and the format is described in Section~\ref{sec:collconfig}.
    454455
    455 To build a collection, place the source documents and optional metadata.xml file(s) in the import directory, place the \gst{collectionConfig.xml} file in the etc directory, and execute \gst{gs3build.sh/bat sitename collectionname}.  The process will run, placing the new indexes in the \gst{building} subdirectory of the collection's directory. You must have mysql running before you start building---running \gst{gs3-launch.sh/bat} will start up the MySQL server as well as tomcat.
     456To build a collection, place the source documents and optional metadata.xml file(s) in the import directory, place the \gst{collectionConfig.xml} file in the etc directory, and execute \gst{gs3build.sh/bat sitename collectionname}.  The process will run, placing the new indexes in the \gst{building} subdirectory of the collection's directory. You must have mysql running before you start building---running \gst{ant start} will start up the MySQL server as well as tomcat.
    456457
    457458Once the build process is complete, the building directory should be renamed to index (after deleting or renaming the existing index directory, if any), and Tomcat prompted to reload the collection---either by restarting the server, or by sending an activate collection command to the library servlet.
     
    10311032\begin{figure}[t]
    10321033  \centering
    1033   \includegraphics[width=4in]{newlocal} %5.8
     1034  \includegraphics[width=4in]{local} %5.8
    10341035  \caption{A simple stand-alone site.}
    10351036  \label{fig:local}
     
    21762177\end{figure}
    21772178
    2178 We have used Apache SOAP for Java. This is run as a servlet in Tomcat. Tomcat in Greenstone comes set up to use SOAP, but it is not enabled. To enable it, run \gst{gs3-enable-soap.sh/bat}. For more details about SOAP in Greenstone, see Appendix~\ref{app:soap}. Debugging soap is described in Appendix~\ref{app:soap-debug}.
     2179We have used Apache Axis SOAP implementation. This is run as a servlet in Tomcat. Axis is setup during installation of Greenstone. For more details about SOAP in Greenstone, see Appendix~\ref{app:soap}. Debugging soap is described in Appendix~\ref{app:soap-debug}.
    21792180
    21802181\subsection{Serving a site using soap}
    21812182
    2182 A script has been created to setup a SOAP server for a site. On Linux, from the gsdl3 directory, run
    2183 \gst{./gs3-soap-deploy-site.sh <sitename> <siteuri>}
    2184 
    2185 Sitename is the name of the site's directory, e.g. localsite. The siteuri is the identifier that will be used for the SOAP resource, e.g. org.greenstone.localsite. It should be a unique name amongst all the SOAP services that you want to connect to.
    2186 
    2187 The script  deploys the service for the site specified. A resource file (\gst{sitename.xml}) is created which is used to specify the service. It can be found in \gst{gsdl3/resources/soap}, and is generated from \gst{site.xml.in}.
     2183A webs service for localsite comes predeployed, but if you want to setup a service for another site, run \gst{ant soap-deploy-site}. This will prompt you for the sitename (its directory name), and a siteuri - a unique identifier for the web service.
     2184
     2185The ant target deploys the service for the site specified. A resource file (\gst{<sitename>.wsdd}) is created which is used to specify the service. It can be found in \gst{gsdl3/resources/soap}, and is generated from \gst{site.wsdd.template}.
    21882186
    21892187To get siteA to talk to siteB, you need to deploy a SOAP server on siteB, then add a \gst{<site>} element to the \gst{<siteList>} of siteA's \gst{siteConfig.xml} file (in \gst{gsdl3/web/sites/siteA/siteConfig.xml}).
     
    21932191\begin{gsc}\begin{verbatim}
    21942192<site name="siteAuri"
    2195   address="http://localhost:8080/soap/servlet/rpcrouter"
     2193  address="http://localhost:8080/axis/services/siteAuri"
    21962194  type="soap"/>
    21972195\end{verbatim}\end{gsc}
     
    22082206\gsiii\  is also available via CVS. You can download the latest version of the code. This is not guaranteed to be stable, in fact it is likely to be unstable. The advantage of using CVS is that you can update the code and get the latest fixes.
    22092207
    2210 Note that you will need the Java 2 SDK, version 1.4.0 or higher.
     2208Note that you will need the Java 2 SDK, version 1.4.0 or higher, and Ant (Apache's Java based build tool, http://ant.apache.org) installed.
    22112209
    22122210To check out the \gs\  code, use:
     
    22192217If you need it, the password for anonymous CVS access is \gst{anonymous}. Note that some older versions of CVS have trouble accessing this repository due to the port number being present. We are using version 1.11.1p1.
    22202218
    2221 The software needs to be compiled and installed. The installation procedure uses a shell script or batch file. The most up to date instructions may be found in the README.txt file in the top level gsdl3 directory.
    2222 
    2223 To install Greenstone once you have checked it out of CVS, do the following (alternatives for Linux or Windows):
     2219Greenstone is built and installed using Ant (Apache's Java based build tool,
     2220http://ant.apache.org). You will need a Java Development
     2221Environment (1.4 or higher), and Ant installed to use Greenstone. You can download Ant from http://ant.apache.org/bindownload.cgi.
     2222
     2223In the gsdl3 directory, you can run 'ant' which will give you a help message.
     2224Running 'ant -projecthelp' gives a list of the targets that you can run - these
     2225do various things like compile the source code, startup the server etc.
     2226
     2227For a first time install, run 'ant install'.
     2228
     2229The file build.properties contains various parameters that can be set by the user. Please check these settings before running 'ant install'. The install process will ask you if you accept the properties before starting.
     2230For a  non-interactive version of the install, run
     2231ant -Dproperties.accepted=yes install
     2232
     2233To log the output in build.log, run
     2234ant -Dproperties.accepted=yes -logfile build.log install
     2235
     2236Under Linux, Java and C/C++ compilation is carried out. For windows, since Visual Studio is not a standard component, only Java compilation is carried out. Pre-compiled binaries are provided for the C/C++ components (packages and Greenstone 2 style building). If you have Visual Studio installed (version 6), you can run the compile-windows-c++ targets to compile the code locally. (Don't forget to setup the Visual Studio environment first, by running, e.g. C:/Program Files/Microsoft Visual Studio/VC98/Bin/VCVARS32.BAT or equivalent.)
     2237
     2238
     2239Note: \gst{gs3-setup} sets the environment variables \gst{CLASSPATH, PATH, JAVA\_HOME} and needs to be done in a shell before doing collection building etc.
     2240
     2241To startup or shutdown the library (includes the Tomcat server and MYSQL server), the commands are (run from the gsdl3 directory):
    22242242
    22252243\begin{quote}\begin{gsc}
    2226 cd gsdl3\\
    2227 ./gs3-install.sh or gs3-install\\
    2228 source gs3-setup.sh or gs3-setup
     2244ant start \\
     2245ant stop
    22292246\end{gsc}\end{quote}
    22302247
    2231 To recompile the code at any stage, you can use
    2232 \begin{quote}\begin{gsc}
    2233 source gs3-setup.sh or gs3-setup\\
    2234 make\\
    2235 make install\\
    2236 \end{gsc}\end{quote}
    2237 
    2238 Note: \gst{gs3-setup} sets the environment variables \gst{CLASSPATH, PATH, JAVA\_HOME} and needs to be done in a shell before doing collection building etc.
    2239 
    2240 To startup or shutdown the library (includes the Tomcat server and MYSQL server), the commands are (run from the gsdl3 directory):
    2241 \begin{quote}\begin{gsc}
    2242 ./gs3-launch.sh or gs3-launch \\
    2243 ./gs3-launch.sh -shutdown or close the window
    2244 \end{gsc}\end{quote}
    2245 
     2248If you want to restart only Tomcat, run \gst{ant restart-tomcat}.
    22462249
    22472250\newpage
    22482251\section{Tomcat}\label{app:tomcat}
    22492252
    2250 Tomcat is a servlet container. It is used to serve a \gs\  site using a servlet.
     2253Tomcat is a servlet container, and Greenstone 3 runs as a servlet inside it.
    22512254
    22522255The file \gst{\gsdlhome/comms/jakarta/tomcat/conf/server.xml} is the Tomcat configuration file. The installation process adds a context for \gsiii\  servlets (\gst{\gsdlhome/web})---this tells Tomcat where to find the web.xml file, and what URL (\gst{/gsdl3}) to give it. Anything inside the context directory is accessible via Tomcat\footnote{can we use .htaccess files to restrict access??}. For example, the index.html file that lives in \gst{\gsdlhome/web} can be accessed through the URL \gst{localhost:8080/gsdl3/index.html}. The demo collection's images can be accessed through \\
     
    22542257
    22552258
    2256 Tomcat runs by default on port 8080---this can be changed in server.xml, in the \begin{quote}\begin{gsc}
    2257 <!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 -->\\
    2258 <Connector>
    2259 \end{gsc}\end{quote}
    2260  element.  The siteConfig files also need changing if Tomcat's port is changed: \gst{<httpAddress>} for the site, and \gst{<address>} for a remote site both use this.
     2259Grenstone sets up Tomcat to run on port 8080 by default. To change this, you can edit the tomcat.port property in build.properties. If you do this before installing Greenstone, then running 'ant install' will use the new port number. If you want to change it later on, shutdown tomcat, run 'ant reconfigure-server-settings', then when you restart tomcat it will use the new port.
    22612260
    22622261Note: Tomcat must be shutdown and restarted any time you make changes in the following for those changes to take effect:
     
    22642263\begin{gsc}
    22652264\item \gsdlhome/web/WEB-INF/web.xml
    2266 \item \gsdlhome/comms/jakarta/tomcat-tomcat-4.0.1/conf/server.xml
     2265\item \gsdlhome/comms/jakarta/tomcat/conf/server.xml
    22672266\end{gsc}
    22682267\item any classes or jar files used by the servlets
    22692268\end{bulletedlist}
    2270 \noindent Note: stdin and stdout for the servlets both go to\\
     2269\noindent Note: stdin and stdout for the servlets (on linux) both go to\\
    22712270\gst{\gsdlhome/comms/jakarta/tomcat/logs/catalina.out}
    22722271
     
    22822281\end{gsc}\end{quote}
    22832282
    2284 We have set up Tomcat to disallow directory listings for everything in the docBase directory.  To turn this back on, you need to edit Tomcat's default web.xml file (\gst{\$GSDL3HOME/comms/jakarta/tomcat/conf/web.xml}):
    2285 
    2286 In the default servlet definition, change the 'listings' parameter to true.
     2283By default, Tomcat allows directory listings. To disable this, change the 'listings' paramter to false in the default servlet definition, in Tomcat's web.xml file (\gst{\$GSDL3HOME/comms/jakarta/tomcat/conf/web.xml}):
    22872284
    22882285Tomcat uses a Manager to handle HTTP session information. This may be stored between restarts if possible. To use a persistent session handling manager, uncomment the \gst{<Manager>} element in \\
     
    23142311\section{SOAP}\label{app:soap}
    23152312
    2316 Grenstone uses Apache SOAP for distributed communications. This runs as a servlet inside Tomcat, and services can be deployed by the servlet. The SOAP servlet comes ready to run, but not enabled. To enable it, run:
    2317 
    2318 \begin{quote}\begin{gsc}
    2319 gs3-enable-soap.[sh/bat]
    2320 \end{gsc}\end{quote}
    2321 
    2322 All this does is to rename the SOAP web.xml.disabled file to web.xml.
    2323 
    2324 The SOAP service for localsite comes pre-deployed. To get the gateway servlet talking to the localsite SOAP server, you need to shutdown and restart Tomcat. You should now see more collections when you run the gateway servlet.
    2325 
    2326 To deploy a SOAP service for other sites, run
    2327 \begin{quote}\begin{gsc}
    2328 gs3-soap-deploy-site.[sh/bat] <sitename> <siteURI>
    2329 \end{gsc}\end{quote}
    2330 
    2331 This creates a new SOAPServer class for the site \\(\gst{\$GSDL3HOME/src/java/org/greenstone/gsdl3/SOAPServer<sitename>.java}), creates a resource file for deployment (\gst{\$GSDL3HOME/resources/soap/<sitename>.xml}), and then tries to deploy the service. If the deployment doesn't work, you can run it from the command line like:
    2332 
    2333 \begin{gsc}\begin{verbatim}
    2334 java org.apache.soap.server.ServiceManagerClient
    2335   http://localhost:8080/soap/servlet/rpcrouter deploy
    2336   resources/soap/<sitename>.xml
    2337 \end{verbatim}\end{gsc}
    2338 
    2339 You can also deploy a service through the website.  If Tomcat is not running, start it up.
    2340 
    2341 The SOAP servlet can be accessed at \begin{gsc}{\tt http://localhost:8080/soap}\end{gsc}. You should see a welcome page. Click on ``Run the admin client''. This enables you to list, deploy and undeploy SOAP services.
    2342 
    2343 To deploy the SOAPServer for siteX:
    2344 
    2345 Click on ``deploy'' and edit the following fields in the deploy form:
    2346 
    2347 \begin{tabular}{ll}
    2348 ID: & <URI for siteX>\\
    2349 Scope: (choose Session  & Request---new instantiation for each request\\
    2350   or Application)   &    Session---same instantiation across a session\\
    2351         &    Application---only uses one instantiation\\
    2352 Methods: &process\\
    2353 Java Provider / Provider Class: & org.greenstone.gsdl3.SOAPServersiteX\\
    2354 \end{tabular}
    2355 
    2356 Now click the ``deploy'' button at the bottom of the page. If the service has been deployed, it should appear when you click on the left hand ``List'' button.
    2357 
    2358 Information about deployed services is maintained between Tomcat sessions---you only need to deploy it once.
     2313Grenstone uses the Apache Axis SOAP implementation for distributed communications. Axis runs as a servlet inside Tomcat, and SOAP web services can be deployed by this Axis servlet. The Greenstone installation process sets up Axis for Tomcat, and predeploys the localsite web service.
     2314
     2315To deploy a SOAP service for other sites, run \gst{ant soap-deploy-site}
     2316
     2317This will prompt you for the sitename (the site's directory name), and a unique URI for the site. It creates a new SOAPServer class for the site \\(\gst{\$GSDL3HOME/src/java/org/greenstone/gsdl3/SOAPServer<sitename>.java}), creates a resource file for deployment (\gst{\$GSDL3HOME/resources/soap/<sitename>.wsdd}), and then tries to deploy the service.
     2318
     2319Information about deployed services is maintained between Tomcat sessions---you only need to deploy something once. To undeploy a site, use \gst{ant undeploy-soap-site}.
     2320
     2321The axis servlet can be accessed at \gst{localhost:8080/axis}.
    23592322
    23602323\subsection{Debugging SOAP}\label{app:soap-debug}
    23612324
    2362 If you need to debug the SOAP stuff for some reason, or just want to look at the SOAP messages that are being passed back and forth, use a program called TcpTunnelGui. This intercepts messages coming in to one port, displays them, and passes them to another port.
     2325If you need to debug the SOAP stuff for some reason, or just want to look at the SOAP messages that are being passed back and forth, you can use the TCP monitor. This intercepts messages coming in to one port, displays them, and passes them to another port.
    23632326To run it, type:
    23642327
    2365 \begin{quote}\gst{java org.apache.soap.util.net.TcpTunnelGui 8070 localhost 8080}
     2328\begin{quote}\gst{java -cp <path to gsdl3>/comms/soap/axis/lib/axis.jar \\
     2329org.apache.axis.utils.tcpmon}
    23662330\end{quote}
    23672331
    2368 8070 is the port that TcpTunnelGui listens on, and 8080 is the port that it sends the messages onto---the port that Tomcat is using. You need to modify \gs\  to talk to port 8070 when it wants to talk to Tomcat, so that the messages go through TcpTunnelGui. This is specified in the \gst{<site>} element of the gateway site configuration file (\gst{\gsdlhome/web/sites/gateway/siteConfig.xml}).
    2369 \begin{quote}\begin{gsc}\begin{verbatim}
    2370 <site name="org.greenstone.localsite"
    2371       address="http://localhost:8080/soap/servlet/rpcrouter"
    2372       type="soap"/>
    2373 \end{verbatim}\end{gsc}\end{quote}
    2374 
    2375 Note that \gst{http://localhost:8080/soap/servlet/rpcrouter} is the
    2376 address for talking to the Tomcat SOAP servlet services.
    2377 
     2332The listen port is the port that you want the monitor to be listening on. It should 'act as' a Listener, with target hostname 127.0.0.1 (localhost), and target port the port that Tomcat is running on (8080). You need to modify the address used to talk to the SOAP service. For example, if you want to monitor traffic between the gateway site and the localsite SOAP server, you will need to edit gateway's siteConfig.xml file and change the port number (in the site element) to whatever you have chosen as the listen port.
    23782333
    23792334\newpage
  • trunk/gsdl3/extensions/gsdl-as/build.xml

    r8738 r9874  
    147147-->
    148148
    149   <taskdef name="install" classname="org.apache.catalina.ant.InstallTask"/>
    150   <taskdef name="list"    classname="org.apache.catalina.ant.ListTask"/>
    151   <taskdef name="reload"  classname="org.apache.catalina.ant.ReloadTask"/>
    152   <taskdef name="remove"  classname="org.apache.catalina.ant.RemoveTask"/>
     149  <taskdef name="install" classname="org.apache.catalina.ant.InstallTask"
     150    classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
     151  <taskdef name="list"    classname="org.apache.catalina.ant.ListTask"
     152    classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
     153  <taskdef name="reload"  classname="org.apache.catalina.ant.ReloadTask"
     154    classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
     155  <taskdef name="remove"  classname="org.apache.catalina.ant.RemoveTask"
     156    classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
    153157
    154158
     
    220224        <include name="*.jar"/>
    221225    </fileset>
    222 
     226    <!-- include greenstone files -->
     227    <fileset dir="../../lib/java">
     228      <include name="*.jar"/>
     229    </fileset>
    223230    <!-- Include all elements that Tomcat exposes to applications -->
    224231    <pathelement location="${catalina.home}/common/classes"/>
  • trunk/gsdl3/extensions/gsdl-as/src/org/greenstone/gsdlas/AlertingService.java

    r8888 r9874  
    8686            String title = "Unknown action";
    8787            String message = "I don't know how to " + action;
    88             String details = "The only actions I know are " + Arrays.toString(actions);
     88            String details = "The only actions I know are " + ArrayHelper.toString(actions);
    8989            return showError(context, message, details);
    9090        }
  • trunk/gsdl3/extensions/gsdl-as/src/org/greenstone/gsdlas/EventStore.java

    r8888 r9874  
    101101     */
    102102    private String encodeSpecialChars(String string) {
    103         String encodedString = string.replace("&", "&amp;");
    104         encodedString = encodedString.replace("<", "&lt;");
    105         encodedString = encodedString.replace(">", "&gt;");
    106         encodedString = encodedString.replace("'", "&apos;");
    107         encodedString = encodedString.replace("\"", "&quot;");
     103        String encodedString = string.replaceAll("&", "&amp;");
     104        encodedString = encodedString.replaceAll("<", "&lt;");
     105        encodedString = encodedString.replaceAll(">", "&gt;");
     106        encodedString = encodedString.replaceAll("\'", "&apos;");
     107        encodedString = encodedString.replaceAll("\"", "&quot;");
    108108        return encodedString;
    109109    }
  • trunk/gsdl3/extensions/gsdl-as/src/org/greenstone/gsdlas/GreenstoneCommunicator.java

    r8874 r9874  
    2121import org.w3c.dom.*;
    2222
     23import org.greenstone.gsdlas.util.ArrayHelper;
    2324
    2425/**
     
    7071        }
    7172       
    72         System.out.println(Arrays.toString(result));
     73    System.out.println(ArrayHelper.toString(result));
    7374       
    7475        return result;
  • trunk/gsdl3/extensions/gsdl-as/src/org/greenstone/gsdlas/NotificationStore.java

    r8738 r9874  
    5454            String key = (String) iter.next();
    5555            String value = (String) event.get(key);
    56             String encodedValue = value.replace("&", "&amp;");
    57             encodedValue = encodedValue.replace("<", "&lt;");
    58             encodedValue = encodedValue.replace(">", "&gt;");
    59             encodedValue = encodedValue.replace("'", "&apos;");
    60             encodedValue = encodedValue.replace("\"", "&quot;");
     56            String encodedValue = value.replaceAll("&", "&amp;");
     57            encodedValue = encodedValue.replaceAll("<", "&lt;");
     58            encodedValue = encodedValue.replaceAll(">", "&gt;");
     59            encodedValue = encodedValue.replaceAll("\'", "&apos;");
     60            encodedValue = encodedValue.replaceAll("\"", "&quot;");
    6161           
    6262            event.put(key, encodedValue);
  • trunk/gsdl3/extensions/gsdl-as/src/org/greenstone/gsdlas/util/ArrayHelper.java

    r8775 r9874  
    2626        return index > -1 && index <= array.length;
    2727    }
     28
     29    static public String toString(String [] array) {
     30    StringBuffer buffer = new StringBuffer();
     31    buffer.append("[");
     32    for (int i=0; i<array.length; i++) {
     33        buffer.append((String)array[i]);
     34        buffer.append(",");
     35    }
     36    buffer.append("]");
     37    return buffer.toString();
     38
     39    }
    2840}
  • trunk/gsdl3/extensions/vishnu/README

    r8412 r9874  
    55If you want to run it standalone:
    66
    7 The environment variable JAVA_HOME needs to be set.
     7You need to have Java 1.4 or higher and Ant installed. The environment variable JAVA_HOME needs to be set.
    88You need to have MG installed - this should be the version from Greenstone, and you need the mg.jar file in your CLASSPATH and the libmgjni.so in your LD_LIBRARY_PATH.
    99You need the lucene 1.4 or higher jar file in your CLASSPATH.
    10 Other jar files needed in CLASSPATH: xercesImpl.jar, servlet.jar.
     10Other jar files needed in CLASSPATH: xercesImpl.jar, servlet-api.jar.
    1111These jar files all come as part of the Greenstone download. Some in gsdl3/lib/java, and servlet.jar in gsdl3/comms/jakarta/tomcat/lib (when unpacked).
    1212
    13 Edit the src/vishnu Makefile/winMake.bat and uncomment the prefix for stand-alone vishnu.
     13Edit the build.xml file and change the prefix property to be the current directory.
    1414
    15 Then run the following (on both linux or windows)
    16 
    17 make
    18 make install
     15Then run 'ant' (or "ant all').
    1916
    2017
     
    7067We have provided an example configuration for use with Tomcat (version 4.1).
    7168
    72 Set the prefix in the src/vishnu Makefile to be ../.., then the servlet class and jar files will be installed in the correct places.
    7369The vishnu/web directory is setup to be the context directory for vishnu in Tomcat.
    7470You need to edit Tomcat's conf/server.xml file, and add in the context for vishnu. Add the following element after the tomcat root context element:
  • trunk/gsdl3/gs3-setup.sh

    r8067 r9874  
    4343export MANPATH
    4444
    45 CLASSPATH=$GSDL3HOME/resources/java:$GSDL3HOME/resources/dtd:$GSDL3HOME/src/java:$GSDL3HOME/comms/jakarta/tomcat/common/lib/servlet.jar:$GSDL3HOME/lib/java
     45CLASSPATH=$GSDL3HOME/resources/java:$GSDL3HOME/resources/dtd:$GSDL3HOME/src/java:$GSDL3HOME/comms/jakarta/tomcat/common/lib/servlet-api.jar:$GSDL3HOME/lib/java
    4646for JARFILE in  $GSDL3HOME/lib/java/*.jar; do
    4747    CLASSPATH=$CLASSPATH:$JARFILE
    4848done
     49for JARFILE in $GSDL3HOME/comms/soap/axis/lib/*.jar; do
     50    CLASSPATH=$CLASSPATH:$JARFILE
     51done   
    4952export CLASSPATH
    5053
  • trunk/gsdl3/packages/gsdl-as/build.xml

    r8738 r9874  
    147147-->
    148148
    149   <taskdef name="install" classname="org.apache.catalina.ant.InstallTask"/>
    150   <taskdef name="list"    classname="org.apache.catalina.ant.ListTask"/>
    151   <taskdef name="reload"  classname="org.apache.catalina.ant.ReloadTask"/>
    152   <taskdef name="remove"  classname="org.apache.catalina.ant.RemoveTask"/>
     149  <taskdef name="install" classname="org.apache.catalina.ant.InstallTask"
     150    classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
     151  <taskdef name="list"    classname="org.apache.catalina.ant.ListTask"
     152    classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
     153  <taskdef name="reload"  classname="org.apache.catalina.ant.ReloadTask"
     154    classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
     155  <taskdef name="remove"  classname="org.apache.catalina.ant.RemoveTask"
     156    classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
    153157
    154158
     
    220224        <include name="*.jar"/>
    221225    </fileset>
    222 
     226    <!-- include greenstone files -->
     227    <fileset dir="../../lib/java">
     228      <include name="*.jar"/>
     229    </fileset>
    223230    <!-- Include all elements that Tomcat exposes to applications -->
    224231    <pathelement location="${catalina.home}/common/classes"/>
  • trunk/gsdl3/packages/gsdl-as/src/org/greenstone/gsdlas/AlertingService.java

    r8888 r9874  
    8686            String title = "Unknown action";
    8787            String message = "I don't know how to " + action;
    88             String details = "The only actions I know are " + Arrays.toString(actions);
     88            String details = "The only actions I know are " + ArrayHelper.toString(actions);
    8989            return showError(context, message, details);
    9090        }
  • trunk/gsdl3/packages/gsdl-as/src/org/greenstone/gsdlas/EventStore.java

    r8888 r9874  
    101101     */
    102102    private String encodeSpecialChars(String string) {
    103         String encodedString = string.replace("&", "&amp;");
    104         encodedString = encodedString.replace("<", "&lt;");
    105         encodedString = encodedString.replace(">", "&gt;");
    106         encodedString = encodedString.replace("'", "&apos;");
    107         encodedString = encodedString.replace("\"", "&quot;");
     103        String encodedString = string.replaceAll("&", "&amp;");
     104        encodedString = encodedString.replaceAll("<", "&lt;");
     105        encodedString = encodedString.replaceAll(">", "&gt;");
     106        encodedString = encodedString.replaceAll("\'", "&apos;");
     107        encodedString = encodedString.replaceAll("\"", "&quot;");
    108108        return encodedString;
    109109    }
  • trunk/gsdl3/packages/gsdl-as/src/org/greenstone/gsdlas/GreenstoneCommunicator.java

    r8874 r9874  
    2121import org.w3c.dom.*;
    2222
     23import org.greenstone.gsdlas.util.ArrayHelper;
    2324
    2425/**
     
    7071        }
    7172       
    72         System.out.println(Arrays.toString(result));
     73    System.out.println(ArrayHelper.toString(result));
    7374       
    7475        return result;
  • trunk/gsdl3/packages/gsdl-as/src/org/greenstone/gsdlas/NotificationStore.java

    r8738 r9874  
    5454            String key = (String) iter.next();
    5555            String value = (String) event.get(key);
    56             String encodedValue = value.replace("&", "&amp;");
    57             encodedValue = encodedValue.replace("<", "&lt;");
    58             encodedValue = encodedValue.replace(">", "&gt;");
    59             encodedValue = encodedValue.replace("'", "&apos;");
    60             encodedValue = encodedValue.replace("\"", "&quot;");
     56            String encodedValue = value.replaceAll("&", "&amp;");
     57            encodedValue = encodedValue.replaceAll("<", "&lt;");
     58            encodedValue = encodedValue.replaceAll(">", "&gt;");
     59            encodedValue = encodedValue.replaceAll("\'", "&apos;");
     60            encodedValue = encodedValue.replaceAll("\"", "&quot;");
    6161           
    6262            event.put(key, encodedValue);
  • trunk/gsdl3/packages/gsdl-as/src/org/greenstone/gsdlas/util/ArrayHelper.java

    r8775 r9874  
    2626        return index > -1 && index <= array.length;
    2727    }
     28
     29    static public String toString(String [] array) {
     30    StringBuffer buffer = new StringBuffer();
     31    buffer.append("[");
     32    for (int i=0; i<array.length; i++) {
     33        buffer.append((String)array[i]);
     34        buffer.append(",");
     35    }
     36    buffer.append("]");
     37    return buffer.toString();
     38
     39    }
    2840}
  • trunk/gsdl3/packages/mg/java/org/greenstone/mg/MGQueryResult.java

    r3794 r9874  
    5353    }
    5454
     55    public boolean isClear() {
     56    return (total_num_docs_ == 0 && docs_.isEmpty() && terms_.isEmpty());
     57    }
    5558
    5659    /** returns the result as a String - useful for printing out results */
  • trunk/gsdl3/packages/mg/jni/MGWrapperImpl.c

    r8920 r9874  
    315315
    316316  /* Check that the index was loaded successfully */
    317   assert(qd != NULL);
     317  if (qd==NULL) {
     318    return NULL;
     319  }
     320  /*assert(qd != NULL);*/
    318321
    319322  /* Get the document position and length in the text file */
     
    372375  jthrowable exc;
    373376
    374   /* Make sure an index has been specified */
    375   index_path = data->queryInfo->index;
    376   assert(index_path != NULL);
    377 
    378   /* Obtain C versions of the two string parameters */
    379   base_dir = (*j_env)->GetStringUTFChars(j_env, j_base_dir, NULL);
    380   if (base_dir == NULL) {
    381     return;
    382   }
    383   text_path = (*j_env)->GetStringUTFChars(j_env, j_text_path, NULL);
    384   if (text_path == NULL) {
    385     (*j_env)->ReleaseStringUTFChars(j_env, j_base_dir, base_dir);
    386     return;
    387   }
    388 
    389   /* Load the appropriate index for satisfying this request */
    390   qd = loadIndexData((char*) base_dir, (char*) index_path, (char*) text_path);
    391 
    392   /* The C text strings are no longer needed */
    393   (*j_env)->ReleaseStringUTFChars(j_env, j_base_dir, base_dir);
    394   (*j_env)->ReleaseStringUTFChars(j_env, j_text_path, text_path);
    395 
    396   /* Check that the index was loaded successfully */
    397   assert(qd != NULL);
    398 
    399   /* Remove anything hanging around from last time */
    400   FreeQueryDocs(qd);
    401 
     377  /* First of all, clear the previous result */
    402378  /* The result to write to */
    403379  result_ptr = (*j_env)->GetObjectField(j_env, j_obj, FID_query_result);
     
    411387    return;
    412388  }
     389
     390  /* Make sure an index has been specified */
     391  index_path = data->queryInfo->index;
     392  assert(index_path != NULL);
     393
     394  /* Obtain C versions of the two string parameters */
     395  base_dir = (*j_env)->GetStringUTFChars(j_env, j_base_dir, NULL);
     396  if (base_dir == NULL) {
     397    return;
     398  }
     399  text_path = (*j_env)->GetStringUTFChars(j_env, j_text_path, NULL);
     400  if (text_path == NULL) {
     401    (*j_env)->ReleaseStringUTFChars(j_env, j_base_dir, base_dir);
     402    return;
     403  }
     404
     405  /* Load the appropriate index for satisfying this request */
     406  qd = loadIndexData((char*) base_dir, (char*) index_path, (char*) text_path);
     407
     408  /* The C text strings are no longer needed */
     409  (*j_env)->ReleaseStringUTFChars(j_env, j_base_dir, base_dir);
     410  (*j_env)->ReleaseStringUTFChars(j_env, j_text_path, text_path);
     411
     412  /* Check that the index was loaded successfully */
     413  if (qd == NULL) {
     414    return;
     415  }
     416  /*assert(qd != NULL);*/
     417
     418  /* Remove anything hanging around from last time */
     419  FreeQueryDocs(qd);
    413420
    414421  /* Obtain a C version of the query string */
  • trunk/gsdl3/packages/mg/src/images/WIN32.MAK

    r3921 r9874  
    156156
    157157mostlyclean:
    158     rm -f *$o _*.c _*.o *._c *._o core core.*
     158    if exist *$o del *$o
     159    if exist  _*.c del  _*.c
     160    if exist _*.o  del  _*.o
     161    if exist *._c  del *._c
     162    if exist *._o  del *._o
     163    if exist core  del  core
     164    if exist core.* del  core.*
    159165 
    160166clean: mostlyclean
    161     rm -f $(EXEC)
     167    if exist *$e del *$e
    162168 
    163169distclean: clean
    164     rm -f ansi2knr
    165     rm -f Makefile
    166  
     170    del ansi2knr
     171     
    167172maintainer-clean: distclean
    168173    @echo "This command is intended only for maintainers to use;"
  • trunk/gsdl3/packages/mg/src/text/win32.mak

    r7585 r9874  
    237237clean:
    238238        if exist *$o del *$o
    239     if exist $(EXEC) del $(EXEC)
     239    if exist *$e del *$e
    240240        if exist libmgtextin.lib del libmgtextin.lib
    241241        if exist libmgpass.lib del libmgpass.lib
  • trunk/gsdl3/packages/mg/winMake.bat

    r6416 r9874  
    2929    cd ..\..
    3030
     31    cd java\org\greenstone\mg
     32    call winMake.bat %1
     33    cd ..\..\..\..
     34
    3135    cd jni
    3236    %MAKE% %MAKE_OPTIONS% win32.mak %1
     
    4044
    4145:done
     46
     47
  • trunk/gsdl3/packages/vishnu/README

    r8412 r9874  
    55If you want to run it standalone:
    66
    7 The environment variable JAVA_HOME needs to be set.
     7You need to have Java 1.4 or higher and Ant installed. The environment variable JAVA_HOME needs to be set.
    88You need to have MG installed - this should be the version from Greenstone, and you need the mg.jar file in your CLASSPATH and the libmgjni.so in your LD_LIBRARY_PATH.
    99You need the lucene 1.4 or higher jar file in your CLASSPATH.
    10 Other jar files needed in CLASSPATH: xercesImpl.jar, servlet.jar.
     10Other jar files needed in CLASSPATH: xercesImpl.jar, servlet-api.jar.
    1111These jar files all come as part of the Greenstone download. Some in gsdl3/lib/java, and servlet.jar in gsdl3/comms/jakarta/tomcat/lib (when unpacked).
    1212
    13 Edit the src/vishnu Makefile/winMake.bat and uncomment the prefix for stand-alone vishnu.
     13Edit the build.xml file and change the prefix property to be the current directory.
    1414
    15 Then run the following (on both linux or windows)
    16 
    17 make
    18 make install
     15Then run 'ant' (or "ant all').
    1916
    2017
     
    7067We have provided an example configuration for use with Tomcat (version 4.1).
    7168
    72 Set the prefix in the src/vishnu Makefile to be ../.., then the servlet class and jar files will be installed in the correct places.
    7369The vishnu/web directory is setup to be the context directory for vishnu in Tomcat.
    7470You need to edit Tomcat's conf/server.xml file, and add in the context for vishnu. Add the following element after the tomcat root context element:
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/SOAPServer.java.in

    r8081 r9874  
    1717 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    1818 */
     19
    1920package org.greenstone.gsdl3;
    2021
    2122import org.greenstone.gsdl3.core.*;
     23import org.greenstone.gsdl3.util.GSXML;
    2224import org.w3c.dom.Element;
    2325import java.io.File;
     
    3032 *
    3133 * @author <a href="mailto:kjdon@cs.waikato.ac.nz">Katherine Don</a>
    32  * @version $Revision$
    3334 * @see <a href="http://www.w3.org/TR/SOAP/">Simple Object Access Protocol (SOAP) 1.1 </a>
    3435 */
    3536
    36 public class SOAPServer
    37     implements ModuleInterface {
    38  
     37public class SOAPServerlocalsite
     38{
    3939    private String config_file_name = "SOAPServer.cfg";
    4040   
     
    4343 
    4444  /** The no-args constructor */
    45     public SOAPServer() {
     45    public SOAPServer@sitename@() {
    4646    // find out gsdl3home
    4747    URL url = ClassLoader.getSystemResource(config_file_name);
     
    5454        return;
    5555    }
    56     String site_home=gsdl3_home+File.separator+"web"+File.separator+"sites"+File.separator+"@sitename@";
     56    String site_home=gsdl3_home+File.separator+"web"+File.separator+"sites"+File.separator+"localsite";
    5757   
    5858    File site_file = new File(site_home);
     
    6666    }
    6767   
    68    
    69     /** Process a String request */
    70     public String process(String xml_in) {
    71     return mr_.process(xml_in);
    72    
    73     }
    74 
    75     /** Process an Element request  */
    76     public Element process(Element xml_in) {
    77     return mr_.process(xml_in);
     68    public Element [] process (Element [] xml_in) {
     69    Element [] result = new Element[xml_in.length];
     70    for (int i=0; i<xml_in.length; i++) {
     71        Element req = xml_in[i];
     72        // get rid of the obligatory namespace that axis needs
     73        String tag_name = req.getTagName();
     74        String namespace="";
     75        if (tag_name.indexOf(':')!= -1) {
     76        namespace = tag_name.substring(0, tag_name.indexOf(':'));
     77        tag_name = tag_name.substring(tag_name.indexOf(':')+1);
     78        }
     79        Element new_req = GSXML.duplicateWithNewName(req.getOwnerDocument(), req, tag_name, true);
     80        Element r = mr_.process(new_req);
     81        // add the namespace back on
     82        //Element new_res = r;
     83        //if (!namespace.equals("")) {
     84        //  new_res = GSXML.duplicateWithNewName(r.getOwnerDocument(), r, namespace+r.getTagName(), true);
     85        //}
     86        result[i] = r;
     87    }
     88    return result;
    7889    }
    7990
     
    92103    return null;
    93104    }
    94 
     105   
    95106}
    96107
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/Action.java

    r8832 r9874  
    5252    public String process(String xml_in) {
    5353       
    54     Element message = this.converter.getDOM(xml_in).getDocumentElement();
    55    
    56     Element result = process(message);
     54    Document message_doc = this.converter.getDOM(xml_in);
     55    if (message_doc == null) {
     56        System.err.println("Action.process(String) Error: Couldn't parse request");
     57        System.err.println(xml_in);
     58        return null;
     59    }
     60    Element result = process(message_doc.getDocumentElement());
    5761    return this.converter.getString(result);
    5862    }
     
    115119    }
    116120
     121    protected boolean processErrorElements(Element message, Element page) {
     122    NodeList error_nodes = message.getElementsByTagName(GSXML.ERROR_ELEM);
     123    if (error_nodes.getLength()==0) {
     124        return false;
     125    }
     126    Document owner = page.getOwnerDocument();
     127    for (int i=0; i<error_nodes.getLength(); i++) {
     128        page.appendChild(owner.importNode(error_nodes.item(i), true));
     129    }
     130    return true;
     131    }
    117132}
    118133
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/DocumentAction.java

    r9007 r9874  
    209209        // Process the document structure retrieve message
    210210        Element ds_response_message = (Element) this.mr.process(ds_message);
    211        
     211        if (processErrorElements(ds_response_message, page_response)) {
     212        return result;
     213        }
     214
    212215        // get the info and print out
    213216        String path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
     
    309312    doc_list.appendChild(doc_node);
    310313    Element dm_response_message = (Element) this.mr.process(dm_message);
     314    if (processErrorElements(dm_response_message, page_response)) {
     315        return result;
     316    }
    311317
    312318    String path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
     
    348354    System.err.println("request = "+converter.getString(dc_message));
    349355    Element dc_response_message = (Element) this.mr.process(dc_message);
     356    if (processErrorElements(dc_response_message, page_response)) {
     357        return result;
     358    }
     359
    350360    Element dc_response_doc_list = (Element) GSXML.getNodeByPath(dc_response_message, path);
    351361
     
    536546    HashMap params = GSXML.extractParams(cgi_param_list, false);
    537547   
    538    
    539     String service_name = (String)((HashMap)params.get("p")).get(GSParams.SERVICE);
     548    HashMap previous_params = (HashMap)params.get("p");
     549    if (previous_params == null) {
     550        return dc_response_doc_content;
     551    }
     552        String service_name = (String)previous_params.get(GSParams.SERVICE);
    540553    if (service_name == null || !service_name.endsWith("Query")) { // hack for now - we only do highlighting if we were in a query last - ie not if we were in a browse thingy
    541554        System.err.println("DocumentAction: invalid service, not doing highlighting");
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/GS2BrowseAction.java

    r8575 r9874  
    126126        horizontal_at_top = true;
    127127    }
    128     if (top_id.equals(classifier_node) && horizontal_at_top) {
     128    // *** TODO need to fix this
     129    //if (top_id.equals(classifier_node) && horizontal_at_top) {
    129130        // we have asked for a top node - if the first list is horizontal, we will select the first element of that list
    130         // this is a hack. also it craps out if the classifier really isn't horizontalAtTop.
    131         classifier_node = classifier_node+".1";
     131        // this is a hack. also it craps out if the classifier really isn't horizontalAtTop. -
     132        //classifier_node = classifier_node+".1";
    132133           
    133     }
     134    //}
    134135
    135136    // get the browse structure for the selected node
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/QueryAction.java

    r9264 r9874  
    6060    String to = GSPath.appendLink(collection, service_name);
    6161   
    62     // part of the response is the service description
    63     // for now get this again from the service.
    64     // this will probably need to be cached somehow later on.
    65     Element mr_info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    66     Element mr_info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE,  to, lang, uid);
    67     mr_info_message.appendChild(mr_info_request);
    68 
     62    if (request_type.indexOf("d")!=-1) {
     63        // we have been asked for the service description
     64        Element mr_info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     65        Element mr_info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE,  to, lang, uid);
     66        mr_info_message.appendChild(mr_info_request);
     67       
     68        // process the message
     69        Element mr_info_response = (Element) this.mr.process(mr_info_message);
     70        // the response
     71        Element service_response = (Element)GSXML.getChildByTagName(mr_info_response, GSXML.RESPONSE_ELEM);
     72       
     73        Element service_description = (Element)this.doc.importNode(GSXML.getChildByTagName(service_response, GSXML.SERVICE_ELEM), true);
     74        page_response.appendChild(service_description);
     75    }
     76   
     77    if (request_type.indexOf("r") == -1) {
     78        // just a display request, no actual processing to do
     79        return page_response;
     80    }
     81   
     82    // check that we have some service params
     83    HashMap service_params = (HashMap)params.get("s1");
     84    if (service_params == null) { // no query
     85        return page_response;
     86    }
     87
     88    // create the query request
     89    Element mr_query_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     90    Element mr_query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, lang, uid);
     91    mr_query_message.appendChild(mr_query_request);
     92   
     93    Element query_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     94    GSXML.addParametersToList(this.doc, query_param_list, service_params);
     95    mr_query_request.appendChild(query_param_list);
     96   
    6997    // also get the format stuff now if there is some
    7098    Element format_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT, to, lang, uid);
    71     mr_info_message.appendChild(format_request);
    72 
    73     // process the messages
    74     Element mr_info_response = (Element) this.mr.process(mr_info_message);
    75    
    76     // the two responses
    77     NodeList responses = mr_info_response.getElementsByTagName(GSXML.RESPONSE_ELEM);
    78     Element service_response = (Element)responses.item(0);
    79     Element format_response = (Element)responses.item(1);
    80    
    81     Element service_description = (Element)this.doc.importNode(GSXML.getChildByTagName(service_response, GSXML.SERVICE_ELEM), true);
    82     page_response.appendChild(service_description);
    83    
    84     if (request_type.equals("d")) {// just a display request
    85         return page_response;
    86     }
    87    
     99    mr_query_message.appendChild(format_request);
     100
     101    // do the query
     102        Element mr_query_response = (Element)this.mr.process(mr_query_message);
     103
     104    // check for errors
     105    if (processErrorElements(mr_query_response, page_response)) {
     106        return page_response;
     107    }
     108   
     109    NodeList responses = mr_query_response.getElementsByTagName(GSXML.RESPONSE_ELEM);
     110    Element query_response = (Element) responses.item(0);
     111    Element format_response = (Element) responses.item(1);
     112   
     113    Element query_result_metadata_list = (Element) GSXML.getChildByTagName(query_response, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
     114    if (query_result_metadata_list == null) {
     115        System.err.println("QueryAction: Warning: No query result metadata.\n");
     116    } else { // add it into the page response
     117        page_response.appendChild(this.doc.importNode(query_result_metadata_list, true));
     118    }
     119   
     120    Element query_term_info_list = (Element) GSXML.getChildByTagName(query_response, GSXML.TERM_ELEM+GSXML.LIST_MODIFIER);
     121    if (query_term_info_list == null) {
     122        System.err.println("QueryAction: Warning: No query term information.\n");
     123    } else { // add it into the page response
     124        page_response.appendChild(this.doc.importNode(query_term_info_list, true));
     125    }
     126   
     127    // check that there are some documents - for now check the list, but later should use a numdocs metadata elem   
     128    Element document_list = (Element)GSXML.getChildByTagName(query_response, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
     129    // documentList not present if no docs found
     130    if (document_list == null) {
     131        return page_response;
     132    }
     133
     134    // now we check to see if there is metadata already - some search services return predefined metadata. if there is some, don't do a metadata request
     135    NodeList doc_metadata = document_list.getElementsByTagName(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
     136    if (doc_metadata.getLength()>0) {
     137        System.err.println("have already found metadata!");
     138        // append the doc list to the result
     139        page_response.appendChild(this.doc.importNode(document_list, true));
     140        return page_response;
     141    }
     142   
     143    // get the metadata elements needed from the format statement if any
    88144    HashSet metadata_names = new HashSet();
    89145    metadata_names.add("Title");
     
    98154        extractMetadataNames(format_elem, metadata_names);
    99155    }
    100 
    101     // do the query
    102     Element mr_query_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    103     Element mr_query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, lang, uid);
    104     mr_query_message.appendChild(mr_query_request);
    105    
    106     // paramList
    107     HashMap service_params = (HashMap)params.get("s1");
    108     if (service_params == null) { // no query
    109         return page_response;
    110     }
    111     Element query_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    112     GSXML.addParametersToList(this.doc, query_param_list, service_params);
    113     ///ystem.out.println("service params are "+this.converter.getString(query_param_list));
    114     mr_query_request.appendChild(query_param_list);
    115 
    116     // do the query
    117         Element mr_query_response = (Element)this.mr.process(mr_query_message);
    118 
    119     //. check for errors
    120     String path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.ERROR_ELEM);
    121     Element error_elem = (Element) GSXML.getNodeByPath(mr_query_response, path);
    122     if (error_elem != null) {
    123         // should we continue?? perhaps have a kind of error - information vs fatal??
    124         System.err.println("found an error elem");
    125         page_response.appendChild(this.doc.importNode(error_elem, true));
    126         return page_response;
    127     }
    128     path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
    129     Element query_result_metadata_list = (Element) GSXML.getNodeByPath(mr_query_response, path);
    130     if (query_result_metadata_list == null) {
    131         System.err.println("QueryAction: Warning: No query result metadata.\n");
    132     } else { // add it into the page response
    133         page_response.appendChild(this.doc.importNode(query_result_metadata_list, true));
    134     }
    135    
    136     path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.TERM_ELEM+GSXML.LIST_MODIFIER);
    137     Element query_term_info_list = (Element) GSXML.getNodeByPath(mr_query_response, path);
    138     if (query_term_info_list == null) {
    139         System.err.println("QueryAction: Warning: No query term information.\n");
    140     } else { // add it into the page response
    141         page_response.appendChild(this.doc.importNode(query_term_info_list, true));
    142     }
    143 
    144     // check that there are some documents - for now check the list, but later should use a numdocs metadata elem
    145     path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
    146    
    147     Element document_list = (Element)GSXML.getNodeByPath(mr_query_response,
    148                                  path);
    149     // documentList not present if no docs found
    150     if (document_list == null) {
    151         return page_response;
    152     }
    153156   
    154157    // paging of the results is done here - we filter the list to remove unwanted entries before retrieving metadata
    155     Element filtered_doc_list = filterDocList(params, service_description, document_list);
    156    
    157     // now we check to see if there is metadata already - some search services return predefined metadata. if there is some, don't do a metadata request
    158     NodeList doc_metadata = document_list.getElementsByTagName(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
    159     if (doc_metadata.getLength()>0) {
    160         System.err.println("have already found metadata!");
    161         // append the doc list to the result
    162         page_response.appendChild(this.doc.importNode(document_list, true));
    163         return page_response;
    164     }
     158    Element filtered_doc_list = filterDocList(params, service_params, document_list);
     159   
    165160    // do the metadata request on the filtered list
    166161    Element mr_metadata_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     
    176171    mr_metadata_request.appendChild(dm_param_list);
    177172   
    178    
    179173    // add in the doc node list too
    180174    mr_metadata_request.appendChild(filtered_doc_list);
    181175
    182176    Element mr_metadata_response = (Element) this.mr.process(mr_metadata_message); 
    183    
    184     path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
    185     Element query_result_document_list = (Element) GSXML.getNodeByPath(mr_metadata_response, path);
    186 
     177    // check for errors
     178    processErrorElements(mr_metadata_response, page_response);
     179   
     180    Element metadata_response = (Element) GSXML.getChildByTagName(mr_metadata_response, GSXML.RESPONSE_ELEM);
     181
     182    Element query_result_document_list = (Element) GSXML.getChildByTagName(metadata_response, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
     183   
    187184    if (query_result_document_list != null) {
    188185        page_response.appendChild(this.doc.importNode(query_result_document_list, true));
    189186    }
    190 
    191     System.out.println("Query page:\n" + this.converter.getPrettyString(page_response));
     187   
     188    ///ystem.out.println("Query page:\n" + this.converter.getPrettyString(page_response));
    192189    return page_response;
    193190    }
    194191
    195192    /** this filters out some of the doc results for result paging */
    196     protected Element filterDocList(HashMap params, Element service_description, Element orig_doc_list) {
    197    
    198     // check in the service descripiton to see if hitsPerpage is a param
    199     Element service_p_list = (Element)GSXML.getChildByTagName(service_description, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    200     Element hits_param = GSXML.getNamedElement(service_p_list, GSXML.PARAM_ELEM, GSXML.NAME_ATT, "hitsPerPage");
    201    
    202     boolean service_paging = false;
    203     if (hits_param != null) {
    204         service_paging = true;
    205     }
    206     if (service_paging) {
    207         // the service is doing the paging, so we want to display all of teh returned docs
     193    protected Element filterDocList(HashMap params, HashMap service_params, Element orig_doc_list) {
     194   
     195    // check the hits_per_page param - is it a service param??
     196    String hits_pp = (String) service_params.get("hitsPerPage");
     197    if (hits_pp != null) {
     198        // the service is doing the paging, so we want to display all of the returned docs
    208199        return (Element)this.doc.importNode(orig_doc_list, true);
    209200    }
    210201   
    211     String hits_pp = (String)params.get("hitsPerPage");
     202    hits_pp = (String)params.get("hitsPerPage");
    212203    int hits = 20;
    213204    if (hits_pp != null && !hits_pp.equals("")) {
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/collection/Collection.java

    r5403 r9874  
    101101    }
    102102    // get the xml for both files
    103     Element coll_config_elem = this.converter.getDOM(coll_config_file, CONFIG_ENCODING).getDocumentElement();
     103    Document coll_config_doc = this.converter.getDOM(coll_config_file, CONFIG_ENCODING);
     104    Element coll_config_elem = null;
     105    if (coll_config_doc != null) {
     106        coll_config_elem = coll_config_doc.getDocumentElement();
     107    }
    104108    return coll_config_elem;
    105109
     
    116120        return null;
    117121    }
    118     Element build_config_elem = this.converter.getDOM(build_config_file, CONFIG_ENCODING).getDocumentElement();
    119 
     122    Document build_config_doc = this.converter.getDOM(build_config_file, CONFIG_ENCODING);
     123    Element build_config_elem = null;
     124    if (build_config_doc != null) {
     125        build_config_elem = build_config_doc.getDocumentElement();
     126    }
    120127    return build_config_elem;
    121128    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/collection/ServiceCluster.java

    r9433 r9874  
    3434import java.io.File;
    3535import java.util.HashMap;
     36import java.util.Iterator;
    3637
    3738/* ServiceCluster - a groups of services that are related in some way
     
    9192    }
    9293
     94    public void cleanUp() {
     95    Iterator i = this.service_map.values().iterator();
     96    while (i.hasNext()) {
     97        ServiceRack s = (ServiceRack)i.next();
     98        s.cleanUp();
     99    }
     100    }
    93101    public void setClusterName(String name) {
    94102    this.cluster_name = name;   
     
    139147
    140148    Document doc = this.converter.getDOM(config_file, CONFIG_ENCODING);
     149    if (doc == null) {
     150        System.err.println("ServiceCluster: couldn't parse config file "+config_file.getPath());
     151        return false;
     152    }
    141153   
    142154    // get the appropriate service cluster element
     
    147159    return this.configure(sc);
    148160    }
    149  
     161    
    150162   
    151163    public boolean configure(Element service_cluster_info) {
     
    159171        }
    160172    }
    161 
     173   
    162174    // get the display info
    163175    Element display_list = (Element) GSXML.getChildByTagName(service_cluster_info, GSXML.DISPLAY_TEXT_ELEM+GSXML.LIST_MODIFIER);
     
    528540    }
    529541   
    530     Element site_config_elem  = this.converter.getDOM(configFile).getDocumentElement();
     542    Document site_config_doc  = this.converter.getDOM(configFile);
     543    if (site_config_doc == null) {
     544        System.err.println("ServiceCluster: could not read in site config file: "+configFile.getPath());
     545        return false;
     546    }
     547   
     548    Element site_config_elem = site_config_doc.getDocumentElement();
    531549    Element cluster_config_elem = GSXML.getNamedElement((Element)GSXML.getChildByTagName(site_config_elem, GSXML.CLUSTER_ELEM+GSXML.LIST_MODIFIER), GSXML.CLUSTER_ELEM, GSXML.NAME_ATT, this.cluster_name);
    532550    if (cluster_config_elem == null) {
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/comms/Communicator.java

    r4035 r9874  
    4848    converter_ = new XMLConverter();
    4949    }
     50    public void cleanUp() {}
    5051
    5152    public void setLocalSiteName(String name) {
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/comms/SOAPCommunicator.java

    r4035 r9874  
    2626import java.net.MalformedURLException;
    2727import java.util.Vector;
    28 import org.apache.soap.SOAPException;
    29 import org.apache.soap.Fault;
    30 import org.apache.soap.Constants;
    31 import org.apache.soap.rpc.Call;
    32 import org.apache.soap.rpc.Parameter;
    33 import org.apache.soap.rpc.Response;
     28// import org.apache.soap.SOAPException;
     29// import org.apache.soap.Fault;
     30// import org.apache.soap.Constants;
     31// import org.apache.soap.rpc.Call;
     32// import org.apache.soap.rpc.Parameter;
     33// import org.apache.soap.rpc.Response;
     34import org.apache.axis.client.Call;
     35import org.apache.axis.client.Service;
     36import org.apache.axis.message.SOAPBodyElement;
     37import javax.xml.namespace.QName;
    3438
    3539import org.w3c.dom.Node;
     
    5761    public SOAPCommunicator() {
    5862   
    59     call_ = new Call();
     63
    6064    // Set Encoding Style to standard SOAP encoding
    6165    //call_.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
    6266    // set Encoding Style to use literal XML
    63     call_.setEncodingStyleURI(Constants.NS_URI_LITERAL_XML);
     67    //call_.setEncodingStyleURI(Constants.NS_URI_LITERAL_XML);
    6468    }
    6569       
    6670    public boolean configure(Element site_elem) {
    6771
     72   
    6873    String type = site_elem.getAttribute(GSXML.TYPE_ATT);
    6974    if (!type.equals(GSXML.COMM_TYPE_SOAP_JAVA)) {
     
    8186        return false;
    8287    }
    83     call_.setTargetObjectURI(remote_site_name_);
    84     call_.setMethodName("process");
    85 
     88    try {
     89        Service service = new Service();
     90        call_ = (Call) service.createCall();
     91       
     92        //call_.setTargetObjectURI(remote_site_name_);
     93        //call_.setMethodName("process");
     94        call_.setTargetEndpointAddress( new java.net.URL(remote_site_address_) );
     95        //      call_.setOperationStyle(org.apache.axis.enum.Style.MESSAGE_STR);
     96        //call_.setOperationUse(org.apache.axis.enum.Use.LITERAL_STR);
     97        //call_.setOperationName(new QName("http://soapinterop.org/", "process"));
     98    } catch (Exception e) {
     99        System.err.println("SOAPCommunicator.configure() Error: Exception occurred "+e);
     100        return false;
     101    }
    86102    return true;
    87103    }
    88104
    89 
    90105    public Element process(Element message) {
    91 
     106   
    92107    NodeList requests = message.getElementsByTagName(GSXML.REQUEST_ELEM);
    93108    if (requests.getLength()==0) {
     
    95110        return null;
    96111    }
    97    
     112
    98113    // if the communicator is part of a site, it needs to edit the to and from fields, otherwise it just passes the message on, as is
    99114    // for now, use local_site_name_ as the flag.
     
    110125        }
    111126    }
     127    // else do nothing to the requests, just pass it on
     128
     129    // the soap impl needs a namespace for the top level element
     130    Element message_to_send = message;
     131    if (message.getNamespaceURI() == null) {
     132        message_to_send = GSXML.duplicateWithNewNameNS(message.getOwnerDocument(), message, "gs3:"+message.getTagName(), "urn:foo", true);
     133        //System.err.println("**"+new XMLConverter().getPrettyString(new_message));
     134    }
     135   
     136    // do the soap query
     137    Element result = null;
     138    try {
     139        SOAPBodyElement[] input = new SOAPBodyElement[1];
     140        input[0] = new SOAPBodyElement(message_to_send);
     141        Vector output = (Vector) call_.invoke( input );
     142        SOAPBodyElement elem = (SOAPBodyElement) output.get(0);
     143        result = elem.getAsDOM();
     144    } catch (Exception e) {
     145        e.printStackTrace();
     146        return null;
     147    }
     148   
     149    if (local_site_name_ != null) {// have to modify the from field
     150       
     151        NodeList responses = result.getElementsByTagName(GSXML.RESPONSE_ELEM);
     152        for (int i=0;i<responses.getLength(); i++) {
     153        Element e = (Element)responses.item(i);
     154        String from = e.getAttribute(GSXML.FROM_ATT);
     155        from = GSPath.prependLink(from, remote_site_name_);
     156        e.setAttribute(GSXML.FROM_ATT, from);
     157        }
     158    } // else return as is
     159   
     160    return result;
     161    }
     162
     163    public static void main (String [] args) {
     164    SOAPCommunicator comm = new SOAPCommunicator();
     165    XMLConverter converter = new XMLConverter();
     166    String message = "<site name=\"localsite\" address=\"http://kanuka.cs.waikato.ac.nz:7070/axis/services/localsite\" type=\"soap\"/>";
     167    Element site_elem = converter.getDOM(message).getDocumentElement();
     168    comm.configure(site_elem);
     169    message = "<message><request type=\"describe\" to=\"\" lang=\"en\"/></message>";
     170    //message = "<message><request type=\"describe\" to=\"\" lang=\"en\"/></message>";
     171    Element request_elem = converter.getDOM(message).getDocumentElement();
     172    Element response = comm.process(request_elem);
     173   
     174    System.err.println("response was "+converter.getPrettyString(response));
     175    }
     176    /*
     177    public Element process(Element message) {
     178
     179    NodeList requests = message.getElementsByTagName(GSXML.REQUEST_ELEM);
     180    if (requests.getLength()==0) {
     181        // no requests
     182        return null;
     183    }
     184   
     185    // if the communicator is part of a site, it needs to edit the to and from fields, otherwise it just passes the message on, as is
     186    // for now, use local_site_name_ as the flag.
     187    if (local_site_name_!=null) { // no local site
     188       
     189        for (int i=0;i<requests.getLength(); i++) {
     190        Element e = (Element)requests.item(i);
     191        String to = e.getAttribute(GSXML.TO_ATT);
     192        to = GSPath.removeFirstLink(to); // remove the server name, should check that it is present
     193        e.setAttribute(GSXML.TO_ATT, to);
     194        String from = e.getAttribute(GSXML.FROM_ATT);
     195        from = GSPath.appendLink(from, local_site_name_);
     196        e.setAttribute(GSXML.FROM_ATT, from);
     197        }
     198    }
    112199    // else do nothing to the message, just pass it on
    113200   
     
    116203
    117204        // Set Method Parameters - use literal xml
    118         Parameter param = new Parameter("xml_in",
    119                         org.w3c.dom.Element.class,
    120                         message,
    121                         Constants.NS_URI_LITERAL_XML);
     205//      Parameter param = new Parameter("xml_in",
     206//                      org.w3c.dom.Element.class,
     207//                      message,
     208//                      Constants.NS_URI_LITERAL_XML);
    122209                       
    123         Vector param_list = new Vector ();
    124         param_list.addElement (param);
    125         call_.setParams (param_list);
    126        
    127         //  Set the URL for the Web Service
    128         URL url = new URL(remote_site_address_);
     210//      Vector param_list = new Vector ();
     211//      param_list.addElement (param);
     212//      call_.setParams (param_list);
     213       
     214//      //  Set the URL for the Web Service
     215//      URL url = new URL(remote_site_address_);
    129216       
    130217        // Invoke the Service
     
    167254    }
    168255    }
    169    
     256    */
    170257}
    171258
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/core/DefaultReceptionist.java

    r7825 r9874  
    2424   
    2525    Element page_request = (Element)GSXML.getChildByTagName(page, GSXML.PAGE_REQUEST_ELEM);
     26    // if it is a system request, then we don't bother with this.
     27    String action = page_request.getAttribute(GSXML.ACTION_ATT);
     28    if (action.equals("s")) {
     29        System.err.println("HACK: don't ask for coll info if system action");
     30        return;
     31    }
    2632    ///ystem.out.println("add extra info, page request="+this.converter.getString(page_request));
    2733    // is a collection defined?
     
    6066        Element coll_about_response_message = this.mr.process(coll_about_message);
    6167        Element coll_about_response = (Element)GSXML.getChildByTagName(coll_about_response_message, GSXML.RESPONSE_ELEM);
     68        if (coll_about_response == null) {
     69        return;
     70        }
    6271        coll_description = (Element)GSXML.getChildByTagName(coll_about_response, GSXML.COLLECTION_ELEM);
    6372        if (coll_description==null) { // may be a cluster
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/core/MessageRouter.java

    r9276 r9874  
    9898    this.converter = new XMLConverter();
    9999    this.doc = this.converter.newDOM();
    100    
    101    
    102     }
    103 
     100    }
     101
     102    public void cleanUp() {
     103    if (this.module_map != null) {
     104        Iterator i = this.module_map.values().iterator();
     105        while (i.hasNext()) {
     106        ((ModuleInterface)i.next()).cleanUp();
     107        }
     108    }
     109    }
    104110    /** site_home must be set before configure called */
    105111    public void setSiteHome(String home) {
     
    133139    this.module_map = new HashMap();
    134140
    135     Element config = this.converter.getDOM(configFile).getDocumentElement();
    136    
    137     Element local_site_name = (Element)GSXML.getChildByTagName(config, GSXML.SITE_NAME_ELEM);
     141    Document config_doc = this.converter.getDOM(configFile);
     142    if (config_doc == null) {
     143System.err.println("MessageRouter: couldn't parse site config file: "+configFile.getPath());
     144        return false;
     145    }
     146    Element config_elem = config_doc.getDocumentElement();
     147   
     148    Element local_site_name = (Element)GSXML.getChildByTagName(config_elem, GSXML.SITE_NAME_ELEM);
    138149    if (local_site_name == null) {
    139150        System.err.println("MessageRouter configure error:no site name in config file");
     
    143154    }
    144155   
    145     Element http_address = (Element)GSXML.getChildByTagName(config, GSXML.SITE_HTTP_ADDRESS_ELEM);
     156    Element http_address = (Element)GSXML.getChildByTagName(config_elem, GSXML.SITE_HTTP_ADDRESS_ELEM);
    146157    if (http_address == null) {
    147158        System.err.println("MessageRouter configure error: no http address  in config file");
     
    151162    }
    152163
    153     Element proxy = (Element)GSXML.getChildByTagName(config, "proxy");
     164    Element proxy = (Element)GSXML.getChildByTagName(config_elem, "proxy");
    154165    if (proxy != null) {
    155166        String host = proxy.getAttribute("host");
     
    180191                     
    181192    // load up the services
    182     Element service_rack_list = (Element)GSXML.getChildByTagName(config, GSXML.SERVICE_CLASS_ELEM+GSXML.LIST_MODIFIER);
     193    Element service_rack_list = (Element)GSXML.getChildByTagName(config_elem, GSXML.SERVICE_CLASS_ELEM+GSXML.LIST_MODIFIER);
    183194    configureServices(service_rack_list);
    184195   
    185196    // load up the service clusters
    186     Element cluster_list = (Element)GSXML.getChildByTagName(config, GSXML.CLUSTER_ELEM+GSXML.LIST_MODIFIER);   
     197    Element cluster_list = (Element)GSXML.getChildByTagName(config_elem, GSXML.CLUSTER_ELEM+GSXML.LIST_MODIFIER);   
    187198    configureClusters(cluster_list);
    188199
     
    191202
    192203    // load up the external sites - this also adds their services/clusters/collections to the other lists - so must be done last
    193     Element site_list = (Element)GSXML.getChildByTagName(config, GSXML.SITE_ELEM+GSXML.LIST_MODIFIER);
     204    Element site_list = (Element)GSXML.getChildByTagName(config_elem, GSXML.SITE_ELEM+GSXML.LIST_MODIFIER);
    194205    configureSites(site_list);
    195206   
     
    603614                    continue;
    604615                }
    605                 site_config_elem  = this.converter.getDOM(configFile).getDocumentElement();
     616                Document site_config_doc = this.converter.getDOM(configFile);
     617                if (site_config_doc == null) {
     618                    System.err.println("MessageRouter: couldn't parse site config file: "+configFile.getPath());
     619                    continue;
     620                }
     621                site_config_elem  = site_config_doc.getDocumentElement();
    606622                }
    607623                if (subset.equals(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER)) {
     
    684700    File init_file = new File(GSFile.collectionInitFile(this.site_home, col_name));
    685701    if (init_file.exists()) {
    686         Element init_elem = this.converter.getDOM(init_file).getDocumentElement();
    687         String coll_class_name = init_elem.getAttribute("class");
    688         if (coll_class_name.equals("")) {
    689         c = new Collection();
    690         } else {
    691         try {
    692             c = (Collection)Class.forName("org.greenstone.gsdl3.collection."+coll_class_name).newInstance();
    693         } catch (Exception e) {
    694             System.out.println("MessageRouter: couldn't create a new collection, type "+coll_class_name+", defaulting to class Collection");
    695             c = new Collection();
    696         }
    697         }
    698     } else {
    699         // use the defualt collection
     702        Document init_doc = this.converter.getDOM(init_file);
     703        if (init_doc != null) {
     704        Element init_elem = init_doc.getDocumentElement();
     705        if (init_elem != null) {
     706            String coll_class_name = init_elem.getAttribute("class");
     707            if (!coll_class_name.equals("")) {
     708            try {
     709                c = (Collection)Class.forName("org.greenstone.gsdl3.collection."+coll_class_name).newInstance();
     710            } catch (Exception e) {
     711                System.out.println("MessageRouter: couldn't create a new collection, type "+coll_class_name+", defaulting to class Collection");
     712            }
     713            }
     714        }
     715        }
     716    }
     717    if (c==null) { // we haven't found anpther classname to use
    700718        c = new Collection();
    701719    }
     720   
    702721    c.setCollectionName(col_name);
    703722    c.setSiteHome(this.site_home);
     
    720739   
    721740    }
    722 
     741   
    723742    protected boolean activateSite(String site_name) {
    724743    System.out.println("MessageRouter:Activating site: "+site_name+".");
     
    732751        return false;
    733752    }
    734     Element config = this.converter.getDOM(configFile).getDocumentElement();
    735    
    736     Element site_list = (Element)GSXML.getChildByTagName(config, GSXML.SITE_ELEM+GSXML.LIST_MODIFIER);
     753    Document config_doc = this.converter.getDOM(configFile);
     754    if (config_doc == null) {
     755        System.err.println("MessageRouter: couldn't parse site config file: "+configFile.getPath());
     756        return false;
     757    }
     758    Element config_elem = config_doc.getDocumentElement();
     759   
     760    Element site_list = (Element)GSXML.getChildByTagName(config_elem, GSXML.SITE_ELEM+GSXML.LIST_MODIFIER);
    737761    if (site_list ==null ) {
    738762        System.err.println("MessageRouter:activateSite, no sites found");
     
    789813
    790814        System.out.println("MessageRouter: deactivating "+name);
    791         this.module_map.remove(name);
    792 
     815        ModuleInterface m = (ModuleInterface)this.module_map.remove(name);
     816        m.cleanUp(); // clean up any open files/connections etc - can cause trouble on windows
    793817        // also remove the xml bit from description list
    794818        if (type.equals(GSXML.COLLECTION_ELEM)) {
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/core/ModuleInterface.java

    r3502 r9874  
    5252   */
    5353    abstract public Element process(Element xml_in);
     54
     55    /**
     56     * Do any clean up necessary for deactivating the module, eg
     57     * close any open file handles (gdbm in particular) or windows
     58     * holds locks on them.
     59     */
     60    abstract public void cleanUp();
    5461}   
    5562                                                                           
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/core/Receptionist.java

    r8921 r9874  
    5050    }
    5151   
     52    public void cleanUp() {}
    5253    public void setParams(GSParams params) {
    5354    this.params = params;
     
    8182    }
    8283   
    83     Element config_doc = this.converter.getDOM(interface_config_file).getDocumentElement();
    84     String base_interface = config_doc.getAttribute("baseInterface");
     84    Document config_doc = this.converter.getDOM(interface_config_file);
     85    if (config_doc == null) {
     86        System.err.println("Receptionist: could not parse interface config file: "+interface_config_file.getPath());
     87        return false;
     88    }
     89    Element config_elem = config_doc.getDocumentElement();
     90    String base_interface = config_elem.getAttribute("baseInterface");
    8591    setUpBaseInterface(base_interface);
    86     setUpInterfaceOptions(config_doc);
     92    setUpInterfaceOptions(config_elem);
    8793
    8894    // load up the actions
    89     Element action_list = (Element)GSXML.getChildByTagName(config_doc, GSXML.ACTION_ELEM+GSXML.LIST_MODIFIER);
     95    Element action_list = (Element)GSXML.getChildByTagName(config_elem, GSXML.ACTION_ELEM+GSXML.LIST_MODIFIER);
    9096    NodeList actions = action_list.getElementsByTagName(GSXML.ACTION_ELEM);
    9197
     
    109115    }
    110116
    111     this.language_list = (Element)GSXML.getChildByTagName(config_doc, "languageList");
     117    this.language_list = (Element)GSXML.getChildByTagName(config_elem, "languageList");
    112118    if (language_list == null) {
    113119        System.err.println("Receptionist: didn't find a language list in the config file!!");
     
    229235        base_interfaces.add(base_interface);
    230236        // now see if this has a base interface
    231         Element config_doc = this.converter.getDOM(base_interface_config_file).getDocumentElement();
    232         base_interface = config_doc.getAttribute("baseInterface");
     237        Document config_doc = this.converter.getDOM(base_interface_config_file);
     238        if (config_doc == null) {
     239        System.err.println("Receptionist: could not parse base interface config file: "+base_interface_config_file.getPath());
     240        return false;
     241        }
     242        Element config_elem = config_doc.getDocumentElement();
     243        base_interface = config_elem.getAttribute("baseInterface");
    233244    }
    234245    return true;
    235246    }
    236247
    237     protected boolean setUpInterfaceOptions(Element config_doc) {
    238     Element option_list = (Element)GSXML.getChildByTagName(config_doc, "optionList");
     248    protected boolean setUpInterfaceOptions(Element config_elem) {
     249    Element option_list = (Element)GSXML.getChildByTagName(config_elem, "optionList");
    239250    if (option_list != null) {
    240251        System.err.println("found an option list");
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java

    r9405 r9874  
    5252        return false;
    5353    }
    54    
    55     Element config_doc = this.converter.getDOM(interface_config_file, "utf-8").getDocumentElement();
    56     String base_interface = config_doc.getAttribute("baseInterface");
     54    Document config_doc = this.converter.getDOM(interface_config_file, "utf-8");
     55    if (config_doc == null) {
     56        System.err.println("TransformingReceptionist: could not parse interface config file: "+interface_config_file.getPath());
     57        return false;
     58    }
     59    Element config_elem = config_doc.getDocumentElement();
     60    String base_interface = config_elem.getAttribute("baseInterface");
    5761    setUpBaseInterface(base_interface);
    58     setUpInterfaceOptions(config_doc);
    59 
    60     Element action_list = (Element)GSXML.getChildByTagName(config_doc, GSXML.ACTION_ELEM+GSXML.LIST_MODIFIER);
     62    setUpInterfaceOptions(config_elem);
     63
     64    Element action_list = (Element)GSXML.getChildByTagName(config_elem, GSXML.ACTION_ELEM+GSXML.LIST_MODIFIER);
    6165    NodeList actions = action_list.getElementsByTagName(GSXML.ACTION_ELEM);
    6266
     
    97101       
    98102    }
    99     Element lang_list = (Element)GSXML.getChildByTagName(config_doc, "languageList");
     103    Element lang_list = (Element)GSXML.getChildByTagName(config_elem, "languageList");
    100104    if (lang_list == null) {
    101105        System.err.println("TransformingReceptionist: didn't find a language list in the config file!!");
     
    157161    }
    158162    Document style_doc = this.converter.getDOM(new File(xslt_file), "UTF-8");
     163    if (style_doc == null) {
     164        System.err.println("TransformingReceptionist: cant parse the xslt file needed, so returning the original page!");
     165        return page;
     166       
     167    }
    159168
    160169    // look for the format element in the page response
     
    166175        // need to transform the format info
    167176        String stylesheet_file = GSFile.stylesheetFile((String)this.config_params.get(GSConstants.GSDL3_HOME), (String)this.config_params.get(GSConstants.SITE_NAME), collection, (String)this.config_params.get(GSConstants.INTERFACE_NAME), base_interfaces,   "config_format.xsl");
    168         Document stylesheet = this.converter.getDOM(new File(stylesheet_file));
    169         Document format_doc = this.converter.newDOM();
    170         format_doc.appendChild(format_doc.importNode(format_elem, true));
    171         Element new_format = (Element)this.transformer.transform(stylesheet, format_doc);
     177        Document stylesheet_doc = this.converter.getDOM(new File(stylesheet_file));
     178        if (stylesheet_doc != null) {
     179        Document format_doc = this.converter.newDOM();
     180        format_doc.appendChild(format_doc.importNode(format_elem, true));
     181        Element new_format = (Element)this.transformer.transform(stylesheet_doc, format_doc);
    172182        ///ystem.err.println("new format elem="+this.converter.getPrettyString(new_format));
    173183       
    174184        // add it in to the main stylesheet
    175         GSXSLT.mergeStylesheets(style_doc, new_format);
     185        GSXSLT.mergeStylesheets(style_doc, new_format);
     186        } else {
     187        System.err.println("TransformingReceptionist: couldn't parse the config_format stylesheet, adding the format info as is");
     188        GSXSLT.mergeStylesheets(style_doc, format_elem);
     189        }
    176190        ///ystem.out.println("the converted stylesheet is:");
    177191        ///ystem.out.println(this.converter.getPrettyString(style_doc.getDocumentElement()));
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/CollectionManager.java

    r8969 r9874  
    216216      GS3SQLSelect select = new GS3SQLSelect("build");
    217217      select.addField("*");
    218       this.database.execute(select.toString());
    219       ResultSet results = this.database.getResultSet();
    220       if (results != null &&
    221       results.first()) {
     218      Statement statement = this.database.createStatement();
     219      ResultSet results = statement.executeQuery(select.toString());
     220      if (results.first()) {
    222221    System.out.println("Reading all keys");
    223222    do {
     
    238237    } while (results.next());
    239238      }
     239      statement.close();
    240240    }
    241241    catch (SQLException ex)
     
    479479   
    480480    // Update build date information
    481     GS3SQLDelete remove = new GS3SQLDelete("build");
    482     //    GS3SQLWhere where = new GS3SQLWhere(new GS3SQLWhereItem("buildKey", "=", "NextSeqNo"));
    483     //    rem
    484     this.database.execute(remove.toString());
    485    
    486     GS3SQLInsert insert = new GS3SQLInsert("build");
    487     insert.addValue("buildKey", "NextSeqNo");
    488     insert.addValue("buildValue", Integer.toString(this.buildDocNo));
    489     this.database.execute(insert.toString());
    490    
    491     insert = new GS3SQLInsert("build");
    492     insert.addValue("buildKey", "lastBuildDate");
    493     insert.addValue("buildValue", getDateString(this.lastBuildDate));
    494     this.database.execute(insert.toString());
    495 
     481    try {
     482      GS3SQLDelete remove = new GS3SQLDelete("build");
     483      //    GS3SQLWhere where = new GS3SQLWhere(new GS3SQLWhereItem("buildKey", "=", "NextSeqNo"));
     484      //    rem
     485      Statement statement = this.database.createStatement();
     486      statement.execute(remove.toString());
     487     
     488      GS3SQLInsert insert = new GS3SQLInsert("build");
     489      insert.addValue("buildKey", "NextSeqNo");
     490      insert.addValue("buildValue", Integer.toString(this.buildDocNo));
     491      statement.execute(insert.toString());
     492   
     493      insert = new GS3SQLInsert("build");
     494      insert.addValue("buildKey", "lastBuildDate");
     495      insert.addValue("buildValue", getDateString(this.lastBuildDate));
     496      statement.execute(insert.toString());
     497      statement.close();
     498    } catch (SQLException e) {
     499    System.err.println("CollectionManager.endBuild(): Can't update build information: "+e);
     500    }
     501   
    496502    // Do tail of build output
    497503    Date startDate = this.lastBuildDate.getTime();
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/Create.java

    r8497 r9874  
    4848
    4949    System.err.println("New collection created in "+coll_home);
    50     System.err.println("Put source documents into import, set the collection's configuration in etc/collectionConfig.xml, then run gs3-build.sh to build the collection");
     50    System.err.println("Put source documents into import, set the collection's configuration in etc/collectionConfig.xml, then run gs3-build.sh (linux) or gs3-build (windows) to build the collection");
    5151    }
    5252
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/classifier/AZListClassifier.java

    r8742 r9874  
    99import java.sql.ResultSet;
    1010import java.sql.SQLException;
     11import java.sql.Statement;
    1112
    1213import org.xml.sax.XMLReader;
     
    189190    select.setWhere(where);
    190191
    191     connection.execute(select.toString());
    192192
    193193    try {
    194       ResultSet results = connection.getResultSet();
    195       if (results != null && results.first()) {
     194      Statement statement = connection.createStatement();
     195      ResultSet results = statement.executeQuery(select.toString());
     196      if (results.first()) {
    196197    GS3SQLUpdate update = new GS3SQLUpdate("classifiers");
    197198    update.setWhere(where);
     
    206207
    207208    action = insert;
     209    classifyRef = -1;
    208210      }
    209211      action.addValue("ClassifyID", label);
     
    213215      action.addValue("NumLeafDocs", Integer.toString(noOfLeafDocs), GS3SQLField.INTEGER_TYPE);
    214216
    215       connection.execute(action.toString());
    216       classifyRef = -1;
    217     }
    218     catch (SQLException sqlEx) {
    219       System.err.println(sqlEx);
    220       return -1;
    221     }
    222 
    223     // get the ClassifyRef if we don't already have it (have done a
    224     // insert action above)...
    225     if (classifyRef == -1) {
    226       connection.execute(select.toString());
    227      
    228       try {
    229     ResultSet results = connection.getResultSet();
    230     if (results == null || !results.first()) {
     217      // do the update/insert
     218      statement.execute(action.toString());
     219
     220
     221      // get the ClassifyRef if we don't already have it (have done a
     222      // insert action above)...
     223      if (classifyRef == -1) {
     224    results = statement.executeQuery(select.toString());
     225    if (!results.first()) {
    231226      return -1;
    232227    }
     
    234229    classifyRef = results.getInt("ClassifyRef");
    235230      }
    236       catch (SQLException sqlEx) {
    237     System.err.println(sqlEx);
     231     
     232      statement.close();
     233    }  catch (SQLException sqlEx) {
     234    System.err.println("AZListClassifier.writeSQLClassifyNode(): "+sqlEx);
    238235    return -1;
    239       }
    240     }
     236    }
     237 
    241238
    242239    return classifyRef;
     
    274271    }
    275272
     273    try {
     274    Statement statement = connection.createStatement();
     275   
    276276    List children;
    277277   
     
    292292        Iterator iterator = childDocs.iterator();
    293293    int childOrder = 1;
     294    //St
    294295    while (iterator.hasNext()) {
    295296      AZDocumentItem documentItem = (AZDocumentItem) iterator.next();
     
    301302      insert.addValue("DocOrder", Integer.toString(childOrder), GS3SQLField.INTEGER_TYPE);   
    302303
    303       connection.execute(insert.toString());
     304      statement.execute(insert.toString());
    304305
    305306      childOrder ++;
     
    310311    }
    311312
     313   
    312314    /*
    313315    else {
     
    318320      delete.setWhere(where);
    319321
    320       connection.execute(delete.toString());
     322      statement.execute(delete.toString());
    321323    }
    322324
     
    331333    }
    332334    */
     335    statement.close();
     336    } catch (SQLException e) {
     337    System.err.println("AZListClassifier.writeSQL(): "+e);
     338    return false;
     339    }
    333340
    334341    return true;
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/classifier/AbstractHierarchyNode.java

    r8742 r9874  
    77import java.sql.ResultSet;
    88import java.sql.SQLException;
     9import java.sql.Statement;
    910
    1011import org.greenstone.gsdl3.gs3build.doctypes.DocumentID;
     
    273274    GS3SQLInsert insert;
    274275
     276    Statement statement;
     277    // can we connect to the database?
     278    try {
     279    statement = connection.createStatement();
     280    } catch (SQLException e) {
     281    System.err.println("AbstractHierarchyNode.writeSQL(): "+e);
     282    return false;
     283    }
     284   
    275285    // Get own full id
    276286    String fullId = this.id.length() > 0 ? this.prefix+"."+this.id : this.prefix;
     
    283293    select.setWhere(where);
    284294
    285     connection.execute(select.toString());
    286295
    287296    // update or insert the classifier as required
    288297    try {
    289       ResultSet results = connection.getResultSet();
    290       if (results != null && results.first()) {
     298      ResultSet results = statement.executeQuery(select.toString());
     299      if (results.first()) {
    291300    GS3SQLUpdate update = new GS3SQLUpdate("classifiers");
    292301    update.setWhere(where);
     
    313322
    314323    action = insert;
     324    classifyRef = -1;
    315325      }
    316326      action.addValue("ClassifyID", fullId);
     
    331341      action.addValue("NumLeafDocs", Integer.toString(this.noOfLeafDocs()), GS3SQLField.INTEGER_TYPE);
    332342
    333       connection.execute(action.toString());
    334       classifyRef = -1;
     343      statement.execute(action.toString());
    335344    }
    336345    catch (SQLException sqlEx) {
    337346      if (action == null) {
    338     System.err.println(sqlEx);
     347    System.err.println("AbstractHierarchyNode.writeSQL(): "+sqlEx);
    339348      }
    340349      else {
    341     System.err.println(sqlEx + " " + action.toString());
     350    System.err.println("AbstractHierarchyNode.writeSQL(): "+sqlEx + " " + action.toString());
    342351      }
    343352      return false;
     
    347356    // insert action above)...
    348357    if (classifyRef == -1) {
    349       connection.execute(select.toString());
    350      
    351358      try {
    352     ResultSet results = connection.getResultSet();
    353     if (results == null || !results.first()) {
    354       return false;
     359        ResultSet results = statement.executeQuery(select.toString());
     360    if (!results.first()) {
     361        statement.close();
     362        return false;
    355363    }
    356364   
    357365    classifyRef = results.getInt("ClassifyRef");
     366   
    358367      }
    359368      catch (SQLException sqlEx) {
    360     System.err.println(sqlEx);
     369    System.err.println("AbstractHierarchyNode.writeSQL(): "+sqlEx);
    361370    return false;
    362371      }
     
    368377      GS3SQLDelete delete = new GS3SQLDelete("classdocuments");
    369378      delete.setWhere(where);
    370 
    371       connection.execute(delete.toString());
    372     }
    373 
     379      try {
     380      statement.execute(delete.toString());
     381      } catch (SQLException e) {
     382      System.err.println("AbstractHierarchyNode.writeSQL(): "+e);
     383      return false;
     384      }
     385    }
     386   
    374387    // post the child nodes...
    375388    Iterator iterator = this.childNodes.iterator();
     
    379392      if (!childNode.writeSQL(connection)) {
    380393      System.out.println("Failed to write " );
    381     return false;
     394      return false;
    382395      }
    383396    }
     
    394407      insert.addValue("DocID", docId.toString());
    395408      insert.addValue("DocOrder", Integer.toString(order), GS3SQLField.INTEGER_TYPE);
    396 
    397       connection.execute(insert.toString());
    398 
     409      try {
     410      statement.execute(insert.toString());
     411      } catch (SQLException e) {
     412      System.err.println("AbstractHierarchyNode.writeSQL(): "+e);
     413      return false;
     414      }
    399415      order ++;
    400416    }
     417    // close the statment
     418    try {
     419    statement.close();
     420    } catch (SQLException e) {
     421    System.err.println("AbstractHierarchyNode.writeSQL(): "+e);
     422    }
     423
    401424    return true;
    402425  }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/database/GS3SQLConnection.java

    r8773 r9874  
    1414{
    1515
    16     public GS3SQLConnection(java.sql.Connection connection)
     16    public GS3SQLConnection(java.sql.Connection connection, String database)
    1717    {
    18     super(connection);
     18    super(connection, database);
    1919    }
    2020   
     
    2525  }
    2626   
    27 
     27    public GS3SQLConnection cloneConnection() {
     28    GS3SQLConnection conn = GS3SQLConnectionFactory.getGS3SQLConnection(this.database);
     29    return conn;
     30    }
    2831  /**
    2932   *  Initialise a collection for use.
     
    6265     
    6366    try {
    64       statement = this.connection.createStatement();
     67      Statement statement = this.connection.createStatement();
    6568
    6669      // create build history table
     
    224227      statement.execute(classData.toString());
    225228
     229      statement.close();
    226230      //
    227231      // END OF GSDL TABLES
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/database/GS3SQLConnectionFactory.java

    r8745 r9874  
    3232        return null;
    3333    }
    34     return new SQLConnection(c);
     34    return new SQLConnection(c, database);
    3535    }
    3636
     
    4242        return null;
    4343    }
    44     return new GS3SQLConnection(c);
     44    return new GS3SQLConnection(c, database);
    4545    }
    4646
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/database/SQLConnection.java

    r8745 r9874  
    1010{
    1111    protected Connection connection;
    12     protected Statement  statement;
    13 
    14 
    15     public SQLConnection(java.sql.Connection connection)
     12    protected String database;
     13   
     14    public SQLConnection(java.sql.Connection connection, String database)
    1615    {
    1716    this.connection = connection;
     17    this.database = database;
    1818    }
    1919   
     
    2121    if (this.connection!=null) {
    2222        try {
    23         this.connection.close();
     23        this.connection.close();       
    2424        } catch (Exception e) {}
    25        
    26         this.connection = null;
    27     }
     25    }   
     26    this.connection = null;   
    2827    }
    2928   
    30     public boolean execute(String sql)
    31     {
    32     try {
    33         this.statement = this.connection.createStatement();
    34         this.statement.execute(sql);
    35     }
    36     catch (SQLException ex) {
    37         System.out.println(ex);
    38         return false;
    39     }
    40     return true;
     29    public void close() {
     30    finalize();
    4131    }
    4232   
    43     public Statement createStatement()
     33    public Statement createStatement() throws SQLException
    4434    {
    45     try {
    46         return this.connection.createStatement();
    47     }
    48     catch (SQLException ex) {
    49         return null;
    50     }
    51     }
    52    
    53     public Statement getStatement()
    54     {
    55     return this.statement;
    56     }
    57    
    58     public ResultSet getResultSet()
    59     {
    60     try {
    61         return this.statement.getResultSet();
    62     }
    63     catch (SQLException ex) {
    64         return null;
    65     }
     35    return this.connection.createStatement();
    6636    }
    6737   
    6838    public boolean connectToDatabase(String database) {
     39    if (this.connection != null) {
     40        try {
     41        this.connection.close();
     42        } catch (Exception e) {}
     43    }
    6944    this.connection = GS3SQLConnectionFactory.getConnection(database);
    7045    if (this.connection == null) {
    7146        return false;
    7247    }
     48    this.database = database;
    7349    return true;
    7450    }
     
    7652    public boolean dropDatabase(String database) {
    7753    try {
    78         this.statement = this.connection.createStatement();
    79         this.statement.execute("DROP DATABASE "+database+";");
     54        Statement statement = this.connection.createStatement();
     55        statement.execute("DROP DATABASE "+database+";");
     56        statement.close();
    8057    }
    8158    catch (SQLException ex){
     
    9067    try {
    9168        String command = "CREATE DATABASE " + database;
    92         this.statement = this.connection.createStatement();
    93         this.statement.execute(command);
     69        Statement statement = this.connection.createStatement();
     70        statement.execute(command);
     71        statement.close();
    9472    } catch (Exception e) {
    9573        System.err.println(e);
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/AbstractDocument.java

    r8742 r9874  
    99
    1010import java.sql.SQLException;
     11import java.sql.Statement;
    1112import java.sql.ResultSet;
    1213import java.sql.Timestamp;
     
    190191    // Query for documents using the same file...
    191192    String query = "SELECT DocID FROM files INNER JOIN filegroups ON files.FileGroupRef=filegroups.FileGroupRef WHERE (filegroups.FileGroupId=\"default\" AND files.FileLocation=\"" + this.fileSet.getFile(0).getLocation().toString() + "\")";
    192     connection.execute(query);
    193 
    194     List docs = new ArrayList();
    195     ResultSet results = connection.getResultSet();
    196 
    197193    try {
    198       if (results != null &&
    199       results.first())
    200       { do {
    201           String value = results.getString("DocID");
    202 
    203       docs.add(value);
    204         } while (results.next());
    205 
    206         Iterator docIterator = docs.iterator();
    207     while (docIterator.hasNext()) {
    208       String docId = docIterator.next().toString();
    209       String innerQuery = "SELECT * FROM document WHERE DocID=\"" + docId + "\"";
    210       connection.execute(innerQuery);
    211       ResultSet innerSet = connection.getResultSet();
    212       if (innerSet != null && innerSet.first()) {
    213         String docType = innerSet.getString("DocType");
    214         if (docType.equals(this.getDocumentType())) {
    215           return docId;
     194    Statement statement = connection.createStatement();
     195    ResultSet results = statement.executeQuery(query);
     196
     197    List docs = new ArrayList();
     198
     199    if (results.first()) {
     200        do {
     201        String value = results.getString("DocID");     
     202        docs.add(value);
     203        } while (results.next());
     204       
     205        Iterator docIterator = docs.iterator();
     206        while (docIterator.hasNext()) {
     207        String docId = docIterator.next().toString();
     208        String innerQuery = "SELECT * FROM document WHERE DocID=\"" + docId + "\"";
     209        results = statement.executeQuery(innerQuery);
     210        if (results.first()) {
     211            String docType = results.getString("DocType");
     212            if (docType.equals(this.getDocumentType())) {
     213            return docId;
     214            }
     215        }
    216216        }
    217       }
    218217    }
    219       }
     218    statement.close();
    220219    }
    221220    catch (java.sql.SQLException sqlEx) {
    222       System.err.println(sqlEx);
     221      System.err.println("AbstractDocument.getDuplicateID(): "+sqlEx);
    223222    }
    224223
     
    447446   *  Obtain a document from the SQL database
    448447   */
    449   public static AbstractDocument readSQL(GS3SQLConnection connection, ResultSet sqlResult)
     448    public static AbstractDocument readSQL(GS3SQLConnection connection, ResultSet sqlResult)
    450449  { try {
    451450      DocumentID id = new DocumentID(sqlResult.getString("DocID"));
     
    454453      // Use a factory method to create the correct subtype...
    455454      AbstractDocument document = DocumentFactory.createDocument(type, id);
    456 
    457455      // Append the document date information
    458456      document.indexDate    = sqlResult.getTimestamp("IndexedDate");
     
    473471    }
    474472    catch (SQLException sqlEx) {
    475       System.out.println("Failure to load document: " + sqlEx);
     473      System.err.println("AbstractDocument.readSQL(): Failure to load document: " + sqlEx);
    476474    }
    477475    return null;
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/DocumentFactory.java

    r8742 r9874  
    22
    33import java.sql.SQLException;
     4import java.sql.Statement;
    45import java.sql.ResultSet;
    56import java.net.URL;
     
    6162  {
    6263    String query = "SELECT * FROM document WHERE DocID=\""+id.toString()+"\";";
    63     connection.execute(query);
    64 
    6564    try {
    66       ResultSet results = connection.getResultSet();
    67       if (results != null && results.first()) {
    68     return AbstractDocument.readSQL(connection, results);
    69       }
     65    Statement statement = connection.createStatement();
     66    ResultSet results = statement.executeQuery(query);
     67   
     68    DocumentInterface di = null;
     69    if (results.first()) {
     70        di = AbstractDocument.readSQL(connection, results);
     71    }
     72    statement.close();
     73    return di;
    7074    }
    7175    catch (SQLException sqlEx) {
    72       System.err.println(sqlEx);
     76      System.err.println("AbstractDocument.readSQLDocument():"+sqlEx);
    7377    }
    7478    return null;
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/DocumentList.java

    r8861 r9874  
    1313
    1414import java.sql.SQLException;
     15import java.sql.Statement;
    1516import java.sql.ResultSet;
    1617
     
    6869    select.setWhere(where);
    6970
    70     this.connection.execute(select.toString());
    71 
    72     ResultSet results = this.connection.getResultSet();
    73     if (results != null) {
    74       select = new GS3SQLSelect("filegroups");
    75       select.addField("DocID");
    76       select.setDistinct(true);
    77      
    78       where = new GS3SQLWhere();
    79       where.setCondition(GS3SQLWhere.OR_CONDITION);
    80 
    81       GS3SQLWhereItem whereItem = null;
    82 
    83       try {
    84     results.first();
     71    try {
     72    Statement statement = connection.createStatement();
     73    ResultSet results = statement.executeQuery(select.toString());
     74   
     75    select = new GS3SQLSelect("filegroups");
     76    select.addField("DocID");
     77    select.setDistinct(true);
     78     
     79    where = new GS3SQLWhere();
     80    where.setCondition(GS3SQLWhere.OR_CONDITION);
     81   
     82    GS3SQLWhereItem whereItem = null;
     83
     84        results.first();
    8585    do {
    8686      int fileGroupRef = results.getInt("FileGroupRef");
     
    9090    while (results.next());
    9191    select.setWhere(where);
    92     results.close();
    93    
    94     this.connection.execute(select.toString());
    95    
    96     results = this.connection.getResultSet();
     92   
     93    results = statement.executeQuery(select.toString());
     94   
    9795    results.first();
    9896    do {
     
    10098      reply.add(docId);
    10199    } while (results.next());
    102       }
    103       catch (SQLException sqlEx)
    104       { System.err.println(sqlEx);
    105       }
    106     }
     100    statement.close();
     101    }
     102    catch (SQLException sqlEx) {
     103    System.err.println("DocumentList.getDocumentIdsWithFile(): "+sqlEx);
     104    }
     105   
    107106    return reply;
    108107  }
     
    173172  }
    174173
    175   private List findDocumentIdsUsingFileQuery(String query)
    176   { this.connection.execute(query);
    177 
    178     try {
    179 
    180       ResultSet results = this.connection.getResultSet();
    181       if (results == null ||
    182       !results.first()) {
    183     return null;
    184       }
     174    private List findDocumentIdsUsingFileQuery(String query) {
     175   
     176    try {
     177   
     178    Statement statement = connection.createStatement();
     179    ResultSet results = statement.executeQuery(query);
     180
     181    if (!results.first()) {
     182        statement.close();
     183        return null;
     184    }
    185185     
    186186      // get a list of group ids first and turn it into a query on filegroups
     
    207207      // structures...recreating new filegroup queries as necessary
    208208      while (queryBuffer.length() > 0) {
    209     connection.execute(queryBuffer.toString());
    210    
    211     results = this.connection.getResultSet();
    212     if (results == null || !results.first()) {
    213       return null;
     209    results = statement.executeQuery(queryBuffer.toString());
     210   
     211    if (!results.first()) {
     212        statement.close();
     213        return null;
    214214    }
    215215   
     
    256256     
    257257      // execute the division query
    258       this.connection.execute(queryBuffer.toString());
    259      
    260       results = this.connection.getResultSet();
    261       if (results == null ||
    262       !results.first()) {
    263     return null;
     258      results = statement.executeQuery(queryBuffer.toString());
     259     
     260      if (!results.first()) {
     261      statement.close();
     262      return null;
    264263      }
    265264
     
    268267    reply.add(results.getString("DocID"));
    269268      } while (results.next());
    270 
     269     
     270      statement.close();
    271271      return reply;
    272272    }
    273273    catch (SQLException ex) {
    274       System.err.println(ex);
     274      System.err.println("DocumentList.findDocumentIdsUsingFileQuery()"+ ex);
    275275    }
    276276    return null;
     
    454454    select.addField("*");
    455455   
    456     ResultSet documents;
    457456    try {
    458       connection.execute(select.toString());
    459       documents = connection.getResultSet();
    460 
    461       if (documents.first())
    462       { do
    463     { DocumentInterface document = AbstractDocument.readSQL(connection, documents);
    464           list.addDocument(document);
    465     }
    466     while (documents.next());
    467       }
    468     }
    469     catch (java.sql.SQLException ex)
    470     { System.out.println(ex);
    471       return null;
     457    Statement statement = connection.createStatement();
     458    ResultSet documents = statement.executeQuery(select.toString());
     459    if (documents.first()) {
     460        do {
     461        DocumentInterface document = AbstractDocument.readSQL(connection, documents);
     462        list.addDocument(document);
     463        }
     464        while (documents.next());
     465    }
     466    statement.close();
     467    }
     468    catch (java.sql.SQLException ex) {
     469    System.out.println("DocumentList.writeSQLDocuments(): "+ex);
     470    return null;
    472471    }
    473472
     
    487486{
    488487  private boolean hasNext;
     488  private Statement statement;
    489489  private ResultSet resultSet;
    490490  private GS3SQLConnection connection;
     
    498498
    499499    try {
    500       connection.execute(select.toString());
    501       this.resultSet = connection.getResultSet();
     500    this.statement = connection.createStatement();
     501      this.resultSet = statement.executeQuery(select.toString());
    502502      this.hasNext = this.resultSet.first();
    503503    } catch (SQLException ex) {
     504      System.err.println("DocumentListIterator(): "+ex);
    504505      this.hasNext = false;
    505506    }
     
    520521
    521522      if (!this.hasNext) {
    522     this.resultSet.close(); // be a good citizen & close used result sets
     523      this.statement.close(); // be a good citizen & close used statement
    523524      }
    524525    } catch (SQLException ex) {
     526    System.err.println("DocumentList.iterator.next(): "+ex);
    525527      this.hasNext = false;
    526528    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/DocumentSQLWriter.java

    r8742 r9874  
    1919    update.addDate("IndexedDate", new java.sql.Timestamp(touchTime));
    2020    update.addDate("ModifiedDate", new java.sql.Timestamp(modTime));
    21     connection.execute(update.toString());
     21    try {
     22    Statement statement = connection.createStatement();
     23    statement.execute(update.toString());
     24    statement.close();
     25    } catch (SQLException e) {
     26    System.err.println("DocumentSQLWriter.touchDocument() Error: "+ e);
     27    return false;
     28    }
    2229    System.out.println(update.toString());
    2330    return true;
     
    3946    select.addField("*");
    4047    select.setWhere(new GS3SQLWhere(new GS3SQLWhereItem("DocID", "=", document.getID().toString())));
    41     connection.execute(select.toString());
    4248   
    43     ResultSet results = connection.getResultSet();
    44 
    45     if (results == null ||
    46         !results.first())
    47     { GS3SQLInsert insert = new GS3SQLInsert("document");
     49    Statement statement = connection.createStatement();
     50    ResultSet results = statement.executeQuery(select.toString());
     51    if (!results.first()) { // empty result
     52      GS3SQLInsert insert = new GS3SQLInsert("document");
    4853      insert.addValue("DocID", document.getID().toString());
    4954      insert.addValue("DocType", document.getDocumentType());
     
    5358      insert.addDate("ModifiedDate", new java.sql.Timestamp(document.getModifiedDatestamp()));
    5459
    55       connection.execute(insert.toString());
     60      statement.execute(insert.toString());
    5661    }
    5762    else {
     
    6166      //      connection.execute(update.toString());
    6267    }
     68    statement.close();
    6369      }
    64     } catch (Exception ex) {
    65     System.out.println(ex);
     70    } catch (SQLException ex) {
     71    System.out.println("DocumentSQLWriter.writeDocument() Error:"+ex);
    6672    }
    6773    //    output.println(tag);
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/HTMLDocument.java

    r8929 r9874  
    279279    public Document getDOMDocument()
    280280    {   
    281     if (this.domDocument == null) {
     281      if (this.domDocument == null) {
    282282      URL     url =(URL) this.fileSet.getFile(0).getLocation();
    283283      this.loadDocument(url);
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/indexers/MGPPIndexer.java

    r9006 r9874  
    175175    {
    176176    if (this.pass == 0) {
    177         document.removeAllMetadata("gsdl3", "mgppseqno");
     177        document.removeAllMetadata("gsdl3", "mgseqno");
    178178    }
    179179
     
    188188    String docText = null;
    189189   
    190     int startSeqNo = this.sectionSeqNo;
    191     this.sectionSeqNo ++;
    192    
     190    //int startSeqNo = this.sectionSeqNo;
     191    //this.sectionSeqNo ++;
     192    int startSeqNo = this.documentSeqNo;
     193
    193194    Document domDocument = document.getDOMDocument();
    194195    if (domDocument != null) {
     
    288289
    289290    if (this.pass == 0) {   
    290         document.addDocumentMetadata("gsdl3", "mgppseqno", "dtx."+Integer.toString(startSeqNo));
    291     }
    292     this.documentSeqNo += 1;
     291        document.addDocumentMetadata("gsdl3", "mgseqno", "dtx."+Integer.toString(startSeqNo));
     292    }
     293    this.documentSeqNo++;
    293294   
    294295//  try {
     
    317318    this.firstDocument = true;
    318319    this.documentSeqNo = 1;
    319    
     320    this.sectionSeqNo = 1;
     321
    320322    this.mgppPasses = new MGPPPassesWrapper();
    321323    this.indexBuffer = new StringBuffer();
     
    430432        System.out.println("Compressed dictionary successfully written");
    431433        } else {
    432         System.err.println("Error from mg_compression_dict: " + exit_value);
    433         index.setError(true);
    434        
     434        System.err.println("Error from mgpp_compression_dict: " + exit_value);
     435        //index.setError(true);
    435436        return false;
    436437        }
     
    444445        } else {
    445446        System.err.println("Unable to build the perfect hash");
    446         index.setError(true);
     447        //index.setError(true);
    447448        return false;
    448449        }
     
    456457        } else {
    457458        System.err.println("Unable to create weights file");
    458         index.setError(true);
     459        //index.setError(true);
    459460        return false;
    460461        }
     
    466467        } else {
    467468        System.out.println("Unable to create inverted dictionary file");
    468         index.setError(true);
     469        //index.setError(true);
    469470        return false;
    470471        }
     
    476477        } else {
    477478        System.out.println("Unable to create stemmed index 1");
    478         index.setError(true);
     479        //index.setError(true);
    479480        return false;
    480481        }
     
    485486        } else {
    486487        System.out.println("Unable to create stemmed index 2");
    487         index.setError(true);
     488        //index.setError(true);
    488489        return false;
    489490        }
     
    493494        } else {
    494495        System.out.println("Unable to create stemmed index 3");
    495         index.setError(true);
     496        //index.setError(true);
    496497        return false;
    497498        }
     
    553554    Element default_index = doc.createElement("defaultIndex");
    554555    default_index.setAttribute(GSXML.NAME_ATT, def_index);
     556
    555557    Element base_index_name = doc.createElement("baseIndexPrefix");
    556     base_index_name.setAttribute(GSXML.NAME_ATT, "index");  //overallName);
     558    base_index_name.setAttribute(GSXML.NAME_ATT, "dtx");  //overallName);
     559
    557560    Element index_stem = doc.createElement("indexStem");
    558561    index_stem.setAttribute(GSXML.NAME_ATT, "index");
     
    561564    Element retrieve_service_elem = doc.createElement(GSXML.SERVICE_CLASS_ELEM);
    562565    Element default_level = doc.createElement("defaultLevel");
    563     default_index.setAttribute(GSXML.NAME_ATT, "Document");
     566    default_level.setAttribute(GSXML.NAME_ATT, "Document");
     567
     568    Element level_list = doc.createElement("levelList");
     569    Element level = doc.createElement("level");
     570    level.setAttribute(GSXML.NAME_ATT, "Document");
     571    level_list.appendChild(level);
     572
     573    Element field_list = doc.createElement("fieldList");
     574    Element field = doc.createElement("field");
     575    field.setAttribute(GSXML.NAME_ATT, "ZZ");
     576    field_list.appendChild(field);
     577
    564578    service_rack_list.appendChild(search_service_elem);
    565579    service_rack_list.appendChild(retrieve_service_elem);
     
    568582    search_service_elem.appendChild(index_list);
    569583    search_service_elem.appendChild(default_index);
     584    search_service_elem.appendChild(level_list);
    570585    search_service_elem.appendChild(default_level);
     586search_service_elem.appendChild(field_list); // do we need this??
    571587    search_service_elem.appendChild(base_index_name);
    572588    search_service_elem.appendChild(index_stem);
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSDescriptive.java

    r8742 r9874  
    88
    99import java.sql.SQLException;
     10import java.sql.Statement;
    1011import java.sql.ResultSet;
    1112
     
    275276        } else {
    276277        // TODO: raise an error!
    277         System.out.println("Error: METSDescriiptive: unrecognised tag "+childName);
     278        System.out.println("Error: METSDescriptive: unrecognised tag "+childName);
    278279        }
    279280    }
     
    375376    select.setWhere(where);
    376377   
    377     connection.execute(select.toString());
    378    
    379378    try {
     379        Statement statement = connection.createStatement();
     380        ResultSet resultSet = statement.executeQuery(select.toString());
    380381        GS3SQLAction action;
    381382       
    382         ResultSet resultSet = connection.getResultSet();
    383        
    384         if (resultSet != null &&
    385         resultSet.first()) {
     383        if (resultSet.first()) {
    386384        // the node already exists - no need to do anything as such
    387385        GS3SQLUpdate update = new GS3SQLUpdate("metadata");
     
    389387        action = update;
    390388        }
    391         else
    392         { // Set result set to null, just in case next() didn't work above...
    393             resultSet = null;
    394            
    395             // It is a new node and needs writing
    396             action = new GS3SQLInsert("metadata");
    397            
    398             action.addValue("DocID", document.getID().toString());
    399             action.addValue("MetaID", this.ID);
    400         }
     389        else { // Set result set to null, just in case first() didn't work above...
     390        // It is a new node and needs writing
     391        action = new GS3SQLInsert("metadata");
     392       
     393        action.addValue("DocID", document.getID().toString());
     394        action.addValue("MetaID", this.ID);
     395        }
    401396       
    402397        // always set the group identifier
     
    404399       
    405400        // execute the action as required
    406         connection.execute(action.toString());
    407        
    408         // create a new resultset if necessary
    409         if (resultSet == null) {
    410         // now execute the select statement again to get the new identifier
    411         // 'MetadataRef'
    412         // System.out.println(select.toString());
    413         connection.execute(select.toString());
    414        
    415         resultSet = connection.getResultSet();
    416         resultSet.first();
    417         }
    418        
    419         // get the reference for this item...
    420         sqlId = resultSet.getInt("MetadataRef");
     401        statement.execute(action.toString());
     402       
     403        // get the resultSet again
     404        // now execute the select statement again to get the new identifier
     405        // 'MetadataRef'
     406        // System.out.println(select.toString());
     407        resultSet = statement.executeQuery(select.toString());
     408       
     409        if (resultSet.first()) {
     410        // get the reference for this item...
     411        sqlId = resultSet.getInt("MetadataRef");
     412        }
     413        statement.close();
    421414    }
    422415    catch (SQLException sql){
    423         System.out.println(sql);
     416        System.err.println("METSDescriptive.writeSQL(): "+sql);
     417    }
     418    if (sqlId == -1) {
     419        return false;
    424420    }
    425421   
     
    471467        select.setWhere(where);
    472468       
    473         connection.execute(select.toString());
    474        
    475         // parse through the namespaces, calling the namespace class to create instances
    476         // as it will
    477         ResultSet namespaceSet = connection.getResultSet();
    478         if (namespaceSet != null && namespaceSet.first()) {
     469        Statement statement = connection.createStatement();
     470        ResultSet namespaceSet = statement.executeQuery(select.toString());
     471       
     472        // parse through the namespaces, calling the namespace class to create instances as it will
     473        if (namespaceSet.first()) {
    479474        do {
    480475            METSNamespace namespace = METSNamespace.readSQL(connection, namespaceSet);
     
    483478            }
    484479            else {
    485             System.out.println("Null namespace output");
     480            System.err.println("Null namespace output");
    486481            }
    487482        }
    488483        while (namespaceSet.next());
    489484        }
    490        
     485        statement.close();
    491486        return descriptive;
    492487    }
    493488    catch (SQLException sqlEx){
    494         System.out.println(sqlEx);
     489        System.err.println("METSDescriptive.readSQL(): "+sqlEx);
    495490        System.exit(1);
    496491    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSDescriptiveSet.java

    r8742 r9874  
    99
    1010import java.sql.SQLException;
     11import java.sql.Statement;
    1112import java.sql.ResultSet;
    1213
     
    236237    GS3SQLWhereItem whereItem = new GS3SQLWhereItem("DocID", "=", document.getID().toString());
    237238    select.setWhere(new GS3SQLWhere(whereItem));
    238     connection.execute(select.toString());
    239    
     239
    240240    // start going through the matching metadata blocks
    241241    try {
    242         ResultSet resultSet = connection.getResultSet();
    243         resultSet.first();
    244         do {
    245         METSDescriptive descriptive = METSDescriptive.readSQL(document, connection, resultSet);
    246         if (descriptive != null) {
    247             set.addDescriptive(descriptive);
    248         }
    249         else {
    250             System.out.println("Null descriptive");
    251         }
    252         } while (resultSet.next());
     242        Statement statement = connection.createStatement();
     243        ResultSet resultSet = statement.executeQuery(select.toString());
     244        if (resultSet.first()) {
     245        do {
     246            METSDescriptive descriptive = METSDescriptive.readSQL(document, connection, resultSet);
     247            if (descriptive != null) {
     248            set.addDescriptive(descriptive);
     249            }
     250            else {
     251            System.out.println("Null descriptive");
     252            }
     253        } while (resultSet.next());
     254        }
     255        statement.close();
    253256    }
    254257    catch (SQLException sqlEx) {
    255         System.out.println(sqlEx);
     258        System.err.println("METSDescriptiveSet.readSQL(): "+sqlEx);
    256259        System.exit(1);
    257260    }
    258261   
     262   
    259263    return set;
    260264    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSDivision.java

    r8742 r9874  
    1010
    1111import java.sql.SQLException;
     12import java.sql.Statement;
    1213import java.sql.ResultSet;
    1314
     
    475476    select.setWhere(where);
    476477   
    477     connection.execute(select.toString());
     478    Statement statement = null;
     479    ResultSet resultSet = null;
    478480   
    479481    // Do the actual writing
    480482    GS3SQLAction action;
    481483   
    482     ResultSet resultSet = connection.getResultSet();
    483484    try {
    484         if (resultSet == null ||
    485         !resultSet.first()) {
    486         resultSet = null;
     485        statement = connection.createStatement();
     486        resultSet = statement.executeQuery(select.toString());
     487        if (!resultSet.first()) {
    487488       
    488489        GS3SQLInsert insert = new GS3SQLInsert("divisions");
     
    499500        GS3SQLUpdate update = new GS3SQLUpdate("divisions");
    500501        GS3SQLWhere  updateWhere =
    501             new GS3SQLWhere(new GS3SQLWhereItem("DivisionRef", "=", Integer.toString(sqlRef),
    502                             GS3SQLField.INTEGER_TYPE));
     502            new GS3SQLWhere(new GS3SQLWhereItem("DivisionRef", "=", Integer.toString(sqlRef), GS3SQLField.INTEGER_TYPE));
    503503        update.setWhere(updateWhere);
    504504        action = update;
     
    515515    action.addValue("UserLabel", this.userLabel);
    516516   
    517     if (!connection.execute(action.toString())){
     517    try {
     518        statement.execute(action.toString());
     519    } catch (SQLException e) {
     520        System.err.println("METSDivision.writeSQL(): "+e);
    518521        return false;
    519522    }
    520523   
    521524    // if doing a fresh item, get the new structure reference...
    522     if (resultSet == null){
     525    if (sqlRef == -1){
    523526        // get the new structure reference
    524         connection.execute(select.toString());
    525        
    526         // get the sql reference for the division
    527527        try {
    528528        // read in the structure reference
    529         resultSet = connection.getResultSet();
    530         if (resultSet == null) {
    531             return false;
     529        resultSet = statement.executeQuery(select.toString());
     530        if (resultSet.first()) {
     531            sqlRef = resultSet.getInt("DivisionRef");
    532532        }
    533         resultSet.first();
    534         sqlRef = resultSet.getInt("DivisionRef");
    535         resultSet.close();
    536         resultSet = null;
    537533        }
    538534        catch (SQLException sqlex) {
    539         System.err.println("Unable to retrieve reference for Division " + sqlex);
     535        System.err.println("METSDIVISION.writeSQL(): Unable to retrieve reference for Division " + sqlex);
    540536        return false;
    541537        }
    542538    }
    543     // close the open resultSet, as we don't need it any longer...
    544     else {
    545         try {
    546         resultSet.close();
    547         }
    548         catch (SQLException sql) {
    549         System.err.println(sql + " " + select.toString());
    550         }
    551     }
    552539   
    553540    // delete the old file/metadata references
    554     GS3SQLWhere referenceWhere =
    555         new GS3SQLWhere(new GS3SQLWhereItem("DivisionRef", "=", Integer.toString(sqlRef),
    556                         GS3SQLField.INTEGER_TYPE));
    557    
    558     GS3SQLDelete delete = new GS3SQLDelete("divisionfilerefs");
    559     delete.setWhere(referenceWhere);
    560     connection.execute(delete.toString());
    561    
    562     delete = new GS3SQLDelete("divisionmetarefs");
    563     delete.setWhere(referenceWhere);
    564     connection.execute(delete.toString());
    565    
    566     // write the new file references
    567     if (this.fileRefs.size() > 0){
    568         Iterator iterator = this.fileRefs.iterator();
    569        
    570         while (iterator.hasNext()) {
    571         GS3SQLInsert fileinsert = new GS3SQLInsert("divisionfilerefs");
    572         fileinsert.addValue("DocID", docId.toString());
    573         fileinsert.addValue("DivisionRef", Integer.toString(sqlRef), GS3SQLField.INTEGER_TYPE);
    574         fileinsert.addValue("DivisionType", "Group");
    575         fileinsert.addValue("FileID", iterator.next().toString());
    576         connection.execute(fileinsert.toString());
    577         }
    578     }
    579    
    580     // write the metadata references
    581     if (this.metadataRefs.size() > 0){
    582         Iterator iterator = this.metadataRefs.iterator();
    583        
    584         while (iterator.hasNext()) {
    585         GS3SQLInsert metainsert = new GS3SQLInsert("divisionmetarefs");
    586         metainsert.addValue("DocID", docId.toString());
    587         metainsert.addValue("DivisionRef", Integer.toString(sqlRef), GS3SQLField.INTEGER_TYPE);
    588         metainsert.addValue("DivisionType", "Group");
    589         metainsert.addValue("MetaID", iterator.next().toString());
    590         connection.execute(metainsert.toString());
    591         }
    592     }
    593    
     541    try {
     542        GS3SQLWhere referenceWhere =
     543        new GS3SQLWhere(new GS3SQLWhereItem("DivisionRef", "=", Integer.toString(sqlRef),
     544                            GS3SQLField.INTEGER_TYPE));
     545       
     546        GS3SQLDelete delete = new GS3SQLDelete("divisionfilerefs");
     547        delete.setWhere(referenceWhere);
     548       
     549        statement.execute(delete.toString());
     550       
     551        delete = new GS3SQLDelete("divisionmetarefs");
     552        delete.setWhere(referenceWhere);
     553        statement.execute(delete.toString());
     554   
     555        // write the new file references
     556        if (this.fileRefs.size() > 0){
     557        Iterator iterator = this.fileRefs.iterator();
     558       
     559        while (iterator.hasNext()) {
     560            GS3SQLInsert fileinsert = new GS3SQLInsert("divisionfilerefs");
     561            fileinsert.addValue("DocID", docId.toString());
     562            fileinsert.addValue("DivisionRef", Integer.toString(sqlRef), GS3SQLField.INTEGER_TYPE);
     563            fileinsert.addValue("DivisionType", "Group");
     564            fileinsert.addValue("FileID", iterator.next().toString());
     565            statement.execute(fileinsert.toString());
     566        }
     567        }
     568       
     569        // write the metadata references
     570        if (this.metadataRefs.size() > 0){
     571        Iterator iterator = this.metadataRefs.iterator();
     572       
     573        while (iterator.hasNext()) {
     574            GS3SQLInsert metainsert = new GS3SQLInsert("divisionmetarefs");
     575            metainsert.addValue("DocID", docId.toString());
     576            metainsert.addValue("DivisionRef", Integer.toString(sqlRef), GS3SQLField.INTEGER_TYPE);
     577            metainsert.addValue("DivisionType", "Group");
     578            metainsert.addValue("MetaID", iterator.next().toString());
     579            statement.execute(metainsert.toString());
     580        }
     581        }
     582        statement.close();
     583    } catch (SQLException e) {
     584        System.err.println("METSDIVISION.writeSQL(): "+e);
     585        return false;
     586    }
    594587    // write out any children in turn
    595588    Iterator groups = this.children.values().iterator();
     
    633626        select.setWhere(where);
    634627
    635         connection.execute(select.toString());
     628        Statement statement = connection.createStatement();
     629        ResultSet childSet = statement.executeQuery(select.toString());
    636630     
    637631        // circulate through to obtain further children
    638         ResultSet childSet = connection.getResultSet();
    639632        if (childSet.first())
    640633        {
     
    645638            while (childSet.next());
    646639        }
    647 
    648640        select = new GS3SQLSelect("divisionfilerefs");
    649641        select.addField("*");
     
    652644        select.setWhere(where);
    653645
    654         connection.execute(select.toString());
    655 
    656         ResultSet fileSet = connection.getResultSet();
    657         if (fileSet != null && fileSet.first()){
     646        ResultSet fileSet = statement.executeQuery(select.toString());
     647
     648        if (fileSet.first()){
    658649        do {
    659650            String reference = fileSet.getString("FileID");
     
    662653        while (fileSet.next()); 
    663654        }
    664 
     655       
    665656        select = new GS3SQLSelect("divisionmetarefs");
    666657        select.addField("*");
     
    669660        select.setWhere(where);
    670661
    671         connection.execute(select.toString());
    672 
    673         ResultSet metaSet = connection.getResultSet();
    674         if (metaSet != null && metaSet.first()){
     662        ResultSet metaSet = statement.executeQuery(select.toString());
     663
     664        if (metaSet.first()){
    675665        do {
    676666            String reference = metaSet.getString("MetaID");
     
    680670        }
    681671       
     672        statement.close();
    682673        return division;
    683674    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFile.java

    r8742 r9874  
    1111import java.sql.ResultSet;
    1212import java.sql.SQLException;
     13import java.sql.Statement;
    1314
    1415import org.w3c.dom.Document;
     
    201202    where.add(whereItem);
    202203    select.setWhere(where);
    203     connection.execute(select.toString());
     204
     205    Statement statement = null;
    204206   
    205207    // if not, then make an insert action
    206208    try {
    207         ResultSet results = connection.getResultSet();
    208         if (results == null ||
    209         !results.first()){
     209        statement = connection.createStatement();
     210        ResultSet results = statement.executeQuery(select.toString());
     211        if (!results.first()){
    210212        GS3SQLInsert insert = new GS3SQLInsert("files");
    211213       
     
    223225    }
    224226    catch (SQLException ex){
    225         System.err.println(ex);
     227        System.err.println("METSFile.writeSQL(): "+ex);
    226228        return false;
    227229    }
     
    230232    action.addValue("MIMEType", this.MIMEType);
    231233   
    232     return connection.execute(action.toString());
     234    try {
     235        statement.execute(action.toString());
     236        statement.close();
     237       
     238    } catch (SQLException e) {
     239        System.err.println("METSFile.writeSQL():"+e);
     240        return false;
     241    }
     242    return true;
    233243    }
    234244   
     
    248258    }
    249259    catch (SQLException ex){
    250         System.out.println(ex);
     260        System.out.println("METSFile.readSQL(): "+ex);
    251261    }
    252262    catch (java.net.MalformedURLException urlEx){
    253         System.out.println(urlEx);
     263        System.out.println("METSFile.readSQL(): "+urlEx);
    254264    }
    255265    return null;
     
    309319    } catch (java.net.MalformedURLException ex) {
    310320        // TODO: raise error
    311         System.err.println(ex);
     321        System.err.println("METSFile.parse_flocateXML(): "+ex);
    312322    }
    313323    return thisFilePos;
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFileGroup.java

    r8742 r9874  
    88
    99import java.sql.SQLException;
     10import java.sql.Statement;
    1011import java.sql.ResultSet;
    1112
     
    271272    {
    272273    int sqlId = -1;
    273    
    274274    // check if this node is in the database already
    275275    GS3SQLSelect select = new GS3SQLSelect("filegroups");
     
    281281    select.setWhere(where);
    282282   
    283     connection.execute(select.toString());
    284    
    285     ResultSet selectResult = connection.getResultSet();
     283    ResultSet results = null;
     284    Statement statement = null;
    286285   
    287286    try {
    288         if (selectResult == null ||
    289         !selectResult.first()) {
     287        statement = connection.createStatement();
     288        results = statement.executeQuery(select.toString());
     289        if (!results.first()) {
    290290        GS3SQLInsert insert = new GS3SQLInsert("filegroups");
    291291       
     
    295295        insert.addValue("ParentType", parentIsSection ? SECTION_PARENT : GROUP_PARENT);
    296296       
    297         if (!connection.execute(insert.toString())) {
    298             return false;
    299         }
     297        statement.execute(insert.toString());
    300298        }
    301299        else {
     
    304302    }
    305303    catch (SQLException ex){
    306         System.err.println(ex);
     304        System.err.println("METSFileGroup.writeSQL(): "+ex);
    307305        return false;
    308306    }
    309307   
    310308    // get the filegroup reference now
    311     connection.execute(select.toString());
    312    
    313309    try {
    314         ResultSet results = connection.getResultSet();
    315         if (results == null) {
     310        results = statement.executeQuery(select.toString());
     311        if (results.first()) {
     312        sqlId = results.getInt("FileGroupRef");
     313        } else {
     314        statement.close();
    316315        return false;
    317316        }
    318         results.first();
    319         sqlId = results.getInt("FileGroupRef");
    320     }
    321     catch (SQLException sqlex) {
    322         System.out.println(sqlex);
     317        statement.close();
     318    } catch (SQLException sqlex) {
     319        System.err.println("METSFileGroup.writeSQL(): "+sqlex);
    323320        return false;
    324321    }
    325    
    326322    // iterate over the child groups
    327323    Iterator childIter = childGroups.iterator();
     
    330326       
    331327        if (!fileGroup.writeSQL(document, Integer.toString(sqlId), false, connection)){
     328        System.err.println("METSFileGroup.writeSQL(): Couldn't write FileGroup");
    332329        return false;
    333330        }
     
    337334    childIter = children.iterator();
    338335    while (childIter.hasNext()){
    339         METSFile file = (METSFile) childIter.next();
    340        
     336        METSFile file = (METSFile) childIter.next();       
    341337        if (!file.writeSQL(sqlId, connection)){
     338        System.err.println("METSFileGroup.writeSQL(): Couldn't write File");
    342339        return false;
    343340        }
     
    371368        select.setWhere(where);
    372369       
    373         connection.execute(select.toString());
     370        Statement statement = connection.createStatement();
    374371       
    375372        // parse through the child groups
    376         ResultSet childSet = connection.getResultSet();
     373        ResultSet childSet = statement.executeQuery(select.toString());
    377374        if (childSet.first()) {
    378375        do {
     
    384381        while (childSet.next());
    385382        }
    386        
    387383        // now scan for file members
    388384        select = new GS3SQLSelect("files");
    389385        select.addField("*");
    390         whereItem = new GS3SQLWhereItem("FileGroupRef", "=", Integer.toString(groupRef),
    391                         GS3SQLField.INTEGER_TYPE);
     386        whereItem = new GS3SQLWhereItem("FileGroupRef", "=", Integer.toString(groupRef), GS3SQLField.INTEGER_TYPE);
    392387        where = new GS3SQLWhere(whereItem);
    393388        select.setWhere(where);
    394         connection.execute(select.toString());
    395        
    396         ResultSet childFileSet = connection.getResultSet();
    397         if (childFileSet != null && childFileSet.first()) {
     389        ResultSet childFileSet = statement.executeQuery(select.toString());
     390        if (childFileSet.first()) {
    398391        do {
    399392            METSFile file = METSFile.readSQL(connection, childFileSet);
     
    404397        while (childFileSet.next());
    405398        }
    406        
     399        statement.close();
    407400        return group;
    408401    }
    409402    catch (SQLException sqlEx){
    410         System.out.println(sqlEx);
     403        System.err.println("METSFileGroup.readSQL(): "+sqlEx);
    411404        System.exit(1);
    412405    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFileSet.java

    <
    r8742 r9874  
    1616
    1717import java.sql.SQLException;