Changeset 30196


Ignore:
Timestamp:
09/03/15 20:59:30 (5 years ago)
Author:
ak19
Message:

Fixes to do with networked Derby: port and host number changes propagated from build.props to global.props are now at last picked up by DerbyWrapper.java by build.xml setting a system property (-Dgsdl3.writablehome), which is then used to force load Global.Properties if it's not loaded yet. It won't be loaded when launching the ant update-userdb cmd which runs ModifyUsersDB.java. Or if running ModifyUsersDB.java, txt2usersDB.java or usersDB2txt from the cmdline.

Location:
main/trunk/greenstone3
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/build.xml

    r30170 r30196  
    18551855      <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
    18561856    </input>
    1857     <input addproperty="user.groups" defaultvalue="" message="Groups (comma-separated list):&gt;"/>
     1857    <input addproperty="user.groups" defaultvalue="" message="Groups (comma-separated list, e.g. personal-collections-editor):&gt;"/>
    18581858    <input addproperty="user.status" defaultvalue="true" message="Enabled (true/false):&gt;"/>
    18591859    <input addproperty="user.comment" defaultvalue="" message="Comment:&gt;"/>
     
    18891889    <java classname="org.greenstone.gsdl3.util.ModifyUsersDB">
    18901890      <classpath refid="compile.classpath"/> <!--for ${web.lib}/gsdl3.jar and supporting files-->
     1891      <sysproperty key="gsdl3.writablehome" value="${gsdl3.writablehome}" /> <!-- passes -D<syspropKey=syspropVal> to java class ModifyUsersDB. Available in java code as System.getProperty("syspropKey") -->
    18911892      <arg file="${web.home}/etc/usersDB"/>
    18921893      <arg value="${user.username}"/>
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/DerbyWrapper.java

    r30055 r30196  
    3535public class DerbyWrapper
    3636{
    37     static final String PORT = GlobalProperties.getProperty("derby.server.port", "1527");
    38     static final String DERBYSERVER = GlobalProperties.getProperty("derby.server", "localhost");
    39     static final String PROTOCOL = "jdbc:derby://"+DERBYSERVER+":"+PORT+"/"; // "jdbc:derby://localhost:1527";
    40     static final String DRIVER = "org.apache.derby.jdbc.ClientDriver"; //"org.apache.derby.jdbc.EmbeddedDriver";
     37    static final String PORT;
     38    static final String DERBYSERVER;
     39    static final String PROTOCOL;   
     40
     41    // static code block to initialise the above
     42    static {
     43    // GlobalProperties won't be loaded at this point if running ant config-admin or ant config-user
     44    // from the command line (both of which call ant update-userdb which in turn calls ModifyUsersDB.java)
     45    // In such a case, the ant command will have set the system property (-Dgsdl3_writablehome)
     46    // and passed this to ModifyUsersDB.java. Use that to load the GlobalProperties at this point
     47
     48    if(GlobalProperties.getGSDL3Home() == null) { // testing whether GlobalProperties is already loaded
     49        String gsdl3_writablehome = System.getProperty("gsdl3.writablehome"); // set by 'ant update-userdb' cmd
     50
     51        //System.err.println("@@@@@ writablehome: " + gsdl3_writablehome);
     52        GlobalProperties.loadGlobalProperties(gsdl3_writablehome);
     53    }
     54   
     55    //System.err.println("@@@@@ GlobalProperties.getGSDL3Home(): " + GlobalProperties.getGSDL3Home()); //test
     56   
     57    // No more fallback values, use exactly what's propagated into global.properties from build.properties
     58    PORT = GlobalProperties.getProperty("derby.server.port");//, "1527");
     59    DERBYSERVER = GlobalProperties.getProperty("derby.server");//, "localhost");
     60    PROTOCOL = "jdbc:derby://"+DERBYSERVER+":"+PORT+"/"; // "jdbc:derby://localhost:1527"; // by default
     61    }
     62   
     63
     64    static final String DRIVER = "org.apache.derby.jdbc.ClientDriver"; //"org.apache.derby.jdbc.EmbeddedDriver";
    4165    static final String USERSDB = "usersDB";
    4266    static final String USERS = "users";
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/ModifyUsersDB.java

    r30055 r30196  
    2323//import org.greenstone.admin.guiext.PropertiesStep;
    2424
    25 // To run this from the command-line, first make sure that the tomcat server is stopped, then run:
    26 // java -cp /full/path/to/GS3/web/WEB-INF/lib/gsdl3.jar:/full/path/to/GS3/web/WEB-INF/lib/derby.jar org.greenstone.gsdl3.util.usersDB2txt web/etc/usersDB/
     25/**
     26    To run this from the command-line, first make sure that the networked derby server is running (ant start-derby),
     27    then run:
     28
     29    java -Dgsdl3.writablehome=/Scratch/ak19/gs3-svn-2Sep2015/web -cp web/WEB-INF/lib/gsdl3.jar:web/WEB-INF/lib/gutil.jar:web/WEB-INF/lib/derby.jar:web/WEB-INF/lib/derbyclient.jar:web/WEB-INF/lib/log4j-1.2.8.jar:web/WEB-INF/lib/commons-codec-1.7.jar:web/WEB-INF/classes org.greenstone.gsdl3.util.ModifyUsersDB web/etc/usersDB/ <username> [options specifying user fields to change, e.g.: password=me!]
     30   
     31    Don't forget to stop the networked derby server again at the end, if you had started it: ant stop-derby
     32
     33    or if using embedded derby, ensure that tomcat is stopped, then run:
     34    java -cp /full/path/to/GS3/web/WEB-INF/lib/gsdl3.jar:/full/path/to/GS3/web/WEB-INF/lib/derby.jar org.greenstone.gsdl3.util.ModifyUsersDB web/etc/usersDB/
     35*/
    2736public class ModifyUsersDB
    2837{
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/txt2usersDB.java

    r28202 r30196  
    2727import org.greenstone.gsdl3.service.Authentication;
    2828
     29/**
     30    To run this from the command-line, first make sure that the derby networked server is running (ant start-derby),
     31    then run:
     32
     33    java -Dgsdl3.writablehome=/full/path/to/GS3/web -cp web/WEB-INF/lib/gsdl3.jar:web/WEB-INF/lib/gutil.jar:web/WEB-INF/lib/derby.jar:./web/WEB-INF/lib/derbyclient.jar:./web/WEB-INF/lib/log4j-1.2.8.jar:./web/WEB-INF/classes org.greenstone.gsdl3.util.txt2usersDB <filename>.txt web/etc/usersDB/ [-append]
     34
     35    Don't forget to stop the networked derby server again at the end, if you had started it: ant stop-derby
     36
     37    Or if using embedded derby, ensure that tomcat is stopped, then run:
     38    java -cp /full/path/to/GS3/web/WEB-INF/lib/gsdl3.jar:/full/path/to/GS3/web/WEB-INF/lib/derby.jar org.greenstone.gsdl3.util.txt2usersDB <filename>.txt web/etc/usersDB/ [-append]
     39*/
    2940public class txt2usersDB
    3041{
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/usersDB2txt.java

    r27135 r30196  
    2929import java.util.Properties;
    3030
    31 // Run as java org.greenstone.gsdl3.util.usersDB2txt <usersDB file>
     31/**
     32    To run this from the command-line, first make sure that the networked derby server is running (ant start-derby)
     33    then run:
     34 
     35    java -Dgsdl3.writablehome=/full/path/to/GS3/web -cp ./web/WEB-INF/lib/gsdl3.jar:./web/WEB-INF/lib/gutil.jar:./web/WEB-INF/lib/derby.jar:./web/WEB-INF/lib/derbyclient.jar:./web/WEB-INF/lib/log4j-1.2.8.jar:./web/WEB-INF/classes org.greenstone.gsdl3.util.usersDB2txt web/etc/usersDB/
     36
     37    if redirecting to a file append ">& filename.txt" to the above command
     38    since the usersDB2txt program output goes to System.err and needs to be redirected to the file too
     39
     40    Don't forget to stop the networked derby server again at the end, if you had started it: ant stop-derby
     41
     42    Or if using embedded derby, ensure that tomcat is stopped, then run:
     43    java -cp /full/path/to/GS3/web/WEB-INF/lib/gsdl3.jar:/full/path/to/GS3/web/WEB-INF/lib/derby.jar org.greenstone.gsdl3.util.usersDB2txt web/etc/usersDB/ [>& <output file>]
     44*/
    3245public class usersDB2txt
    3346{
Note: See TracChangeset for help on using the changeset viewer.