[cvs] expresso commit by lhamel: use superuser privileges during
JCorporate Ltd
jcorp at jcorp2.servlets.net
Tue Nov 23 19:59:46 PST 2004
Log Message:
-----------
use superuser privileges during initialization of object metadata
Modified Files:
--------------
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc:
ConfigManager.java
Revision Data
-------------
Index: ConfigManager.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/ConfigManager.java,v
retrieving revision 1.76
retrieving revision 1.77
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/ConfigManager.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/ConfigManager.java -u -r1.76 -r1.77
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/ConfigManager.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/ConfigManager.java
@@ -120,7 +120,6 @@
* execution of the application.
*
* @author Adam Rossi
- * @version $Revision$ $Date$
*/
public final class ConfigManager {
@@ -447,43 +446,52 @@
try {
String oneDBName = (String) i.next();
ConfigContext oneContext = ConfigManager.getContext(oneDBName);
- new MutableRequestRegistry(oneDBName,
- null);
- if (oneContext.hasSetupTables()) {
+ // set up superuser ID on this thread, which is typically called from
+ // servlet initialization
+ try {
+ //This sets thread local variables with the local registry settings.
+ //We set it as a superuser instance for initialization purposes
+ //only. Once the first requests come through, we initialize it
+ //through the Filter.
+ new MutableRequestRegistry(oneDBName, SuperUser.SUPER_USER);
+ if (oneContext.hasSetupTables()) {
- try {
- SchemaList sl = new SchemaList(SecuredDBObject.SYSTEM_ACCOUNT);
- sl.setDataContext(oneDBName);
- sl.count(); /** count in order to see if table is ok **/
- } catch (DBException e) {
- if (log.isInfoEnabled()) {
- log.info("Schema is not initialized yet- run dbcreate for context: " + oneDBName);
+ try {
+ SchemaList sl = new SchemaList(SecuredDBObject.SYSTEM_ACCOUNT);
+ sl.setDataContext(oneDBName);
+ sl.count(); /** count in order to see if table is ok **/
+ } catch (DBException e) {
+ if (log.isInfoEnabled()) {
+ log.info("Schema is not initialized yet- run dbcreate for context: " + oneDBName);
+ }
+ continue;
}
- continue;
- }
- // make sure expresso in initialized before any others
- if (expressoInitialized == false) {
- initializeOneSchema(com.jcorporate.expresso.core.ExpressoSchema.class.getName());
- expressoInitialized = true;
- }
+ // make sure expresso in initialized before any others
+ if (expressoInitialized == false) {
+ initializeOneSchema(com.jcorporate.expresso.core.ExpressoSchema.class.getName());
+ expressoInitialized = true;
+ }
- SchemaList sl = new SchemaList(SecuredDBObject.SYSTEM_ACCOUNT);
- sl.setDataContext(oneDBName);
- ArrayList al = sl.searchAndRetrieveList();
+ SchemaList sl = new SchemaList(SecuredDBObject.SYSTEM_ACCOUNT);
+ sl.setDataContext(oneDBName);
+ ArrayList al = sl.searchAndRetrieveList();
- for (Iterator schemas = al.iterator(); schemas.hasNext();) {
- SchemaList oneSchema = (SchemaList) schemas.next();
- try {
- initializeOneSchema(oneSchema.getField(SchemaList.FLD_SCHEMA_CLASS));
- } catch (Exception ex) {
- log.error("Error initializing schema: "
- + oneSchema.getField(SchemaList.FLD_SCHEMA_CLASS), ex);
- }
+ for (Iterator schemas = al.iterator(); schemas.hasNext();) {
+ SchemaList oneSchema = (SchemaList) schemas.next();
+ try {
+ initializeOneSchema(oneSchema.getField(SchemaList.FLD_SCHEMA_CLASS));
+ } catch (Exception ex) {
+ log.error("Error initializing schema: "
+ + oneSchema.getField(SchemaList.FLD_SCHEMA_CLASS), ex);
+ }
+ }
}
+ } finally {
+ new MutableRequestRegistry(oneDBName, null);
}
} catch (DBException dbe) {
log.warn("Unable to initialize dbobjects... SchemaList may not be initialized yet", dbe);
@@ -1126,6 +1134,7 @@
if (log.isInfoEnabled()) {
log.info("Initializing Schema Objects");
}
+
initializeAllDBObjects();
com.jcorporate.expresso.core.dbobj.NextNumber.getInstance();
@@ -1240,8 +1249,7 @@
//We set it as a superuser instance for initialization purposes
//only. Once the first requests come through, we initialize it
//through the Filter.
- new MutableRequestRegistry(oneKey,
- SuperUser.SUPER_USER);
+ new MutableRequestRegistry(oneKey, SuperUser.SUPER_USER);
try {
SchemaList sl = new SchemaList(SecuredDBObject.SYSTEM_ACCOUNT);
@@ -1522,15 +1530,14 @@
if (log.isDebugEnabled()) {
log.debug("using initial state =`" + stateName + "'");
}
- }
- catch (ControllerException ex) {
+ } catch (ControllerException ex) {
throw new RuntimeException("ConfigManager.getMapping(): "
- + "stateName was null and can't construct controller of name: "
- + controllerName, ex);
+ + "stateName was null and can't construct controller of name: "
+ + controllerName, ex);
} catch (ClassCastException ex) {
log.error("Error getting controller", ex);
throw new IllegalArgumentException("ClassCastException getting"
- +" controller: " + ex.toString());
+ + " controller: " + ex.toString());
}
}
@@ -2023,6 +2030,4 @@
new SaxParserConfigurer();
}
-}
-
-/* ConfigManager */
+} /* ConfigManager */
More information about the cvs
mailing list