geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r656360 - in /geronimo/server/branches/2.1/plugins: j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/ jetty/geronimo-jetty6-builder/src/test/java/org/apache/geronimo/jetty6/deployment/ jetty/geronimo-jetty6-bui...
Date Wed, 14 May 2008 18:58:45 GMT
Author: gawor
Date: Wed May 14 11:58:45 2008
New Revision: 656360

URL: http://svn.apache.org/viewvc?rev=656360&view=rev
Log:
make sure security and persistence elements get reordered correctly (GERONIMO-3944)

Added:
    geronimo/server/branches/2.1/plugins/jetty/geronimo-jetty6-builder/src/test/resources/plans/plan-convert.xml
  (with props)
    geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-builder/src/test/resources/plans/plan-convert.xml
  (with props)
Modified:
    geronimo/server/branches/2.1/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverter.java
    geronimo/server/branches/2.1/plugins/jetty/geronimo-jetty6-builder/src/test/java/org/apache/geronimo/jetty6/deployment/PlanParsingTest.java
    geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java

Modified: geronimo/server/branches/2.1/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverter.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverter.java?rev=656360&r1=656359&r2=656360&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverter.java
(original)
+++ geronimo/server/branches/2.1/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverter.java
Wed May 14 11:58:45 2008
@@ -16,6 +16,11 @@
  */
 package org.apache.geronimo.web.deployment;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import javax.xml.namespace.QName;
 
 import org.apache.geronimo.common.DeploymentException;
@@ -83,6 +88,7 @@
                         cursor.removeXml();
                     }
                     cursor.pop();
+                    
                     cursor.push();
                     while (cursor.hasNextToken()) {
                         if (cursor.isStart()) {
@@ -93,31 +99,19 @@
                         }
                         cursor.toNextToken();
                     }
-                    //move security elements after refs
-
                     cursor.pop();
-                    cursor.push();
-                    if (cursor.toChild(this.namespace, "security-realm-name")) {
-                        XmlCursor other = cursor.newCursor();
-                        try {
-                            other.toParent();
-                            if (other.toChild(SYSTEM_NAMESPACE, "gbean")) {
-                                other.toPrevToken();
-                            } else {
-                                other.toEndToken();
-                                other.toPrevToken();
-                            }
-                            cursor.moveXml(other);
-                            cursor.pop();
-                            cursor.push();
-                            if (cursor.toChild(SECURITY_QNAME)) {
-                                cursor.moveXml(other);
-                            }
-                        } finally {
-                            other.dispose();
-                        }
-                    }
+                    
+                    cursor.push();                    
+                    Map<Object, List<XmlCursor>> map = createElementMap(cursor);
                     cursor.pop();
+                                                            
+                    moveToBottom(cursor, map.get("security-realm-name"));
+                    moveToBottom(cursor, map.get("security"));
+                    moveToBottom(cursor, map.get("gbean"));
+                    moveToBottom(cursor, map.get("persistence"));
+                                
+                    clearElementMap(map);
+                    
                     return webPlan;
                 } finally {
                     cursor.dispose();
@@ -130,5 +124,40 @@
             rawCursor.dispose();
         }
     }
-
+               
+    private static Map<Object, List<XmlCursor>> createElementMap(XmlCursor cursor)
{        
+        Map<Object, List<XmlCursor>> map = new HashMap<Object, List<XmlCursor>>();
  
+        cursor.toStartDoc();
+        cursor.toFirstChild();
+        do {
+            QName name = cursor.getName();            
+            List<XmlCursor> locations = map.get(name);
+            if (locations == null) {
+                locations = new ArrayList<XmlCursor>();
+                map.put(name, locations);
+                map.put(name.getLocalPart(), locations);
+            }
+            locations.add(cursor.newCursor());
+        } while(cursor.toNextSibling());
+        return map;
+    }
+    
+    private static void clearElementMap(Map<Object, List<XmlCursor>> map) {
+        for (Map.Entry<Object, List<XmlCursor>> entry : map.entrySet()) {
+            for (XmlCursor cursor : entry.getValue()) {
+                cursor.dispose();
+            }
+        }
+        map.clear();
+    }
+    
+    private static void moveToBottom(XmlCursor cursor, List<XmlCursor> locations) {
+        if (locations != null) {
+            for (XmlCursor location : locations) {
+                cursor.toEndDoc();
+                location.moveXml(cursor);
+            }
+        }
+    }
+    
 }
\ No newline at end of file

