← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1834: Minor fixes

 

------------------------------------------------------------
revno: 1834
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Mon 2010-05-10 20:08:02 +0200
message:
  Minor fixes
modified:
  dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/framework/XPathFilter.java
  dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/reader/DefaultXMLEventReader.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/listener/AuthenticationListener.java
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/framework/XPathFilter.java'
--- dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/framework/XPathFilter.java	2010-05-10 17:50:39 +0000
+++ dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/framework/XPathFilter.java	2010-05-10 18:08:02 +0000
@@ -63,7 +63,6 @@
      */
     public static Node findNode( InputStream in, String xpathExpr )
     {
-
         Node result = null;
 
         try

=== modified file 'dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/reader/DefaultXMLEventReader.java'
--- dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/reader/DefaultXMLEventReader.java	2010-05-10 17:50:39 +0000
+++ dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/reader/DefaultXMLEventReader.java	2010-05-10 18:08:02 +0000
@@ -10,8 +10,6 @@
 import javax.xml.stream.events.StartElement;
 import javax.xml.stream.events.XMLEvent;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.codehaus.stax2.XMLEventReader2;
 import org.codehaus.stax2.XMLStreamReader2;
 
@@ -42,205 +40,280 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 /**
- *
+ * 
  * @author bobj
  * @version created 28-Dec-2009
  */
-public class DefaultXMLEventReader implements XMLReader {
-
-  private static final Log log = LogFactory.getLog(DefaultXMLEventReader.class);
-  private XMLEventReader2 reader;
-  private XMLEvent currentEvent;
-
-  // -------------------------------------------------------------------------
-  // Constructor
-  // -------------------------------------------------------------------------
-  public DefaultXMLEventReader(XMLEventReader2 reader) {
-    this.reader = reader;
-  }
-
-  @Override
-  public String getElementName() {
-
-    String localName = null;
-
-    if (currentEvent.isStartElement()) {
-      localName = currentEvent.asStartElement().getName().getLocalPart();
-    }
-
-    if (currentEvent.isEndElement()) {
-      localName = currentEvent.asEndElement().getName().getLocalPart();
-    }
-
-    return localName;
-  }
-
-  @Override
-  public String getElementValue() {
-    try {
-      if (reader.peek().isCharacters()) {
-        currentEvent = reader.nextEvent();
-        return currentEvent.asCharacters().getData();
-      } else {
-        return null;
-      }
-    } catch (XMLStreamException ex) {
-      throw new RuntimeException("Failed to get element value", ex);
-    }
-  }
-
-  @Override
-  public void moveToStartElement(String name) {
-    try {
-      while (reader.hasNext()) {
-        currentEvent = reader.nextEvent();
-        if (currentEvent.isStartElement() && currentEvent.asStartElement().getName().getLocalPart().equals(name)) {
-          break;
-        }
-      }
-    } catch (XMLStreamException ex) {
-      throw new RuntimeException("Failed to move to start element", ex);
-    }
-  }
-
-  @Override
-  public boolean moveToStartElement(String startElementName, String endElementName) {
-    try {
-      while (reader.hasNext()) {
-        currentEvent = reader.nextEvent();
-        if (currentEvent.isStartElement() && currentEvent.asStartElement().getName().getLocalPart().equals(startElementName)) {
-          return true;
-        }
-        if (currentEvent.isEndElement() && currentEvent.asEndElement().getName().getLocalPart().equals(endElementName)) {
-          return false;
-        }
-      }
-      return false;
-    } catch (XMLStreamException ex) {
-      throw new RuntimeException("Failed to move to start element", ex);
-    }
-  }
-
-  @Override
-  public boolean isStartElement(String name) {
-    try {
-      return currentEvent.asStartElement().getName().getLocalPart().equals(name);
-    } catch (ClassCastException ex) {
-      // asStartElement() will throw ClassCastException if not a StartElement
-      return false;
-    }
-  }
-
-  @Override
-  public boolean isEndElement(String name) {
-    try {
-      return currentEvent.asEndElement().getName().getLocalPart().equals(name);
-    } catch (ClassCastException ex) {
-      return false;
-    }
-  }
-
-  @Override
-  public boolean next() {
-    try {
-      currentEvent = reader.nextEvent();
-      return !currentEvent.isEndDocument();
-    } catch (XMLStreamException ex) {
-      throw new RuntimeException("Failed to move to next element", ex);
-    }
-  }
-
-  @Override
-  public boolean next(String endElementName) {
-    try {
-      currentEvent = reader.nextEvent();
-      return !(currentEvent.isEndElement()
-              && currentEvent.asEndElement().getName().getLocalPart().equals(endElementName));
-    } catch (XMLStreamException ex) {
-      throw new RuntimeException("Failed to move to next element", ex);
-    }
-  }
-
-  @Override
-  public String getAttributeValue(String attributeName) {
-    try {
-      QName attributeQName = new QName(null, attributeName);
-      Attribute attribute = currentEvent.asStartElement().getAttributeByName(attributeQName);
-      return attribute != null ? attribute.getValue() : null;
-    } catch (ClassCastException ex) {
-      return null;
-    }
-  }
-
-  @Override
-  public int getAttributeCount() {
-    try {
-      Iterator attributeIter = currentEvent.asStartElement().getAttributes();
-      int count = 0;
-      while (attributeIter.hasNext()) {
-        ++count;
-        attributeIter.next();
-      }
-      return count;
-    } catch (ClassCastException ex) {
-      return 0;
-    }
-  }
-
-  @Override
-  public Map<String, String> readElements(String elementName) {
-    try {
-      final Map<String, String> elements = new HashMap<String, String>();
-      StartElement startEvent = currentEvent.asStartElement();
-      Iterator attributeIter = startEvent.getAttributes();
-      if (attributeIter.hasNext()) {
-        while (attributeIter.hasNext()) {
-          Attribute a = (Attribute) attributeIter.next();
-          elements.put(a.getName().getLocalPart(), a.getValue());
-        }
-        return elements;
-      } else {
-        while (reader.hasNext()) {
-          currentEvent = reader.nextEvent();
-          if (currentEvent.isEndElement() && currentEvent.asEndElement().getName().getLocalPart().equals(elementName)) {
-            break;
-          }
-          if (currentEvent.isStartElement()) {
-            String name = currentEvent.asStartElement().getName().getLocalPart();
-            String value = this.getElementValue();
-            elements.put(name, value);
-          }
-        }
-        return elements;
-      }
-    } catch (XMLStreamException ex) {
-      throw new RuntimeException("Failed to read elements", ex);
-    } catch (ClassCastException ex) {
-      throw new RuntimeException("Failed to read elements", ex);
-    }
-  }
-
-  @Override
-  public XMLStreamReader2 getXmlStreamReader() {
-    throw new UnsupportedOperationException("Can't get the stream reader back from event reader");
-  }
-
-  @Override
-  public XMLEventReader2 getXmlEventReader() {
-    return reader;
-  }
-
-  @Override
-  public void dryRun() {
-    throw new UnsupportedOperationException("Not supported yet.");
-  }
-
-  @Override
-  public void closeReader() {
-    try {
-      reader.close();
-    } catch (XMLStreamException ex) {
-      throw new RuntimeException("Failed to close reader", ex);
-    }
-  }
+public class DefaultXMLEventReader
+    implements XMLReader
+{
+    private XMLEventReader2 reader;
+
+    private XMLEvent currentEvent;
+
+    // -------------------------------------------------------------------------
+    // Constructor
+    // -------------------------------------------------------------------------
+    
+    public DefaultXMLEventReader( XMLEventReader2 reader )
+    {
+        this.reader = reader;
+    }
+
+    @Override
+    public String getElementName()
+    {
+        String localName = null;
+
+        if ( currentEvent.isStartElement() )
+        {
+            localName = currentEvent.asStartElement().getName().getLocalPart();
+        }
+
+        if ( currentEvent.isEndElement() )
+        {
+            localName = currentEvent.asEndElement().getName().getLocalPart();
+        }
+
+        return localName;
+    }
+
+    @Override
+    public String getElementValue()
+    {
+        try
+        {
+            if ( reader.peek().isCharacters() )
+            {
+                currentEvent = reader.nextEvent();
+                return currentEvent.asCharacters().getData();
+            }
+            else
+            {
+                return null;
+            }
+        }
+        catch ( XMLStreamException ex )
+        {
+            throw new RuntimeException( "Failed to get element value", ex );
+        }
+    }
+
+    @Override
+    public void moveToStartElement( String name )
+    {
+        try
+        {
+            while ( reader.hasNext() )
+            {
+                currentEvent = reader.nextEvent();
+                if ( currentEvent.isStartElement()
+                    && currentEvent.asStartElement().getName().getLocalPart().equals( name ) )
+                {
+                    break;
+                }
+            }
+        }
+        catch ( XMLStreamException ex )
+        {
+            throw new RuntimeException( "Failed to move to start element", ex );
+        }
+    }
+
+    @Override
+    public boolean moveToStartElement( String startElementName, String endElementName )
+    {
+        try
+        {
+            while ( reader.hasNext() )
+            {
+                currentEvent = reader.nextEvent();
+                if ( currentEvent.isStartElement()
+                    && currentEvent.asStartElement().getName().getLocalPart().equals( startElementName ) )
+                {
+                    return true;
+                }
+                if ( currentEvent.isEndElement()
+                    && currentEvent.asEndElement().getName().getLocalPart().equals( endElementName ) )
+                {
+                    return false;
+                }
+            }
+            return false;
+        }
+        catch ( XMLStreamException ex )
+        {
+            throw new RuntimeException( "Failed to move to start element", ex );
+        }
+    }
+
+    @Override
+    public boolean isStartElement( String name )
+    {
+        try
+        {
+            return currentEvent.asStartElement().getName().getLocalPart().equals( name );
+        }
+        catch ( ClassCastException ex )
+        {
+            // asStartElement() will throw ClassCastException if not a
+            // StartElement
+            return false;
+        }
+    }
+
+    @Override
+    public boolean isEndElement( String name )
+    {
+        try
+        {
+            return currentEvent.asEndElement().getName().getLocalPart().equals( name );
+        }
+        catch ( ClassCastException ex )
+        {
+            return false;
+        }
+    }
+
+    @Override
+    public boolean next()
+    {
+        try
+        {
+            currentEvent = reader.nextEvent();
+            return !currentEvent.isEndDocument();
+        }
+        catch ( XMLStreamException ex )
+        {
+            throw new RuntimeException( "Failed to move to next element", ex );
+        }
+    }
+
+    @Override
+    public boolean next( String endElementName )
+    {
+        try
+        {
+            currentEvent = reader.nextEvent();
+            return !(currentEvent.isEndElement() && currentEvent.asEndElement().getName().getLocalPart().equals(
+                endElementName ));
+        }
+        catch ( XMLStreamException ex )
+        {
+            throw new RuntimeException( "Failed to move to next element", ex );
+        }
+    }
+
+    @Override
+    public String getAttributeValue( String attributeName )
+    {
+        try
+        {
+            QName attributeQName = new QName( null, attributeName );
+            Attribute attribute = currentEvent.asStartElement().getAttributeByName( attributeQName );
+            return attribute != null ? attribute.getValue() : null;
+        }
+        catch ( ClassCastException ex )
+        {
+            return null;
+        }
+    }
+
+    @Override
+    public int getAttributeCount()
+    {
+        try
+        {
+            Iterator<?> attributeIter = currentEvent.asStartElement().getAttributes();
+            int count = 0;
+            while ( attributeIter.hasNext() )
+            {
+                ++count;
+                attributeIter.next();
+            }
+            return count;
+        }
+        catch ( ClassCastException ex )
+        {
+            return 0;
+        }
+    }
+
+    @Override
+    public Map<String, String> readElements( String elementName )
+    {
+        try
+        {
+            final Map<String, String> elements = new HashMap<String, String>();
+            StartElement startEvent = currentEvent.asStartElement();
+            Iterator<?> attributeIter = startEvent.getAttributes();
+            if ( attributeIter.hasNext() )
+            {
+                while ( attributeIter.hasNext() )
+                {
+                    Attribute a = (Attribute) attributeIter.next();
+                    elements.put( a.getName().getLocalPart(), a.getValue() );
+                }
+                return elements;
+            }
+            else
+            {
+                while ( reader.hasNext() )
+                {
+                    currentEvent = reader.nextEvent();
+                    if ( currentEvent.isEndElement()
+                        && currentEvent.asEndElement().getName().getLocalPart().equals( elementName ) )
+                    {
+                        break;
+                    }
+                    if ( currentEvent.isStartElement() )
+                    {
+                        String name = currentEvent.asStartElement().getName().getLocalPart();
+                        String value = this.getElementValue();
+                        elements.put( name, value );
+                    }
+                }
+                return elements;
+            }
+        }
+        catch ( XMLStreamException ex )
+        {
+            throw new RuntimeException( "Failed to read elements", ex );
+        }
+        catch ( ClassCastException ex )
+        {
+            throw new RuntimeException( "Failed to read elements", ex );
+        }
+    }
+
+    @Override
+    public XMLStreamReader2 getXmlStreamReader()
+    {
+        throw new UnsupportedOperationException( "Can't get the stream reader back from event reader" );
+    }
+
+    @Override
+    public XMLEventReader2 getXmlEventReader()
+    {
+        return reader;
+    }
+
+    @Override
+    public void dryRun()
+    {
+        throw new UnsupportedOperationException( "Not supported yet." );
+    }
+
+    @Override
+    public void closeReader()
+    {
+        try
+        {
+            reader.close();
+        }
+        catch ( XMLStreamException ex )
+        {
+            throw new RuntimeException( "Failed to close reader", ex );
+        }
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/listener/AuthenticationListener.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/listener/AuthenticationListener.java	2010-05-03 13:44:59 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/listener/AuthenticationListener.java	2010-05-10 18:08:02 +0000
@@ -38,7 +38,7 @@
  * @author Lars Helge Overland
  */
 public class AuthenticationListener
-    implements ApplicationListener
+    implements ApplicationListener<ApplicationEvent>
 {
     private UserAuditService userAuditService;
     

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml	2010-05-03 13:44:59 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml	2010-05-10 18:08:02 +0000
@@ -26,8 +26,7 @@
         <sec:filter-chain pattern="/dhis-web-commons/security/**" filters="none"/>
         <sec:filter-chain pattern="/dhis-web-commons/util/**" filters="none"/>
         <sec:filter-chain pattern="/dhis-web-commons/css/**" filters="none"/>
-        <sec:filter-chain pattern="/**"
-            filters="httpSessionContextIntegrationFilter,authenticationProcessingFilter,logoutFilter,automaticAccessFilter,requiredLoginFilter"/>
+        <sec:filter-chain pattern="/**" filters="httpSessionContextIntegrationFilter,authenticationProcessingFilter,logoutFilter,automaticAccessFilter,requiredLoginFilter"/>
         </sec:filter-chain-map>
     </bean>
 		
@@ -286,8 +285,8 @@
 	<bean id="authenticationProcessingFilter"
 		class="org.springframework.security.web.authentication.AuthenticationProcessingFilter">
 		<property name="authenticationManager" ref="authenticationManager" />
-                <property name="authenticationFailureHandler" ref="failureHandler" />
-                <property name="authenticationSuccessHandler" ref="successHandler" />
+        <property name="authenticationFailureHandler" ref="failureHandler" />
+        <property name="authenticationSuccessHandler" ref="successHandler" />
 		<property name="filterProcessesUrl" value="/dhis-web-commons-security/login.action" />
 	</bean>