[cvs] expresso commit by lhamel: do not throw if new 5.6 servlet filter is

JCorporate Ltd jcorp at jcorp2.servlets.net
Fri Oct 29 21:54:44 PDT 2004


Log Message:
-----------
do not throw if new 5.6 servlet filter is not set;  after expresso v.5.7, change impl to throw exception if servlet filter is not found. Introducing this in v5.6, and legacy does not want exceptions

Modified Files:
--------------
    expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj:
        RowSecuredDBObject.java

Revision Data
-------------
Index: RowSecuredDBObject.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/RowSecuredDBObject.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/RowSecuredDBObject.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/RowSecuredDBObject.java -u -r1.29 -r1.30
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/RowSecuredDBObject.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/RowSecuredDBObject.java
@@ -65,6 +65,7 @@
 
 import com.jcorporate.expresso.core.db.DBConnection;
 import com.jcorporate.expresso.core.db.DBException;
+import com.jcorporate.expresso.core.registry.RequestRegistry;
 import com.jcorporate.expresso.core.security.User;
 import com.jcorporate.expresso.services.dbobj.RowGroupPerms;
 import com.jcorporate.expresso.services.dbobj.RowPermissions;
@@ -74,7 +75,6 @@
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
-import com.jcorporate.expresso.core.registry.RequestRegistry;
 
 
 /**
@@ -119,18 +119,22 @@
     private static final String CREATED_NEW = "CREATED_NEW";
 
     /**
-     * Constructor without parameters is required by framework, but if you use
-     * this constructor, be sure to set the requesting userid after
-     * constructing.
+     * Constructor without parameters.  This constructor will attempt to use servlet filter
+     * to set data context and user ID from expresso v.5.6.  However, if you
+     * have not set up this filter in web.xml, be sure to set dbname and user id
+     * after constructing.
+     * @todo after expresso v.5.7, change impl to throw exception if servlet filter is not found. Introducing this in v5.6, so legacy does not want exceptions
      *
      * @throws DBException upon database communication error
      */
     public RowSecuredDBObject() throws DBException {
-        // by default, the requesting user ID is set to system,
-        //which gives a superuser status to all requests
-        //so reset the requesting user here
-        setDataContext(RequestRegistry.getDataContext());
-        setRequestingUid(RequestRegistry.getUser().getUid());
+        try {
+            setDataContext(RequestRegistry.getDataContext());
+            setRequestingUid(RequestRegistry.getUser().getUid());
+        } catch (IllegalStateException e) {
+            // no error for now if filter not found.
+            // @todo after expresso v.5.7, change impl to throw exception if servlet filter is not found. Introducing this in v5.6, so legacy does not want exceptions
+        }
 
         // warn if key of this row may be too long
         checkKeyLength();
@@ -157,12 +161,24 @@
 
     /**
      * Creates a new RowSecuredDBObject object.
+     *  This constructor will attempt to use servlet filter
+     * to set data context--from expresso v.5.6.  However, if you
+     * have not set up this filter in web.xml, be sure to set dbname and user id
+     * after constructing.
+     * @todo after expresso v.5.7, change impl to throw exception if servlet filter is not found. Introducing this in v5.6, so legacy does not want exceptions     *
      *
      * @param theUser requesting user
      * @throws DBException upon database communication error
      */
     public RowSecuredDBObject(int theUser) throws DBException {
         super(theUser);
+
+        try {
+            setDataContext(RequestRegistry.getDataContext());
+        } catch (IllegalStateException e) {
+            // no error for now if filter not found.
+            // @todo after expresso v.5.7, change impl to throw exception if servlet filter is not found. Introducing this in v5.6, so legacy does not want exceptions
+        }
 
         // check that key is not too long
         checkKeyLength();


More information about the cvs mailing list