Modified: geronimo/server/branches/2.1/plugins/jetty/geronimo-jetty6-builder/src/test/java/org/apache/geronimo/jetty6/deployment/PlanParsingTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/jetty/geronimo-jetty6-builder/src/test/java/org/apache/geronimo/jetty6/deployment/PlanParsingTest.java?rev=656360&r1=656359&r2=656360&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/jetty/geronimo-jetty6-builder/src/test/java/org/apache/geronimo/jetty6/deployment/PlanParsingTest.java
(original)
+++ geronimo/server/branches/2.1/plugins/jetty/geronimo-jetty6-builder/src/test/java/org/apache/geronimo/jetty6/deployment/PlanParsingTest.java
Wed May 14 11:58:45 2008
@@ -139,6 +139,19 @@
 //        assertEquals(4, jettyWebApp.getSecurity().getRoleMappings().getRoleArray().length);
     }
 
+    public void testConvertPlan() throws Exception {
+        URL srcXml = classLoader.getResource("plans/plan-convert.xml");
+        XmlObject rawPlan = XmlBeansUtil.parse(srcXml, getClass().getClassLoader());
+
+        XmlObject webPlan = new GenericToSpecificPlanConverter(
+                "http://geronimo.apache.org/xml/ns/web/jetty/config-1.0.1",
+                "http://geronimo.apache.org/xml/ns/j2ee/web/jetty-2.0.2", 
+                "jetty").convertToSpecificPlan(rawPlan);
+        
+        XmlObject p = webPlan.changeType(JettyWebAppType.type);
+        XmlBeansUtil.validateDD(p);
+    }
+    
     public void testOldFormatExploded() throws Exception {
         URL war = classLoader.getResource("deployables/war5");
         assertTrue(war != null);

Added: geronimo/server/branches/2.1/plugins/jetty/geronimo-jetty6-builder/src/test/resources/plans/plan-convert.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/jetty/geronimo-jetty6-builder/src/test/resources/plans/plan-convert.xml?rev=656360&view=auto
==============================================================================
--- geronimo/server/branches/2.1/plugins/jetty/geronimo-jetty6-builder/src/test/resources/plans/plan-convert.xml
(added)
+++ geronimo/server/branches/2.1/plugins/jetty/geronimo-jetty6-builder/src/test/resources/plans/plan-convert.xml
Wed May 14 11:58:45 2008
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns='http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1'>
+       <dep:environment xmlns:dep='http://geronimo.apache.org/xml/ns/deployment-1.2'>
+               <dep:moduleId>
+                       <dep:groupId>ssi.web</dep:groupId>
+                       <dep:artifactId>equipment-aaf</dep:artifactId>
+                       <dep:version>1.0</dep:version>
+                       <dep:type>war</dep:type>
+               </dep:moduleId>
+               <dep:dependencies>
+                       <dep:dependency>
+                               <dep:groupId>com.ibm</dep:groupId>
+                               <dep:artifactId>jtopen</dep:artifactId>
+                               <dep:version>6.1</dep:version>
+                               <dep:type>jar</dep:type>
+                       </dep:dependency>
+                       <dep:dependency>
+                               <dep:groupId>org.apache.openjpa</dep:groupId>
+                               <dep:artifactId>openjpa</dep:artifactId>
+                               <dep:version>1.0.2</dep:version>
+                               <dep:type>jar</dep:type>
+                       </dep:dependency>
+
+           <!--
+           <dep:dependency>
+               <dep:groupId>ssi</dep:groupId>
+               <dep:artifactId>ssi-api</dep:artifactId>
+               <dep:version>1.0</dep:version>
+               <dep:type>jar</dep:type>
+           </dep:dependency>
+           -->
+                       <dep:dependency>
+                               <dep:groupId>console.dbpool</dep:groupId>
+                               <dep:artifactId>jdbc%2FAAF</dep:artifactId>
+               <dep:version>1.0</dep:version>
+               <dep:type>rar</dep:type>
+           </dep:dependency>
+       </dep:dependencies>
+
+       </dep:environment>
+
+       <context-root>/aaf/equipment</context-root>
+
+       <security-realm-name>realm-SSLIB</security-realm-name>
+
+       <security xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0">
+               <default-principal realm-name="realm-SSLIB">
+                       <principal name="anonymous"
+class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal"/>
+               </default-principal>
+               <role-mappings>
+                       <role role-name="equipment-user">
+                               <realm realm-name="realm-SSLIB">
+                                       <principal name="ADMIN"
+class="org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal"/>
+                               </realm>
+                               <realm realm-name="realm-SSLIB">
+                                       <principal name="AAF"
+class="org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal"/>
+                               </realm>
+                       </role>
+               </role-mappings>
+       </security>
+
+       <nam:resource-ref xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.2">
+               <nam:ref-name>jdbc/ds</nam:ref-name>
+               <nam:resource-link>jdbc/AAF</nam:resource-link>
+       </nam:resource-ref>
+
+       <jpa:persistence version="1.0" xmlns:jpa='http://java.sun.com/xml/ns/persistence'>
+               <jpa:persistence-unit name="equipment-pu" transaction-type="JTA">
+                       <jpa:provider>org.apache.openjpa.persistence.PersistenceProviderImpl</jpa:provider>
+                       <jpa:jta-data-source>jdbc%2FAAF</jpa:jta-data-source>
+                       <jpa:non-jta-data-source>jdbc%2FAAF</jpa:non-jta-data-source>
+                       <jpa:class>ssi.api.jpa.company.Description</jpa:class>
+                       <jpa:class>ssi.api.jpa.company.Equipment</jpa:class>
+                       <jpa:class>ssi.api.jpa.company.EquipmentMaintanence</jpa:class>
+                       <jpa:class>ssi.api.jpa.company.EquipmentMaintanenceType</jpa:class>
+                       <jpa:class>ssi.api.jpa.company.EquipmentType</jpa:class>
+                       <jpa:exclude-unlisted-classes>true</jpa:exclude-unlisted-classes>
+                       <jpa:properties>
+                               <jpa:property name="openjpa.Log" value="DefaultLevel=TRACE,
Tool=INFO,
+SQL=TRACE"/>
+                               <jpa:property name="openjpa.jdbc.DBDictionary"
+value="ssi.api.jpa.AS400Dictionary"/>
+                               <!--
+                               <jpa:property name="openjpa.jdbc.SynchronizeMappings" value="validate"/>
+
+                               <jpa:property name="openjpa.jdbc.TransactionIsolation"
value="none"/>
+                               <jpa:property name="openjpa.LockManager" value="none"/>
+                               <jpa:property name="openjpa.ConnectionRetainMode" value="always"/>
+                               <jpa:property name="openjpa.FlushBeforeQueries" value="true"/>
+                                -->
+                       </jpa:properties>
+               </jpa:persistence-unit>
+       </jpa:persistence>
+
+</web-app>

Propchange: geronimo/server/branches/2.1/plugins/jetty/geronimo-jetty6-builder/src/test/resources/plans/plan-convert.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java?rev=656360&r1=656359&r2=656360&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java
(original)
+++ geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java
Wed May 14 11:58:45 2008
@@ -34,11 +34,13 @@
 import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.web.deployment.GenericToSpecificPlanConverter;
 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
 import org.apache.geronimo.xbeans.geronimo.web.GerWebAppDocument;
 import org.apache.geronimo.xbeans.geronimo.web.GerWebAppType;
 import org.apache.geronimo.xbeans.geronimo.web.tomcat.TomcatWebAppType;
 import org.apache.geronimo.security.deployment.GeronimoSecurityBuilderImpl;
+import org.apache.xmlbeans.XmlObject;
 
 /**
  */
@@ -71,6 +73,19 @@
         builder.doStop();
     }
 
