// Validate: symbolic names must match
String appSymbolicName = applicationMetadata.getApplicationSymbolicName();
String depSymbolicName = applicationMetadata.getApplicationSymbolicName();
if (!appSymbolicName.equals(depSymbolicName)) {
throw new ManagementException (MessageUtil.getMessage("APPMANAGEMENT0002E", ebaFile.getName(), appSymbolicName, depSymbolicName));
}
}
/* 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
InputStream 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()));
}
if (convertedBinary != null) {
modifiedBundles.put (f.getName(), convertedBinary);
bm = BundleManifest.fromBundle(f);
extraBundlesInfo.add(new SimpleBundleInfo(_applicationMetadataFactory, bm, f.getName()));
}
}
}
}
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});
throw new ManagementException(iox);
}
return application;
}