You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by ha...@apache.org on 2001/11/26 10:28:08 UTC

cvs commit: xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess HsqlIdentityAutoIncrementHelper.java IfxSerialAutoIncrementHelper.java ManualAutoIncrementHelper.java AbstractAttributeHelper.java AbstractAutoIncrementHelper.java AbstractOutputHelper.java AttributeHelper.java AutoIncrementHelper.java OutputHelper.java RequestAttributeHelper.java RequestAttributeOutputHelper.java RequestParameterHelper.java HsqlIdentityKeyAttributeHelper.java IfxSerialKeyAttributeHelper.java ManualKeyAttributeHelper.java

haul        01/11/26 01:28:08

  Modified:    scratchpad/webapp/mount/mod-db sitemap.xmap
               scratchpad/src/org/apache/cocoon/acting
                        ModularDatabaseAction.java
                        ModularDatabaseAddAction.java
                        ModularDatabaseDeleteAction.java
                        ModularDatabaseSelectAction.java
                        ModularDatabaseUpdateAction.java
               scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess
                        AbstractAttributeHelper.java
                        AbstractAutoIncrementHelper.java
                        AbstractOutputHelper.java AttributeHelper.java
                        AutoIncrementHelper.java OutputHelper.java
                        RequestAttributeHelper.java
                        RequestAttributeOutputHelper.java
                        RequestParameterHelper.java
  Added:       scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess
                        HsqlIdentityAutoIncrementHelper.java
                        IfxSerialAutoIncrementHelper.java
                        ManualAutoIncrementHelper.java
  Removed:     scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess
                        HsqlIdentityKeyAttributeHelper.java
                        IfxSerialKeyAttributeHelper.java
                        ManualKeyAttributeHelper.java
  Log:
  - Renamed *KeyAttributeHelper to *AutoIncrementHelper
  - removed modifiers from interfaces
  - (hopefully) removed all tabs
  - started code reformating to comply to code conventions (CC)
    Please feel free to email me to bring to my attention specific
    breaches from CC that you'd liked to have fixed NOW but also those
    you'd just like to see followed in new files. Thanks.
  
    Reviews & Comments welcome.
  
  Revision  Changes    Path
  1.3       +6 -6      xml-cocoon2/scratchpad/webapp/mount/mod-db/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/scratchpad/webapp/mount/mod-db/sitemap.xmap,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- sitemap.xmap	2001/11/23 10:50:35	1.2
  +++ sitemap.xmap	2001/11/26 09:28:07	1.3
  @@ -29,8 +29,8 @@
   	      the transaction when encountering an error during
   	      database ops? 
   	 -->
  -   	 <!-- <mode name="auto" src="org.apache.cocoon.acting.ModularDatabaseAccess.IfxSerialKeyAttributeHelper"/> -->
  -   	 <mode name="auto" src="org.apache.cocoon.acting.ModularDatabaseAccess.HsqlIdentityKeyAttributeHelper"/>
  +   	 <!-- <mode name="auto" src="org.apache.cocoon.acting.ModularDatabaseAccess.IfxSerialAutoIncrementHelper"/> -->
  +   	 <mode name="auto" src="org.apache.cocoon.acting.ModularDatabaseAccess.HsqlIdentityAutoIncrementHelper"/>
      	 <mode name="request" src="org.apache.cocoon.acting.ModularDatabaseAccess.RequestParameterHelper"/>
      	 <mode name="attribute" src="org.apache.cocoon.acting.ModularDatabaseAccess.RequestAttributeHelper"/>
      	 <output name="request" src="org.apache.cocoon.acting.ModularDatabaseAccess.RequestAttributeOutputHelper"/>
  @@ -45,8 +45,8 @@
   	    ModularDatabaseAction will complain if such a helper is
   	    missing. 
   	 -->
  -   	 <!-- <mode name="auto" src="org.apache.cocoon.acting.ModularDatabaseAccess.IfxSerialKeyAttributeHelper"/> -->
  -   	 <mode name="auto" src="org.apache.cocoon.acting.ModularDatabaseAccess.HsqlIdentityKeyAttributeHelper"/>
  +   	 <!-- <mode name="auto" src="org.apache.cocoon.acting.ModularDatabaseAccess.IfxSerialAutoIncrementHelper"/> -->
  +   	 <mode name="auto" src="org.apache.cocoon.acting.ModularDatabaseAccess.HsqlIdentityAutoIncrementHelper"/>
      	 <mode name="request" src="org.apache.cocoon.acting.ModularDatabaseAccess.RequestParameterHelper"/>
      	 <mode name="attribute" src="org.apache.cocoon.acting.ModularDatabaseAccess.RequestAttributeHelper"/>
      	 <output name="request" src="org.apache.cocoon.acting.ModularDatabaseAccess.RequestAttributeOutputHelper"/>
  @@ -61,8 +61,8 @@
   	    ModularDatabaseAction will complain if such a helper is
   	    missing. 
   	 -->
  -   	 <!-- <mode name="auto" src="org.apache.cocoon.acting.ModularDatabaseAccess.IfxSerialKeyAttributeHelper"/> -->
  -   	 <mode name="auto" src="org.apache.cocoon.acting.ModularDatabaseAccess.HsqlIdentityKeyAttributeHelper"/>
  +   	 <!-- <mode name="auto" src="org.apache.cocoon.acting.ModularDatabaseAccess.IfxSerialAutoIncrementHelper"/> -->
  +   	 <mode name="auto" src="org.apache.cocoon.acting.ModularDatabaseAccess.HsqlIdentityAutoIncrementHelper"/>
      	 <mode name="request" src="org.apache.cocoon.acting.ModularDatabaseAccess.RequestParameterHelper"/>
      	 <mode name="attribute" src="org.apache.cocoon.acting.ModularDatabaseAccess.RequestAttributeHelper"/>
      	 <output name="request" src="org.apache.cocoon.acting.ModularDatabaseAccess.RequestAttributeOutputHelper"/>
  
  
  
  1.3       +489 -529  xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAction.java
  
  Index: ModularDatabaseAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ModularDatabaseAction.java	2001/11/23 11:09:52	1.2
  +++ ModularDatabaseAction.java	2001/11/26 09:28:07	1.3
  @@ -86,55 +86,72 @@
    * components can utilize the helper components.
    *
    * @author <a href="mailto:haul@apache.org">Christian Haul</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2001/11/23 11:09:52 $
  + * @version CVS $Revision: 1.3 $ $Date: 2001/11/26 09:28:07 $
    */
  -public abstract class ModularDatabaseAction 
  -    extends AbstractDatabaseAction 
  -    implements Disposable, ThreadSafe, Contextualizable
  -{
  +public abstract class ModularDatabaseAction extends AbstractDatabaseAction 
  +    implements Disposable, ThreadSafe, Contextualizable {
   
       // ========================================================================
       // inner helper classes
       // ========================================================================
   
  +    /**
  +     * Structure that takes all processed data for one column.
  +     */
       protected class Column {
  -	boolean isKey = false;
  -	boolean isSet = false;
  -	boolean isAutoIncrement = false;
  -	String mode = null;
  -	Configuration modeConf = null;
  -	Configuration columnConf = null;
  +        boolean isKey = false;
  +        boolean isSet = false;
  +        boolean isAutoIncrement = false;
  +        String mode = null;
  +        Configuration modeConf = null;
  +        Configuration columnConf = null;
       }
   
  +    /**
  +     * Structure that takes all processed data for a table depending
  +     * on current default modes 
  +     */
       protected class CacheHelper {
  -	public String queryString = null;
  -	public int setMaster = -1;
  -	public boolean isSet = false;
  -	public int noOfKeys = 0;
  -	public Column[] columns = null;
  -
  -	public CacheHelper( int cols ) {
  -	    this(0,cols);
  -	}
  -	
  -	public CacheHelper( int keys, int cols ) {
  -	    noOfKeys = keys;
  -	    columns = new Column[cols];
  +        /**
  +         * Generated query string
  +         */
  +        public String queryString = null;
  +        /**
  +         * if a set is used, column number which is used to determine
  +         * the number of rows to insert. 
  +         */
  +        public int setMaster = -1;
  +        public boolean isSet = false;
  +        public int noOfKeys = 0;
  +        public Column[] columns = null;
  +        
  +        public CacheHelper( int cols ) {
  +            this(0,cols);
  +        }
  +        
  +        public CacheHelper( int keys, int cols ) {
  +            noOfKeys = keys;
  +            columns = new Column[cols];
               for ( int i=0; i<cols; i++ ) {
                   columns[i] = new Column();
               }
  -	}
  +        }
       }
   
   
  +    /**
  +     * Structure that takes up both current mode types for database
  +     * operations and table configuration data. Used to access parsed
  +     * configuration data.
  +     */
       protected class LookUpKey {
  -	public Configuration tableConf = null;
  -	public Map modeTypes = null;
  -	
  -	public LookUpKey( Configuration tableConf, Map modeTypes ) {
  -	    this.tableConf = tableConf;
  -	    this.modeTypes = modeTypes;
  -	}
  +        public Configuration tableConf = null;
  +        public Map modeTypes = null;
  +        
  +        public LookUpKey( Configuration tableConf, Map modeTypes ) {
  +            this.tableConf = tableConf;
  +            this.modeTypes = modeTypes;
  +        }
       }
   
       // ========================================================================
  @@ -191,90 +208,84 @@
       /**
        * Set the role manager
        */
  -    public void setRoleManager( 
  -			       RoleManager roles, 
  -			       Configuration config
  -			       ) 
  -    {
  +    public void setRoleManager( RoleManager roles, Configuration config ) {
           this.roleManager = roles;
           this.defaultConfig = config;
       }
   
  +
       /**
        * Set the current <code>ComponentManager</code> instance used by this
        * <code>Composable</code>.
        */
  -    public void compose( 
  -			ComponentManager manager
  -			) 
  -	throws ComponentException 
  -    {
  -	super.compose( manager );
  -	getLogger().debug("compose");
  +    public void compose( ComponentManager manager ) throws ComponentException {
  +
  +        super.compose( manager );
  +        if (getLogger().isDebugEnabled()) 
  +            getLogger().debug("compose");
           this.manager2 = new ExcaliburComponentManager(manager);
           this.manager2.setLogger(getLogger());
           this.manager2.contextualize(this.context);
           this.manager2.setRoleManager(this.roleManager);
   
  -	try {
  -	    if (this.defaultConfig != null) {
  -		this.manager2.configure(this.defaultConfig);
  -	    }
  -	    this.urlFactory = (URLFactory)manager.lookup(URLFactory.ROLE);
  -	    this.modeMapping = new ExcaliburComponentSelector();
  -	    this.outputMapping = new ExcaliburComponentSelector();
  -	    this.setupSelector(this.modeMapping);
  -	    this.setupSelector(this.outputMapping);
  -	    this.manager2.addComponentInstance(Selector.ROLE + "Selector", this.modeMapping);
  -	    this.manager2.addComponentInstance(Selector.ROLE + "Selector", this.outputMapping);
  +        try {
  +            if (this.defaultConfig != null) {
  +                this.manager2.configure(this.defaultConfig);
  +            }
  +            this.urlFactory = (URLFactory)manager.lookup(URLFactory.ROLE);
  +            this.modeMapping = new ExcaliburComponentSelector();
  +            this.outputMapping = new ExcaliburComponentSelector();
  +            this.setupSelector(this.modeMapping);
  +            this.setupSelector(this.outputMapping);
  +            this.manager2.addComponentInstance(Selector.ROLE + "Selector", this.modeMapping);
  +            this.manager2.addComponentInstance(Selector.ROLE + "Selector", this.outputMapping);
           } catch (Exception e) {
  -            getLogger().error("cannot obtain the Component", e);
  +            if (getLogger().isDebugEnabled())
  +                getLogger().error("cannot obtain the Component", e);
               throw new ComponentException("cannot obtain the URLFactory", e);
           }
       }
   
  -    private void setupSelector(
  -			       ExcaliburComponentSelector selector
  -			       ) 
  -	throws Exception 
  -    {
  +
  +
  +    private void setupSelector( ExcaliburComponentSelector selector ) throws Exception {
  +
           selector.setLogger(getLogger());
           selector.contextualize(this.context);
           selector.setRoleManager(this.roleManager);
           selector.compose(this.manager2);
       }
  +
  +
  +
  +    public void contextualize( Context context ) throws ContextException {
   
  -    public void contextualize(
  -			      Context context
  -			      ) 
  -	throws ContextException 
  -    {
           this.context = context;
       }
   
       /**
        * Return the component manager for this sitemap
        */
  -    public ComponentManager getComponentManager() 
  -    {
  +    public ComponentManager getComponentManager() {
  +
           return this.manager2;
       }
   
       /**
        * Release all components.
        */
  -    public void dispose() 
  -    {
  +    public void dispose() {
  +
           if (this.urlFactory != null) {
               manager.release((Component)this.urlFactory);
           }
           if (this.modeMapping != null) {
               manager2.release((Component)this.modeMapping);
  -	}
  +        }
           if (this.outputMapping != null) {
               manager2.release((Component)this.outputMapping);
           }
  -	manager2.dispose();
  +        manager2.dispose();
       }
   
   
  @@ -282,87 +293,89 @@
        * Configure modes that are used to delegate database specific methods
        * and other modes.
        */
  -    public void configure(
  -			  Configuration conf
  -			  ) 
  -	throws ConfigurationException 
  -    {
  -	try {
  -	    getLogger().debug("MDAA: configure");
  -	    LinkedList hints = new LinkedList();
  -	    if (conf != null) {
  -		String val = null;
  -		String nodeName = null;
  -		Configuration[] parameters = conf.getChildren();
  -		this.settings = new HashMap(parameters.length);
  -		for ( int i = 0; i < parameters.length; i++) {
  -		    nodeName= parameters[i].getName();
  -		    getLogger().debug("configure -- " + nodeName);
  -		    if ( nodeName != null ) {
  -			if ( "mode".equals(nodeName.trim()) || "output".equals(nodeName.trim())) {
  -			    String modeName = parameters[i].getAttribute("name");
  -			    String src = parameters[i].getAttribute("src");
  -			    if (modeName!=null && src!=null) {
  -				Configuration modeConfig = parameters[i];
  -				if (modeConfig == null) {
  -				    modeConfig = this.defaultConfig;
  -				}
  -				getLogger().debug("load -- " + modeName + " -> " + src);
  -				if ( "mode".equals(nodeName.trim())) {
  -				    this.load_component(modeMapping, modeName, src, modeConfig);
  -				    hints.add(modeName);
  -				} else {
  -				    this.load_component(outputMapping, modeName, src, modeConfig);
  -				    if ( !defaultModeNames.containsKey( MODE_OUTPUT ) ) {
  -					defaultModeNames.put( MODE_OUTPUT, modeName );
  -				    }
  -				}
  -			    }
  -			} else {
  -			    val = parameters[i].getValue();
  -			    this.settings.put(nodeName, val);
  -			}
  -		    }
  -		}
  -	    }
  -	    
  -	    this.modeMapping.initialize();
  -	    this.outputMapping.initialize();
  -	    this.manager2.initialize();
  -
  -	    ListIterator li = hints.listIterator();
  -	    while ( li.hasNext() ) {
  -		String modeName = (String) li.next();
  -		Component helper = modeMapping.select( modeName );
  -		if ( !defaultModeNames.containsKey( MODE_OTHERS ) && helper instanceof AttributeHelper ) { 
  -		    defaultModeNames.put( MODE_OTHERS, modeName );
  -		    getLogger().debug(modeName + " default mode for normal columns");
  -		}
  -		
  -		if ( !defaultModeNames.containsKey( MODE_AUTOINCR ) && helper instanceof AutoIncrementHelper ) { 
  -		    defaultModeNames.put( MODE_AUTOINCR, modeName );
  -		    getLogger().debug(modeName + " default mode for autoincrement columns");
  -		}
  -		modeMapping.release(helper);
  -	    }
  -	
  -	    if ( !defaultModeNames.containsKey( MODE_OTHERS ) || 
  -		 !defaultModeNames.containsKey( MODE_AUTOINCR ) || 
  -		 !defaultModeNames.containsKey( MODE_OUTPUT ) 
  -		 ) {
  -		throw new ConfigurationException("Not all default modes are configured:"
  -						 + ( defaultModeNames.containsKey( MODE_AUTOINCR ) ? " insert mode" : "" )
  -						 + ( defaultModeNames.containsKey( MODE_OTHERS ) ? " others" : "" )
  -						 + ( defaultModeNames.containsKey( MODE_OUTPUT ) ? " output" : "" )
  -						 );
  -	    }
  -	    
  -	} catch (Exception e) {
  -	    throw new ConfigurationException(e.toString());
  -	}
  -    }
  -
  +    public void configure( Configuration conf ) throws ConfigurationException {
   
  +        try {
  +            if (getLogger().isDebugEnabled())
  +                getLogger().debug("MDAA: configure");
  +            LinkedList hints = new LinkedList();
  +            if (conf != null) {
  +                String val = null;
  +                String nodeName = null;
  +                Configuration[] parameters = conf.getChildren();
  +                this.settings = new HashMap(parameters.length);
  +                for ( int i = 0; i < parameters.length; i++) {
  +                    nodeName= parameters[i].getName();
  +                    if (getLogger().isDebugEnabled())
  +                        getLogger().debug("configure -- " + nodeName);
  +                    if ( nodeName != null ) {
  +                        if ( "mode".equals(nodeName.trim()) || "output".equals(nodeName.trim())) {
  +                            String modeName = parameters[i].getAttribute("name");
  +                            String src = parameters[i].getAttribute("src");
  +                            if (modeName!=null && src!=null) {
  +                                Configuration modeConfig = parameters[i];
  +                                if (modeConfig == null) {
  +                                    modeConfig = this.defaultConfig;
  +                                }
  +                                if (getLogger().isDebugEnabled())
  +                                    getLogger().debug("load -- " + modeName + " -> " + src);
  +                                if ( "mode".equals(nodeName.trim())) {
  +                                    this.load_component(modeMapping, modeName, src, modeConfig);
  +                                    hints.add(modeName);
  +                                } else {
  +                                    this.load_component(outputMapping, modeName, src, modeConfig);
  +                                    if ( !defaultModeNames.containsKey( MODE_OUTPUT ) ) {
  +                                        defaultModeNames.put( MODE_OUTPUT, modeName );
  +                                    }
  +                                }
  +                            }
  +                        } else {
  +                            val = parameters[i].getValue();
  +                            this.settings.put(nodeName, val);
  +                        }
  +                    }
  +                }
  +            }
  +            
  +            this.modeMapping.initialize();
  +            this.outputMapping.initialize();
  +            this.manager2.initialize();
  +            
  +            ListIterator li = hints.listIterator();
  +            while ( li.hasNext() ) {
  +                String modeName = (String) li.next();
  +                Component helper = modeMapping.select( modeName );
  +                if ( !defaultModeNames.containsKey( MODE_OTHERS ) && helper instanceof AttributeHelper ) { 
  +                    defaultModeNames.put( MODE_OTHERS, modeName );
  +                    if (getLogger().isDebugEnabled())
  +                        getLogger().debug(modeName + " default mode for normal columns");
  +                }
  +                
  +                if ( !defaultModeNames.containsKey( MODE_AUTOINCR ) && helper instanceof AutoIncrementHelper ) { 
  +                    defaultModeNames.put( MODE_AUTOINCR, modeName );
  +                    if (getLogger().isDebugEnabled())
  +                        getLogger().debug(modeName + " default mode for autoincrement columns");
  +                }
  +                modeMapping.release(helper);
  +            }
  +            
  +            if ( !defaultModeNames.containsKey( MODE_OTHERS ) || 
  +                 !defaultModeNames.containsKey( MODE_AUTOINCR ) || 
  +                 !defaultModeNames.containsKey( MODE_OUTPUT ) 
  +                 ) {
  +                throw new ConfigurationException("Not all default modes are configured:"
  +                                                 + ( defaultModeNames.containsKey( MODE_AUTOINCR ) ? " insert mode" : "" )
  +                                                 + ( defaultModeNames.containsKey( MODE_OTHERS ) ? " others" : "" )
  +                                                 + ( defaultModeNames.containsKey( MODE_OUTPUT ) ? " output" : "" )
  +                                                 );
  +            }
  +            
  +        } catch (Exception e) {
  +            throw new ConfigurationException(e.toString());
  +        }
  +    }
  +    
  +    
       /**
        * Load a component.
        *
  @@ -370,36 +383,31 @@
        * @param classURL component's class name / URL
        * @param config configuration for this component
        */
  -    private void load_component( 
  -				ExcaliburComponentSelector selector,
  -				Object hint, 
  -				String classURL, 
  -				Configuration config 
  -				) 
  -	throws Exception 
  -    {
  -	Class clazz = null;
  -	//FIXME(GP): Is it true that a class name containing a colon should be an URL?
  -	if (classURL.indexOf(':') > 1) {
  -	    URL url = urlFactory.getURL(classURL);
  -	    byte[] b = getByteArrayFromStream(url.openStream());
  -	    clazz = ((RepositoryClassLoader)ClassUtils.getClassLoader()).defineClass(b);
  -	} else {
  -	    clazz = ClassUtils.loadClass(classURL);
  -	}
  -	if (!Component.class.isAssignableFrom(clazz)) {
  -	    throw new IllegalAccessException("Object " + classURL + " is not a Component");
  -	}
  -	selector.addComponent(hint, clazz, config);
  +    private void load_component( ExcaliburComponentSelector selector, Object hint, 
  +                                 String classURL, Configuration config ) throws Exception {
  +
  +        Class clazz = null;
  +        //FIXME(GP): Is it true that a class name containing a colon should be an URL?
  +        if (classURL.indexOf(':') > 1) {
  +            URL url = urlFactory.getURL(classURL);
  +            byte[] b = getByteArrayFromStream(url.openStream());
  +            clazz = ((RepositoryClassLoader)ClassUtils.getClassLoader()).defineClass(b);
  +        } else {
  +            clazz = ClassUtils.loadClass(classURL);
  +        }
  +        if (!Component.class.isAssignableFrom(clazz)) {
  +            throw new IllegalAccessException("Object " + classURL + " is not a Component");
  +        }
  +        selector.addComponent(hint, clazz, config);
       }
   
  +
  +    
       /**
        * Helper to read in a class
        */
  -    private byte[] getByteArrayFromStream(
  -					  InputStream stream
  -					  ) 
  -    {
  +    private byte[] getByteArrayFromStream( InputStream stream ) {
  +
           List list = new ArrayList();
           byte[] b = new byte[BYTE_ARRAY_SIZE];
           int last = 0;
  @@ -409,7 +417,8 @@
                   b = new byte[BYTE_ARRAY_SIZE];
               }
           } catch (IOException ioe) {
  -            getLogger().error("cannot read class byte stream", ioe);
  +            if (getLogger().isErrorEnabled())
  +                getLogger().error("cannot read class byte stream", ioe);
           }
           list.add(b);
           int listSize = list.size();
  @@ -436,17 +445,19 @@
        * descriptor file.
        */
       protected DataSourceComponent getDataSource( Configuration conf, Parameters parameters )
  -	throws ComponentException
  -    {
  -	String sourceName = parameters.getParameter( "connection", (String) settings.get( "connection" ) );
  -	if ( sourceName == null ) {
  -	    return getDataSource( conf );
  -	} else {
  -	    getLogger().debug("Using datasource: "+sourceName);
  -	    return (DataSourceComponent) this.dbselector.select(sourceName);
  -	}
  +        throws ComponentException {
  +
  +        String sourceName = parameters.getParameter( "connection", (String) settings.get( "connection" ) );
  +        if ( sourceName == null ) {
  +            return getDataSource( conf );
  +        } else {
  +            if (getLogger().isDebugEnabled())
  +                getLogger().debug("Using datasource: "+sourceName);
  +            return (DataSourceComponent) this.dbselector.select(sourceName);
  +        }
       }
   
  +
       /**
        * Store a key/value pair in the request attributes. We prefix the key
        * with the name of this class to prevent potential name collisions.
  @@ -454,38 +465,43 @@
        * to take care of what to do with the values.
        */
       void setRequestAttribute(Request request, String key, Object value) {
  -	try {
  -	    OutputHelper oh = (OutputHelper) outputMapping.select( (String) defaultModeNames.get( MODE_OUTPUT ) );
  -	    oh.setAttribute( null, request, key, value );
  -	    outputMapping.release( oh );
  -	} catch (Exception e) {
  -	    getLogger()
  -		.warn( "Could not select output mode " 
  -		       + (String) defaultModeNames.get( MODE_OUTPUT ) 
  -		       + ":" + e.getMessage() );
  -	}
  +
  +        try {
  +            OutputHelper oh = (OutputHelper) outputMapping.select( (String) defaultModeNames.get( MODE_OUTPUT ) );
  +            oh.setAttribute( null, request, key, value );
  +            outputMapping.release( oh );
  +        } catch (Exception e) {
  +                if (getLogger().isWarnEnabled())
  +                    getLogger()
  +                        .warn( "Could not select output mode " 
  +                               + (String) defaultModeNames.get( MODE_OUTPUT ) 
  +                               + ":" + e.getMessage() );
  +        }
       }
   
  +
       /**
        * Retrieve a value from the request attributes.
        * This method overrides super class' method to allow an OutputHelper 
        * to take care of where to get the values.
        */
       Object getRequestAttribute(Request request, String key) {
  -	Object value = null;
  -	try {
  -	    OutputHelper oh = (OutputHelper) outputMapping.select( (String) defaultModeNames.get( MODE_OUTPUT ) );
  -	    value = oh.getAttribute( null, request, key );
  -	    outputMapping.release( oh );
  -	} catch (Exception e) {
  -	    getLogger()
  -		.warn( "Could not select output mode "
  -		       + (String) defaultModeNames.get( MODE_OUTPUT )
  -		       + ":" + e.getMessage());
  -	}
  -	return value;
  -    }
   
  +        Object value = null;
  +        try {
  +            OutputHelper oh = (OutputHelper) outputMapping.select( (String) defaultModeNames.get( MODE_OUTPUT ) );
  +            value = oh.getAttribute( null, request, key );
  +            outputMapping.release( oh );
  +        } catch (Exception e) {
  +            if (getLogger().isWarnEnabled())
  +                getLogger()
  +                    .warn( "Could not select output mode "
  +                           + (String) defaultModeNames.get( MODE_OUTPUT )
  +                           + ":" + e.getMessage());
  +        }
  +        return value;
  +    }
  +    
   
       // ========================================================================
       // main method
  @@ -497,52 +513,46 @@
        * the file referenced by the "descriptor" parameter conforms
        * to the AbstractDatabaseAction specifications.
        */
  -    public Map act(
  -		   Redirector redirector, 
  -		   SourceResolver resolver, 
  -		   Map objectModel, 
  -		   String source, 
  -		   Parameters param
  -		   ) 
  -	throws Exception 
  -    {
  +    public Map act( Redirector redirector, SourceResolver resolver, Map objectModel, 
  +                    String source, Parameters param ) throws Exception {
  +
           DataSourceComponent datasource = null;
           Connection conn = null;
           Map results = new HashMap();
   
  -	// read global parameter settings
  -	boolean reloadable = Constants.DESCRIPTOR_RELOADABLE_DEFAULT;
  -	Request request = (Request) objectModel.get(Constants.REQUEST_OBJECT);
  -
  -	if (this.settings.containsKey("reloadable"))
  -	    reloadable = Boolean.getBoolean((String) this.settings.get("reloadable"));
  -	// read local parameter settings
  +        // read global parameter settings
  +        boolean reloadable = Constants.DESCRIPTOR_RELOADABLE_DEFAULT;
  +        Request request = (Request) objectModel.get(Constants.REQUEST_OBJECT);
  +        
  +        if (this.settings.containsKey("reloadable"))
  +            reloadable = Boolean.getBoolean((String) this.settings.get("reloadable"));
  +        // read local parameter settings
           try {
               Configuration conf = 
  -		this.getConfiguration(param.getParameter("descriptor", (String) this.settings.get("descriptor")), 
  -				      param.getParameterAsBoolean("reloadable",reloadable));
  -
  +                this.getConfiguration(param.getParameter("descriptor", (String) this.settings.get("descriptor")), 
  +                                      param.getParameterAsBoolean("reloadable",reloadable));
  +            
               datasource = this.getDataSource(conf, param);
               conn = datasource.getConnection();
               if (conn.getAutoCommit() == true) {
                   conn.setAutoCommit(false);
               }
   
  -	    Configuration[] tables = conf.getChildren("table");
  -	    String tablesetname = param.getParameter("table-set", (String) this.settings.get("table-set"));
  -	    Map set_tables = null; // default to old behaviour
  -	    
  -	    HashMap modeTypes = null;
  -
  -	    if (tablesetname != null) {
  -		// new set based behaviour
  -		Configuration[] tablesets = conf.getChildren("table-set");
  -		String setname = null;
  -		boolean found = false;
  -		
  -		// find tables contained in tableset
  -		int j = 0;
  -		for (j=0; j<tablesets.length; j++) {
  +            Configuration[] tables = conf.getChildren("table");
  +            String tablesetname = param.getParameter("table-set", (String) this.settings.get("table-set"));
  +            Map set_tables = null; // default to old behaviour
  +            
  +            HashMap modeTypes = null;
  +
  +            if (tablesetname != null) {
  +                // new set based behaviour
  +                Configuration[] tablesets = conf.getChildren("table-set");
  +                String setname = null;
  +                boolean found = false;
  +                
  +                // find tables contained in tableset
  +                int j = 0;
  +                for (j=0; j<tablesets.length; j++) {
                       setname = tablesets[j].getAttribute ("name", "");
                       if (tablesetname.trim().equals (setname.trim ())) {
                           found = true;
  @@ -552,62 +562,65 @@
                   if (!found) {
                       throw new IOException(" given set " + tablesetname + " does not exists in a description file.");
                   }
  -
  -		Configuration[] set = tablesets[j].getChildren("table");
  -		
  -		// construct a Map that contains the names of the tables
  -		// contained in the requested tableset
  -		set_tables = new HashMap(set.length);
  -		for (int i=0; i<set.length; i++) {
  -		    // look for alternative modes
  -		    modeTypes = new HashMap(2);
  -		    modeTypes.put( MODE_AUTOINCR, set[i].getAttribute( "autoincr-mode", "autoincr" ) );
  -		    modeTypes.put( MODE_OTHERS, set[i].getAttribute( "others-mode",   "others" ) );
  -		    set_tables.put(set[i].getAttribute("name",""), modeTypes);
  -		}
  -	    } else {
  -		modeTypes = new HashMap(2);
  -		modeTypes.put( MODE_AUTOINCR, "autoincr" );
  -		modeTypes.put( MODE_OTHERS, "others" );
  -	    };
  -	    for (int i=0; i<tables.length; i++) {
  -		if ( set_tables == null || 
  -		     set_tables.containsKey( tables[i].getAttribute( "name" ) ) ||
  -		     ( tables[i].getAttribute( "alias", null ) != null && set_tables.containsKey( tables[i].getAttribute( "alias" ) ) )
  -		    ) {
  -		    if (tablesetname != null) {
  -			modeTypes = (HashMap) set_tables.get(tables[i].getAttribute("name"));
  -		    }
  -		    processTable( tables[i], conn, request, results, modeTypes );
  -		}
  -	    }
  -
  +                
  +                Configuration[] set = tablesets[j].getChildren("table");
  +        
  +                // construct a Map that contains the names of the tables
  +                // contained in the requested tableset
  +                set_tables = new HashMap(set.length);
  +                for (int i=0; i<set.length; i++) {
  +                    // look for alternative modes
  +                    modeTypes = new HashMap(2);
  +                    modeTypes.put( MODE_AUTOINCR, set[i].getAttribute( "autoincr-mode", "autoincr" ) );
  +                    modeTypes.put( MODE_OTHERS, set[i].getAttribute( "others-mode",   "others" ) );
  +                    set_tables.put(set[i].getAttribute("name",""), modeTypes);
  +                }
  +            } else {
  +                modeTypes = new HashMap(2);
  +                modeTypes.put( MODE_AUTOINCR, "autoincr" );
  +                modeTypes.put( MODE_OTHERS, "others" );
  +            };
  +            for (int i=0; i<tables.length; i++) {
  +                if ( set_tables == null || 
  +                     set_tables.containsKey( tables[i].getAttribute( "name" ) ) ||
  +                     ( tables[i].getAttribute( "alias", null ) != null && set_tables.containsKey( tables[i].getAttribute( "alias" ) ) )
  +                     ) {
  +                    if (tablesetname != null) {
  +                        modeTypes = (HashMap) set_tables.get(tables[i].getAttribute("name"));
  +                    }
  +                    processTable( tables[i], conn, request, results, modeTypes );
  +                }
  +            }
  +            
               conn.commit();
  -	    OutputHelper oh = (OutputHelper) outputMapping.select( (String) defaultModeNames.get( MODE_OUTPUT ) );
  -	    oh.commit( null, request );
  -	    outputMapping.release( oh );
  +            OutputHelper oh = (OutputHelper) outputMapping.select( (String) defaultModeNames.get( MODE_OUTPUT ) );
  +            oh.commit( null, request );
  +            outputMapping.release( oh );
           } catch (Exception e) {
               if ( conn != null ) {
                   try {
  -		    getLogger().debug( "Rolling back transaction. Caused by " + e.getMessage() );
  +                    if (getLogger().isDebugEnabled())
  +                        getLogger().debug( "Rolling back transaction. Caused by " + e.getMessage() );
                       conn.rollback();
  -		    OutputHelper oh = (OutputHelper) outputMapping.select( (String) defaultModeNames.get( MODE_OUTPUT ) );
  -		    oh.rollback( null, request, e );
  -		    outputMapping.release( oh );
  +                    OutputHelper oh = (OutputHelper) outputMapping.select( (String) defaultModeNames.get( MODE_OUTPUT ) );
  +                    oh.rollback( null, request, e );
  +                    outputMapping.release( oh );
                   } catch (SQLException se) {
  -                    getLogger().debug("There was an error rolling back the transaction", se);
  +                    if (getLogger().isDebugEnabled())
  +                        getLogger().debug("There was an error rolling back the transaction", se);
                   }
               }
   
               //throw new ProcessingException("Could not add record :position = " + currentIndex, e);
   
  -	    // don't throw an exception, an error has been signalled, that should suffice
  -	    
  -	    String throwException = (String) this.settings.get( "throw-exception", param.getParameter( "throw-exception", null ) );
  -	    if ( throwException != null && 
  -		 ( throwException.equalsIgnoreCase( "true" ) || throwException.equalsIgnoreCase( "yes" ) ) ) {
  -		throw new ProcessingException("Could not add record",e);
  -	    }
  +            // don't throw an exception, an error has been signalled, that should suffice
  +        
  +            String throwException = (String) this.settings.get( "throw-exception", 
  +                                                                param.getParameter( "throw-exception", null ) );
  +            if ( throwException != null && 
  +                 ( throwException.equalsIgnoreCase( "true" ) || throwException.equalsIgnoreCase( "yes" ) ) ) {
  +                throw new ProcessingException("Could not add record",e);
  +            }
           } finally {
               if (conn != null) {
                   try {
  @@ -616,14 +629,16 @@
                       getLogger().warn("There was an error closing the datasource", sqe);
                   }
               }
  -
  -            if (datasource != null) this.dbselector.release(datasource);
  +            
  +            if (datasource != null) 
  +                this.dbselector.release(datasource);
           }
  -
  +        
           return Collections.unmodifiableMap(results);
       }
   
   
  +
       /**
        * Inserts a row or a set of rows into the given table based on the
        * request parameters
  @@ -632,48 +647,44 @@
        * @param conn the database connection
        * @param request the request
        */
  -    void processTable(
  -		      Configuration table, 
  -		      Connection conn, 
  -		      Request request, 
  -		      Map results,
  -		      HashMap modeTypes
  -		      ) 
  -	throws SQLException,
  -	       ConfigurationException,
  -	       Exception 
  -    {
  -      PreparedStatement statement = null;
  -      try {
  -	  CacheHelper queryData = this.getQuery( table, modeTypes, defaultModeNames );
  -	  getLogger().debug("query: "+queryData.queryString);
  -	  statement = conn.prepareStatement(queryData.queryString);
  -
  -	  Object[][] columnValues = this.getColumnValues( table, queryData, request );
  -
  -	  int setLength = 1;
  -	  if ( queryData.isSet ) {
  -	      if ( columnValues[ queryData.setMaster ] != null ) {
  -		  setLength = columnValues[ queryData.setMaster ].length;
  -	      } else {
  -		  setLength = 0;
  -	      }
  -	  }
  -
  -	  for ( int rowIndex = 0; rowIndex < setLength; rowIndex++ ) {
  -	      getLogger().debug( "====> row no. " + rowIndex );
  -	      processRow( request, conn, statement, table, queryData, columnValues, rowIndex, results );
  -	  }
  -
  -      } finally {
  -	  try {
  -	      if (statement != null) {
  -		  statement.close();
  -	      }
  -	  } catch (SQLException e) {}
  -      }
  +    protected void processTable( Configuration table, Connection conn, Request request, 
  +                                 Map results, HashMap modeTypes ) 
  +        throws SQLException, ConfigurationException, Exception {
  +
  +        PreparedStatement statement = null;
  +        try {
  +            CacheHelper queryData = this.getQuery( table, modeTypes, defaultModeNames );
  +            if (getLogger().isDebugEnabled())
  +                getLogger().debug("query: "+queryData.queryString);
  +            statement = conn.prepareStatement(queryData.queryString);
  +            
  +            Object[][] columnValues = this.getColumnValues( table, queryData, request );
  +            
  +            int setLength = 1;
  +            if ( queryData.isSet ) {
  +                if ( columnValues[ queryData.setMaster ] != null ) {
  +                    setLength = columnValues[ queryData.setMaster ].length;
  +                } else {
  +                    setLength = 0;
  +                }
  +            }
  +            
  +            for ( int rowIndex = 0; rowIndex < setLength; rowIndex++ ) {
  +                if (getLogger().isDebugEnabled())
  +                    getLogger().debug( "====> row no. " + rowIndex );
  +                processRow( request, conn, statement, table, queryData, columnValues, rowIndex, results );
  +            }
  +            
  +        } finally {
  +            try {
  +                if (statement != null) {
  +                    statement.close();
  +                }
  +            } catch (SQLException e) {}
  +        }
       }
   
  +    
       /**
        * Choose a mode configuration based on its name.
        * @param conf Configuration (i.e. a column's configuration) that might have
  @@ -683,38 +694,34 @@
        * Special mode "all" matches all queried types.
        * @return configuration that has desired type or type "all" or null.
        */
  -    protected Configuration getMode( 
  -				    Configuration conf,
  -				    String type
  -				    ) throws ConfigurationException
  -    {
  -	String modeAll = "all";
  -	Configuration[] modes = conf.getChildren("mode");
  -	Configuration modeConfig = null;;
  -
  -	for ( int i=0; i<modes.length; i++ ) {
  -	    String modeType = modes[i].getAttribute("type", "others");
  -	    if ( modeType.equals(type) || modeType.equals(modeAll)) {
  -		getLogger().debug("requested mode was \""+type+"\" returning \""+modeType+"\"");
  -		modeConfig = modes[i];
  -		break;
  -	    };
  -	}
  +    protected Configuration getMode( Configuration conf, String type ) 
  +        throws ConfigurationException {
   
  -	return modeConfig;
  +        String modeAll = "all";
  +        Configuration[] modes = conf.getChildren("mode");
  +        Configuration modeConfig = null;;
  +        
  +        for ( int i=0; i<modes.length; i++ ) {
  +            String modeType = modes[i].getAttribute("type", "others");
  +            if ( modeType.equals(type) || modeType.equals(modeAll)) {
  +                if (getLogger().isDebugEnabled())
  +                    getLogger().debug("requested mode was \""+type+"\" returning \""+modeType+"\"");
  +                modeConfig = modes[i];
  +                break;
  +            };
  +        }
  +        
  +        return modeConfig;
       }
   
   
       /**
        * compose name for output a long the lines of "table.column"
        */
  -    String getOutputName (
  -			  Configuration tableConf,
  -			  Configuration columnConf
  -			  )
  -	throws ConfigurationException
  -    {
  -	return getOutputName( tableConf, columnConf, -1 );
  +    protected String getOutputName ( Configuration tableConf, Configuration columnConf )
  +        throws ConfigurationException {
  +
  +        return getOutputName( tableConf, columnConf, -1 );
       }
   
   
  @@ -722,18 +729,14 @@
        * compose name for output a long the lines of "table.column[row]" or
        * "table.column" if rowIndex is -1.
        */
  -    String getOutputName (
  -			  Configuration tableConf,
  -			  Configuration columnConf,
  -			  int rowIndex
  -			  )
  -	throws ConfigurationException
  -    {
  -	return ( tableConf.getAttribute("alias", tableConf.getAttribute("name") ) 
  -		 + "." + columnConf.getAttribute("name") 
  -		 + ( rowIndex == -1 ? "" : "[" + rowIndex + "]" ) );
  -    }
  +    protected String getOutputName ( Configuration tableConf, Configuration columnConf, int rowIndex )
  +        throws ConfigurationException {
   
  +        return ( tableConf.getAttribute("alias", tableConf.getAttribute("name") ) 
  +                 + "." + columnConf.getAttribute("name") 
  +                 + ( rowIndex == -1 ? "" : "[" + rowIndex + "]" ) );
  +    }
  +    
   
       /*
        * Read all values for a column from an AttributeHelper
  @@ -744,87 +747,83 @@
        * a set.
        *
        */
  -    Object[] getColumnValue( 
  -			    Configuration tableConf,
  -			    Column column,
  -			    Request request
  -			    )
  -	throws ConfigurationException,
  -	       ComponentException
  -    {
  -	if ( column.isAutoIncrement ) {
  -	    return new Object[1];
  -	} else {
  -	    Object[] values;
  -	    AttributeHelper dph = (AttributeHelper) modeMapping.select( column.mode );
  -	    String cname = getOutputName( tableConf, column.columnConf );
  -	    if ( column.isSet ){
  -		getLogger().debug( "Trying to set column " + cname +" using getAttributeValues method");
  -		values = dph.getAttributeValues( cname, column.modeConf, request );
  -	    } else {
  -		getLogger().debug( "Trying to set column " + cname +" using getAttribute method");
  -		values = new Object[1];
  -		values[0] = dph.getAttribute( cname, column.modeConf, request );
  -	    }
  -	    modeMapping.release( dph );
  -	    if ( values != null ) {
  -		for ( int i = 0; i < values.length; i++ ) {
  -		    getLogger().debug( "Setting column " + cname + " [" + i + "] " + values[i] );
  -		}
  -	    }
  -	    return values;
  -	}
  +    protected Object[] getColumnValue( Configuration tableConf, Column column, Request request )
  +        throws ConfigurationException, ComponentException {
  +
  +        if ( column.isAutoIncrement ) {
  +            return new Object[1];
  +        } else {
  +            Object[] values;
  +            AttributeHelper dph = (AttributeHelper) modeMapping.select( column.mode );
  +            String cname = getOutputName( tableConf, column.columnConf );
  +            if ( column.isSet ){
  +                if (getLogger().isDebugEnabled())
  +                    getLogger().debug( "Trying to set column " + cname +" using getAttributeValues method");
  +                values = dph.getAttributeValues( cname, column.modeConf, request );
  +            } else {
  +                if (getLogger().isDebugEnabled())
  +                    getLogger().debug( "Trying to set column " + cname +" using getAttribute method");
  +                values = new Object[1];
  +                values[0] = dph.getAttribute( cname, column.modeConf, request );
  +            }
  +            modeMapping.release( dph );
  +            if ( values != null ) {
  +                for ( int i = 0; i < values.length; i++ ) {
  +                    if (getLogger().isDebugEnabled())
  +                        getLogger().debug( "Setting column " + cname + " [" + i + "] " + values[i] );
  +                }
  +            }
  +            return values;
  +        }
       }
   
   
       /**
        * Setup parsed attribute configuration object
        */
  -    protected void fillModes ( Configuration[] conf,
  -			       boolean isKey,
  -			       HashMap defaultModeNames,
  -			       HashMap modeTypes,
  -			       CacheHelper set
  -			       )
  -	throws ConfigurationException
  -    {
  -	String setMode = null;
  -	int setMaster = -1;
  -	String setMastersMode = null;
  -	boolean manyrows = false;
  -	int offset = ( isKey ? 0: set.noOfKeys);
  -
  +    protected void fillModes ( Configuration[] conf, boolean isKey, HashMap defaultModeNames,
  +                               HashMap modeTypes, CacheHelper set )
  +        throws ConfigurationException {
  +
  +        String setMode = null;
  +        int setMaster = -1;
  +        String setMastersMode = null;
  +        boolean manyrows = false;
  +        int offset = ( isKey ? 0: set.noOfKeys);
  +        
           for ( int i = offset; i < conf.length + offset; i++ ) {
  -	    getLogger().debug("i="+i);
  -	    set.columns[i].columnConf =  conf[ i - offset ];
  -	    set.columns[i].isSet = false;
  -	    set.columns[i].isKey = isKey;
  -	    set.columns[i].isAutoIncrement = false;
  -	    if ( isKey & this.honourAutoIncrement() ) {
  -		String autoIncrement = set.columns[i].columnConf.getAttribute("autoincrement","false");
  -		if ( autoIncrement.equalsIgnoreCase("yes") || autoIncrement.equalsIgnoreCase("true") ) {
  -		    set.columns[i].isAutoIncrement = true;
  -		}
  -	    }
  -	    set.columns[i].modeConf = getMode( set.columns[i].columnConf, 
  -					       selectMode( set.columns[i].isAutoIncrement, modeTypes ) );
  -	    set.columns[i].mode = ( set.columns[i].modeConf != null ? 
  -				    set.columns[i].modeConf.getAttribute( "name", selectMode( isKey, defaultModeNames ) ) :  selectMode( isKey, defaultModeNames ) );
  -	    // Determine set mode for a whole column ...
  -	    setMode = set.columns[i].columnConf.getAttribute("set", null);  // master vs slave vs null
  -	    if ( setMode == null && set.columns[i].modeConf != null ) {
  -		// ... or for each mode individually
  -		setMode = set.columns[i].modeConf.getAttribute("set", null);
  -	    }
  -	    if ( setMode != null ) {
  -		manyrows = true;
  -		set.columns[i].isSet = true;
  -		set.isSet = true;
  -		if ( setMode.equals("master") ) {
  -		    set.setMaster = i;
  -		}
  -	    } 
  -	}
  +            if (getLogger().isDebugEnabled())
  +                getLogger().debug("i="+i);
  +            set.columns[i].columnConf =  conf[ i - offset ];
  +            set.columns[i].isSet = false;
  +            set.columns[i].isKey = isKey;
  +            set.columns[i].isAutoIncrement = false;
  +            if ( isKey & this.honourAutoIncrement() ) {
  +                String autoIncrement = set.columns[i].columnConf.getAttribute("autoincrement","false");
  +                if ( autoIncrement.equalsIgnoreCase("yes") || autoIncrement.equalsIgnoreCase("true") ) {
  +                    set.columns[i].isAutoIncrement = true;
  +                }
  +            }
  +            set.columns[i].modeConf = getMode( set.columns[i].columnConf, 
  +                                               selectMode( set.columns[i].isAutoIncrement, modeTypes ) );
  +            set.columns[i].mode = ( set.columns[i].modeConf != null ? 
  +                                    set.columns[i].modeConf.getAttribute( "name", selectMode( isKey, defaultModeNames ) ) :  
  +                                    selectMode( isKey, defaultModeNames ) );
  +            // Determine set mode for a whole column ...
  +            setMode = set.columns[i].columnConf.getAttribute("set", null);  // master vs slave vs null
  +            if ( setMode == null && set.columns[i].modeConf != null ) {
  +                // ... or for each mode individually
  +                setMode = set.columns[i].modeConf.getAttribute("set", null);
  +            }
  +            if ( setMode != null ) {
  +                manyrows = true;
  +                set.columns[i].isSet = true;
  +                set.isSet = true;
  +                if ( setMode.equals("master") ) {
  +                    set.setMaster = i;
  +                }
  +            } 
  +        }
       }
   
   
  @@ -832,28 +831,20 @@
       /**
        * Put key values into request attributes.
        */
  -    void storeKeyValue( 
  -		       Configuration tableConf, 
  -		       Column key,
  -		       int rowIndex,
  -		       Connection conn, 
  -		       Statement statement, 
  -		       Request request, 
  -		       Map results
  -		       ) 
  -	throws SQLException, 
  -	       ConfigurationException, 
  -	       ComponentException 
  -    {
  -	AutoIncrementHelper dah = (AutoIncrementHelper) modeMapping.select( key.mode );
  -	if (!dah.includeAsValue()) {
  -	    String keyname = getOutputName( tableConf, key.columnConf, rowIndex );
  -	    Object value = dah.getPostValue( tableConf, key.columnConf, key.modeConf, conn, statement, request );
  -	    getLogger().debug( "Retrieving autoincrement for " + keyname + "as " + value );
  -	    setRequestAttribute( request, keyname, value );
  -	    results.put( keyname, String.valueOf( value ) );
  -	}
  -	modeMapping.release(dah);
  +    protected void storeKeyValue( Configuration tableConf, Column key, int rowIndex, Connection conn, 
  +                                  Statement statement, Request request, Map results ) 
  +        throws SQLException, ConfigurationException, ComponentException {
  +
  +        AutoIncrementHelper dah = (AutoIncrementHelper) modeMapping.select( key.mode );
  +        if (!dah.includeAsValue()) {
  +            String keyname = getOutputName( tableConf, key.columnConf, rowIndex );
  +            Object value = dah.getPostValue( tableConf, key.columnConf, key.modeConf, conn, statement, request );
  +            if (getLogger().isDebugEnabled())
  +                getLogger().debug( "Retrieving autoincrement for " + keyname + "as " + value );
  +            setRequestAttribute( request, keyname, value );
  +            results.put( keyname, String.valueOf( value ) );
  +        }
  +        modeMapping.release(dah);
       }
   
   
  @@ -870,40 +861,30 @@
        * @param result sitemap result object
        * @return the number of columns by which to increment the currentIndex
        */
  -    int setKeyAuto (
  -		    Configuration table, 
  -		    Column column, 
  -		    int currentIndex, 
  -		    int rowIndex,
  -		    Connection conn, 
  -		    PreparedStatement statement, 
  -		    Request request, 
  -		    Map results
  -		    ) 
  -	throws ConfigurationException, 
  -	       SQLException, 
  -	       ComponentException, 
  -	       Exception 
  -    {
  -
  -      int columnCount = 0;
  -
  -      AutoIncrementHelper dah = (AutoIncrementHelper) modeMapping.select( column.mode );
  -      if ( dah.includeInQuery() ) {
  -	  if ( dah.includeAsValue() ) {
  -	      Object value = dah.getPreValue( table, column.columnConf, column.modeConf, conn, request );
  -	      String keyname = this.getOutputName( table, column.columnConf, rowIndex );
  -	      getLogger().debug( "Setting key " + keyname + " to " + value );
  -	      statement.setObject( currentIndex, value );
  -	      setRequestAttribute( request, keyname, value );
  -	      results.put( keyname, String.valueOf( value ) );
  -	      columnCount = 1;
  -	  }
  -      } else {
  -	  getLogger().debug( "Automatically setting key" );
  -      }  
  -      modeMapping.release( dah );
  -      return columnCount;
  +    protected int setKeyAuto ( Configuration table, Column column, int currentIndex, int rowIndex,
  +                               Connection conn, PreparedStatement statement, Request request, Map results ) 
  +        throws ConfigurationException, SQLException, ComponentException, Exception {
  +
  +        int columnCount = 0;
  +
  +        AutoIncrementHelper dah = (AutoIncrementHelper) modeMapping.select( column.mode );
  +        if ( dah.includeInQuery() ) {
  +            if ( dah.includeAsValue() ) {
  +                Object value = dah.getPreValue( table, column.columnConf, column.modeConf, conn, request );
  +                String keyname = this.getOutputName( table, column.columnConf, rowIndex );
  +                if (getLogger().isDebugEnabled())
  +                    getLogger().debug( "Setting key " + keyname + " to " + value );
  +                statement.setObject( currentIndex, value );
  +                setRequestAttribute( request, keyname, value );
  +                results.put( keyname, String.valueOf( value ) );
  +                columnCount = 1;
  +            }
  +        } else {
  +            if (getLogger().isDebugEnabled())
  +                getLogger().debug( "Automatically setting key" );
  +        }  
  +        modeMapping.release( dah );
  +        return columnCount;
       }
   
       // ========================================================================
  @@ -917,19 +898,10 @@
        * This method is intended to be overridden by classes that
        * implement other operations e.g. delete
        */
  -    protected abstract void processRow( 
  -				       Request request,
  -				       Connection conn,
  -				       PreparedStatement statement,
  -				       Configuration table,
  -				       CacheHelper queryData,
  -				       Object[][] columnValues,
  -				       int rowIndex,
  -				       Map results
  -				       )
  -	throws SQLException,
  -	       ConfigurationException,
  -	       Exception;
  +    protected abstract void processRow( Request request, Connection conn, PreparedStatement statement,
  +                                        Configuration table, CacheHelper queryData, Object[][] columnValues,
  +                                        int rowIndex, Map results )
  +        throws SQLException, ConfigurationException, Exception;
       
       /**
        * determine which mode to use as default mode
  @@ -937,10 +909,7 @@
        * This method is intended to be overridden by classes that
        * implement other operations e.g. delete
        */
  -    protected abstract String selectMode(
  -					 boolean isAutoIncrement,
  -					 HashMap modes
  -					 );
  +    protected abstract String selectMode( boolean isAutoIncrement, HashMap modes );
   
   
       /**
  @@ -960,13 +929,8 @@
        * This method is intended to be overridden by classes that
        * implement other operations e.g. delete
        */
  -    abstract Object[][] getColumnValues( 
  -					Configuration tableConf,
  -					CacheHelper queryData,
  -					Request request
  -					)
  -	throws ConfigurationException,
  -	       ComponentException;
  +    abstract Object[][] getColumnValues( Configuration tableConf, CacheHelper queryData, Request request )
  +        throws ConfigurationException, ComponentException;
   
       /**
        * Get the String representation of the PreparedStatement.  This is
  @@ -979,11 +943,7 @@
        * @param table the table's configuration object
        * @return the insert query as a string
        */
  -    protected abstract CacheHelper getQuery(
  -					    Configuration table,
  -					    HashMap modeTypes,
  -					    HashMap defaultModeNames
  -					    ) 
  -	throws ConfigurationException, 
  -	       ComponentException;
  +    protected abstract CacheHelper getQuery( Configuration table, HashMap modeTypes, HashMap defaultModeNames ) 
  +        throws ConfigurationException, ComponentException;
  +
   }
  
  
  
  1.3       +89 -108   xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAddAction.java
  
  Index: ModularDatabaseAddAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAddAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ModularDatabaseAddAction.java	2001/11/23 10:50:35	1.2
  +++ ModularDatabaseAddAction.java	2001/11/26 09:28:07	1.3
  @@ -38,51 +38,41 @@
    * components can utilize the helper components.
    *
    * @author <a href="mailto:haul@apache.org">Christian Haul</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2001/11/23 10:50:35 $
  + * @version CVS $Revision: 1.3 $ $Date: 2001/11/26 09:28:07 $
    */
  -public class ModularDatabaseAddAction 
  -    extends ModularDatabaseAction 
  -{
  +public class ModularDatabaseAddAction extends ModularDatabaseAction {
  +
  +
       /**
        * set all necessary ?s and execute the query
        */
  -    protected void processRow ( 
  -			       Request request,
  -			       Connection conn,
  -			       PreparedStatement statement,
  -			       Configuration table,
  -			       CacheHelper queryData,
  -			       Object[][] columnValues,
  -			       int rowIndex,
  -			       Map results
  -			       )
  -	throws SQLException,
  -	       ConfigurationException,
  -	       Exception 
  -    {
  -	
  -	int currentIndex = 1;
  -	for (int i = 0; i < queryData.columns.length; i++) {
  -	    Column col = queryData.columns[i];
  -	    if ( col.isAutoIncrement && col.isKey ) {
  -		currentIndex += setKeyAuto( table, col, currentIndex, rowIndex, 
  -					    conn, statement, request, results );
  -	    } else {
  -		this.setColumn( statement, currentIndex, request, col.columnConf, 
  -				getOutputName( table, col.columnConf, rowIndex ),
  -				columnValues[ i ][ ( col.isSet ? rowIndex : 0 ) ], 
  -				rowIndex);
  -		currentIndex++;
  -	    }
  -	}
  -	statement.execute();
  -	// get resulting ids for autoincrement columns
  -	for (int i = 0; i < queryData.columns.length; i++) {
  -	    if ( queryData.columns[i].isAutoIncrement && queryData.columns[i].isKey ) {
  -		storeKeyValue( table, queryData.columns[i], rowIndex, 
  -			       conn, statement, request, results );
  -	    }
  -	}
  +    protected void processRow ( Request request, Connection conn, PreparedStatement statement,
  +                                Configuration table, CacheHelper queryData, Object[][] columnValues,
  +                                int rowIndex, Map results ) 
  +        throws SQLException, ConfigurationException, Exception {
  +    
  +        int currentIndex = 1;
  +        for (int i = 0; i < queryData.columns.length; i++) {
  +            Column col = queryData.columns[i];
  +            if ( col.isAutoIncrement && col.isKey ) {
  +                currentIndex += setKeyAuto( table, col, currentIndex, rowIndex, 
  +                                            conn, statement, request, results );
  +            } else {
  +                this.setColumn( statement, currentIndex, request, col.columnConf, 
  +                                getOutputName( table, col.columnConf, rowIndex ),
  +                                columnValues[ i ][ ( col.isSet ? rowIndex : 0 ) ], 
  +                                rowIndex);
  +                currentIndex++;
  +            }
  +        }
  +        statement.execute();
  +        // get resulting ids for autoincrement columns
  +        for (int i = 0; i < queryData.columns.length; i++) {
  +            if ( queryData.columns[i].isAutoIncrement && queryData.columns[i].isKey ) {
  +                storeKeyValue( table, queryData.columns[i], rowIndex, 
  +                               conn, statement, request, results );
  +            }
  +        }
       }
   
   
  @@ -91,17 +81,15 @@
        * here: INSERT
        * highly specific to operation INSERT / UPDATE / DELETE / SELECT
        */
  -    protected String selectMode (
  -				  boolean isAutoIncrement,
  -				  HashMap modes
  -				  )
  -    {
  -	if ( isAutoIncrement )
  -	    return (String) modes.get( MODE_AUTOINCR );
  -	else 
  -	    return (String) modes.get( MODE_OTHERS );
  +    protected String selectMode ( boolean isAutoIncrement, HashMap modes ) {
  +
  +        if ( isAutoIncrement )
  +            return (String) modes.get( MODE_AUTOINCR );
  +        else 
  +            return (String) modes.get( MODE_OTHERS );
       }
   
  +
       /**
        * determine whether autoincrement columns should be honoured by
        * this operation. This is usually snsible only for INSERTs.
  @@ -113,22 +101,18 @@
        * Fetch all values for all columns that are needed to do the
        * database operation.
        */
  -    Object[][] getColumnValues( 
  -			     Configuration tableConf,
  -			     CacheHelper queryData,
  -			     Request request
  -			     )
  -	throws ConfigurationException,
  -	       ComponentException
  -    {
  -	Object[][] columnValues = new Object[ queryData.columns.length ][];
  -	for ( int i = 0; i < queryData.columns.length; i++ ){
  -	    columnValues[i] = this.getColumnValue( tableConf, queryData.columns[i], request );
  -	}
  -	return columnValues;
  +    protected Object[][] getColumnValues( Configuration tableConf, CacheHelper queryData,
  +                                          Request request ) 
  +        throws ConfigurationException, ComponentException {
  +
  +        Object[][] columnValues = new Object[ queryData.columns.length ][];
  +        for ( int i = 0; i < queryData.columns.length; i++ ){
  +            columnValues[i] = this.getColumnValue( tableConf, queryData.columns[i], request );
  +        }
  +        return columnValues;
       }
   
  -
  +    
       /**
        * Get the String representation of the PreparedStatement.  This is
        * mapped to the Configuration object itself, so if it doesn't exist,
  @@ -136,15 +120,10 @@
        * @param table the table's configuration object
        * @return the insert query as a string
        */
  -    protected CacheHelper getQuery(
  -				   Configuration table,
  -				   HashMap modeTypes,
  -				   HashMap defaultModeNames
  -				   ) 
  -	throws ConfigurationException, 
  -	       ComponentException 
  -    {
  -	LookUpKey lookUpKey = new LookUpKey( table, modeTypes );
  +    protected CacheHelper getQuery( Configuration table, HashMap modeTypes, HashMap defaultModeNames ) 
  +        throws ConfigurationException, ComponentException {
  +
  +        LookUpKey lookUpKey = new LookUpKey( table, modeTypes );
           CacheHelper queryData = null;
           synchronized( this.cachedQueryData ) {
               queryData = (CacheHelper) this.cachedQueryData.get( lookUpKey );
  @@ -152,54 +131,56 @@
               if (queryData == null) {
                   Configuration[] values = table.getChild("values").getChildren("value");
                   Configuration[] keys = table.getChild("keys").getChildren("key");
  -
  -		queryData = new CacheHelper( keys.length, keys.length + values.length );
  -		fillModes( keys,   true,  defaultModeNames, modeTypes, queryData );
  - 		fillModes( values, false, defaultModeNames, modeTypes, queryData );
   
  +                queryData = new CacheHelper( keys.length, keys.length + values.length );
  +                fillModes( keys,   true,  defaultModeNames, modeTypes, queryData );
  +                fillModes( values, false, defaultModeNames, modeTypes, queryData );
  +                
                   StringBuffer queryBuffer = new StringBuffer("INSERT INTO ");
                   StringBuffer valueBuffer = new StringBuffer(") VALUES (");
  -		AutoIncrementHelper dah;
  -
  +                AutoIncrementHelper dah;
  +                
                   queryBuffer.append(table.getAttribute("name"));
                   queryBuffer.append(" (");
  -		int actualColumns = 0;
  +                int actualColumns = 0;
   
                   for (int i = 0; i < queryData.columns.length; i++) {
  -		    if ( actualColumns > 0 ) {
  -			queryBuffer.append( ", " );
  -			valueBuffer.append( ", " );
  -		    }
  -		    if ( queryData.columns[i].isKey && queryData.columns[i].isAutoIncrement ) {
  -			dah = (AutoIncrementHelper) modeMapping.select( queryData.columns[i].mode );
  -			if ( dah.includeInQuery() ) {
  -			    actualColumns++;
  -			    queryBuffer.append( queryData.columns[i].columnConf.getAttribute( "name" ) );
  -			    if ( dah.includeAsValue() ) {
  -				valueBuffer.append( "?" );
  -			    } else {
  -				valueBuffer.append( dah.getSubquery( table, queryData.columns[i].columnConf, queryData.columns[i].modeConf ) );
  -			    }
  -			}
  -			modeMapping.release( dah );
  -		    } else {
  -			actualColumns++;
  -			queryBuffer.append( queryData.columns[i].columnConf.getAttribute( "name" ) );
  -			valueBuffer.append( "?" );
  -		    }
  -		}
  -
  +                    if ( actualColumns > 0 ) {
  +                        queryBuffer.append( ", " );
  +                        valueBuffer.append( ", " );
  +                    }
  +                    if ( queryData.columns[i].isKey && queryData.columns[i].isAutoIncrement ) {
  +                        dah = (AutoIncrementHelper) modeMapping.select( queryData.columns[i].mode );
  +                        if ( dah.includeInQuery() ) {
  +                            actualColumns++;
  +                            queryBuffer.append( queryData.columns[i].columnConf.getAttribute( "name" ) );
  +                            if ( dah.includeAsValue() ) {
  +                                valueBuffer.append( "?" );
  +                            } else {
  +                                valueBuffer.append( 
  +                                                   dah.getSubquery( table, queryData.columns[i].columnConf, 
  +                                                                    queryData.columns[i].modeConf ) );
  +                            }
  +                        }
  +                        modeMapping.release( dah );
  +                    } else {
  +                        actualColumns++;
  +                        queryBuffer.append( queryData.columns[i].columnConf.getAttribute( "name" ) );
  +                        valueBuffer.append( "?" );
  +                    }
  +                }
  +                
                   valueBuffer.append(")");
  -		queryBuffer.append(valueBuffer);
  -
  +                queryBuffer.append(valueBuffer);
  +                
                   queryData.queryString = queryBuffer.toString();
  -
  +                
                   this.cachedQueryData.put( lookUpKey, queryData );
               }
           }
  -
  +        
           return queryData;
       }
  -
  +    
   
   }
  
  
  
  1.3       +54 -81    xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseDeleteAction.java
  
  Index: ModularDatabaseDeleteAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseDeleteAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ModularDatabaseDeleteAction.java	2001/11/23 10:50:35	1.2
  +++ ModularDatabaseDeleteAction.java	2001/11/26 09:28:07	1.3
  @@ -25,27 +25,19 @@
    * form descriptor semantics for this are still in a bit of a state of
    * flux. 
    *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @author <a href="mailto:balld@apache.org">Donald Ball</a>
    * @author <a href="mailto:haul@apache.org">Christian Haul</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2001/11/23 10:50:35 $
  + * @version CVS $Revision: 1.3 $ $Date: 2001/11/26 09:28:07 $
    */
  -public class ModularDatabaseDeleteAction 
  -    extends ModularDatabaseAction
  -{
  -
  +public class ModularDatabaseDeleteAction extends ModularDatabaseAction {
  +    
       /**
        * determine which mode to use as default mode
        * here: DELETE
        * highly specific to operation INSERT / UPDATE / DELETE / SELECT
        */
  +    protected String selectMode ( boolean isAutoIncrement, HashMap modes ) {
   
  -    protected String selectMode (
  -				  boolean isAutoIncrement,
  -				  HashMap modes
  -				  )
  -    {
  -	return (String) modes.get( MODE_OTHERS );
  +        return (String) modes.get( MODE_OTHERS );
       }
   
   
  @@ -60,23 +52,18 @@
        * Fetch all values for all key columns that are needed to do the
        * database operation.
        */
  -    Object[][] getColumnValues( 
  -			     Configuration tableConf,
  -			     CacheHelper queryData,
  -			     Request request
  -			     )
  -	throws ConfigurationException,
  -	       ComponentException
  -    {
  -	Object[][] columnValues = new Object[ queryData.columns.length ][];
  -	for ( int i = 0; i < queryData.columns.length; i++ ){
  -	    if ( queryData.columns[i].isKey ) {
  -		columnValues[i] = this.getColumnValue( tableConf, queryData.columns[i], request );
  -	    } else {
  -		// columnValues[i] = new Object[1]; // this should not be needed
  -	    }
  -	}
  -	return columnValues;
  +    protected Object[][] getColumnValues( Configuration tableConf, CacheHelper queryData, Request request )
  +        throws ConfigurationException, ComponentException {
  +
  +        Object[][] columnValues = new Object[ queryData.columns.length ][];
  +        for ( int i = 0; i < queryData.columns.length; i++ ){
  +            if ( queryData.columns[i].isKey ) {
  +                columnValues[i] = this.getColumnValue( tableConf, queryData.columns[i], request );
  +            } else {
  +                // columnValues[i] = new Object[1]; // this should not be needed
  +            }
  +        }
  +        return columnValues;
       }
   
   
  @@ -89,77 +76,63 @@
        * @param table the table's configuration object
        * @return the insert query as a string
        */
  -    protected CacheHelper getQuery(
  -				   Configuration table,
  -				   HashMap modeTypes,
  -				   HashMap defaultModeNames
  -				   ) 
  -	throws ConfigurationException, 
  -	       ComponentException 
  -    {
  -	LookUpKey lookUpKey = new LookUpKey( table, modeTypes );
  +    protected CacheHelper getQuery( Configuration table, HashMap modeTypes, HashMap defaultModeNames ) 
  +        throws ConfigurationException, ComponentException {
  +
  +        LookUpKey lookUpKey = new LookUpKey( table, modeTypes );
           CacheHelper queryData = null;
           synchronized( this.cachedQueryData ) {
               queryData = (CacheHelper) this.cachedQueryData.get( lookUpKey );
               if (queryData == null) {
                   Configuration[] keys = table.getChild("keys").getChildren("key");
  -
  -		queryData = new CacheHelper( keys.length, keys.length );
  -		fillModes( keys, true, defaultModeNames, modeTypes, queryData );
  -
  +                
  +                queryData = new CacheHelper( keys.length, keys.length );
  +                fillModes( keys, true, defaultModeNames, modeTypes, queryData );
  +                
                   StringBuffer queryBuffer = new StringBuffer("DELETE FROM ");
                   queryBuffer.append(table.getAttribute("name")).append(" WHERE ");
                   for (int i = 0; i < queryData.columns.length; i++) {
                       if ( i > 0 ) {
  -			queryBuffer.append(" AND ");
  -		    }
  -		    queryBuffer
  -			.append( queryData.columns[i].columnConf.getAttribute( "name" ) )
  -			.append( "= ?" );
  +                        queryBuffer.append(" AND ");
  +                    }
  +                    queryBuffer
  +                        .append( queryData.columns[i].columnConf.getAttribute( "name" ) )
  +                        .append( "= ?" );
                   }
  -
  +                
                   queryData.queryString = queryBuffer.toString();
  -
  +                
                   this.cachedQueryData.put( lookUpKey, queryData );
               }
           }
  -
  +        
           return queryData;
       }
  +    
   
   
       /**
        * set all necessary ?s and execute the query
        */
  -    protected void processRow ( 
  -			       Request request,
  -			       Connection conn,
  -			       PreparedStatement statement,
  -			       Configuration table,
  -			       CacheHelper queryData,
  -			       Object[][] columnValues,
  -			       int rowIndex,
  -			       Map results
  -			       )
  -	throws SQLException,
  -	       ConfigurationException,
  -	       Exception 
  -    {
  -	
  -	int currentIndex = 1;
  -
  -	// ordering is different for DELETE just needs keys
  -	for (int i = 0; i < queryData.columns.length; i++) {
  -	    Column col = queryData.columns[i];
  -	    if ( col.isKey ) {
  -		this.setColumn( statement, currentIndex, request, col.columnConf, 
  -				getOutputName( table, col.columnConf, rowIndex ),
  -				columnValues[ i ][ ( col.isSet ? rowIndex : 0 ) ], 
  -				rowIndex);
  -		currentIndex++;
  -	    }
  -	}
  -	statement.execute();
  +    protected void processRow ( Request request, Connection conn, PreparedStatement statement,
  +                                Configuration table, CacheHelper queryData, Object[][] columnValues,
  +                                int rowIndex, Map results )
  +        throws SQLException, ConfigurationException, Exception {
  +    
  +        int currentIndex = 1;
  +        
  +        // ordering is different for DELETE just needs keys
  +        for (int i = 0; i < queryData.columns.length; i++) {
  +            Column col = queryData.columns[i];
  +            if ( col.isKey ) {
  +                this.setColumn( statement, currentIndex, request, col.columnConf, 
  +                                getOutputName( table, col.columnConf, rowIndex ),
  +                                columnValues[ i ][ ( col.isSet ? rowIndex : 0 ) ], 
  +                                rowIndex);
  +                currentIndex++;
  +            }
  +        }
  +        statement.execute();
       }
  -
  +    
   }
  
  
  
  1.3       +148 -177  xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseSelectAction.java
  
  Index: ModularDatabaseSelectAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseSelectAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ModularDatabaseSelectAction.java	2001/11/23 10:50:35	1.2
  +++ ModularDatabaseSelectAction.java	2001/11/26 09:28:07	1.3
  @@ -33,27 +33,19 @@
    * time. The form descriptor semantics for this are still in a bit of
    * a state of flux.
    *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @author <a href="mailto:balld@apache.org">Donald Ball</a>
    * @author <a href="mailto:haul@apache.org">Christian Haul</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2001/11/23 10:50:35 $
  + * @version CVS $Revision: 1.3 $ $Date: 2001/11/26 09:28:07 $
    */
  -public class ModularDatabaseSelectAction 
  -    extends ModularDatabaseAction
  -{
  +public class ModularDatabaseSelectAction extends ModularDatabaseAction {
   
       /**
        * determine which mode to use as default mode
        * here: SELECT
        * highly specific to operation INSERT / UPDATE / DELETE / SELECT
        */
  +    protected String selectMode ( boolean isAutoIncrement, HashMap modes ) {
   
  -    protected String selectMode (
  -				  boolean isAutoIncrement,
  -				  HashMap modes
  -				  )
  -    {
  -	return (String) modes.get( MODE_OTHERS );
  +        return (String) modes.get( MODE_OTHERS );
       }
   
   
  @@ -72,211 +64,190 @@
        * @param table the table's configuration object
        * @return the insert query as a string
        */
  -    protected CacheHelper getQuery(
  -				   Configuration table,
  -				   HashMap modeTypes,
  -				   HashMap defaultModeNames
  -				   ) 
  -	throws ConfigurationException, 
  -	       ComponentException 
  -    {
  -	LookUpKey lookUpKey = new LookUpKey( table, modeTypes );
  +    protected CacheHelper getQuery( Configuration table, HashMap modeTypes, HashMap defaultModeNames ) 
  +        throws ConfigurationException, ComponentException {
  +
  +        LookUpKey lookUpKey = new LookUpKey( table, modeTypes );
           CacheHelper queryData = null;
           synchronized( this.cachedQueryData ) {
               queryData = (CacheHelper) this.cachedQueryData.get( lookUpKey );
               if (queryData == null) {
                   Configuration[] keys = table.getChild("keys").getChildren("key");
                   Configuration[] values = table.getChild("values").getChildren("value");
  -
  -		queryData = new CacheHelper( keys.length, keys.length );
  -		fillModes( keys, true, defaultModeNames, modeTypes, queryData );
  -		fillModes( values, false, defaultModeNames, modeTypes, queryData );
   
  +                queryData = new CacheHelper( keys.length, keys.length );
  +                fillModes( keys, true, defaultModeNames, modeTypes, queryData );
  +                fillModes( values, false, defaultModeNames, modeTypes, queryData );
  +                
                   StringBuffer queryBuffer = new StringBuffer("SELECT ");
  -
  +                
                   queryBuffer.append(table.getAttribute("name")).append(" WHERE ");
                   for (int i = 0; i < queryData.columns.length; i++) {
  -		    if ( !queryData.columns[i].isKey ) {
  -			if ( i > 0 ) {
  -			    queryBuffer.append(", ");
  -			}
  -			queryBuffer
  -			    .append( queryData.columns[i].columnConf.getAttribute( "name" ) );
  -		    }
  +                    if ( !queryData.columns[i].isKey ) {
  +                        if ( i > 0 ) {
  +                            queryBuffer.append(", ");
  +                        }
  +                        queryBuffer
  +                            .append( queryData.columns[i].columnConf.getAttribute( "name" ) );
  +                    }
                   }
  -
  +                
                   queryBuffer.append(" FROM ").append(table.getAttribute("name")).append(" WHERE ");
                   for (int i = 0; i < queryData.columns.length; i++) {
  -		    if ( queryData.columns[i].isKey ) {
  -			if ( i > 0 ) {
  -			    queryBuffer.append(" AND ");
  -			}
  -			queryBuffer
  -			    .append( queryData.columns[i].columnConf.getAttribute( "name" ) )
  -			    .append( "= ?");
  -		    }
  +                    if ( queryData.columns[i].isKey ) {
  +                        if ( i > 0 ) {
  +                            queryBuffer.append(" AND ");
  +                        }
  +                        queryBuffer
  +                            .append( queryData.columns[i].columnConf.getAttribute( "name" ) )
  +                            .append( "= ?");
  +                    }
                   }
  -
  +                
                   queryData.queryString = queryBuffer.toString();
  -
  +                
                   this.cachedQueryData.put( lookUpKey, queryData );
               }
           }
  -
  +        
           return queryData;
       }
  -
  -
  +    
  +    
       /**
        * Fetch all values for all key columns that are needed to do the
        * database operation.
        */
  -    Object[][] getColumnValues( 
  -			     Configuration tableConf,
  -			     CacheHelper queryData,
  -			     Request request
  -			     )
  -	throws ConfigurationException,
  -	       ComponentException
  -    {
  -	Object[][] columnValues = new Object[ queryData.columns.length ][];
  -	for ( int i = 0; i < queryData.columns.length; i++ ){
  -	    if ( queryData.columns[i].isKey ) {
  -		columnValues[i] = this.getColumnValue( tableConf, queryData.columns[i], request );
  -	    } else {
  -		// columnValues[i] = new Object[1]; // this should not be needed
  -	    }
  -	}
  -	return columnValues;
  +    protected Object[][] getColumnValues( Configuration tableConf, CacheHelper queryData, Request request )
  +        throws ConfigurationException, ComponentException {
  +
  +        Object[][] columnValues = new Object[ queryData.columns.length ][];
  +        for ( int i = 0; i < queryData.columns.length; i++ ){
  +            if ( queryData.columns[i].isKey ) {
  +                columnValues[i] = this.getColumnValue( tableConf, queryData.columns[i], request );
  +            } else {
  +                // columnValues[i] = new Object[1]; // this should not be needed
  +            }
  +        }
  +        return columnValues;
       }
   
   
       /**
        * set all necessary ?s and execute the query
        */
  -    protected void processRow ( 
  -			       Request request,
  -			       Connection conn,
  -			       PreparedStatement statement,
  -			       Configuration table,
  -			       CacheHelper queryData,
  -			       Object[][] columnValues,
  -			       int rowIndex,
  -			       Map results
  -			       )
  -	throws SQLException,
  -	       ConfigurationException,
  -	       Exception 
  -    {
  -	
  -	int currentIndex = 1;
  -
  -	// ordering is different for SELECT just needs keys
  -	for (int i = 0; i < queryData.columns.length; i++) {
  -	    Column col = queryData.columns[i];
  -	    if ( col.isKey ) {
  -		this.setColumn( statement, currentIndex, request, col.columnConf, 
  -				getOutputName( table, col.columnConf, rowIndex ),
  -				columnValues[ i ][ ( col.isSet ? rowIndex : 0 ) ], 
  -				rowIndex);
  -		currentIndex++;
  -	    }
  -	}
  -	statement.execute();
  -	// retrieve values
  -	ResultSet resultset = statement.getResultSet();
  -	rowIndex = -1;
  -	while ( resultset.next() ){
  -	    if ( ! ( rowIndex == -1 && resultset.isLast() ) ) {
  -		rowIndex++;
  -	    }
  -	    for (int i = 0; i < queryData.columns.length; i++) {
  -		if ( !queryData.columns[i].isKey ) {
  -		    Object value = this.getColumn( resultset, queryData.columns[i].columnConf );
  -		    String param = getOutputName( table, queryData.columns[i].columnConf, rowIndex );
  -		    this.setRequestAttribute( request, param, value );
  -		}
  -	    }
  -	}
  +    protected void processRow ( Request request, Connection conn, PreparedStatement statement, Configuration table,
  +                                CacheHelper queryData, Object[][] columnValues, int rowIndex, Map results )
  +        throws SQLException, ConfigurationException, Exception {
  +    
  +        int currentIndex = 1;
  +
  +        // ordering is different for SELECT just needs keys
  +        for (int i = 0; i < queryData.columns.length; i++) {
  +            Column col = queryData.columns[i];
  +            if ( col.isKey ) {
  +                this.setColumn( statement, currentIndex, request, col.columnConf, 
  +                                getOutputName( table, col.columnConf, rowIndex ),
  +                                columnValues[ i ][ ( col.isSet ? rowIndex : 0 ) ], 
  +                                rowIndex);
  +                currentIndex++;
  +            }
  +        }
  +        statement.execute();
  +        // retrieve values
  +        ResultSet resultset = statement.getResultSet();
  +        rowIndex = -1;
  +        while ( resultset.next() ){
  +            if ( ! ( rowIndex == -1 && resultset.isLast() ) ) {
  +                rowIndex++;
  +            }
  +            for (int i = 0; i < queryData.columns.length; i++) {
  +                if ( !queryData.columns[i].isKey ) {
  +                    Object value = this.getColumn( resultset, queryData.columns[i].columnConf );
  +                    String param = getOutputName( table, queryData.columns[i].columnConf, rowIndex );
  +                    this.setRequestAttribute( request, param, value );
  +                }
  +            }
  +        }
       }
  -
  -
  +    
  +    
       /**
        * Get the Statement column so that the results are mapped correctly.
        * (this has been copied from AbstractDatabaseAction and modified slightly)
        */
  -    protected Object getColumn(ResultSet set, Configuration column )
  -    throws Exception {
  +    protected Object getColumn(ResultSet set, Configuration column ) throws Exception {
  +        
           Integer type = (Integer) AbstractDatabaseAction.typeConstants.get(column.getAttribute("type"));
           String dbcol = column.getAttribute("name");
           Object value = null;
  -
  +        
           switch (type.intValue()) {
  -            case Types.CLOB:
  -                Clob dbClob = set.getClob(dbcol);
  -                int length = (int) dbClob.length();
  -                InputStream asciiStream = new BufferedInputStream(dbClob.getAsciiStream());
  -                byte[] buffer = new byte[length];
  -                asciiStream.read(buffer);
  -                String str = new String(buffer);
  -                asciiStream.close();
  -                value = str;
  -                break;
  -            case Types.BIGINT:
  -                value = set.getBigDecimal(dbcol);
  -                break;
  -            case Types.TINYINT:
  -                value = new Byte(set.getByte(dbcol));
  -                break;
  -            case Types.VARCHAR:
  -                value  = set.getString(dbcol);
  -                break;
  -            case Types.DATE:
  -                value = set.getDate(dbcol);
  -                break;
  -            case Types.DOUBLE:
  -                value = new Double(set.getDouble(dbcol));
  -                break;
  -            case Types.FLOAT:
  -                value = new Float(set.getFloat(dbcol));
  -                break;
  -            case Types.INTEGER:
  -                value = new Integer(set.getInt(dbcol));
  -                break;
  -            case Types.NUMERIC:
  -                value = new Long(set.getLong(dbcol));
  -                break;
  -            case Types.SMALLINT:
  -                value = new Short(set.getShort(dbcol));
  -                break;
  -            case Types.TIME:
  -                value = set.getTime(dbcol);
  -                break;
  -            case Types.TIMESTAMP:
  -                value = set.getTimestamp(dbcol);
  -                break;
  -            case Types.ARRAY:
  -                value = set.getArray(dbcol); // new Integer(set.getInt(dbcol));
  -                break;
  -            case Types.BIT:
  -                value = new Integer(set.getInt(dbcol));
  -                break;
  -            case Types.CHAR:
  -                value = new Integer(set.getInt(dbcol));
  -                break;
  -	    case Types.STRUCT:
  -		value = (Struct) set.getObject(dbcol);
  -		break;
  -	    case Types.OTHER:
  -		value = set.getObject(dbcol);
  -		break;
  -
  -            default:
  -                // The blob types have to be requested separately, via a Reader.
  -                value = "";
  -                break;
  +        case Types.CLOB:
  +            Clob dbClob = set.getClob(dbcol);
  +            int length = (int) dbClob.length();
  +            InputStream asciiStream = new BufferedInputStream(dbClob.getAsciiStream());
  +            byte[] buffer = new byte[length];
  +            asciiStream.read(buffer);
  +            String str = new String(buffer);
  +            asciiStream.close();
  +            value = str;
  +            break;
  +        case Types.BIGINT:
  +            value = set.getBigDecimal(dbcol);
  +            break;
  +        case Types.TINYINT:
  +            value = new Byte(set.getByte(dbcol));
  +            break;
  +        case Types.VARCHAR:
  +            value  = set.getString(dbcol);
  +            break;
  +        case Types.DATE:
  +            value = set.getDate(dbcol);
  +            break;
  +        case Types.DOUBLE:
  +            value = new Double(set.getDouble(dbcol));
  +            break;
  +        case Types.FLOAT:
  +            value = new Float(set.getFloat(dbcol));
  +            break;
  +        case Types.INTEGER:
  +            value = new Integer(set.getInt(dbcol));
  +            break;
  +        case Types.NUMERIC:
  +            value = new Long(set.getLong(dbcol));
  +            break;
  +        case Types.SMALLINT:
  +            value = new Short(set.getShort(dbcol));
  +            break;
  +        case Types.TIME:
  +            value = set.getTime(dbcol);
  +            break;
  +        case Types.TIMESTAMP:
  +            value = set.getTimestamp(dbcol);
  +            break;
  +        case Types.ARRAY:
  +            value = set.getArray(dbcol); // new Integer(set.getInt(dbcol));
  +            break;
  +        case Types.BIT:
  +            value = new Integer(set.getInt(dbcol));
  +            break;
  +        case Types.CHAR:
  +            value = new Integer(set.getInt(dbcol));
  +            break;
  +        case Types.STRUCT:
  +            value = (Struct) set.getObject(dbcol);
  +            break;
  +        case Types.OTHER:
  +            value = set.getObject(dbcol);
  +            break;
  +            
  +        default:
  +            // The blob types have to be requested separately, via a Reader.
  +            value = "";
  +            break;
           }
  -
  +        
           return value;
       }
   
  
  
  
  1.3       +79 -107   xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseUpdateAction.java
  
  Index: ModularDatabaseUpdateAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseUpdateAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ModularDatabaseUpdateAction.java	2001/11/23 10:50:35	1.2
  +++ ModularDatabaseUpdateAction.java	2001/11/26 09:28:07	1.3
  @@ -25,27 +25,19 @@
    * form descriptor semantics for this are still in a bit of a state of
    * flux. 
    *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @author <a href="mailto:balld@apache.org">Donald Ball</a>
    * @author <a href="mailto:haul@apache.org">Christian Haul</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2001/11/23 10:50:35 $
  + * @version CVS $Revision: 1.3 $ $Date: 2001/11/26 09:28:07 $
    */
  -public class ModularDatabaseUpdateAction 
  -    extends ModularDatabaseAction
  -{
  +public class ModularDatabaseUpdateAction extends ModularDatabaseAction {
   
       /**
        * determine which mode to use as default mode
        * here: UPDATE
        * highly specific to operation INSERT / UPDATE / DELETE / SELECT
        */
  +    protected String selectMode ( boolean isAutoIncrement, HashMap modes ) {
   
  -    protected String selectMode (
  -				  boolean isAutoIncrement,
  -				  HashMap modes
  -				  )
  -    {
  -	return (String) modes.get( MODE_OTHERS );
  +        return (String) modes.get( MODE_OTHERS );
       }
   
   
  @@ -60,19 +52,14 @@
        * Fetch all values for all columns that are needed to do the
        * database operation.
        */
  -    Object[][] getColumnValues( 
  -			     Configuration tableConf,
  -			     CacheHelper queryData,
  -			     Request request
  -			     )
  -	throws ConfigurationException,
  -	       ComponentException
  -    {
  -	Object[][] columnValues = new Object[ queryData.columns.length ][];
  -	for ( int i = 0; i < queryData.columns.length; i++ ){
  -	    columnValues[i] = this.getColumnValue( tableConf, queryData.columns[i], request );
  -	}
  -	return columnValues;
  +    protected Object[][] getColumnValues( Configuration tableConf, CacheHelper queryData, Request request )
  +        throws ConfigurationException, ComponentException {
  +
  +        Object[][] columnValues = new Object[ queryData.columns.length ][];
  +        for ( int i = 0; i < queryData.columns.length; i++ ){
  +            columnValues[i] = this.getColumnValue( tableConf, queryData.columns[i], request );
  +        }
  +        return columnValues;
       }
   
   
  @@ -84,106 +71,91 @@
        * @param table the table's configuration object
        * @return the insert query as a string
        */
  -    protected CacheHelper getQuery(
  -				   Configuration table,
  -				   HashMap modeTypes,
  -				   HashMap defaultModeNames
  -				   ) 
  -	throws ConfigurationException, 
  -	       ComponentException 
  -    {
  -	LookUpKey lookUpKey = new LookUpKey( table, modeTypes );
  +    protected CacheHelper getQuery( Configuration table, HashMap modeTypes, HashMap defaultModeNames ) 
  +        throws ConfigurationException, ComponentException {
  +
  +        LookUpKey lookUpKey = new LookUpKey( table, modeTypes );
           CacheHelper queryData = null;
           synchronized( this.cachedQueryData ) {
               queryData = (CacheHelper) this.cachedQueryData.get( lookUpKey );
               if (queryData == null) {
                   Configuration[] keys = table.getChild("keys").getChildren("key");
                   Configuration[] values = table.getChild("values").getChildren("value");
  -
  -		queryData = new CacheHelper( keys.length, keys.length + values.length );
  -		fillModes( keys,   true,  defaultModeNames, modeTypes, queryData );
  -		fillModes( values, false, defaultModeNames, modeTypes, queryData );
  -
  +                
  +                queryData = new CacheHelper( keys.length, keys.length + values.length );
  +                fillModes( keys,   true,  defaultModeNames, modeTypes, queryData );
  +                fillModes( values, false, defaultModeNames, modeTypes, queryData );
  +                
                   StringBuffer queryBuffer = new StringBuffer("UPDATE ");
                   queryBuffer.append(table.getAttribute("name")).append(" SET ");
  -
  -		
  -		int cols = 0;
  -		for (int i = 0; i < queryData.columns.length; i++) {
  -		    if ( !queryData.columns[i].isKey ) {
  -			if ( cols > 0 ) {
  -			    queryBuffer.append(", ");
  -			}
  -			cols++;
  -			queryBuffer
  -			    .append( queryData.columns[i].columnConf.getAttribute( "name" ) )
  -			    .append( "= ?" );
  -		    }
  -		}
  +                
  +                
  +                int cols = 0;
  +                for (int i = 0; i < queryData.columns.length; i++) {
  +                    if ( !queryData.columns[i].isKey ) {
  +                        if ( cols > 0 ) {
  +                            queryBuffer.append(", ");
  +                        }
  +                        cols++;
  +                        queryBuffer
  +                            .append( queryData.columns[i].columnConf.getAttribute( "name" ) )
  +                            .append( "= ?" );
  +                    }
  +                }
                   queryBuffer.append(" WHERE ");
                   for (int i = 0; i < queryData.columns.length; i++) {
  -		    if ( queryData.columns[i].isKey ) {
  -			if ( i > 0 ) {
  -			    queryBuffer.append(" AND ");
  -			}
  -			queryBuffer
  -			    .append( queryData.columns[i].columnConf.getAttribute( "name" ) )
  -			    .append( "= ?" );
  -		    }
  -		}
  -
  +                    if ( queryData.columns[i].isKey ) {
  +                        if ( i > 0 ) {
  +                            queryBuffer.append(" AND ");
  +                        }
  +                        queryBuffer
  +                            .append( queryData.columns[i].columnConf.getAttribute( "name" ) )
  +                            .append( "= ?" );
  +                    }
  +                }
  +                
                   queryData.queryString = queryBuffer.toString();
  -
  +                
                   this.cachedQueryData.put( lookUpKey, queryData );
               }
           }
  -
  +        
           return queryData;
       }
  -
  -
  +    
  +    
       /**
        * set all necessary ?s and execute the query
        */
  -    protected void processRow ( 
  -			       Request request,
  -			       Connection conn,
  -			       PreparedStatement statement,
  -			       Configuration table,
  -			       CacheHelper queryData,
  -			       Object[][] columnValues,
  -			       int rowIndex,
  -			       Map results
  -			       )
  -	throws SQLException,
  -	       ConfigurationException,
  -	       Exception 
  -    {
  -	
  -	int currentIndex = 1;
  -
  -	// ordering is different for UPDATE than for INSERT: values, keys
  -	for (int i = 0; i < queryData.columns.length; i++) {
  -	    Column col = queryData.columns[i];
  -	    if ( !col.isKey ) {
  -		this.setColumn( statement, currentIndex, request, col.columnConf, 
  -				getOutputName( table, col.columnConf, rowIndex ),
  -				columnValues[ i ][ ( col.isSet ? rowIndex : 0 ) ], 
  -				rowIndex);
  -		currentIndex++;
  -	    }
  -	}
  -	for (int i = 0; i < queryData.columns.length; i++) {
  -	    Column col = queryData.columns[i];
  -	    if ( col.isKey ) {
  -		this.setColumn( statement, currentIndex, request, col.columnConf, 
  -				getOutputName( table, col.columnConf, rowIndex ),
  -				columnValues[ i ][ ( col.isSet ? rowIndex : 0 ) ], 
  -				rowIndex);
  -		currentIndex++;
  -	    }
  -	}
  -	statement.execute();
  +    protected void processRow ( Request request, Connection conn, PreparedStatement statement, Configuration table,
  +                                CacheHelper queryData, Object[][] columnValues, int rowIndex, Map results )
  +        throws SQLException, ConfigurationException, Exception {
  +
  +    
  +        int currentIndex = 1;
  +
  +        // ordering is different for UPDATE than for INSERT: values, keys
  +        for (int i = 0; i < queryData.columns.length; i++) {
  +            Column col = queryData.columns[i];
  +            if ( !col.isKey ) {
  +                this.setColumn( statement, currentIndex, request, col.columnConf, 
  +                                getOutputName( table, col.columnConf, rowIndex ),
  +                                columnValues[ i ][ ( col.isSet ? rowIndex : 0 ) ], 
  +                                rowIndex);
  +                currentIndex++;
  +            }
  +        }
  +        for (int i = 0; i < queryData.columns.length; i++) {
  +            Column col = queryData.columns[i];
  +            if ( col.isKey ) {
  +                this.setColumn( statement, currentIndex, request, col.columnConf, 
  +                                getOutputName( table, col.columnConf, rowIndex ),
  +                                columnValues[ i ][ ( col.isSet ? rowIndex : 0 ) ], 
  +                                rowIndex);
  +                currentIndex++;
  +            }
  +        }
  +        statement.execute();
       }
  -
  +    
   }
  
  
  
  1.3       +13 -12    xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/AbstractAttributeHelper.java
  
  Index: AbstractAttributeHelper.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/AbstractAttributeHelper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractAttributeHelper.java	2001/11/23 10:50:36	1.2
  +++ AbstractAttributeHelper.java	2001/11/26 09:28:08	1.3
  @@ -21,7 +21,7 @@
    * Logger, use getLogger().
    *
    * @author <a href="mailto:haul@apache.org">Christian Haul</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2001/11/23 10:50:36 $ */
  + * @version CVS $Revision: 1.3 $ $Date: 2001/11/26 09:28:08 $ */
   public abstract class AbstractAttributeHelper extends AbstractLoggable
       implements AttributeHelper, Configurable, Disposable { 
   
  @@ -42,18 +42,19 @@
        * For nested configurations override this function.  
        * */
       public void configure(Configuration conf) throws ConfigurationException {
  +        
           if (conf != null) {
  -	    String key = null;
  -	    String val = null;
  -	    Configuration[] parameters = conf.getChildren();
  -	    this.settings = new HashMap(parameters.length);
  -	    for ( int i = 0; i < parameters.length; i++) {
  -		key = parameters[i].getName();
  -		val = parameters[i].getValue();
  -		if ( key != null )
  -		    this.settings.put(key, val);
  -	    }
  -	}
  +            String key = null;
  +            String val = null;
  +            Configuration[] parameters = conf.getChildren();
  +            this.settings = new HashMap(parameters.length);
  +            for ( int i = 0; i < parameters.length; i++) {
  +                key = parameters[i].getName();
  +                val = parameters[i].getValue();
  +                if ( key != null )
  +                    this.settings.put(key, val);
  +            }
  +        }
       }
   
       /**
  
  
  
  1.2       +13 -13    xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/AbstractAutoIncrementHelper.java
  
  Index: AbstractAutoIncrementHelper.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/AbstractAutoIncrementHelper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractAutoIncrementHelper.java	2001/11/23 10:50:36	1.1
  +++ AbstractAutoIncrementHelper.java	2001/11/26 09:28:08	1.2
  @@ -21,7 +21,7 @@
    * getLogger().
    *
    * @author <a href="mailto:haul@apache.org">Christian Haul</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2001/11/23 10:50:36 $ */
  + * @version CVS $Revision: 1.2 $ $Date: 2001/11/26 09:28:08 $ */
   public abstract class AbstractAutoIncrementHelper extends AbstractLoggable
       implements AutoIncrementHelper, Configurable, Disposable {
   
  @@ -42,19 +42,19 @@
        * For nested configurations override this function. 
        * */
       public void configure(Configuration conf) throws ConfigurationException {
  -	getLogger().debug("ADBH: configure");
  +
           if (conf != null) {
  -	    String key = null;
  -	    String val = null;
  -	    Configuration[] parameters = conf.getChildren();
  -	    this.settings = new HashMap(parameters.length);
  -	    for ( int i = 0; i < parameters.length; i++) {
  -		key = parameters[i].getName();
  -		val = parameters[i].getValue();
  -		if ( key != null )
  -		    this.settings.put(key, val);
  -	    }
  -	}
  +            String key = null;
  +            String val = null;
  +            Configuration[] parameters = conf.getChildren();
  +            this.settings = new HashMap(parameters.length);
  +            for ( int i = 0; i < parameters.length; i++) {
  +                key = parameters[i].getName();
  +                val = parameters[i].getValue();
  +                if ( key != null )
  +                    this.settings.put(key, val);
  +            }
  +        }
       }
   
       /**
  
  
  
  1.2       +13 -12    xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/AbstractOutputHelper.java
  
  Index: AbstractOutputHelper.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/AbstractOutputHelper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractOutputHelper.java	2001/11/23 10:50:36	1.1
  +++ AbstractOutputHelper.java	2001/11/26 09:28:08	1.2
  @@ -21,7 +21,7 @@
    * Logger, use getLogger().
    *
    * @author <a href="mailto:haul@apache.org">Christian Haul</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2001/11/23 10:50:36 $ */
  + * @version CVS $Revision: 1.2 $ $Date: 2001/11/26 09:28:08 $ */
   public abstract class AbstractOutputHelper extends AbstractLoggable
       implements OutputHelper, Configurable, Disposable { 
   
  @@ -42,18 +42,19 @@
        * For nested configurations override this function.  
        * */
       public void configure(Configuration conf) throws ConfigurationException {
  +
           if (conf != null) {
  -	    String key = null;
  -	    String val = null;
  -	    Configuration[] parameters = conf.getChildren();
  -	    this.settings = new HashMap(parameters.length);
  -	    for ( int i = 0; i < parameters.length; i++) {
  -		key = parameters[i].getName();
  -		val = parameters[i].getValue();
  -		if ( key != null )
  -		    this.settings.put(key, val);
  -	    }
  -	}
  +            String key = null;
  +            String val = null;
  +            Configuration[] parameters = conf.getChildren();
  +            this.settings = new HashMap(parameters.length);
  +            for ( int i = 0; i < parameters.length; i++) {
  +                key = parameters[i].getName();
  +                val = parameters[i].getValue();
  +                if ( key != null )
  +                    this.settings.put(key, val);
  +            }
  +        }
       }
   
       /**
  
  
  
  1.3       +9 -18     xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/AttributeHelper.java
  
  Index: AttributeHelper.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/AttributeHelper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AttributeHelper.java	2001/11/23 10:50:36	1.2
  +++ AttributeHelper.java	2001/11/26 09:28:08	1.3
  @@ -21,13 +21,13 @@
    * attributes, session attributes &c.
    *
    * @author <a href="mailto:haul@apache.org">Christian Haul</a>
  - * @version CVS $Id: AttributeHelper.java,v 1.2 2001/11/23 10:50:36 haul Exp $
  + * @version CVS $Id: AttributeHelper.java,v 1.3 2001/11/26 09:28:08 haul Exp $
    * */
  -public interface AttributeHelper 
  -    extends Component 
  -{
  +public interface AttributeHelper extends Component {
  +
       String ROLE = "org.apache.cocoon.acting.ModularDatabaseAccess.AttributeHelper";
   
  +
       /** 
        * Standard access to an attribute's value. If more than one value
        * exists, the first is returned. If the value does not exist,
  @@ -41,12 +41,9 @@
        * description. This argument is optional.
        * @param request the request object
        */
  -    public Object getAttribute( String name, 
  -				Configuration modeConf, 
  -				Request request
  -				)
  -	throws ConfigurationException;
  +    Object getAttribute( String name, Configuration modeConf, Request request ) throws ConfigurationException;
   
  +
       /**
        * Returns an Enumeration of String objects containing the names
        * of the attributes available. If no attributes are available,
  @@ -55,10 +52,8 @@
        * description. This argument is optional.
        * @param request the request object
        */
  -    public Enumeration getAttributeNames( Configuration modeConf, 
  -					  Request request
  -					  )
  -	throws ConfigurationException;
  +    Enumeration getAttributeNames( Configuration modeConf, Request request ) throws ConfigurationException;
  +
   
       /**
        * Returns an array of String objects containing all of the values
  @@ -72,10 +67,6 @@
        * description. This argument is optional.
        * @param request the request object
        */
  -    public Object[] getAttributeValues( String name, 
  -					Configuration modeConf, 
  -					Request request
  -					)
  -	throws ConfigurationException;
  +    Object[] getAttributeValues( String name, Configuration modeConf, Request request ) throws ConfigurationException;
   
   }
  
  
  
  1.2       +15 -26    xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/AutoIncrementHelper.java
  
  Index: AutoIncrementHelper.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/AutoIncrementHelper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AutoIncrementHelper.java	2001/11/23 10:50:36	1.1
  +++ AutoIncrementHelper.java	2001/11/26 09:28:08	1.2
  @@ -20,12 +20,12 @@
    * attribute columns.
    *
    * @author <a href="mailto:haul@apache.org">Christian Haul</a>
  - * @version CVS $Id: AutoIncrementHelper.java,v 1.1 2001/11/23 10:50:36 haul Exp $ 
  + * @version CVS $Id: AutoIncrementHelper.java,v 1.2 2001/11/26 09:28:08 haul Exp $ 
    * */
  -public interface AutoIncrementHelper 
  -    extends Component 
  -{
  +public interface AutoIncrementHelper extends Component {
  +
       String ROLE = "org.apache.cocoon.acting.ModularDatabaseAccess.AutoIncrementHelper";
  +
       
       /**
        * Return key attribute value of last inserted row.
  @@ -42,14 +42,9 @@
        * @param request The request object
        * @return value representing the last key value value.
        * */
  -    public Object getPostValue( Configuration tableConf, 
  -				Configuration columnConf, 
  -				Configuration modeConf, 
  -				Connection conn, 
  -				Statement stmt, 
  -				Request request
  -			      ) 
  -	throws SQLException, ConfigurationException;
  +    Object getPostValue( Configuration tableConf, Configuration columnConf, Configuration modeConf, 
  +                         Connection conn, Statement stmt, Request request ) throws SQLException, ConfigurationException;
  +
       
       /**
        * Boolean whether the key attribute column needs to be included
  @@ -58,8 +53,9 @@
        * @return true if the column is needed, false if the column
        * should be skipped.  
        * */
  -    public boolean includeInQuery( );
  +    boolean includeInQuery( );
   
  +
       /**
        * Boolean whether the key attribute needs to be included in the
        * insert query as an attribute value (no subquery).
  @@ -67,7 +63,8 @@
        * @return true if a value is needed, false if a subquery
        * expression is used or the column is skipped altogether.
        * */
  -    public boolean includeAsValue( );
  +    boolean includeAsValue( );
  +
   
       /**
        * Provide the value for the key attribute column.
  @@ -83,13 +80,9 @@
        * @param idx In case of multiple rows to be inserted, index to the desired row
        * @return exact value for key attribute column 
        * */
  -    public Object getPreValue( Configuration tableConf, 
  -			       Configuration columnConf, 
  -			       Configuration modeConf, 
  -			       Connection conn, 
  -			       Request request
  -			     ) 
  -	throws SQLException, ConfigurationException;
  +    Object getPreValue( Configuration tableConf, Configuration columnConf, Configuration modeConf, 
  +                        Connection conn, Request request ) throws SQLException, ConfigurationException;
  +
   
       /**
        * Provide subquery string for the key attribute column.
  @@ -101,10 +94,6 @@
        *
        * @return subquery string for autoincrement column.
        */
  -    public String getSubquery( Configuration tableConf, 
  -			       Configuration columnConf, 
  -			       Configuration modeConf
  -			       ) 
  -	throws ConfigurationException;
  +    String getSubquery( Configuration tableConf, Configuration columnConf, Configuration modeConf ) throws ConfigurationException;
   
   }
  
  
  
  1.3       +8 -11     xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/OutputHelper.java
  
  Index: OutputHelper.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/OutputHelper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- OutputHelper.java	2001/11/23 10:50:36	1.2
  +++ OutputHelper.java	2001/11/26 09:28:08	1.3
  @@ -19,9 +19,10 @@
    * the transaction completes successfully.
    *
    * @author <a href="mailto:haul@apache.org">Christian Haul</a>
  - * @version CVS $Id: OutputHelper.java,v 1.2 2001/11/23 10:50:36 haul Exp $
  + * @version CVS $Id: OutputHelper.java,v 1.3 2001/11/26 09:28:08 haul Exp $
    * */
   public interface OutputHelper extends Component {
  +
       String ROLE = "org.apache.cocoon.acting.ModularDatabaseAccess.OutputHelper";
       
       
  @@ -35,11 +36,7 @@
        * same spec.
        * @param value The attriute's value.
        * */
  -    public void setAttribute( Configuration modeConf,
  -			      Request request,
  -			      String name,
  -			      Object value
  -			      );
  +    void setAttribute( Configuration modeConf, Request request, String name, Object value );
   
   
       /**
  @@ -55,9 +52,8 @@
        *
        * Really necessary?
        * */
  -    public Object getAttribute( Configuration modeConf,
  -				Request request,
  -				String name );
  +    Object getAttribute( Configuration modeConf, Request request, String name );
  +
   
       /**
        * If a database transaction needs to rollback, this is called to
  @@ -68,13 +64,14 @@
        * your data straight to some beans or other entities could result
        * in data corruption!</em>
        * */
  -    public void rollback( Configuration modeConf, Request request, Exception e );
  +    void rollback( Configuration modeConf, Request request, Exception e );
   
   
       /**
        * Signal that the database transaction completed
        * successfully. See notes on @link{rollback}.
        * */
  -    public void commit( Configuration modeConf, Request request );
  +    void commit( Configuration modeConf, Request request );
  +
   
   }
  
  
  
  1.3       +69 -76    xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/RequestAttributeHelper.java
  
  Index: RequestAttributeHelper.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/RequestAttributeHelper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RequestAttributeHelper.java	2001/11/23 10:50:36	1.2
  +++ RequestAttributeHelper.java	2001/11/26 09:28:08	1.3
  @@ -17,91 +17,84 @@
   import org.apache.avalon.framework.thread.ThreadSafe;
   
   /**
  - * RequestAttributeHelper accesses request attributes.
  + * RequestAttributeHelper accesses request attributes. If the
  + * attribute name contains an askerisk "*" this is considered a
  + * wildcard and all attributes that would match this wildcard are
  + * considered to be part of an array of that name for
  + * getAttributeValues. Only one "*" is allowed.
    *
    * @author <a href="mailto:haul@apache.org">Christian Haul</a>
  - * @version CVS $Id: RequestAttributeHelper.java,v 1.2 2001/11/23 10:50:36 haul Exp $
  - */
  -public class RequestAttributeHelper 
  -    extends AbstractAttributeHelper 
  -    implements ThreadSafe
  -{
  + * @version CVS $Id: RequestAttributeHelper.java,v 1.3 2001/11/26 09:28:08 haul Exp $ */
  +public class RequestAttributeHelper extends AbstractAttributeHelper implements ThreadSafe {
       
  -    public Object getAttribute( String name, 
  -				Configuration modeConf, 
  -				Request request
  -				)
  -	throws ConfigurationException
  -    {
  -	String pname = name;
  -	if ( modeConf != null ) {
  -	    pname = modeConf.getAttribute( "parameter", pname );
  -	}
  -	return request.getAttribute( pname );
  +    public Object getAttribute( String name, Configuration modeConf, Request request )
  +        throws ConfigurationException {
  +
  +        String pname = name;
  +        if ( modeConf != null ) {
  +            pname = modeConf.getAttribute( "parameter", pname );
  +        }
  +        return request.getAttribute( pname );
       }
   
  +
  +    public Enumeration getAttributeNames( Configuration modeConf, Request request )
  +        throws ConfigurationException {
   
  -    public Enumeration getAttributeNames( Configuration modeConf, 
  -					  Request request
  -					  )
  -	throws ConfigurationException
  -    {
  -	return request.getAttributeNames();
  +        return request.getAttributeNames();
       }
   
  -    public Object[] getAttributeValues( String name, 
  -					Configuration modeConf, 
  -					Request request
  -					)
  -	throws ConfigurationException
  -    {
  -	String wildcard = name;
  -	if ( modeConf != null ) {
  -	    wildcard = modeConf.getAttribute( "parameter", wildcard );
  -	}
  -	int wildcardIndex = wildcard.indexOf( "*" );
  -	if ( wildcardIndex != -1 ) {
  -	    // "*" contained in attribute name => combine all
  -	    // attributes' values that match prefix, suffix
  -
  -	    // split the attribute's name so that the "*" could be
  -	    // determined by looking at the attributes' names that
  -	    // start with the prefix and end with the suffix
  -	    //
  -	    String prefix = wildcard.substring( 0, wildcardIndex );
  -	    String suffix;
  -	    if ( wildcard.length() >= wildcardIndex + 1 ) {
  -		suffix = wildcard.substring( wildcardIndex + 1 );
  -	    } else {
  -		suffix = "";
  -	    }
  -	    List values = new LinkedList();
  -	    Enumeration names = request.getAttributeNames();
  -	    
  -	    while (names.hasMoreElements()) {
  -		String pname = (String) names.nextElement();
  -		if ( pname.startsWith( prefix ) && pname.endsWith( suffix ) ) {
  -		    values.add( request.getAttribute( pname ) );
  -		}
  -	    }
  -
  -	    return values.toArray();
  -
  -	} else {
  -	    // no "*" in attribute name => just return all values of
  -	    // this one attribute. Make sure, it's an array.
  -	    
  -	    Object value = request.getAttribute( wildcard );
  -	    if ( value != null && !value.getClass().isArray() ) {
  -		Object[] values = new Object[1];
  -		values[0] = value;
  -		return values;
  -	    } else {
  -		return (Object[]) value;
  -	    }
   
  -	}
  -	
  +    public Object[] getAttributeValues( String name, Configuration modeConf, Request request )
  +        throws ConfigurationException {
  +
  +        String wildcard = name;
  +        if ( modeConf != null ) {
  +            wildcard = modeConf.getAttribute( "parameter", wildcard );
  +        }
  +        int wildcardIndex = wildcard.indexOf( "*" );
  +        if ( wildcardIndex != -1 ) {
  +            // "*" contained in attribute name => combine all
  +            // attributes' values that match prefix, suffix
  +            
  +            // split the attribute's name so that the "*" could be
  +            // determined by looking at the attributes' names that
  +            // start with the prefix and end with the suffix
  +            //
  +            String prefix = wildcard.substring( 0, wildcardIndex );
  +            String suffix;
  +            if ( wildcard.length() >= wildcardIndex + 1 ) {
  +                suffix = wildcard.substring( wildcardIndex + 1 );
  +            } else {
  +                suffix = "";
  +            }
  +            List values = new LinkedList();
  +            Enumeration names = request.getAttributeNames();
  +            
  +            while (names.hasMoreElements()) {
  +                String pname = (String) names.nextElement();
  +                if ( pname.startsWith( prefix ) && pname.endsWith( suffix ) ) {
  +                    values.add( request.getAttribute( pname ) );
  +                }
  +            }
  +            
  +            return values.toArray();
  +
  +        } else {
  +            // no "*" in attribute name => just return all values of
  +            // this one attribute. Make sure, it's an array.
  +            
  +            Object value = request.getAttribute( wildcard );
  +            if ( value != null && !value.getClass().isArray() ) {
  +                Object[] values = new Object[1];
  +                values[0] = value;
  +                return values;
  +            } else {
  +                return (Object[]) value;
  +            }
  +            
  +        }
  +    
       }
       
   
  
  
  
  1.3       +27 -35    xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/RequestAttributeOutputHelper.java
  
  Index: RequestAttributeOutputHelper.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/RequestAttributeOutputHelper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RequestAttributeOutputHelper.java	2001/11/23 10:50:36	1.2
  +++ RequestAttributeOutputHelper.java	2001/11/26 09:28:08	1.3
  @@ -18,11 +18,9 @@
    * "org.apache.cocoon.acting.ModularDatabaseAccess.OutputHelper"+":"
    *
    * @author <a href="mailto:haul@apache.org">Christian Haul</a>
  - * @version CVS $Id: RequestAttributeOutputHelper.java,v 1.2 2001/11/23 10:50:36 haul Exp $
  + * @version CVS $Id: RequestAttributeOutputHelper.java,v 1.3 2001/11/26 09:28:08 haul Exp $
    * */
  -public class RequestAttributeOutputHelper 
  -    extends AbstractOutputHelper
  -    implements OutputHelper {
  +public class RequestAttributeOutputHelper extends AbstractOutputHelper implements OutputHelper {
       
       /**
        * communicate an attribute value to further processing logic. 
  @@ -34,15 +32,11 @@
        * same spec.
        * @param value The attriute's value.
        * */
  -    public void setAttribute( Configuration modeConf,
  -			      Request request,
  -			      String name,
  -			      Object value
  -			      )
  -    {
  -	request.setAttribute( ( (String) this.settings.get("key-prefix",
  -							   "org.apache.cocoon.acting.ModularDatabaseAccess.OutputHelper" ) )
  -			      + ":" + name, value);
  +    public void setAttribute( Configuration modeConf, Request request, String name, Object value ) {
  +
  +        request.setAttribute( ( (String) this.settings.get("key-prefix",
  +                                                           "org.apache.cocoon.acting.ModularDatabaseAccess.OutputHelper" ) )
  +                              + ":" + name, value);
       }
   
   
  @@ -57,15 +51,14 @@
        * same spec.
        * @return requested object.
        * */
  -    public Object getAttribute( Configuration modeConf,
  -				Request request,
  -				String name )
  -    {
  -	return request.getAttribute( ( (String) this.settings.get("key-prefix",
  -								  "org.apache.cocoon.acting.ModularDatabaseAccess.OutputHelper" ) )
  -			      + ":" + name );
  +    public Object getAttribute( Configuration modeConf, Request request, String name ) {
  +
  +        return request.getAttribute( ( (String) this.settings.get("key-prefix",
  +                                                                  "org.apache.cocoon.acting.ModularDatabaseAccess.OutputHelper" ) )
  +                                     + ":" + name );
       }
   
  +
       /**
        * If a database transaction needs to rollback, this is called to
        * inform the further processing logic about this fact. All
  @@ -75,20 +68,19 @@
        * your data straight to some beans or other entities could result
        * in data corruption!</em>
        * */
  -    public void rollback( Configuration modeConf, Request request, Exception e )
  -    {
  -	/*
  -	Enumeration attributes = request.getAttributeNames();
  -	while ( attributes.hasMoreElements() ) {
  -	    String name = (String) attributes.nextElement();
  -	    if ( name.startsWith("org.apache.cocoon.acting.ModularDatabaseAccess.OutputHelper:") ) {
  -		request.removeAttribute(name);
  -	    }
  -	}
  -	*/
  -	request.setAttribute( ( (String) this.settings.get("key-prefix",
  -							   "org.apache.cocoon.acting.ModularDatabaseAccess.OutputHelper" ) ) + ":",
  -			      e.getMessage());
  +    public void rollback( Configuration modeConf, Request request, Exception e ) {
  +        /*
  +          Enumeration attributes = request.getAttributeNames();
  +          while ( attributes.hasMoreElements() ) {
  +              String name = (String) attributes.nextElement();
  +              if ( name.startsWith("org.apache.cocoon.acting.ModularDatabaseAccess.OutputHelper:") ) {
  +                  request.removeAttribute(name);
  +              }
  +          }
  +        */
  +        request.setAttribute( ( (String) this.settings.get("key-prefix",
  +                                                           "org.apache.cocoon.acting.ModularDatabaseAccess.OutputHelper" ) ) + ":",
  +                              e.getMessage());
       };
   
   
  @@ -98,7 +90,7 @@
        * */
       public void commit( Configuration modeConf, Request request )
       {
  -	// empty method
  +        // empty method
       }
   
   }
  
  
  
  1.3       +63 -69    xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/RequestParameterHelper.java
  
  Index: RequestParameterHelper.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/RequestParameterHelper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RequestParameterHelper.java	2001/11/23 10:50:36	1.2
  +++ RequestParameterHelper.java	2001/11/26 09:28:08	1.3
  @@ -17,83 +17,77 @@
   import org.apache.avalon.framework.thread.ThreadSafe;
   
   /**
  - * RequestParameterHelper accesses request parameters.
  + * RequestParameterHelper accesses request parameters. If the
  + * parameter name contains an askerisk "*" this is considered a
  + * wildcard and all parameters that would match this wildcard are
  + * considered to be part of an array of that name for
  + * getAttributeValues. Only one "*" is allowed. Wildcard matches take
  + * precedence over real arrays. In that case only the first value of
  + * such array is returned.
    *
    * @author <a href="mailto:haul@apache.org">Christian Haul</a>
  - * @version CVS $Id: RequestParameterHelper.java,v 1.2 2001/11/23 10:50:36 haul Exp $
  - */
  -public class RequestParameterHelper 
  -    extends AbstractAttributeHelper 
  -    implements ThreadSafe
  -{
  -    public Object getAttribute( String name, 
  -				Configuration modeConf, 
  -				Request request
  -				)
  -	throws ConfigurationException
  -    {
  -	String pname = name;
  -	if ( modeConf != null ) {
  -	    pname = modeConf.getAttribute( "parameter", pname );
  -	}
  -	return request.getParameter( pname );
  + * @version CVS $Id: RequestParameterHelper.java,v 1.3 2001/11/26 09:28:08 haul Exp $ */
  +public class RequestParameterHelper extends AbstractAttributeHelper implements ThreadSafe {
  +
  +    public Object getAttribute( String name, Configuration modeConf, Request request ) throws ConfigurationException {
  +
  +        String pname = name;
  +        if ( modeConf != null ) {
  +            pname = modeConf.getAttribute( "parameter", pname );
  +        }
  +        return request.getParameter( pname );
       }
   
  +
  +    public Enumeration getAttributeNames( Configuration modeConf, Request request ) throws ConfigurationException {
   
  -    public Enumeration getAttributeNames( Configuration modeConf, 
  -					  Request request
  -					  )
  -	throws ConfigurationException
  -    {
  -	return request.getParameterNames();
  +        return request.getParameterNames();
       }
   
  -    public Object[] getAttributeValues( String name, 
  -					Configuration modeConf, 
  -					Request request
  -					)
  -	throws ConfigurationException
  -    {
  -	String wildcard = name;
  -	if ( modeConf != null ) {
  -	    wildcard = modeConf.getAttribute( "parameter", wildcard );
  -	}
  -	int wildcardIndex = wildcard.indexOf( "*" );
  -	if ( wildcardIndex != -1 ) {
  -	    // "*" contained in parameter name => combine all
  -	    // parameters' values that match prefix, suffix
  -
  -	    // split the parameter's name so that the "*" could be
  -	    // determined by looking at the parameters' names that
  -	    // start with the prefix and end with the suffix
  -	    //
  -	    String prefix = wildcard.substring( 0, wildcardIndex );
  -	    String suffix;
  -	    if ( wildcard.length() >= wildcardIndex + 1 ) {
  -		suffix = wildcard.substring( wildcardIndex + 1 );
  -	    } else {
  -		suffix = "";
  -	    }
  -	    List values = new LinkedList();
  -	    Enumeration names = request.getParameterNames();
  -	    
  -	    while (names.hasMoreElements()) {
  -		String pname = (String) names.nextElement();
  -		if ( pname.startsWith( prefix ) && pname.endsWith( suffix ) ) {
  -		    values.add( request.getParameter( pname ) );
  -		}
  -	    }
  -
  -	    return values.toArray();
  -
  -	} else {
  -	    // no "*" in parameter name => just return all values of
  -	    // this one parameter.
  -	    
  -	    return request.getParameterValues( wildcard );
   
  -	}
  -	
  +    public Object[] getAttributeValues( String name, Configuration modeConf, Request request ) 
  +        throws ConfigurationException {
  +        
  +        String wildcard = name;
  +        if ( modeConf != null ) {
  +            wildcard = modeConf.getAttribute( "parameter", wildcard );
  +        }
  +        int wildcardIndex = wildcard.indexOf( "*" );
  +        if ( wildcardIndex != -1 ) {
  +            // "*" contained in parameter name => combine all
  +            // parameters' values that match prefix, suffix
  +            
  +            // split the parameter's name so that the "*" could be
  +            // determined by looking at the parameters' names that
  +            // start with the prefix and end with the suffix
  +            //
  +            String prefix = wildcard.substring( 0, wildcardIndex );
  +            String suffix;
  +            if ( wildcard.length() >= wildcardIndex + 1 ) {
  +                suffix = wildcard.substring( wildcardIndex + 1 );
  +            } else {
  +                suffix = "";
  +            }
  +            List values = new LinkedList();
  +            Enumeration names = request.getParameterNames();
  +            
  +            while (names.hasMoreElements()) {
  +                String pname = (String) names.nextElement();
  +                if ( pname.startsWith( prefix ) && pname.endsWith( suffix ) ) {
  +                    values.add( request.getParameter( pname ) );
  +                }
  +            }
  +            
  +            return values.toArray();
  +            
  +        } else {
  +            // no "*" in parameter name => just return all values of
  +            // this one parameter.
  +            
  +            return request.getParameterValues( wildcard );
  +            
  +        }
  +        
       }
       
   }
  
  
  
  1.1                  xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/HsqlIdentityAutoIncrementHelper.java
  
  Index: HsqlIdentityAutoIncrementHelper.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included  with this distribution in *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  package org.apache.cocoon.acting.ModularDatabaseAccess;
  
  import java.lang.Integer;
  import java.util.SortedSet;
  import java.sql.CallableStatement;
  import java.sql.PreparedStatement;
  import java.sql.Connection;
  import java.sql.ResultSet;
  import java.sql.Statement;
  import java.sql.Types;
  import java.sql.SQLException;
  import org.apache.cocoon.environment.Request;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.thread.ThreadSafe;
  
  /**
   * Abstraction layer to encapsulate different DBMS behaviour for autoincrement columns.
   *
   * Here: HSQLDB 1.6 IDENTITY columns
   * {@link http://hsqldb.sourceforge.net}
   *
   * @author <a href="mailto:haul@apache.org">Christian Haul</a>
   * @version CVS $Id: HsqlIdentityAutoIncrementHelper.java,v 1.1 2001/11/26 09:28:08 haul Exp $
   */
  public class HsqlIdentityAutoIncrementHelper implements AutoIncrementHelper, ThreadSafe {
      
      public Object getPostValue( Configuration tableConf, Configuration columnConf, Configuration modeConf, 
                                  Connection conn, Statement stmt, Request request )  throws SQLException, ConfigurationException {
  
          Integer id = null;
          /*
            // if hsqldb did support callable statements ...
  
            CallableStatement callStmt = conn.prepareCall("? = {CALL IDENTITY()}");
            callStmt.registerOutParameter(1, Types.INTEGER);
            ResultSet resultSet = callStmt.executeQuery();
          */
          
          PreparedStatement pstmt = conn.prepareStatement("CALL IDENTITY()");
          ResultSet resultSet = pstmt.executeQuery();
          while ( resultSet.next() ) {
              id = new Integer(resultSet.getInt(1));
          }
          resultSet.close();
          
          return id;
      };
      
  
      public boolean includeInQuery() { return false; };
  
  
      public boolean includeAsValue() { return false; };
  
  
      public Object getPreValue( Configuration tableConf, Configuration columnConf, Configuration modeConf, 
                                 Connection conn, Request request ) throws SQLException, ConfigurationException {
  
          return null;
      };
  
  
      public String getSubquery( Configuration tableConf, Configuration columnConf, Configuration modeConf ) 
          throws ConfigurationException {
  
          return null;
      };
  }
  
  
  
  1.1                  xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/IfxSerialAutoIncrementHelper.java
  
  Index: IfxSerialAutoIncrementHelper.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included  with this distribution in *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  package org.apache.cocoon.acting.ModularDatabaseAccess;
  
  import java.lang.Integer;
  import java.util.SortedSet;
  import java.sql.Connection;
  import java.sql.Statement;
  import java.sql.SQLException;
  import org.apache.cocoon.environment.Request;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.thread.ThreadSafe;
  import com.informix.jdbc.IfxStatement;
  
  /**
   * Abstraction layer to encapsulate different DBMS behaviour for autoincrement columns.
   *
   * Here: Informix IUS 9.21 SERIAL columns
   * (need another one for SERIAL8 ones!)
   *
   * @author <a href="mailto:haul@apache.org">Christian Haul</a>
   * @version CVS $Id: IfxSerialAutoIncrementHelper.java,v 1.1 2001/11/26 09:28:08 haul Exp $
   */
  public class IfxSerialAutoIncrementHelper implements AutoIncrementHelper, ThreadSafe {
      
      public Object getPostValue( Configuration tableConf, Configuration columnConf, Configuration modeConf, 
                                  Connection conn, Statement stmt, Request request ) 
          throws SQLException, ConfigurationException {
  
          return new Integer(((com.informix.jdbc.IfxStatement) stmt).getSerial());
      };
      
  
      public boolean includeInQuery() { return false; };
  
  
      public boolean includeAsValue() { return false; };
  
  
      public Object getPreValue( Configuration tableConf, Configuration columnConf, Configuration modeConf, 
                                 Connection conn, Request request ) throws SQLException, ConfigurationException {
  
          return null;
      };
  
      public String getSubquery( Configuration tableConf, Configuration columnConf, Configuration modeConf ) 
          throws ConfigurationException {
  
          return null;
      };
  
  }
  
  
  
  1.1                  xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/ManualAutoIncrementHelper.java
  
  Index: ManualAutoIncrementHelper.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included  with this distribution in *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  package org.apache.cocoon.acting.ModularDatabaseAccess;
  
  import java.sql.Connection;
  import java.sql.Statement;
  import java.sql.PreparedStatement;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import org.apache.cocoon.environment.Request;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.thread.ThreadSafe;
  import java.lang.Integer;
  import java.util.Map;
  import java.util.HashMap;
  import java.util.SortedSet;
  
  /**
   * Abstraction layer to encapsulate different DBMS behaviour for
   * autoincrement columns.
   *
   * Here: manual mode The new value is determined by doing a "select
   * max(column)+1 from table" query. With transactions and correct
   * isolation levels, this should to the trick almost everywhere.
   *
   * Note however, that the above query does not prevent a parallel
   * transaction to try to insert a row with the same ID since it
   * requires only shared locks. C.f. "Phantom Problem"
   *
   * @author <a href="mailto:haul@apache.org">Christian Haul</a>
   * @version CVS $Id: ManualAutoIncrementHelper.java,v 1.1 2001/11/26 09:28:08 haul Exp $
   */
  public class ManualAutoIncrementHelper extends AbstractAutoIncrementHelper implements ThreadSafe {
  
      private Map selectStatements = new HashMap();
      
  
      public Object getPostValue( Configuration tableConf, Configuration columnConf, Configuration modenConf,
                                  Connection conn, Statement stmt, Request request ) 
          throws SQLException, ConfigurationException {
  
          return null;
      };
      
      public boolean includeInQuery( ) { return true; };
  
      
      public boolean includeAsValue( ) { return true; };
  
  
      public Object getPreValue( Configuration tableConf, Configuration columnConf, Configuration modeConf,
                                 Connection conn, Request request ) 
          throws SQLException, ConfigurationException {
  
          /** Set the key value using SELECT MAX(keyname)+1 **/
          String tableName = tableConf.getAttribute("name","");
          String selectQuery = this.getSelectQuery(tableName, columnConf);
          PreparedStatement select_statement = conn.prepareStatement(selectQuery);
          ResultSet set = select_statement.executeQuery();
          set.next();
          int maxid = set.getInt("maxid");
          set.close();
          select_statement.close();
          if (getLogger().isDebugEnabled())
              getLogger().debug("autoincrementValue " + (maxid+1));
          return new Integer(maxid + 1);
      };
  
  
      public String getSubquery( Configuration tableConf, Configuration columnConf, Configuration modeConf ) 
          throws ConfigurationException {
          
          return null;
      };
  
  
      /**
       * Set the String representation of the MaxID lookup statement.  This is
       * mapped to the Configuration object itself, so if it doesn't exist,
       * it will be created.
       */
      protected final synchronized void setSelectQuery( String tableName, Configuration entry ) throws ConfigurationException {
  
          StringBuffer queryBuffer = new StringBuffer("SELECT max(");
          queryBuffer.append(entry.getAttribute("name"));
          queryBuffer.append(") AS maxid FROM ");
          queryBuffer.append(tableName);
          
          this.selectStatements.put(entry, queryBuffer.toString());
      }
      
  
      protected final synchronized String getSelectQuery( String tableName, Configuration entry ) throws ConfigurationException {
  
          String result = (String) this.selectStatements.get(entry);
          if (result == null) {
              setSelectQuery(tableName, entry);
              result = (String) this.selectStatements.get(entry);
          }
          return result;
      }
  
  }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org