incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r906108 - in /sling/trunk/installer/osgi/installer/src: main/java/org/apache/sling/osgi/installer/impl/ main/java/org/apache/sling/osgi/installer/impl/tasks/ test/java/org/apache/sling/osgi/installer/impl/
Date Wed, 03 Feb 2010 16:20:53 GMT
Author: bdelacretaz
Date: Wed Feb  3 16:20:52 2010
New Revision: 906108

URL: http://svn.apache.org/viewvc?rev=906108&view=rev
Log:
SLING-1346 - BundleUpdateTask checks for null InputStream, and more data file logging in RegisteredResourceImpl

Modified:
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/LocalFileRegisteredResource.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java?rev=906108&r1=906107&r2=906108&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java
Wed Feb  3 16:20:52 2010
@@ -120,7 +120,7 @@
 	public void addResource(InstallableResource r) {
 	    RegisteredResource rr = null; 
         try {
-            rr = new RegisteredResourceImpl(bundleContext, r);
+            rr = new RegisteredResourceImpl(this, r);
         } catch(IOException ioe) {
             if(getLogService() != null) {
                 getLogService().log(

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java?rev=906108&r1=906107&r2=906108&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java
Wed Feb  3 16:20:52 2010
@@ -181,7 +181,7 @@
         for(InstallableResource r : data) {
             RegisteredResource rr =  null;
             try {
-                rr = new RegisteredResourceImpl(bundleContext, r);
+                rr = new RegisteredResourceImpl(ctx, r);
             } catch(IOException ioe) {
                 if(ctx.getLogService() != null) {
                     ctx.getLogService().log(
@@ -271,7 +271,7 @@
                 			if(ctx.getLogService()!= null) {
                 				ctx.getLogService().log(LogService.LOG_DEBUG, "Cleanup obsolete " + rr);
                 			}
-                			rr.cleanup(ctx.getBundleContext());
+                			rr.cleanup(ctx);
                 		}
                 	}
                     t.remove(r);
@@ -379,7 +379,7 @@
             }
             for(RegisteredResource r : toDelete) {
                 group.remove(r);
-                r.cleanup(ctx.getBundleContext());
+                r.cleanup(ctx);
                 if(ctx.getLogService() != null) {
                     ctx.getLogService().log(LogService.LOG_DEBUG,
                             "Removing RegisteredResource from list, not installable and has
been processed: " + r);

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java?rev=906108&r1=906107&r2=906108&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java
Wed Feb  3 16:20:52 2010
@@ -42,7 +42,7 @@
 	public static final String ENTITY_BUNDLE_PREFIX = "bundle:";
 	public static final String ENTITY_CONFIG_PREFIX = "config:";
 	
-	void cleanup(BundleContext bc);
+	void cleanup(OsgiInstallerContext ctx);
 	String getURL();
 	InputStream getInputStream(BundleContext bc) throws IOException;
 	Dictionary<String, Object> getDictionary();

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java?rev=906108&r1=906107&r2=906108&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java
Wed Feb  3 16:20:52 2010
@@ -44,6 +44,7 @@
 import org.apache.sling.osgi.installer.impl.propertyconverter.PropertyValue;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
+import org.osgi.service.log.LogService;
 
 /** A resource that's been registered in the OSGi controller.
  * 	Data can be either an InputStream or a Dictionary, and we store
@@ -79,8 +80,9 @@
 	 *  maps to a configuration and the data provides an input stream, it is
 	 *  converted to a Dictionary
 	 */
-	public RegisteredResourceImpl(BundleContext ctx, InstallableResource input) throws IOException
{
+	public RegisteredResourceImpl(OsgiInstallerContext osgiCtx, InstallableResource input) throws
IOException {
 
+	    final BundleContext ctx = osgiCtx.getBundleContext();
 	    try {
     		url = input.getUrl();
     		urlScheme = getUrlScheme(url);
@@ -97,7 +99,12 @@
                     throw new IllegalArgumentException("InputStream is required for BUNDLE
resource type: " + input);
                 }
                 dictionary = null;
-                copyToLocalStorage(input.getInputStream(), getDataFile(ctx));
+                final File f = getDataFile(ctx);
+                if(osgiCtx.getLogService() != null) {
+                    osgiCtx.getLogService().log(LogService.LOG_DEBUG, 
+                            "Copying data to local storage " + f.getAbsolutePath());
+                }
+                copyToLocalStorage(input.getInputStream(), f);
                 hasDataFile = true;
                 digest = input.getDigest();
                 setAttributesFromManifest(ctx);
@@ -144,9 +151,13 @@
 		return ctx.getDataFile(filename);
 	}
 
-	public void cleanup(BundleContext bc) {
-	    final File dataFile = getDataFile(bc);
+	public void cleanup(OsgiInstallerContext ctx) {
+	    final File dataFile = getDataFile(ctx.getBundleContext());
 		if(dataFile.exists()) {
+		    if(ctx.getLogService() != null) {
+		        ctx.getLogService().log(LogService.LOG_DEBUG, "Deleting local storage file " 
+		                + dataFile.getAbsolutePath());
+		    } 
 			dataFile.delete();
 		}
 	}

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java?rev=906108&r1=906107&r2=906108&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java
Wed Feb  3 16:20:52 2010
@@ -18,6 +18,8 @@
  */
 package org.apache.sling.osgi.installer.impl.tasks;
 
+import java.io.InputStream;
+
 import org.apache.sling.osgi.installer.OsgiInstaller;
 import org.apache.sling.osgi.installer.impl.OsgiInstallerContext;
 import org.apache.sling.osgi.installer.impl.OsgiInstallerTask;
@@ -92,7 +94,13 @@
             ctx.addTaskToCurrentCycle(new BundleStartTask(b.getBundleId()));
         }
         b.stop();
-        b.update(resource.getInputStream(ctx.getBundleContext()));
+        final InputStream is = resource.getInputStream(ctx.getBundleContext());
+        if(is == null) {
+            throw new IllegalStateException(
+                    "RegisteredResource provides null InputStream, cannot update bundle:
"
+                    + resource);
+        }
+        b.update(is);
         ctx.saveInstalledBundleInfo(b, resource.getDigest(), newVersion.toString());
         ctx.addTaskToCurrentCycle(new SynchronousRefreshPackagesTask());
         if(ctx.getLogService() != null) {

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/LocalFileRegisteredResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/LocalFileRegisteredResource.java?rev=906108&r1=906107&r2=906108&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/LocalFileRegisteredResource.java
(original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/LocalFileRegisteredResource.java
Wed Feb  3 16:20:52 2010
@@ -29,7 +29,7 @@
 	private File storage;
 	
 	LocalFileRegisteredResource(InstallableResource r) throws IOException {
-		super(null, r);
+		super(new MockOsgiInstallerContext(), r);
 	}
 	
 	@Override

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java?rev=906108&r1=906107&r2=906108&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java
(original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java
Wed Feb  3 16:20:52 2010
@@ -76,7 +76,7 @@
         ;
 	}
 	
-	public void cleanup(BundleContext ctx) {
+	public void cleanup(OsgiInstallerContext ctx) {
 	}
 
 	public Map<String, Object> getAttributes() {

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java?rev=906108&r1=906107&r2=906108&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java
(original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java
Wed Feb  3 16:20:52 2010
@@ -50,7 +50,7 @@
         }
         final InstallableResource r = new InstallableResource("test:" + url, data);
         r.setPriority(priority);
-        return new RegisteredResourceImpl(null, r);
+        return new RegisteredResourceImpl(new MockOsgiInstallerContext(), r);
     }
     
     private void assertOrder(RegisteredResource[] inOrder) {

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java?rev=906108&r1=906107&r2=906108&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java
(original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java
Wed Feb  3 16:20:52 2010
@@ -175,7 +175,7 @@
         };
         for(String url : badOnes) {
             try {
-                new RegisteredResourceImpl(null, new InstallableResource(url, s, null));
+                new RegisteredResourceImpl(new MockOsgiInstallerContext(), new InstallableResource(url,
s, null));
                 fail("Expected bad URL '" + url + "' to throw IllegalArgumentException");
             } catch(IllegalArgumentException asExpected) {
             }
@@ -189,7 +189,8 @@
         };
         
         for(String url : goodOnes) {
-            final RegisteredResource r = new RegisteredResourceImpl(null, new InstallableResource(url,
s, "digest1"));
+            final RegisteredResource r = new RegisteredResourceImpl(new MockOsgiInstallerContext(),

+                    new InstallableResource(url, s, "digest1"));
             assertEquals("Expected scheme 'foo' for URL " + url, "foo", r.getUrlScheme());
         }
     }

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java?rev=906108&r1=906107&r2=906108&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
(original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
Wed Feb  3 16:20:52 2010
@@ -49,7 +49,7 @@
 	}
 	
 	private static RegisteredResource getRegisteredResource(String url) throws IOException {
-		return new RegisteredResourceImpl(null, new InstallableResource(url, new Hashtable<String,
Object>()));
+		return new RegisteredResourceImpl(new MockOsgiInstallerContext(), new InstallableResource(url,
new Hashtable<String, Object>()));
 	}
 	
 	private void assertOrder(int testId, Collection<OsgiInstallerTask> actual, OsgiInstallerTask
[] expected) {



Mime
View raw message