[cvs] expresso commit by rimovm: Fixed issue when there was no db created

JCorporate Ltd jcorp at jcorp2.servlets.net
Thu Nov 11 02:40:26 PST 2004


Log Message:
-----------
Fixed issue when there was no db created yet.

Modified Files:
--------------
    expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/registry:
        RequestRegistryFilter.java

Revision Data
-------------
Index: RequestRegistryFilter.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/registry/RequestRegistryFilter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/registry/RequestRegistryFilter.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/registry/RequestRegistryFilter.java -u -r1.3 -r1.4
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/registry/RequestRegistryFilter.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/registry/RequestRegistryFilter.java
@@ -73,12 +73,16 @@
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
-
+import com.jcorporate.expresso.core.controller.NonHandleableException;
+import com.jcorporate.expresso.core.db.DBException;
 import com.jcorporate.expresso.core.jsdkapi.GenericSession;
 import com.jcorporate.expresso.core.misc.CurrentLogin;
 import com.jcorporate.expresso.core.security.User;
 import com.jcorporate.expresso.core.servlet.CheckLogin;
 import com.jcorporate.expresso.core.security.SuperUser;
+import com.jcorporate.expresso.services.dbobj.DefaultUserInfo;
+import com.jcorporate.expresso.core.dataobjects.DataObject;
+import com.jcorporate.expresso.core.dataobjects.Securable;
 
 /**
  * Does a similar job as Expresso's checkLogin() but it also sets the
@@ -120,14 +124,29 @@
             try {
                 //Set the  current thread to superuser for authentication
                 //purposes.  We downgrade it as soon as we have privlidges.
-                CheckLogin.getInstance().checkLogin((HttpServletRequest)request);
-                cl = (CurrentLogin)GenericSession
-                                  .getAttribute(req,"CurrentLogin");
+                CheckLogin.getInstance().checkLogin((HttpServletRequest)
+                    request);
+                cl = (CurrentLogin) GenericSession
+                    .getAttribute(req, "CurrentLogin");
 
                 u = new User();
                 u.setDataContext(cl.getDBName());
                 u.setUid(cl.getUid());
-                u.retrieve();
+
+                try {
+                    u.retrieve();
+                } catch (DBException ex1) {
+                    //We have a potential situation where the User
+                    //table might not exist yet.
+                    DataObject dao = new DefaultUserInfo(Securable.SYSTEM_ACCOUNT);
+                    dao.setDataContext(cl.getDBName());
+                    try {
+                        dao.count();
+                        throw new DBException("Unable to load user",ex1);
+                    } catch (DBException ex) {
+                        this.log("User Table Doesn't Yet Exist", ex);
+                    }
+                }
             } finally {
                 //Take out the superuser settings to save any chances of
                 //exploits occuring by reuse of a thread.
@@ -143,9 +162,9 @@
             } finally {
                 requestRegistry.releaseSettings();
             }
-        } catch (com.jcorporate.expresso.core.controller.NonHandleableException ex) {
+        } catch (NonHandleableException ex) {
             throw new ServletException("Error pre-processing request", ex);
-        } catch (com.jcorporate.expresso.core.db.DBException ex) {
+        } catch (DBException ex) {
             throw new ServletException("Error pre-processing request", ex);
         }
     }


More information about the cvs mailing list