[cvs] expresso commit by lhamel: add

JCorporate Ltd jcorp at jcorporate.com
Thu Jan 6 19:25:58 UTC 2005


Log Message:
-----------
add

Added Files:
-----------
    expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj:
        SecurDBObject.java

Revision Data
-------------
--- /dev/null
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/SecurDBObject.java
@@ -0,0 +1,159 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:
+ *       "This product includes software developed by Jcorporate Ltd.
+ *        (http://www.jcorporate.com/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written permission,
+ *    please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ *    or other Jcorporate product names; nor may "Expresso" or other
+ *    Jcorporate product names appear in their name, without prior
+ *    written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ *    market space, i.e. framework, without prior written permission
+ *    of Jcorporate Ltd. For written permission, please contact
+ *    partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.core.dbobj;
+
+import com.jcorporate.expresso.core.controller.ControllerRequest;
+import com.jcorporate.expresso.core.dataobjects.Securable;
+import com.jcorporate.expresso.core.db.DBConnection;
+import com.jcorporate.expresso.core.db.DBException;
+import com.jcorporate.expresso.core.registry.RequestRegistry;
+
+
+/**
+ * @author Larry Hamel
+ */
+public abstract class SecurDBObject
+        extends SecuredDBObject implements Securable {
+
+    /**
+     * Constructor that, unlike superclass, we default to permissions of requesting user
+     *
+     * @throws com.jcorporate.expresso.core.db.DBException
+     *          upon construction error.
+     */
+    public SecurDBObject()
+            throws DBException {
+        // unlike superclass, we default to permissions of requesting user
+        setRequestingUid(RequestRegistry.getUser().getUid());
+    }
+
+    /**
+     * Constructor that sets the connection on create
+     *
+     * @param newConnection The dbConnection object to associate with this
+     *                      object
+     * @throws com.jcorporate.expresso.core.db.DBException
+     *          upon construction error.
+     */
+    public SecurDBObject(DBConnection newConnection)
+            throws DBException {
+        this(newConnection, newConnection.getDataContext());
+    }
+
+    /**
+     * <p/>
+     * Constructor that sets a connection as the object is created - typically
+     * this is used when a particular DBConnection is required for the purposes of
+     * maintaining a database transaction. If a specific connection is not used,
+     * there is no way to use commit() and rollback() in the event of failure, as a
+     * different DBConnection might be used for each phase of the transaction.
+     * Critial sections should therefore explicity request a DBConnection from the
+     * connection pool and pass it to each of the DB objects in that section.
+     * </p>
+     * <p>This constructor is neceesary to work with otherDBMap and transaction
+     * capabilities</p>
+     *
+     * @param newConnection      The DBConnection to utilize
+     * @param setupTablesContext The data context that contains the setup (and
+     *                           security) tables for this object
+     * @throws com.jcorporate.expresso.core.db.DBException
+     *          upon construction error.
+     */
+    public SecurDBObject(DBConnection newConnection, String setupTablesContext)
+            throws DBException {
+        super(newConnection, setupTablesContext);
+        // unlike superclass, we default to permissions of requesting user
+        setRequestingUid(RequestRegistry.getUser().getUid());
+    }
+
+
+    /**
+     * Constructor that sets user ID and data context from request
+     *
+     * @param request the request from which to set user, context
+     * @throws com.jcorporate.expresso.core.db.DBException
+     *          upon construction error
+     */
+    public SecurDBObject(ControllerRequest request)
+            throws DBException {
+        this(request.getUid());
+        setDataContext(request.getDataContext());
+    }
+
+    /**
+     * Constructor: Specify a DB connection AND user
+     *
+     * @param newUid User ID attempting to use this object.
+     *               If this is SecuredDBObject.SYSTEM_ACCOUNT, then
+     *               full permissions are granted. Note that you cannot log in
+     *               as SecuredDBObject.SYSTEM_ACCOUNT,
+     *               t can only be used from within a method.
+     * @throws DBException If the object cannot be created
+     */
+    public SecurDBObject(int newUid)
+            throws DBException {
+        setRequestingUid(newUid);
+    }
+}


More information about the cvs mailing list