incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1202561 - in /sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl: DefaultTransformer.java Util.java
Date Wed, 16 Nov 2011 07:20:47 GMT
Author: cziegeler
Date: Wed Nov 16 07:20:47 2011
New Revision: 1202561

URL: http://svn.apache.org/viewvc?rev=1202561&view=rev
Log:
SLING-2288 : Bundle jar is silently ignored by the installer if MANIFEST.MF is not the first
file in the archive

Modified:
    sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/DefaultTransformer.java
    sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/Util.java

Modified: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/DefaultTransformer.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/DefaultTransformer.java?rev=1202561&r1=1202560&r2=1202561&view=diff
==============================================================================
--- sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/DefaultTransformer.java
(original)
+++ sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/DefaultTransformer.java
Wed Nov 16 07:20:47 2011
@@ -78,7 +78,7 @@ public class DefaultTransformer
      * @return
      */
     private TransformationResult[] checkBundle(final RegisteredResource resource) {
-        final Util.BundleHeaders headers = Util.readBundleHeaders(resource);
+        final Util.BundleHeaders headers = Util.readBundleHeaders(resource, logger);
         if ( headers != null ) {
             // check the version for validity
             boolean validVersion = true;

Modified: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/Util.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/Util.java?rev=1202561&r1=1202560&r2=1202561&view=diff
==============================================================================
--- sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/Util.java
(original)
+++ sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/Util.java
Wed Nov 16 07:20:47 2011
@@ -26,6 +26,7 @@ import java.util.jar.Manifest;
 
 import org.apache.sling.installer.api.tasks.RegisteredResource;
 import org.osgi.framework.Constants;
+import org.slf4j.Logger;
 
 public class Util {
 
@@ -55,7 +56,7 @@ public class Util {
     /**
      * Read the manifest from supplied input stream, which is closed before return.
      */
-    private static Manifest getManifest(final RegisteredResource rsrc)
+    private static Manifest getManifest(final RegisteredResource rsrc, final Logger logger)
     throws IOException {
         final InputStream ins = rsrc.getInputStream();
 
@@ -67,6 +68,12 @@ public class Util {
                 jis = new JarInputStream(ins);
                 result= jis.getManifest();
 
+                // SLING-2288 : if this is a jar file, but the manifest is not the first
entry
+                //              log a warning
+                if ( rsrc.getURL().endsWith(".jar") && result == null ) {
+                    logger.warn("Resource {} does not have the manifest as its first entry
in the archive. If this is " +
+                                "a bundle, make sure to put the manifest first in the jar
file.", rsrc.getURL());
+                }
             } finally {
 
                 // close the jar stream or the inputstream, if the jar
@@ -97,9 +104,9 @@ public class Util {
     /**
      * Read the bundle info from the manifest (if available)
      */
-    public static BundleHeaders readBundleHeaders(final RegisteredResource resource) {
+    public static BundleHeaders readBundleHeaders(final RegisteredResource resource, final
Logger logger) {
         try {
-            final Manifest m = Util.getManifest(resource);
+            final Manifest m = Util.getManifest(resource, logger);
             if (m != null) {
                 final String sn = m.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
                 if (sn != null) {



Mime
View raw message