You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 10:23:52 UTC

[sling-org-apache-sling-tooling-support-source] 03/07: SLING-6254 find the pom.xml with arbitrary GAVs to also supported forked Jetty bundles

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.tooling.support.source-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-tooling-support-source.git

commit f2f0c0c0733783580de895aebd3ca461269b06a8
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Tue Nov 8 15:17:28 2016 +0000

    SLING-6254 find the pom.xml with arbitrary GAVs to also supported forked Jetty bundles
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/support/source@1768712 13f79535-47bb-0310-9956-ffa450edef68
---
 .../impl/FelixJettySourceReferenceFinder.java      | 44 ++++++++++++----------
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/src/main/java/org/apache/sling/tooling/support/source/impl/FelixJettySourceReferenceFinder.java b/src/main/java/org/apache/sling/tooling/support/source/impl/FelixJettySourceReferenceFinder.java
index b9d1ee5..704cfd8 100644
--- a/src/main/java/org/apache/sling/tooling/support/source/impl/FelixJettySourceReferenceFinder.java
+++ b/src/main/java/org/apache/sling/tooling/support/source/impl/FelixJettySourceReferenceFinder.java
@@ -20,6 +20,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.Collections;
+import java.util.Enumeration;
 import java.util.List;
 
 import javax.xml.parsers.ParserConfigurationException;
@@ -45,33 +46,36 @@ public class FelixJettySourceReferenceFinder implements SourceReferenceFinder {
         if ( !(jettyVersion instanceof String) ) {
             return Collections.emptyList();
         }
-        
-        URL entry = bundle.getEntry("/META-INF/maven/org.apache.felix/org.apache.felix.http.jetty/pom.xml");
-        
-        InputStream pom = null;
-        try {
-            pom = entry.openStream();
-            
+        Enumeration entries = bundle.findEntries("META-INF/maven", "pom.xml", true);
+        if (entries != null && entries.hasMoreElements()) {
+            URL entry = (URL)entries.nextElement();
+            InputStream pom = null;
             try {
-                SAXParserFactory parserFactory = SAXParserFactory.newInstance();
-                SAXParser parser = parserFactory.newSAXParser();
-                PomHandler handler = new PomHandler((String) jettyVersion);
-                parser.parse(new InputSource(pom), handler);
+                pom = entry.openStream();
                 
-                return handler.getReferences();
-            } catch (SAXException e) {
-                throw new SourceReferenceException(e);
-            } catch (ParserConfigurationException e) {
+                try {
+                    SAXParserFactory parserFactory = SAXParserFactory.newInstance();
+                    SAXParser parser = parserFactory.newSAXParser();
+                    PomHandler handler = new PomHandler((String) jettyVersion);
+                    parser.parse(new InputSource(pom), handler);
+                    
+                    return handler.getReferences();
+                } catch (SAXException e) {
+                    throw new SourceReferenceException(e);
+                } catch (ParserConfigurationException e) {
+                    throw new SourceReferenceException(e);
+                } finally {
+                    IOUtils.closeQuietly(pom);
+                }
+            } catch (IOException e) {
                 throw new SourceReferenceException(e);
             } finally {
                 IOUtils.closeQuietly(pom);
             }
-        } catch (IOException e) {
-            throw new SourceReferenceException(e);
-        } finally {
-            IOUtils.closeQuietly(pom);
+            
+        } else {
+            return Collections.emptyList();
         }
-
     }
 
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.