platformCapabilities.add(pCap);
}
try {
if(stagedSoftware !=null) {
DownloadManager downloadMgr = new DownloadManager(provisionRoot, stagedSoftware);
DownloadRecord record = null;
try {
logger.trace("Provisioning StagedSoftware for PlatformCapability : {}", pCap.getClass().getName());
record = downloadMgr.download();
if(record!=null) {
logger.trace(record.toString());
pCap.addDownloadRecord(record);
pCap.setPath(record.unarchived()?
record.getExtractedPath():record.getPath());
}
pCap.addStagedSoftware(stagedSoftware);
DownloadRecord postInstallRecord = downloadMgr.postInstall();
if(postInstallRecord!=null)
pCap.addDownloadRecord(postInstallRecord);
if(stagedSoftware.getUseAsClasspathResource()) {
String[] classpath;
if(pCap.getPath().endsWith(".jar") || pCap.getPath().endsWith(".zip")) {
classpath = StringUtil.toArray(pCap.getPath());
} else {
String cp = pCap.getPath();
File f = new File(cp);
if(!f.isDirectory())
cp = FileUtils.getFilePath(f.getParentFile());
classpath = new String[]{cp};
}
pCap.setClassPath(classpath);
}
if(!stagedSoftware.removeOnDestroy()) {
String configFileLocation = systemCapabilitiesLoader.getPlatformConfigurationDirectory(config);
if(configFileLocation==null) {
logger.warn("Unable to write PlatformConfiguration [{}] configuration, " +
"unknown platform configuration directory. The RIO_HOME environment " +
"variable must be set", pCap.getName());
} else {
PlatformCapabilityWriter pCapWriter = new PlatformCapabilityWriter();
String fileName = pCapWriter.write(pCap, configFileLocation);
pCap.setConfigurationFile(fileName);
logger.info("Wrote PlatformCapability [{}] configuration to {}", pCap.getName(), fileName);
}
}
logger.trace("Have PlatformCapability : {} load any system resources", pCap.getClass().getName());
stateChange();
} catch(IOException e) {
if(record!=null)
downloadMgr.remove();
logger.warn("Provisioning StagedSoftware for PlatformCapability : {}", pCap.getClass().getName(), e);
}
}
} finally {
synchronized(platformCapabilityPending) {