Return-Path: Delivered-To: apmail-incubator-aries-commits-archive@minotaur.apache.org Received: (qmail 79915 invoked from network); 7 Jul 2010 17:54:56 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 7 Jul 2010 17:54:56 -0000 Received: (qmail 91461 invoked by uid 500); 7 Jul 2010 17:54:56 -0000 Delivered-To: apmail-incubator-aries-commits-archive@incubator.apache.org Received: (qmail 91369 invoked by uid 500); 7 Jul 2010 17:54:55 -0000 Mailing-List: contact aries-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: aries-dev@incubator.apache.org Delivered-To: mailing list aries-commits@incubator.apache.org Received: (qmail 91356 invoked by uid 99); 7 Jul 2010 17:54:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jul 2010 17:54:55 +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, 07 Jul 2010 17:54:52 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 1F1DC2388900; Wed, 7 Jul 2010 17:53:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r961444 - in /incubator/aries/trunk/application/application-management/src/main: java/org/apache/aries/application/management/impl/ resources/org/apache/aries/application/messages/ Date: Wed, 07 Jul 2010 17:53:59 -0000 To: aries-commits@incubator.apache.org From: linsun@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100707175359.1F1DC2388900@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: linsun Date: Wed Jul 7 17:53:58 2010 New Revision: 961444 URL: http://svn.apache.org/viewvc?rev=961444&view=rev Log: ARIES-351 - If an EBA contains a deployment.mf, we should not convert any invalid bunldes but we don't want to throw an exception either - patch from Emily Jiang Modified: incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationManagerImpl.java incubator/aries/trunk/application/application-management/src/main/resources/org/apache/aries/application/messages/AppManagementMessages.properties Modified: incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationManagerImpl.java URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationManagerImpl.java?rev=961444&r1=961443&r2=961444&view=diff ============================================================================== --- incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationManagerImpl.java (original) +++ incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationManagerImpl.java Wed Jul 7 17:53:58 2010 @@ -112,69 +112,63 @@ public class AriesApplicationManagerImpl DeploymentMetadata deploymentMetadata = null; Map modifiedBundles = new HashMap(); AriesApplicationImpl application = null; - + String appName = ebaFile.getName(); + //If the application name is null, we will try to get the file name. + if ((appName == null) || (appName.isEmpty())) { + String fullPath = ebaFile.toString(); + if (fullPath.endsWith("/")) + fullPath = fullPath.substring(0, fullPath.length() -1); + int last_slash = fullPath.lastIndexOf("/"); + appName = fullPath.substring(last_slash + 1, fullPath.length()); + } try { - - /* We require that all other .jar and .war files included by-value be valid bundles - * because a DEPLOYMENT.MF has been provided. If no DEPLOYMENT.MF, migrate - * wars to wabs, plain jars to bundles - */ - - Set extraBundlesInfo = new HashSet(); - for (IFile f : ebaFile) { - if (f.isDirectory()) { - continue; - } - - BundleManifest bm = getBundleManifest (f); - if (bm != null) { - if (bm.isValid()) { - extraBundlesInfo.add(new SimpleBundleInfo(_applicationMetadataFactory, bm, f.toURL().toExternalForm())); - } else if (deploymentMetadata != null) { - throw new ManagementException (MessageUtil.getMessage("APPMANAGEMENT0003E", f.getName(), ebaFile.getName())); - } else { - // We have a jar that needs converting to a bundle, or a war to migrate to a WAB - BundleConversion convertedBinary = null; - Iterator converters = _bundleConverters.iterator(); - List conversionExceptions = Collections.emptyList(); - while (converters.hasNext() && convertedBinary == null) { - try { - convertedBinary = converters.next().convert(ebaFile, f); - } catch (ServiceException sx) { - // We'll get this if our optional BundleConverter has not been injected. - } catch (ConversionException cx) { - conversionExceptions.add(cx); - } - } - if (conversionExceptions.size() > 0) { - for (ConversionException cx : conversionExceptions) { - _logger.error("APPMANAGEMENT0004E", new Object[]{f.getName(), ebaFile.getName(), cx}); - } - throw new ManagementException (MessageUtil.getMessage("APPMANAGEMENT0005E", ebaFile.getName())); + IFile deploymentManifest = ebaFile.getFile(AppConstants.DEPLOYMENT_MF); + /* We require that all other .jar and .war files included by-value be valid bundles + * because a DEPLOYMENT.MF has been provided. If no DEPLOYMENT.MF, migrate + * wars to wabs, plain jars to bundles + */ + Set extraBundlesInfo = new HashSet(); + for (IFile f : ebaFile) { + if (f.isDirectory()) { + continue; + } + BundleManifest bm = getBundleManifest (f); + if (bm != null) { + if (bm.isValid()) { + extraBundlesInfo.add(new SimpleBundleInfo(_applicationMetadataFactory, bm, f.toURL().toExternalForm())); + } else if (deploymentManifest == null){ + // We have a jar that needs converting to a bundle, or a war to migrate to a WAB + // We only do this if a DEPLOYMENT.MF does not exist. + BundleConversion convertedBinary = null; + Iterator converters = _bundleConverters.iterator(); + List conversionExceptions = Collections.emptyList(); + while (converters.hasNext() && convertedBinary == null) { + try { + convertedBinary = converters.next().convert(ebaFile, f); + } catch (ServiceException sx) { + // We'll get this if our optional BundleConverter has not been injected. + } catch (ConversionException cx) { + conversionExceptions.add(cx); } - if (convertedBinary != null) { - modifiedBundles.put (f.getName(), convertedBinary); - bm = BundleManifest.fromBundle(f); - extraBundlesInfo.add(new SimpleBundleInfo(_applicationMetadataFactory, bm, f.getName())); + } + if (conversionExceptions.size() > 0) { + for (ConversionException cx : conversionExceptions) { + _logger.error("APPMANAGEMENT0004E", new Object[]{f.getName(), appName, cx}); } + throw new ManagementException (MessageUtil.getMessage("APPMANAGEMENT0005E", appName)); } - } - } - Manifest applicationManifest = parseApplicationManifest (ebaFile); - String appName = ebaFile.getName(); - //If the application name is null, we will try to get the file name. - if ((appName == null) || (appName.isEmpty())) { - String fullPath = ebaFile.toString(); - if (fullPath.endsWith("/")) - fullPath = fullPath.substring(0, fullPath.length() -1); - int last_slash = fullPath.lastIndexOf("/"); - appName = fullPath.substring(last_slash + 1, fullPath.length()); + if (convertedBinary != null) { + modifiedBundles.put (f.getName(), convertedBinary); + bm = BundleManifest.fromBundle(f); + extraBundlesInfo.add(new SimpleBundleInfo(_applicationMetadataFactory, bm, f.getName())); + } + } + } } - - + Manifest applicationManifest = parseApplicationManifest (ebaFile); ManifestDefaultsInjector.updateManifest(applicationManifest, appName, ebaFile); applicationMetadata = _applicationMetadataFactory.createApplicationMetadata(applicationManifest); - IFile deploymentManifest = ebaFile.getFile(AppConstants.DEPLOYMENT_MF); + if (deploymentManifest != null) { deploymentMetadata = _deploymentMetadataFactory.createDeploymentMetadata(deploymentManifest); @@ -182,18 +176,16 @@ public class AriesApplicationManagerImpl String appSymbolicName = applicationMetadata.getApplicationSymbolicName(); String depSymbolicName = deploymentMetadata.getApplicationSymbolicName(); if (!appSymbolicName.equals(depSymbolicName)) { - throw new ManagementException (MessageUtil.getMessage("APPMANAGEMENT0002E", ebaFile.getName(), appSymbolicName, depSymbolicName)); + throw new ManagementException (MessageUtil.getMessage("APPMANAGEMENT0002E", appName, appSymbolicName, depSymbolicName)); } } - - application = new AriesApplicationImpl (applicationMetadata, extraBundlesInfo, _localPlatform); application.setDeploymentMetadata(deploymentMetadata); // Store a reference to any modified bundles application.setModifiedBundles (modifiedBundles); } catch (IOException iox) { - _logger.error ("APPMANAGEMENT0006E", new Object []{ebaFile.getName(), iox}); + _logger.error ("APPMANAGEMENT0006E", new Object []{appName, iox}); throw new ManagementException(iox); } return application; Modified: incubator/aries/trunk/application/application-management/src/main/resources/org/apache/aries/application/messages/AppManagementMessages.properties URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-management/src/main/resources/org/apache/aries/application/messages/AppManagementMessages.properties?rev=961444&r1=961443&r2=961444&view=diff ============================================================================== --- incubator/aries/trunk/application/application-management/src/main/resources/org/apache/aries/application/messages/AppManagementMessages.properties (original) +++ incubator/aries/trunk/application/application-management/src/main/resources/org/apache/aries/application/messages/AppManagementMessages.properties Wed Jul 7 17:53:58 2010 @@ -18,7 +18,6 @@ # APPMANAGEMENT0001E=APPMANAGEMENT0001E: Unable to fully delete directory {0}. APPMANAGEMENT0002E=APPMANAGEMENT0002E: Unable to create Aries application from {0} since APPLICATION.MF symbolic name {1} does not equals DEPLOYMENT.MF symbolic name {2}. -APPMANAGEMENT0003E=APPMANAGEMENT0003E: Invalid bundle {0} found when DEPLOYMENT.MF present in {1}. APPMANAGEMENT0004E=APPMANAGEMENT0004E: Exception caught when converting artifact {0} in {1}: {2}. APPMANAGEMENT0005E=APPMANAGEMENT0005E: Failed to create application from {0} due to conversion errors: see log for details. APPMANAGEMENT0006E=APPMANAGEMENT0006E: IOException encountered while constructing Aries application from {0}: {1}.