geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmcma...@apache.org
Subject svn commit: r564020 - in /geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors: src/org/apache/geronimo/j2g/descriptors/comp/ test-resources/
Date Wed, 08 Aug 2007 21:00:16 GMT
Author: pmcmahan
Date: Wed Aug  8 14:00:14 2007
New Revision: 564020

URL: http://svn.apache.org/viewvc?view=rev&rev=564020
Log:
GERONIMO-3379 prevent stall when parsing xml

Modified:
    geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/src/org/apache/geronimo/j2g/descriptors/comp/CMPDescriptorTool.java
    geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/src/org/apache/geronimo/j2g/descriptors/comp/EJBJarXmlProcessor.java
    geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/test-resources/openejb-jar.xml

Modified: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/src/org/apache/geronimo/j2g/descriptors/comp/CMPDescriptorTool.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/src/org/apache/geronimo/j2g/descriptors/comp/CMPDescriptorTool.java?view=diff&rev=564020&r1=564019&r2=564020
==============================================================================
--- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/src/org/apache/geronimo/j2g/descriptors/comp/CMPDescriptorTool.java
(original)
+++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/src/org/apache/geronimo/j2g/descriptors/comp/CMPDescriptorTool.java
Wed Aug  8 14:00:14 2007
@@ -152,8 +152,12 @@
 
                     Element ejbRelationName = jbossRelationshipsChildElement
                             .element("ejb-relation-name");
-                    migrateEJBRelation(jbossRelationshipsChildElement, geronimoEJBRelation,
-                            relationships.getEJBRelation(ejbRelationName.getText().trim()));
+                    if(relationships.getEJBRelation(ejbRelationName.getText().trim()) ==
null) {
+                        out.error(CMPDescriptorTool.class.getSimpleName(), "There is not
a mapping to " + ejbRelationName.getText().trim() + ".");
+                    } else {
+                        migrateEJBRelation(jbossRelationshipsChildElement, geronimoEJBRelation,
+                                relationships.getEJBRelation(ejbRelationName.getText().trim()));
+                    }
                 }
             }
         } catch (DocumentException e) {
@@ -163,7 +167,6 @@
 
     private void migrateEJBRelation(Element jbossEJBRelation, Element geronimoEJBRelation,
                                     EJBRelation ejbRelation) {
-
         Element jbossEJBRelationChildElement;
         Element noKeyFieldsRelationshipRole = null;
         Element noCmrFieldRelationshipRole = null;
@@ -193,15 +196,19 @@
                             .element("ejb-relationship-role-name");
                     EJBRelationshipRole ejbRelationshipRole =
                             ejbRelation.getEJBRelationshipRole(ejbRelationshipRoleName.getText().trim());
-                    if (ejbRelationshipRole.getCmrFieldName() != null) {
-                        Element geronimoEJBRelationshipRole = geronimoEJBRelation.addElement(qname);
-
-                        migrateEJBRelationshipRole(jbossEJBRelationChildElement,
-                                geronimoEJBRelationshipRole, ejbRelationshipRole);
-                        isRelationshipRoleMigrated = true;
-                    } else {
-                        // we store this ejb-relationship-role element to process later
-                        noCmrFieldRelationshipRole = jbossEJBRelationChildElement;
+                    try {
+                        if (ejbRelationshipRole.getCmrFieldName() != null) {
+                            Element geronimoEJBRelationshipRole = geronimoEJBRelation.addElement(qname);
+    
+                            migrateEJBRelationshipRole(jbossEJBRelationChildElement,
+                                    geronimoEJBRelationshipRole, ejbRelationshipRole);
+                            isRelationshipRoleMigrated = true;
+                        } else {
+                            // we store this ejb-relationship-role element to process later
+                            noCmrFieldRelationshipRole = jbossEJBRelationChildElement;
+                        }
+                    } catch (Exception e) {
+                        e.printStackTrace();
                     }
                 }
             }
@@ -346,8 +353,7 @@
             if (jbossKeyFieldChild.getName().equals("field-name")) {
                 QName qname = new QName("key-column", geronimoCMRFieldMapping.getNamespace());
                 Element geronimoKeyColumn = geronimoCMRFieldMapping.addElement(qname);
-                // get the table column name
-                geronimoKeyColumn.setText((String) keyFieldMap.get(jbossKeyFieldChild.getText().trim()));
+                geronimoKeyColumn.setText(jbossKeyFieldChild.getText().trim());
             } else if (jbossKeyFieldChild.getName().equals("column-name")) {
                 QName qname = new QName("foreign-key-column", geronimoCMRFieldMapping
                         .getNamespace());

Modified: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/src/org/apache/geronimo/j2g/descriptors/comp/EJBJarXmlProcessor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/src/org/apache/geronimo/j2g/descriptors/comp/EJBJarXmlProcessor.java?view=diff&rev=564020&r1=564019&r2=564020
==============================================================================
--- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/src/org/apache/geronimo/j2g/descriptors/comp/EJBJarXmlProcessor.java
(original)
+++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/src/org/apache/geronimo/j2g/descriptors/comp/EJBJarXmlProcessor.java
Wed Aug  8 14:00:14 2007
@@ -44,10 +44,29 @@
 
     public Relationships getRelationships() throws DocumentException {
         Document document = XMLConversionHelper.getDocument(new File(fileName));
-        List ejbRelations = document.selectNodes("//relationships/ejb-relation");
-
+        List ejbRelations = null;                               // store ejb relationships
+        List e = document.selectNodes("/ejb-jar[@*]");          // get a handle of root element
+        Element relationElement = null;                         // stores the <relationships>
element
+        Element ejbJarNode = null;                              // stores the <ejb-jar>
root element
+        if(e.size() >= 1) {
+            ejbJarNode = (Element)e.get(0);
+        }
+        
+        // find a <relationships> element and save it
+        for(Iterator it = ejbJarNode.elementIterator(); it.hasNext(); ) {
+            Element element = (Element)it.next();
+            if(element.getName().equals("relationships")) {
+                relationElement = element;
+                break;
+            }
+        }
+        
+        // store the <ejb-relation> elements
+        if(relationElement != null) {
+            ejbRelations = relationElement.elements();
+        }
+        
         Relationships relationships = new Relationships();
-
         Element ejbRelationsChileElement;
         for (Iterator iter = ejbRelations.iterator(); iter.hasNext();) {
             ejbRelationsChileElement = (Element) iter.next();

Modified: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/test-resources/openejb-jar.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/test-resources/openejb-jar.xml?view=diff&rev=564020&r1=564019&r2=564020
==============================================================================
--- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/test-resources/openejb-jar.xml
(original)
+++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/test-resources/openejb-jar.xml
Wed Aug  8 14:00:14 2007
@@ -102,7 +102,7 @@
         </cmr-field>
         <role-mapping>
           <cmr-field-mapping>
-            <key-column>id</key-column>
+            <key-column>gangsterId</key-column>
             <foreign-key-column>gangster</foreign-key-column>
           </cmr-field-mapping>
         </role-mapping>



Mime
View raw message