You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jm...@apache.org on 2001/09/10 23:14:03 UTC

cvs commit: jakarta-turbine-torque/src/templates/om ExtensionObject.vm Object.vm

jmcnally    01/09/10 14:14:03

  Modified:    src/conf build.properties
               src/java/org/apache/torque/om BaseObject.java
                        Persistent.java
               src/templates/om ExtensionObject.vm Object.vm
  Added:       src/java/org/apache/torque/om SecurePersistent.java
                        UnsecurePersistent.java
               src/java/org/apache/torque/security SecurityException.java
                        SecurityInfo.java
  Log:
  added a doPreSave protected method to allow bo's some processing prior to
  the actual save.
  
  added a security check method and on/off property to allow for a permission
  check prior to saving the object to the db.
  
  removed the non-implementation of save() from BaseObject.
  
  Revision  Changes    Path
  1.2       +1 -0      jakarta-turbine-torque/src/conf/build.properties
  
  Index: build.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/conf/build.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.properties	2001/08/02 05:08:15	1.1
  +++ build.properties	2001/09/10 21:14:02	1.2
  @@ -66,6 +66,7 @@
   targetPackage=org.apache.turbine
   basePrefix=Base
   addSaveMethod=true
  +secureSaveMethod=false
   addGetByNameMethod=true
   complexObjectModel=true
   addTimeStamp=true
  
  
  
  1.4       +1 -12     jakarta-turbine-torque/src/java/org/apache/torque/om/BaseObject.java
  
  Index: BaseObject.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/om/BaseObject.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BaseObject.java	2001/08/20 21:07:50	1.3
  +++ BaseObject.java	2001/09/10 21:14:02	1.4
  @@ -63,7 +63,7 @@
    *
    * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
    * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
  - * @version $Id: BaseObject.java,v 1.3 2001/08/20 21:07:50 jon Exp $
  + * @version $Id: BaseObject.java,v 1.4 2001/09/10 21:14:02 jmcnally Exp $
    */
   public abstract class BaseObject implements Persistent, Serializable
   {
  @@ -309,17 +309,6 @@
           modified = false;
       }
   
  -    /**
  -     * Saves this object to the data store.  Not implemented by
  -     * default, so must be overridden if called.
  -     *
  -     * @exception Exception Problem saving this object.
  -     */
  -    public void save()
  -        throws Exception
  -    {
  -        throw new Error("BaseObject.save: " + NOT_IMPLEMENTED);
  -    }
   
       /**
        * Retrieves a field from the object by name. Must be overridden if called.
  
  
  
  1.4       +1 -21     jakarta-turbine-torque/src/java/org/apache/torque/om/Persistent.java
  
  Index: Persistent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/om/Persistent.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Persistent.java	2001/09/01 16:28:47	1.3
  +++ Persistent.java	2001/09/10 21:14:02	1.4
  @@ -61,7 +61,7 @@
    *
    * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
    * @author <a href="mailto:fedor@apache.org">Fedor K.</a>
  - * @version $Id: Persistent.java,v 1.3 2001/09/01 16:28:47 dlr Exp $
  + * @version $Id: Persistent.java,v 1.4 2001/09/10 21:14:02 jmcnally Exp $
    */
   public interface Persistent
   {
  @@ -119,24 +119,4 @@
        * @param m The new modified state for the object.
        */
       public void setModified(boolean m);
  -
  -    /**
  -     * Saves the object.
  -     */
  -    public void save() throws Exception;
  -
  -    /**
  -     * Stores the object in the database.  If the object is new,
  -     * it inserts it; otherwise an update is performed.
  -     */
  -    public void save(String dbName) throws Exception;
  -
  -    /**
  -     * Stores the object in the database.  If the object is new,
  -     * it inserts it; otherwise an update is performed.  This method
  -     * is meant to be used as part of a transaction, otherwise use
  -     * the save() method and the connection details will be handled
  -     * internally
  -     */
  -    public void save(DBConnection dbCon) throws Exception;
   }
  
  
  
  1.1                  jakarta-turbine-torque/src/java/org/apache/torque/om/SecurePersistent.java
  
  Index: SecurePersistent.java
  ===================================================================
  package org.apache.torque.om;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  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 the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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 THE APACHE SOFTWARE FOUNDATION 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 Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import org.apache.torque.pool.DBConnection;
  import org.apache.torque.security.SecurityInfo;
  
  /**
   * This interface defines methods related to saving an object
   *
   * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
   * @author <a href="mailto:fedor@apache.org">Fedor K.</a>
   * @version $Id: SecurePersistent.java,v 1.1 2001/09/10 21:14:02 jmcnally Exp $
   */
  public interface SecurePersistent
      extends Persistent
  {
      /**
       * Saves the object.
       */
      public void save(SecurityInfo securityInfo) throws Exception;
  
      /**
       * Stores the object in the database.  If the object is new,
       * it inserts it; otherwise an update is performed.
       */
      public void save(String dbName, SecurityInfo securityInfo) 
          throws Exception;
  
      /**
       * Stores the object in the database.  If the object is new,
       * it inserts it; otherwise an update is performed.  This method
       * is meant to be used as part of a transaction, otherwise use
       * the save() method and the connection details will be handled
       * internally
       */
      public void save(DBConnection dbCon, SecurityInfo securityInfo) 
          throws Exception;
  }
  
  
  
  1.1                  jakarta-turbine-torque/src/java/org/apache/torque/om/UnsecurePersistent.java
  
  Index: UnsecurePersistent.java
  ===================================================================
  package org.apache.torque.om;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  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 the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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 THE APACHE SOFTWARE FOUNDATION 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 Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import org.apache.torque.pool.DBConnection;
  
  /**
   * This interface defines methods related to saving an object
   *
   * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
   * @author <a href="mailto:fedor@apache.org">Fedor K.</a>
   * @version $Id: UnsecurePersistent.java,v 1.1 2001/09/10 21:14:02 jmcnally Exp $
   */
  public interface UnsecurePersistent
      extends Persistent
  {
      /**
       * Saves the object.
       */
      public void save() throws Exception;
  
      /**
       * Stores the object in the database.  If the object is new,
       * it inserts it; otherwise an update is performed.
       */
      public void save(String dbName) throws Exception;
  
      /**
       * Stores the object in the database.  If the object is new,
       * it inserts it; otherwise an update is performed.  This method
       * is meant to be used as part of a transaction, otherwise use
       * the save() method and the connection details will be handled
       * internally
       */
      public void save(DBConnection dbCon) throws Exception;
  }
  
  
  
  1.1                  jakarta-turbine-torque/src/java/org/apache/torque/security/SecurityException.java
  
  Index: SecurityException.java
  ===================================================================
  package org.apache.torque.security;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  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 the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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 THE APACHE SOFTWARE FOUNDATION 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 Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import org.apache.torque.TorqueException;
  
  /**
   * Exception to be thrown if SecurityInfo.hasPermission() returns false.
   *
   * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
   * @version $Id: SecurityException.java,v 1.1 2001/09/10 21:14:02 jmcnally Exp $
   */
  public class SecurityException extends TorqueException
  {
  }
  
  
  
  1.1                  jakarta-turbine-torque/src/java/org/apache/torque/security/SecurityInfo.java
  
  Index: SecurityInfo.java
  ===================================================================
  package org.apache.torque.security;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  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 the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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 THE APACHE SOFTWARE FOUNDATION 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 Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /**
   * Business objects may require this interface to be passed into methods
   * which need to pass authorization.
   *
   * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
   * @version $Id: SecurityInfo.java,v 1.1 2001/09/10 21:14:02 jmcnally Exp $
   */
  public interface SecurityInfo
  {
      /**
       * method called by an om prior to sensitive operation (such as save).
       */
      public boolean hasPermission();
  }
  
  
  
  1.2       +8 -2      jakarta-turbine-torque/src/templates/om/ExtensionObject.vm
  
  Index: ExtensionObject.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/templates/om/ExtensionObject.vm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExtensionObject.vm	2001/08/02 05:08:37	1.1
  +++ ExtensionObject.vm	2001/09/10 21:14:02	1.2
  @@ -10,7 +10,13 @@
       #set ($abstract = "abstract")
   #end
   
  -import org.apache.torque.om.Persistent;
  +#if ($secureSaveMethod)
  +#set ($interface = "SecurePersistent")
  +import org.apache.torque.om.SecurePersistent;
  +#else
  +#set ($interface = "UnsecurePersistent")
  +import org.apache.torque.om.UnsecurePersistent;
  +#end
   
   /** 
   #if ($addTimeStamp)
  @@ -25,6 +31,6 @@
    */
   public $!abstract class $table.JavaName 
       extends ${package}.$basePrefix$table.JavaName
  -    implements Persistent
  +    implements $interface
   {
   }
  
  
  
  1.6       +56 -7     jakarta-turbine-torque/src/templates/om/Object.vm
  
  Index: Object.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/templates/om/Object.vm,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Object.vm	2001/08/30 17:50:32	1.5
  +++ Object.vm	2001/09/10 21:14:02	1.6
  @@ -22,6 +22,10 @@
   #if ($addSaveMethod)
   import org.apache.torque.util.ObjectUtils;
   #end
  +#if ($secureSaveMethod)
  +import org.apache.torque.security.SecurityInfo;
  +import org.apache.torque.security.SecurityException;
  +#end
   
   /** 
   #if ($addTimeStamp)
  @@ -738,16 +742,54 @@
       
   
   #if (!$table.isAlias() && $addSaveMethod)
  +  #if ($secureSaveMethod)
  +      #set ($secInfosecInfo = "SecurityInfo securityInfo")
  +      #set ($secInfo = "securityInfo")
  +      #set ($secComma = ", ")
  +    /**
  +     * This method is called first thing in the save methods to allow
  +     * objects the chance to throw a SecurityException before any changes
  +     * to the persistent data will occur.  The default implementation throws
  +     * the SecurityException on a false result from 
  +     * SecurityInfo.hasPermission()
  +     */
  +    protected void checkSecurity($secInfosecInfo)
  +        throws SecurityException
  +    {
  +        if (!securityInfo.hasPermission())
  +        {
  +            throw new SecurityException();
  +        }
  +    }
  +  #else
  +      #set ($secInfosecInfo = "")
  +      #set ($secInfo = "")
  +      #set ($secComma = "")
  +  #end
  +
       /**
  +     * Allows objects to perform any logic needed before saving.  This method
  +     * is called after securityCheck.  The default implementation does nothing.
  +     */
  +    protected void doPreSave($secInfosecInfo)
  +        throws Exception
  +    {
  +    }
  +
  +    /**
        * Stores the object in the database.  If the object is new,
        * it inserts it; otherwise an update is performed.
        */
  -    public void save() throws Exception
  +    public void save($secInfosecInfo) throws Exception
       {
    #if ($complexObjectModel)
               save(${table.JavaName}Peer.getMapBuilder()
  -                .getDatabaseMap().getName());
  +                .getDatabaseMap().getName()${secComma}$secInfo);
    #else
  +    #if ($secureSaveMethod)
  +        checkSecurity($secInfo);
  +    #end
  +        doPreSave($secInfo);
           if (isModified())
           {
               if (isNew())
  @@ -772,14 +814,14 @@
        * in this file instead of in the super class, BaseObject.
   #end
        */
  -    public void save(String dbName) throws Exception
  +    public void save(String dbName${secComma}$secInfosecInfo) throws Exception
       {
           DBConnection dbCon = null;
    #if ($complexObjectModel)
           try
           {
               dbCon = BasePeer.beginTransaction(dbName);
  -            save(dbCon);
  +            save(dbCon${secComma}$secInfo);
           }
           catch(Exception e)
           {
  @@ -789,7 +831,10 @@
           BasePeer.commitTransaction(dbCon);
   
    #else
  -
  +    #if ($secureSaveMethod)
  +        checkSecurity($secInfo);
  +    #end
  +        doPreSave($secInfo);
           if (isModified())
           {
               try
  @@ -828,8 +873,12 @@
        * the save() method and the connection details will be handled
        * internally
        */
  -    public void save(DBConnection dbCon) throws Exception
  +    public void save(DBConnection dbCon${secComma}$secInfosecInfo) throws Exception
       {
  +    #if ($secureSaveMethod)
  +        checkSecurity($secInfo);
  +    #end
  +        doPreSave($secInfo);
     #if ($complexObjectModel)
         if (!alreadyInSave)
         {
  @@ -872,7 +921,7 @@
             {
                 for (int i=0; i<${collName}.size(); i++)
                 {
  -                  ((${className})${collName}.get(i)).save(dbCon);
  +                  ((${className})${collName}.get(i)).save(dbCon${secComma}$secInfo);
                 }
             }
        #end
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


Re: new methods in torque related to save()

Posted by Daniel Rall <dl...@finemaltcoding.com>.
John McNally <jm...@collab.net> writes:

> I just added a couple protected methods to the OM's to allow for some
> preprocessing prior to saving the object.  The simple one is a doPreSave
> method which has an empty default implementation, but provides a hook to
> allow pre-processing by the om.  The second one involves more classes
> and needs to be turned on with the secureSaveMethod property.  It
> modifies the save methods so that they take an
> object implementing the SecurityInfo interface.  It also adds a
> protected method securityCheck that calls the hasPermission method on
> SecurityInfo.  If the test fails a SecurityException is thrown and
> doPreSave and the rest of the save operations will not occur.  Since
> Persistent had just had the save methods added, I extended the interface
> and moved the save definitions to the children.  Any comments or
> suggestions for improvement?

What's the value of this over just overriding save() and calling
super.save() as your last op?

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


Re: new methods in torque related to save()

Posted by Jon Stevens <jo...@latchkey.com>.
on 9/10/01 1:16 PM, "John McNally" <jm...@collab.net> wrote:

> I just added a couple protected methods to the OM's to allow for some
> preprocessing prior to saving the object.  The simple one is a doPreSave
> method which has an empty default implementation, but provides a hook to
> allow pre-processing by the om.  The second one involves more classes
> and needs to be turned on with the secureSaveMethod property.  It
> modifies the save methods so that they take an
> object implementing the SecurityInfo interface.  It also adds a
> protected method securityCheck that calls the hasPermission method on
> SecurityInfo.  If the test fails a SecurityException is thrown and
> doPreSave and the rest of the save operations will not occur.  Since
> Persistent had just had the save methods added, I extended the interface
> and moved the save definitions to the children.  Any comments or
> suggestions for improvement?
> 
> john mcnally

It looks very good and will make life in the OM's easier in Scarab for sure.

I kind of cringe with the method name "doPreSave()", but I don't have a
better suggestion for a name.

One idea for the future might be to employ a valve/pipeline model on top of
the processing so that people could add valves within the chain of execution
wherever the pipeline dictated. However, this would probably require about a
bazillion times more work and I'm not sure it would be really worth the
effort. In other words, people might also want a doPreDelete(),
doPreSelect(), doPreSetAttributeId() etc...the valve/pipeline model would
allow for that without needing to constantly add doPre* methods all over the
kingdom.

John: On a side note, I just figured out last night that Intake has a
dependency on Torque (the import org.apache.torque.om.Retrievable
interface). It might be nice to get rid of that if possible (maybe copy the
interface into Intake Service) as well as add some documentation to the site
that says that objects which may have $intake.mapTo() called on them need to
implement that interface. It had me stumped last night at 1:00am because I
created an object which wraps around two OM objects (ie: the result of a
join) and I'm using that within Intake's model to populate form fields.

thanks,

-jon


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


new methods in torque related to save()

Posted by John McNally <jm...@collab.net>.
I just added a couple protected methods to the OM's to allow for some
preprocessing prior to saving the object.  The simple one is a doPreSave
method which has an empty default implementation, but provides a hook to
allow pre-processing by the om.  The second one involves more classes
and needs to be turned on with the secureSaveMethod property.  It
modifies the save methods so that they take an
object implementing the SecurityInfo interface.  It also adds a
protected method securityCheck that calls the hasPermission method on
SecurityInfo.  If the test fails a SecurityException is thrown and
doPreSave and the rest of the save operations will not occur.  Since
Persistent had just had the save methods added, I extended the interface
and moved the save definitions to the children.  Any comments or
suggestions for improvement?

john mcnally

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org