Return-Path: Delivered-To: apmail-sling-commits-archive@www.apache.org Received: (qmail 92598 invoked from network); 3 Feb 2010 16:21:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 Feb 2010 16:21:15 -0000 Received: (qmail 48234 invoked by uid 500); 3 Feb 2010 16:21:15 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 48175 invoked by uid 500); 3 Feb 2010 16:21:15 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 48166 invoked by uid 99); 3 Feb 2010 16:21:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Feb 2010 16:21:15 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Feb 2010 16:21:14 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A923623889EC; Wed, 3 Feb 2010 16:20:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@sling.apache.org From: bdelacretaz@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100203162053.A923623889EC@eris.apache.org> 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 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 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())); + return new RegisteredResourceImpl(new MockOsgiInstallerContext(), new InstallableResource(url, new Hashtable())); } private void assertOrder(int testId, Collection actual, OsgiInstallerTask [] expected) {