use of org.apache.aries.util.filesystem.IDirectory in project aries by apache.
the class OBRResolverAdvancedTest method generateOBRRepoXML.
private void generateOBRRepoXML(boolean nullURI, String... bundleFiles) throws Exception {
Set<ModelledResource> mrs = new HashSet<ModelledResource>();
FileOutputStream fout = new FileOutputStream("repository.xml");
RepositoryGenerator repositoryGenerator = context().getService(RepositoryGenerator.class);
ModelledResourceManager modelledResourceManager = context().getService(ModelledResourceManager.class);
for (String fileName : bundleFiles) {
File bundleFile = new File(fileName);
IDirectory jarDir = FileSystem.getFSRoot(bundleFile);
String uri = "";
if (!!!nullURI) {
uri = bundleFile.toURI().toString();
}
if ("delete.jar".equals(fileName)) {
jarDir = null;
}
mrs.add(modelledResourceManager.getModelledResource(uri, jarDir));
}
repositoryGenerator.generateRepository("Test repo description", mrs, fout);
fout.close();
}
use of org.apache.aries.util.filesystem.IDirectory in project aries by apache.
the class AriesApplicationManagerImpl method createApplication.
/**
* Create an application from a URL.
* The first version of this method isn't smart enough to check whether
* the input URL is file://
*/
public AriesApplication createApplication(URL url) throws ManagementException {
OutputStream os = null;
AriesApplication app = null;
try {
File tempFile = _localPlatform.getTemporaryFile();
InputStream is = url.openStream();
os = new FileOutputStream(tempFile);
IOUtils.copy(is, os);
IDirectory downloadedSource = FileSystem.getFSRoot(tempFile);
app = createApplication(downloadedSource);
} catch (IOException iox) {
throw new ManagementException(iox);
} finally {
IOUtils.close(os);
}
return app;
}
use of org.apache.aries.util.filesystem.IDirectory in project aries by apache.
the class BasicSubsystem method install.
@Override
public AriesSubsystem install(String location, final InputStream content, InputStream deploymentManifest) {
AriesSubsystem result = null;
IDirectory directory = null;
try {
directory = content == null ? null : AccessController.doPrivileged(new PrivilegedAction<IDirectory>() {
@Override
public IDirectory run() {
return FileSystem.getFSRoot(content);
}
});
result = install(location, directory, deploymentManifest);
return result;
} finally {
// This method must guarantee the content input stream was closed.
// TODO Not sure closing the content is necessary. The content will
// either be null of will have been closed while copying the data
// to the temporary file.
IOUtils.close(content);
// at start time if it contains any dependencies.
if (directory instanceof ICloseableDirectory) {
if (result == null || Utils.isProvisionDependenciesInstall((BasicSubsystem) result) || !wasInstalledWithChildrenHavingProvisionDependenciesResolve()) {
final IDirectory toClose = directory;
AccessController.doPrivileged(new PrivilegedAction<Void>() {
@Override
public Void run() {
try {
((ICloseableDirectory) toClose).close();
} catch (IOException ioex) {
logger.info("Exception calling close for content {}. Exception {}", content, ioex);
}
return null;
}
});
}
}
}
}
use of org.apache.aries.util.filesystem.IDirectory in project aries by apache.
the class InstallTest method createCompositeDirEsa.
private void createCompositeDirEsa() throws IOException, FileNotFoundException {
ZipFixture feature = ArchiveFixture.newZip().binary("OSGI-INF/SUBSYSTEM.MF", getResourceAsStream("compositeDir" + "/OSGI-INF/SUBSYSTEM.MF")).binary("a.jar/META-INF/MANIFEST.MF", getResourceAsStream("compositeDir" + "/a.jar/META-INF/MANIFEST.MF")).binary("a.jar/a/A.class", getResourceAsStream("a/A.class")).binary("applicationDir.esa/OSGI-INF/SUBSYSTEM.MF", getResourceAsStream("compositeDir" + "/applicationDir/OSGI-INF/SUBSYSTEM.MF")).binary("applicationDir.esa/b.jar/META-INF/MANIFEST.MF", getResourceAsStream("compositeDir" + "/applicationDir/b.jar/META-INF/MANIFEST.MF")).binary("applicationDir.esa/b.jar/b/B.class", getResourceAsStream("b/B.class")).binary("applicationDir.esa/featureDir.esa/OSGI-INF/SUBSYSTEM.MF", getResourceAsStream("compositeDir" + "/applicationDir/featureDir/OSGI-INF/SUBSYSTEM.MF")).binary("applicationDir.esa/featureDir.esa/a.jar/META-INF/MANIFEST.MF", getResourceAsStream("compositeDir" + "/applicationDir/featureDir/a.jar/META-INF/MANIFEST.MF")).binary("applicationDir.esa/featureDir.esa/a.jar/a/A.class", getResourceAsStream("a/A.class")).binary("applicationDir.esa/featureDir.esa/b.jar/META-INF/MANIFEST.MF", getResourceAsStream("compositeDir" + "/applicationDir/featureDir/b.jar/META-INF/MANIFEST.MF")).binary("applicationDir.esa/featureDir.esa/b.jar/b/B.class", getResourceAsStream("b/B.class"));
feature.end();
FileOutputStream fos = new FileOutputStream("compositeDir" + ".esa");
try {
feature.writeOut(fos);
} finally {
Utils.closeQuietly(fos);
}
File userDir = new File(System.getProperty("user.dir"));
IDirectory idir = FileSystem.getFSRoot(userDir);
File compositeDir = new File(userDir, "compositeDir");
compositeDir.mkdir();
IOUtils.unpackZip(idir.getFile("compositeDir.esa"), compositeDir);
}
Aggregations