Hi Tried to correct this in ARIES-352...
Enjoy your holidays! Lin On Wed, Jul 7, 2010 at 3:12 PM, Lin Sun <[email protected]> wrote: > Hi > > Nothing escape your eyes :) Yep that indeed is a prob... I didn't > read into details of that code block as it was there before... > > I'll raise a jira for it. > > Lin > > On Wed, Jul 7, 2010 at 2:20 PM, Alasdair Nottingham <[email protected]> wrote: >> Hi, >> >> The first set of additions seems wrong to me. I don't think the >> ebaFile.getName can return null or an empty string so the following if >> clause won't do anything. I think the code should be defaulting the app name >> if it isn't in the application manifest, but it doesn't do that where it is. >> I just have is diff to go by, so I might be wrong, but could you take a look? >> >> Alasdair Nottingham >> >> On 7 Jul 2010, at 18:53, [email protected] wrote: >> >>> 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<String, BundleConversion> modifiedBundles = new HashMap<String, >>> BundleConversion>(); >>> 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<BundleInfo> extraBundlesInfo = new HashSet<BundleInfo>(); >>> - 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<BundleConverter> converters = >>> _bundleConverters.iterator(); >>> - List<ConversionException> 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<BundleInfo> extraBundlesInfo = new HashSet<BundleInfo>(); >>> + 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<BundleConverter> converters = >>> _bundleConverters.iterator(); >>> + List<ConversionException> 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}. >>> >>> >> >
