bloritsch    2003/01/27 13:20:43

  Modified:    infomover/src/conf infomover-assembly.xml
                        infomover-config.xml
               infomover/src/java/org/apache/infomover/manipulator
                        Normalizer.java
  Log:
  commit working version
  
  Revision  Changes    Path
  1.3       +3 -3      jakarta-avalon-apps/infomover/src/conf/infomover-assembly.xml
  
  Index: infomover-assembly.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/infomover/src/conf/infomover-assembly.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- infomover-assembly.xml    8 Jan 2003 03:30:04 -0000       1.2
  +++ infomover-assembly.xml    27 Jan 2003 21:20:43 -0000      1.3
  @@ -5,8 +5,8 @@
   <assembly>
   
     <!-- The Storage block -->
  -  <block class="org.apache.avalon.cornerstone.blocks.masterstore.RepositoryManager"
  -         name="objectstorage" />
  +  <!--block 
class="org.apache.avalon.cornerstone.blocks.masterstore.RepositoryManager"
  +         name="objectstorage" /-->
   
     <!-- The ThreadManager block -->
     <block class="org.apache.avalon.cornerstone.blocks.threads.DefaultThreadManager"
  @@ -32,7 +32,7 @@
     <!-- Below this section are the demo blocks -->
     <!--                                        -->
   
  -  <block class="org.apache.infomover.connection.impl.ConnectionManagerImpl.java"
  +  <block class="org.apache.infomover.connection.impl.ConnectionManagerImpl"
            name="connection-manager">
        <provide name="connections"
                 
role="org.apache.avalon.cornerstone.services.connection.ConnectionManager"/>
  
  
  
  1.3       +26 -42    jakarta-avalon-apps/infomover/src/conf/infomover-config.xml
  
  Index: infomover-config.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/infomover/src/conf/infomover-config.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- infomover-config.xml      8 Jan 2003 03:30:04 -0000       1.2
  +++ infomover-config.xml      27 Jan 2003 21:20:43 -0000      1.3
  @@ -24,60 +24,44 @@
         </thread-group>
     </thread-manager>
   
  -  <!-- The Storage block -->
  -  <objectstorage>
  -      <repositories>
  -        <repository 
class="org.apache.avalon.cornerstone.blocks.masterstore.File_Persistent_Object_Repository">
  -          <protocols>
  -            <protocol>file</protocol>
  -          </protocols>
  -          <types>
  -            <type>OBJECT</type>
  -          </types>
  -          <models>
  -            <model>SYNCHRONOUS</model>
  -            <model>ASYNCHRONOUS</model>
  -            <model>CACHE</model>
  -          </models>
  -        </repository>
  -        <repository 
class="org.apache.avalon.cornerstone.blocks.masterstore.File_Persistent_Stream_Repository">
  -          <protocols>
  -            <protocol>file</protocol>
  -          </protocols>
  -          <types>
  -            <type>STREAM</type>
  -          </types>
  -          <models>
  -            <model>SYNCHRONOUS</model>
  -            <model>ASYNCHRONOUS</model>
  -            <model>CACHE</model>
  -          </models>
  -        </repository>
  -      </repositories>
  -  </objectstorage>
  -
     <sockets>
         <server-sockets>
           <factory name="plain"
                    
class="org.apache.avalon.cornerstone.blocks.sockets.DefaultServerSocketFactory" />
           <factory name="secure"
  -                 
class="org.apache.avalon.cornerstone.blocks.sockets.TLSServerSocketFactory"/>
  +                 
class="org.apache.avalon.cornerstone.blocks.sockets.TLSServerSocketFactory">
  +           <authenticate-client>false</authenticate-client>
  +            <ssl-factory>
  +              <keystore>
  +                <file>conf/serverstore</file>
  +                <password>password</password>
  +                <algorithm>SunX509</algorithm>
  +                <type>JKS</type>
  +                <protocol>TLS</protocol>
  +                <timeout>-1</timeout>
  +              </keystore>
  +            </ssl-factory>
  +        </factory>
         </server-sockets>
   
         <client-sockets>
           <factory name="plain"
                    
class="org.apache.avalon.cornerstone.blocks.sockets.DefaultSocketFactory" />
           <factory name="secure"
  -                 
class="org.apache.avalon.cornerstone.blocks.sockets.TLSSocketFactory"/>
  +                 
class="org.apache.avalon.cornerstone.blocks.sockets.TLSSocketFactory">
  +            <verify-server-identity>false</verify-server-identity>
  +            <ssl-factory>
  +              <keystore>
  +                <file>conf/clientstore</file>
  +                <password>password</password>
  +                <algorithm>SunX509</algorithm>
  +                <type>JKS</type>
  +                <protocol>TLS</protocol>
  +                <timeout>-1</timeout>
  +              </keystore>
  +            </ssl-factory>
  +        </factory>
         </client-sockets>
     </sockets>
  -
  -  <helloworldserver>
  -      <port>8999</port>
  -      <bind>127.0.0.1</bind>
  -      <helloworldhandler>
  -        <connectiontimeout>360000</connectiontimeout>
  -      </helloworldhandler>
  -  </helloworldserver>
   
   </config>
  
  
  
  1.3       +216 -216  