+    public void testConvertPlan() throws Exception {
+        URL srcXml = classLoader.getResource("plans/plan-convert.xml");
+        XmlObject rawPlan = XmlBeansUtil.parse(srcXml, getClass().getClassLoader());
+
+        XmlObject webPlan = new GenericToSpecificPlanConverter(
+                "http://geronimo.apache.org/xml/ns/web/tomcat/config-1.0",
+                "http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-2.0.1", 
+                "tomcat").convertToSpecificPlan(rawPlan);
+        
+        XmlObject p = webPlan.changeType(TomcatWebAppType.type);
+        XmlBeansUtil.validateDD(p);
+    }
+    
     public void testResourceRef() throws Exception {
         URL resourceURL = classLoader.getResource("plans/plan1.xml");
         File resourcePlan = new File(resourceURL.getFile());

Added: geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-builder/src/test/resources/plans/plan-convert.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-builder/src/test/resources/plans/plan-convert.xml?rev=656360&view=auto
==============================================================================
--- geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-builder/src/test/resources/plans/plan-convert.xml
(added)
+++ geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-builder/src/test/resources/plans/plan-convert.xml
Wed May 14 11:58:45 2008
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns='http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1'>
+       <dep:environment xmlns:dep='http://geronimo.apache.org/xml/ns/deployment-1.2'>
+               <dep:moduleId>
+                       <dep:groupId>ssi.web</dep:groupId>
+                       <dep:artifactId>equipment-aaf</dep:artifactId>
+                       <dep:version>1.0</dep:version>
+                       <dep:type>war</dep:type>
+               </dep:moduleId>
+               <dep:dependencies>
+                       <dep:dependency>
+                               <dep:groupId>com.ibm</dep:groupId>
+                               <dep:artifactId>jtopen</dep:artifactId>
+                               <dep:version>6.1</dep:version>
+                               <dep:type>jar</dep:type>
+                       </dep:dependency>
+                       <dep:dependency>
+                               <dep:groupId>org.apache.openjpa</dep:groupId>
+                               <dep:artifactId>openjpa</dep:artifactId>
+                               <dep:version>1.0.2</dep:version>
+                               <dep:type>jar</dep:type>
+                       </dep:dependency>
+
+           <!--
+           <dep:dependency>
+               <dep:groupId>ssi</dep:groupId>
+               <dep:artifactId>ssi-api</dep:artifactId>
+               <dep:version>1.0</dep:version>
+               <dep:type>jar</dep:type>
+           </dep:dependency>
+           -->
+                       <dep:dependency>
+                               <dep:groupId>console.dbpool</dep:groupId>
+                               <dep:artifactId>jdbc%2FAAF</dep:artifactId>
+               <dep:version>1.0</dep:version>
+               <dep:type>rar</dep:type>
+           </dep:dependency>
+       </dep:dependencies>
+
+       </dep:environment>
+
+       <context-root>/aaf/equipment</context-root>
+
+       <security-realm-name>realm-SSLIB</security-realm-name>
+
+       <security xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0">
+               <default-principal realm-name="realm-SSLIB">
+                       <principal name="anonymous"
+class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal"/>
+               </default-principal>
+               <role-mappings>
+                       <role role-name="equipment-user">
+                               <realm realm-name="realm-SSLIB">
+                                       <principal name="ADMIN"
+class="org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal"/>
+                               </realm>
+                               <realm realm-name="realm-SSLIB">
+                                       <principal name="AAF"
+class="org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal"/>
+                               </realm>
+                       </role>
+               </role-mappings>
+       </security>
+
+       <nam:resource-ref xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.2">
+               <nam:ref-name>jdbc/ds</nam:ref-name>
+               <nam:resource-link>jdbc/AAF</nam:resource-link>
+       </nam:resource-ref>
+
+       <jpa:persistence version="1.0" xmlns:jpa='http://java.sun.com/xml/ns/persistence'>
+               <jpa:persistence-unit name="equipment-pu" transaction-type="JTA">
+                       <jpa:provider>org.apache.openjpa.persistence.PersistenceProviderImpl</jpa:provider>
+                       <jpa:jta-data-source>jdbc%2FAAF</jpa:jta-data-source>
+                       <jpa:non-jta-data-source>jdbc%2FAAF</jpa:non-jta-data-source>
+                       <jpa:class>ssi.api.jpa.company.Description</jpa:class>
+                       <jpa:class>ssi.api.jpa.company.Equipment</jpa:class>
+                       <jpa:class>ssi.api.jpa.company.EquipmentMaintanence</jpa:class>
+                       <jpa:class>ssi.api.jpa.company.EquipmentMaintanenceType</jpa:class>
+                       <jpa:class>ssi.api.jpa.company.EquipmentType</jpa:class>
+                       <jpa:exclude-unlisted-classes>true</jpa:exclude-unlisted-classes>
+                       <jpa:properties>
+                               <jpa:property name="openjpa.Log" value="DefaultLevel=TRACE,
Tool=INFO,
+SQL=TRACE"/>
+                               <jpa:property name="openjpa.jdbc.DBDictionary"
+value="ssi.api.jpa.AS400Dictionary"/>
+                               <!--
+                               <jpa:property name="openjpa.jdbc.SynchronizeMappings" value="validate"/>
+
+                               <jpa:property name="openjpa.jdbc.TransactionIsolation"
value="none"/>
+                               <jpa:property name="openjpa.LockManager" value="none"/>
+                               <jpa:property name="openjpa.ConnectionRetainMode" value="always"/>
+                               <jpa:property name="openjpa.FlushBeforeQueries" value="true"/>
+                                -->
+                       </jpa:properties>
+               </jpa:persistence-unit>
+       </jpa:persistence>
+
+</web-app>

Propchange: geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-builder/src/test/resources/plans/plan-convert.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message