Changeset 38769 for main/trunk
- Timestamp:
- 2024-02-22T18:59:49+13:00 (4 months ago)
- Location:
- main/trunk/greenstone3
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/build.xml
r37759 r38769 455 455 <property name="web.writablehome" value="${gsdl3.writablehome}"/> 456 456 457 <!-- 458 The derby.system.home property can be used to set the same as JAVA_OPT 459 when launching the derby networked server, so that the usersDB can be set to 460 a shorter path in greenstone.xml and accessed with that shorter path through 461 clients like Java code using a Client class, Squirreldb connecting and more. 462 463 https://db.apache.org/derby/docs/10.3/tuning/rtunproper32066.html 464 https://db.apache.org/derby/docs/10.13/devguide/cdevdvlp40350.html 465 https://db.apache.org/derby/docs/10.0/manuals/tuning/perf91.html 466 https://stackoverflow.com/questions/26624031/how-to-manually-specify-the-derby-system-home-property-to-start-a-derby-server 467 but: https://zetcode.com/db/apachederbytutorial/tomcat/ 468 https://db.apache.org/derby/docs/10.4/adminguide/tadmincbdjhhfd.html 469 --> 470 <property name="derby.system.home" value="${web.writablehome}/etc"/> 471 457 472 <!-- The following are useful in Java-based config files (.properties,.json,.xml) 458 473 where the 'Unix style' (really URL style of slash, even in a file://...) is used --> … … 1381 1396 and we want to be consistent in using the same java throughout. Solution: 1382 1397 Refer to the JRE used in executing this ant file, which for installers will always be the bundled one. 1383 https://stackoverflow.com/questions/17571595/env-java-home-not-found-ant --> 1398 https://stackoverflow.com/questions/17571595/env-java-home-not-found-ant 1399 1400 We set the derby.system.home so it doesn't default to the dir derby was 1401 launched from. And then we can set greenstone3.xml to use a shorter URL 1402 to the usersDB instead of the full GS3 web home path. 1403 1404 Setting JAVA OPTS through an ant exec task: 1405 https://stackoverflow.com/questions/55706746/set-java-opts-in-ant-task 1406 --> 1384 1407 <exec executable="${java.home}/bin/java" spawn="true"><!-- failonerror="true"--> 1408 <arg value="-Dderby.system.home=${derby.system.home}"/><!-- Don't put quot-entities around the derby.system.home property! --> 1385 1409 <env key="CLASSPATH" path="${derby.server.classpath.prop}"/> 1386 1410 <arg value="org.apache.derby.drda.NetworkServerControl"/> … … 3368 3392 <classpath refid="compile.classpath"/> <!--for ${web.lib}/gsdl3.jar and supporting files--> 3369 3393 <sysproperty key="gsdl3.writablehome" value="${gsdl3.writablehome}" /> <!-- passes -D<syspropKey=syspropVal> to java class ModifyUsersDB. Available in java code as System.getProperty("syspropKey") --> 3370 <arg file="${web.home}/etc/usersDB"/>3394 <arg value="usersDB"/><!--<arg file="${web.home}/etc/usersDB"/>--> 3371 3395 <arg value="${user.username}"/> 3372 3396 <arg value="password=${user.password}"/> -
main/trunk/greenstone3/resources/tomcat/greenstone3.xml.svn
r38768 r38769 25 25 For more info about why you need the parameter value, see here: 26 26 https://stackoverflow.com/a/41232124 27 28 Because the derby networked server is now launched with the 29 derby.system.home JAVA_OPT property set to the folder containing 30 usersDB, we don't need url set to the full GS3 path to the usersDB. 27 31 --> 28 32 <Resource … … 35 39 validationQuery="values 1" 36 40 driverClassName="org.apache.derby.jdbc.ClientDriver" 37 url="jdbc:derby://@derbyserver@:@derbyserverport@/ @gsdl3webhome@/etc/usersDB" />41 url="jdbc:derby://@derbyserver@:@derbyserverport@/usersDB" /> 38 42 39 43 <Realm className="org.apache.catalina.realm.LockOutRealm"> -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/DepositorAction.java
r36107 r38769 110 110 } 111 111 112 DerbyWrapper database = new DerbyWrapper( GlobalProperties.getGSDL3Home() + File.separatorChar + "etc" + File.separatorChar + "usersDB");112 DerbyWrapper database = new DerbyWrapper(DerbyWrapper.USERSDB_DIR); 113 113 if (pageNumParseFail) 114 114 { -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/Authentication.java
r37517 r38769 1101 1101 { 1102 1102 // check the usersDb database, if it isn't existing, check the etc dir, create the etc dir if it isn't existing, then create the user database and add a "admin" user 1103 String usersDB_dir = GlobalProperties.getGSDL3Home() + File.separatorChar + "etc" + File.separatorChar + "usersDB";1103 String usersDB_dir = DerbyWrapper.USERSDB_DIR; 1104 1104 DerbyWrapper derbyWrapper = new DerbyWrapper(usersDB_dir); 1105 1105 return derbyWrapper; -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/UserTracker.java
r32453 r38769 95 95 String action = (String) params.get(ACTION_PARAM); 96 96 97 DerbyWrapper database = new DerbyWrapper( GlobalProperties.getGSDL3Home() + File.separatorChar + "etc" + File.separatorChar + "usersDB");97 DerbyWrapper database = new DerbyWrapper(DerbyWrapper.USERSDB_DIR); 98 98 database.addUserAction(username, site, collection, oid, action); 99 99 database.closeDatabase(); … … 121 121 String oid = (String) params.get(OID_PARAM); 122 122 123 DerbyWrapper database = new DerbyWrapper( GlobalProperties.getGSDL3Home() + File.separatorChar + "etc" + File.separatorChar + "usersDB");123 DerbyWrapper database = new DerbyWrapper(DerbyWrapper.USERSDB_DIR); 124 124 ArrayList<HashMap<String, String>> userActions = database.getMostRecentUserActions(site, collection, oid); 125 125 -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/DerbyWrapper.java
r37693 r38769 44 44 static final String PROTOCOL; 45 45 46 static final String DRIVER = "org.apache.derby.jdbc.ClientDriver"; //"org.apache.derby.jdbc.EmbeddedDriver"; 47 static final String USERSDB = "usersDB"; 48 public static final String USERSDB_DIR; 49 46 50 // static code block to initialise the above 47 51 static { … … 75 79 PROTOCOL = "jdbc:derby://"+DERBYSERVER+":"+PORT+"/"; // "jdbc:derby://localhost:8327"; // by default 76 80 //System.out.println("@@@ PROTOCOL:" + PROTOCOL); //check in installer 81 82 // if embedded derby Driver (UNTESTED BRANCH), use the full path to usersDB, 83 // else if networked derby server then just append dbname (usersDB) to protocol 84 if(DRIVER.equals("org.apache.derby.jdbc.EmbeddedDriver")) { 85 USERSDB_DIR = GlobalProperties.getGSDL3Home() + File.separatorChar + "etc" + File.separatorChar + USERSDB; 86 } else { // derby network driver, just go direct to usersDB 87 USERSDB_DIR = USERSDB; 88 } 77 89 } 78 79 80 static final String DRIVER = "org.apache.derby.jdbc.ClientDriver"; //"org.apache.derby.jdbc.EmbeddedDriver"; 81 static final String USERSDB = "usersDB"; 90 82 91 public static final String USERS = "users"; 83 92 public static final String ROLES = "roles"; … … 93 102 public static void createDatabaseIfNeeded() 94 103 { 95 String usersDB_dir = GlobalProperties.getGSDL3Home() + File.separatorChar + "etc" + File.separatorChar + "usersDB"; 96 protocol_str = PROTOCOL + usersDB_dir; 97 File usersDB_file = new File(usersDB_dir); 104 protocol_str = PROTOCOL + USERSDB_DIR; 105 File usersDB_file = new File(USERSDB_DIR); 98 106 if (!usersDB_file.exists()) 99 107 { -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/ModifyUsersDB.java
r37660 r38769 28 28 then run: 29 29 30 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 or 'ALL'> [options specifying user fields to change, e.g.: password=me!] 31 30 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 usersDB <username or 'ALL'> [options specifying user fields to change, e.g.: password=me!] 31 32 Now just pass in "usersDB" for networked derby server, previously web/etc/usersDB/ was needed. 33 32 34 Don't forget to stop the networked derby server again at the end, if you had started it: ant stop-derby 33 35 [[ OLD METHOD ]] -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/txt2usersDB.java
r35298 r38769 31 31 then run: 32 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] 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 usersDB [-append] 34 35 Now just pass in "usersDB" for networked derby server, previously web/etc/usersDB/ was needed. 34 36 35 37 Don't forget to stop the networked derby server again at the end, if you had started it: ant stop-derby -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/usersDB2txt.java
r30196 r38769 33 33 then run: 34 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/ 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 usersDB 36 37 Now just pass in "usersDB" for networked derby server, previously web/etc/usersDB/ was needed. 36 38 37 39 if redirecting to a file append ">& filename.txt" to the above command … … 47 49 public static void main(String[] args) throws SQLException{ 48 50 if (args.length!=1){ 49 System.out.println(" The path of usersDB has to be given!");51 System.out.println("Set parameter to \"usersDB\" for a derby networked server or usersDB path if using an embedded derby server"); 50 52 System.exit(0); 51 53 }
Note:
See TracChangeset
for help on using the changeset viewer.