jakarta-avalon-apps/infomover/src/java/org/apache/infomover/manipulator/Normalizer.java
  
  Index: Normalizer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-apps/infomover/src/java/org/apache/infomover/manipulator/Normalizer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Normalizer.java   8 Jan 2003 03:30:04 -0000       1.2
  +++ Normalizer.java   27 Jan 2003 21:20:43 -0000      1.3
  @@ -1,216 +1,216 @@
  -/*
  -
  - ============================================================================
  -                   The Apache Software License, Version 1.1
  - ============================================================================
  -
  - Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
  -
  - Redistribution and use in source and binary forms, with or without modifica-
  - tion, are permitted provided that the following conditions are met:
  -
  - 1. Redistributions of  source code must  retain the above copyright  notice,
  -    this list of conditions and the following disclaimer.
  -
  - 2. Redistributions in binary form must reproduce the above copyright notice,
  -    this list of conditions and the following disclaimer in the documentation
  -    and/or other materials provided with the distribution.
  -
  - 3. The end-user documentation included with the redistribution, if any, must
  -    include  the following  acknowledgment:  "This product includes  software
  -    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  -    Alternately, this  acknowledgment may  appear in the software itself,  if
  -    and wherever such third-party acknowledgments normally appear.
  -
  - 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
  -    must not be used to endorse or promote products derived from this  software
  -    without  prior written permission. For written permission, please contact
  -    [EMAIL PROTECTED]
  -
  - 5. Products  derived from this software may not  be called "Apache", nor may
  -    "Apache" appear  in their name,  without prior written permission  of the
  -    Apache Software Foundation.
  -
  - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  - FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  - APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  - INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  - ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  - (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  -
  - This software  consists of voluntary contributions made  by many individuals
  - on  behalf of the Apache Software  Foundation. For more  information on the
  - Apache Software Foundation, please see <http://www.apache.org/>.
  -
  -*/
  -package org.apache.infomover.manipulator;
  -
  -import org.apache.infomover.transaction.Transaction;
  -import org.apache.infomover.transaction.Record;
  -import org.apache.infomover.transaction.Field;
  -import org.apache.avalon.framework.logger.AbstractLogEnabled;
  -import org.apache.avalon.framework.configuration.Configurable;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -
  -import java.util.*;
  -
  -
  -/**
  - * Normalizer does ....
  - *.
  - * @author <a href="[EMAIL PROTECTED]">Berin Loritsch</a>
  - * @version CVS $Revision$ $Date$
  - */
  -public class Normalizer
  -        extends AbstractLogEnabled
  -        implements Manipulator, Configurable
  -
  -{
  -    private final static String KEYSET = Normalizer.class.getName();
  -    private String m_tableName;
  -    private String m_destTable;
  -    /** Sets up the field name to key entry map */
  -    private Map    m_fieldNames;
  -    private KeyEntry m_multiplexField;
  -
  -    public Normalizer()
  -    {
  -        m_tableName = "";
  -        m_fieldNames = new HashMap();
  -        m_destTable = "";
  -
  -        m_fieldNames.put( KEYSET, new HashSet() );
  -    }
  -
  -    public void configure( Configuration config )
  -        throws ConfigurationException
  -    {
  -        Configuration tableEntries = config.getChild( "table-entries" );
  -        m_tableName = tableEntries.getAttribute( "source" );
  -        m_destTable = tableEntries.getAttribute( "dest" );
  -
  -        if ( getLogger().isDebugEnabled() )
  -        {
  -            getLogger().debug( "The source table is \"" + m_tableName +
  -                               "\", and the destination table is \"" +
  -                               m_destTable + "\".");
  -        }
  -
  -        Configuration[] fields = tableEntries.getChildren( "field" );
  -        for ( int i = 0; i < fields.length; i++ )
  -        {
  -            String fieldName = fields[i].getAttribute( "field" );
  -            String entry = fields[i].getAttribute( "entry" );
  -
  -            m_fieldNames.put( fieldName, entry );
  -
  -            if ( getLogger().isDebugEnabled() )
  -            {
  -                getLogger().debug( fieldName + " = " + entry );
  -            }
  -        }
  -
  -        Set keySet = (Set) m_fieldNames.get( KEYSET );
  -        Configuration[] keys = tableEntries.getChildren( "key" );
  -        boolean hasMultiplexEntry = false;
  -
  -        for ( int i = 0; i < keys.length; i++ )
  -        {
  -            KeyEntry entry = new KeyEntry( keys[i].getAttribute( "name" ),
  -                                 keys[i].getAttributeAsBoolean( "multiplex" , false 
) );
  -            keySet.add( entry );
  -
  -            if ( entry.multiplexEntry )
  -            {
  -                if ( hasMultiplexEntry )
  -                {
  -                    throw new ConfigurationException( "We can only have one 
multiplex key" );
  -                }
  -                else
  -                {
  -                    hasMultiplexEntry = true;
  -                    m_multiplexField = entry;
  -                }
  -            }
  -        }
  -    }
  -
  -    public Transaction process( Transaction trans )
  -    {
  -        Set recordSet = trans.getRecordset( m_tableName );
  -
  -        Iterator it = recordSet.iterator();
  -        while ( it.hasNext() )
  -        {
  -            Record rec = (Record) it.next();
  -            processRecord( trans, rec );
  -            trans.removeRecord( rec );
  -        }
  -
  -        return trans;
  -    }
  -
  -    private void processRecord( Transaction trans, Record rec )
  -    {
  -        Iterator it = m_fieldNames.keySet().iterator();
  -        while ( it.hasNext() )
  -        {
  -            String fieldName = (String) it.next();
  -
  -            if ( KEYSET.equals( fieldName ) ) continue;
  -
  -            Field entryField = new Field( m_multiplexField.name, m_fieldNames.get( 
fieldName ), Field.STRING );
  -            List fields = createFields( rec, entryField );
  -            boolean add = rec.getField( fieldName ).getValue().equals( Boolean.TRUE 
);
  -
  -            Record newRec = new Record( m_destTable, (add) ? Record.ADD : 
Record.DELETE );
  -            trans.addRecord( newRec );
  -        }
  -    }
  -
  -    private List createFields( Record rec, Field multiplexField )
  -    {
  -        List fields = new ArrayList();
  -        Iterator it = ( (Set)m_fieldNames.get( KEYSET ) ).iterator();
  -        while ( it.hasNext() )
  -        {
  -            KeyEntry entry = (KeyEntry)it.next();
  -            Field field = null;
  -
  -            if ( entry.multiplexEntry )
  -            {
  -                field = multiplexField;
  -            }
  -            else
  -            {
  -                field = rec.getField( entry.name );
  -            }
  -
  -            if ( null == field && getLogger().isErrorEnabled() )
  -            {
  -                getLogger().error( "A key field was missing!" + entry.name );
  -            }
  -
  -            fields.add( field );
  -        }
  -
  -        return fields;
  -    }
  -
  -    private static final class KeyEntry
  -    {
  -        public final String name;
  -        public final boolean multiplexEntry;
  -
  -        public KeyEntry( String name, boolean multiplex )
  -        {
  -            this.name = name;
  -            multiplexEntry = multiplex;
  -        }
  -    }
  -}
  +/*
  +
  + ============================================================================
  +                   The Apache Software License, Version 1.1
  + ============================================================================
  +
  + Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
  +
  + Redistribution and use in source and binary forms, with or without modifica-
  + tion, are permitted provided that the following conditions are met:
  +
  + 1. Redistributions of  source code must  retain the above copyright  notice,
  +    this list of conditions and the following disclaimer.
  +
  + 2. Redistributions in binary form must reproduce the above copyright notice,
  +    this list of conditions and the following disclaimer in the documentation
  +    and/or other materials provided with the distribution.
  +
  + 3. The end-user documentation included with the redistribution, if any, must
  +    include  the following  acknowledgment:  "This product includes  software
  +    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  +    Alternately, this  acknowledgment may  appear in the software itself,  if
  +    and wherever such third-party acknowledgments normally appear.
  +
  + 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
  +    must not be used to endorse or promote products derived from this  software
  +    without  prior written permission. For written permission, please contact
  +    [EMAIL PROTECTED]
  +
  + 5. Products  derived from this software may not  be called "Apache", nor may
  +    "Apache" appear  in their name,  without prior written permission  of the
  +    Apache Software Foundation.
  +
  + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  + FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  + APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  + INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  + DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  + OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  + ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  + (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  +
  + This software  consists of voluntary contributions made  by many individuals
  + on  behalf of the Apache Software  Foundation. For more  information on the
  + Apache Software Foundation, please see <http://www.apache.org/>.
  +
  +*/
  +package org.apache.infomover.manipulator;
  +
  +import org.apache.infomover.transaction.Transaction;
  +import org.apache.infomover.transaction.Record;
  +import org.apache.infomover.transaction.Field;
  +import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
  +
  +import java.util.*;
  +
  +
  +/**
  + * Normalizer does ....
  + *.
  + * @author <a href="[EMAIL PROTECTED]">Berin Loritsch</a>
  + * @version CVS $Revision$ $Date$
  + */
  +public class Normalizer
  +        extends AbstractLogEnabled
  +        implements Manipulator, Configurable
  +
  +{
  +    private final static String KEYSET = Normalizer.class.getName();
  +    private String m_tableName;
  +    private String m_destTable;
  +    /** Sets up the field name to key entry map */
  +    private Map    m_fieldNames;
  +    private KeyEntry m_multiplexField;
  +
  +    public Normalizer()
  +    {
  +        m_tableName = "";
  +        m_fieldNames = new HashMap();
  +        m_destTable = "";
  +
  +        m_fieldNames.put( KEYSET, new HashSet() );
  +    }
  +
  +    public void configure( Configuration config )
  +        throws ConfigurationException
  +    {
  +        Configuration tableEntries = config.getChild( "table-entries" );
  +        m_tableName = tableEntries.getAttribute( "source" );
  +        m_destTable = tableEntries.getAttribute( "dest" );
  +
  +        if ( getLogger().isDebugEnabled() )
  +        {
  +            getLogger().debug( "The source table is \"" + m_tableName +
  +                               "\", and the destination table is \"" +
  +                               m_destTable + "\".");
  +        }
  +
  +        Configuration[] fields = tableEntries.getChildren( "field" );
  +        for ( int i = 0; i < fields.length; i++ )
  +        {
  +            String fieldName = fields[i].getAttribute( "field" );
  +            String entry = fields[i].getAttribute( "entry" );
  +
  +            m_fieldNames.put( fieldName, entry );
  +
  +            if ( getLogger().isDebugEnabled() )
  +            {
  +                getLogger().debug( fieldName + " = " + entry );
  +            }
  +        }
  +
  +        Set keySet = (Set) m_fieldNames.get( KEYSET );
  +        Configuration[] keys = tableEntries.getChildren( "key" );
  +        boolean hasMultiplexEntry = false;
  +
  +        for ( int i = 0; i < keys.length; i++ )
  +        {
  +            KeyEntry entry = new KeyEntry( keys[i].getAttribute( "name" ),
  +                                 keys[i].getAttributeAsBoolean( "multiplex" , false 
) );
  +            keySet.add( entry );
  +
  +            if ( entry.multiplexEntry )
  +            {
  +                if ( hasMultiplexEntry )
  +                {
  +                    throw new ConfigurationException( "We can only have one 
multiplex key" );
  +                }
  +                else
  +                {
  +                    hasMultiplexEntry = true;
  +                    m_multiplexField = entry;
  +                }
  +            }
  +        }
  +    }
  +
  +    public Transaction process( Transaction trans )
  +    {
  +        Set recordSet = trans.getRecordset( m_tableName );
  +
  +        Iterator it = recordSet.iterator();
  +        while ( it.hasNext() )
  +        {
  +            Record rec = (Record) it.next();
  +            processRecord( trans, rec );
  +            trans.removeRecord( rec );
  +        }
  +
  +        return trans;
  +    }
  +
  +    private void processRecord( Transaction trans, Record rec )
  +    {
  +        Iterator it = m_fieldNames.keySet().iterator();
  +        while ( it.hasNext() )
  +        {
  +            String fieldName = (String) it.next();
  +
  +            if ( KEYSET.equals( fieldName ) ) continue;
  +
  +            Field entryField = new Field( m_multiplexField.name, m_fieldNames.get( 
fieldName ), Field.STRING );
  +            List fields = createFields( rec, entryField );
  +            boolean add = rec.getField( fieldName ).getValue().equals( Boolean.TRUE 
);
  +
  +            Record newRec = new Record( m_destTable, (add) ? Record.ADD : 
Record.DELETE );
  +            trans.addRecord( newRec );
  +        }
  +    }
  +
  +    private List createFields( Record rec, Field multiplexField )
  +    {
  +        List fields = new ArrayList();
  +        Iterator it = ( (Set)m_fieldNames.get( KEYSET ) ).iterator();
  +        while ( it.hasNext() )
  +        {
  +            KeyEntry entry = (KeyEntry)it.next();
  +            Field field = null;
  +
  +            if ( entry.multiplexEntry )
  +            {
  +                field = multiplexField;
  +            }
  +            else
  +            {
  +                field = rec.getField( entry.name );
  +            }
  +
  +            if ( null == field && getLogger().isErrorEnabled() )
  +            {
  +                getLogger().error( "A key field was missing!" + entry.name );
  +            }
  +
  +            fields.add( field );
  +        }
  +
  +        return fields;
  +    }
  +
  +    private static final class KeyEntry
  +    {
  +        public final String name;
  +        public final boolean multiplexEntry;
  +
  +        public KeyEntry( String name, boolean multiplex )
  +        {
  +            this.name = name;
  +            multiplexEntry = multiplex;
  +        }
  +    }
  +}
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to