Refine search
/** * Close a previously returned sub archive * * @param subArchive output stream to close * @link Archive.getSubArchive} */ @Override public void closeEntry(WritableArchive subArchive) throws IOException { subArchive.close(); }
DeploymentContext context) throws IOException { Enumeration<String> e = source.entries(); while (e.hasMoreElements()) { String entryName = e.nextElement(); InputStream is = new BufferedInputStream(source.getEntry(entryName)); OutputStream os = null; try { os = target.putNextEntry(entryName); FileUtils.copy(is, os, source.getEntrySize(entryName)); } finally { if (os!=null) { target.closeEntry(); Manifest m = source.getManifest(); if (m!=null) { OutputStream os = target.putNextEntry(JarFile.MANIFEST_NAME); m.write(os); target.closeEntry();
/** * Copy this archivist to a new abstract archive * * @param source the source archive to copy from * @param target the target archive to copy to * @param entriesToSkip the entries that will be skipped by target archive * @param overwriteManifest if true, the manifest in source archive * overwrites the one in target archive */ public void copyInto(ReadableArchive source, WritableArchive target, Vector entriesToSkip, boolean overwriteManifest) throws IOException { copyJarElements(source, target, entriesToSkip); if (overwriteManifest) { Manifest m = source.getManifest(); if (m != null) { OutputStream os = target.putNextEntry(JarFile.MANIFEST_NAME); m.write(os); target.closeEntry(); } } }
/** * add a file to an output abstract archive * * @param archive abstraction to use when adding the file * @param filePath to the file to add * @param entryName the entry name in the archive */ protected static void addFileToArchive(WritableArchive archive, String filePath, String entryName) throws IOException { FileInputStream is = new FileInputStream(new File(filePath)); OutputStream os = archive.putNextEntry(entryName); try { ArchivistUtils.copyWithoutClose(is, os); } finally { is.close(); archive.closeEntry(); } }
Enumeration<String> e = source.entries(); while (e.hasMoreElements()) { String entryName = e.nextElement(); continue; InputStream sis = source.getEntry(entryName); if (sis != null) { InputStream is = new BufferedInputStream(sis); OutputStream os = null; try { os = target.putNextEntry(entryName); FileUtils.copy(is, os, source.getEntrySize(entryName)); } finally { if (os!=null) { target.closeEntry(); if (m!=null) { processManifest(m, moduleName); OutputStream os = target.putNextEntry(JarFile.MANIFEST_NAME); m.write(os); target.closeEntry(); source.close(); target.close();
for (ModuleDescriptor aModule : a.getModules()) { entriesAdded.add(aModule.getArchiveUri()); ReadableArchive subSource = source.getSubArchive(aModule.getArchiveUri()); WritableArchive subTarget = target.createSubArchive(aModule.getArchiveUri()); Archivist newArchivist = archivistFactory.get().getArchivist(aModule.getModuleType()); ReadableArchive subArchive = archiveFactory.openArchive(subTarget.getURI()); subSource.setParentArchive(subArchive); newArchivist.copyInto(subSource, subTarget, overwriteManifest); target.closeEntry(subTarget); String subModulePath = subSource.getURI().getSchemeSpecificPart(); String parentPath = source.getURI().getSchemeSpecificPart(); if (subModulePath.startsWith(parentPath)) {
for (ModuleDescriptor aModule : a.getModules()) { entriesAdded.add(aModule.getArchiveUri()); ReadableArchive subSource = source.getSubArchive(aModule.getArchiveUri()); WritableArchive subTarget = target.createSubArchive(aModule.getArchiveUri()); Archivist newArchivist = archivistFactory.get().getPrivateArchivistFor(aModule.getModuleType()); newArchivist.copyInto(subSource, subTarget, overwriteManifest); target.closeEntry(subTarget); String subModulePath = subSource.getURI().getSchemeSpecificPart(); String parentPath = source.getURI().getSchemeSpecificPart(); if (subModulePath.startsWith(parentPath)) { subModulePath = subModulePath.substring(parentPath.length()+File.separator.length());
try { File outputFile=null; if (oldArchive != null && oldArchive.exists() && !(oldArchive instanceof WritableArchive)) { outputFile.delete(); out = archiveFactory.createArchive(outputFile); oldArchive.close(); } else { out = archiveFactory.createArchive(new File(outPath)); out.close(); in.close(); out.close();
ReadableArchive subArchiveToExpand = null; try { subArchive = source2.getSubArchive(moduleUri); if (subArchive == null) { _logger.log(Level.WARNING, moduleUri, subHandler); if (subHandler!=null) { subTarget = target.createSubArchive( FileUtils.makeFriendlyFilenameExtension(moduleUri)); final String msg = MessageFormat.format( _logger.getResourceBundle().getString("enterprise.deployment.backend.badSubModPackaging"), subArchive.getURI().toASCIIString(), subArchive.getClass().getName()); throw new RuntimeException(msg); try { if (subArchive != null) { subArchive.close(); subTarget.close();
public void copyAnEntry(ReadableArchive in, WritableArchive out, String entryName) throws IOException { InputStream is = null; InputStream is2 = null; ReadableArchive in2 = archiveFactory.openArchive(out.getURI()); try { is = in.getEntry(entryName); is2 = in2.getEntry(entryName); if (is != null && is2 == null) { OutputStream os = out.putNextEntry(entryName); ArchivistUtils.copyWithoutClose(is, os); } } finally { /* *Close any streams that were opened. */ in2.close(); if (is != null) { is.close(); } if (is2 != null) { is2.close(); } out.closeEntry(); } }
/** * copy all contents of a jar file to a new jar file except * for all the deployment descriptors files * * @param in jar file * @param out jar file * @param ignoreList vector of entry name to not copy from to source jar file */ protected void copyJarElements(ReadableArchive in, WritableArchive out, Vector ignoreList) throws IOException { Enumeration entries = in.entries(); if (entries != null) { for (; entries.hasMoreElements();) { String anEntry = (String) entries.nextElement(); if (ignoreList == null || !ignoreList.contains(anEntry)) { InputStream is = in.getEntry(anEntry); if (is != null) { OutputStream os = out.putNextEntry(anEntry); ArchivistUtils.copyWithoutClose(is, os); is.close(); } out.closeEntry(); } } } }
DOLUtils.getDefaultLogger().fine("Write " + out.getURI() + " with " + this); for (Enumeration alreadyWritten = out.entries(); alreadyWritten.hasMoreElements();) { String elementName = (String) alreadyWritten.nextElement(); filesToSkip.add(elementName); WritableArchive internalJar = out.createSubArchive(aModule.getArchiveUri()); try (InputStream is = in.getEntry(aModule.getArchiveUri())){ if (in instanceof WritableArchive) { subArchivist.setArchiveUri(internalJar.getURI().getSchemeSpecificPart()); } else { tmpFile = getTempFile(path); out.closeEntry(internalJar); } finally { if (tmpFile!=null) {
/** * writes the content of an archive to a JarFile * * @param in input archive * @param out archive output stream to write to * @param entriesToSkip files to not write from the original archive */ protected void writeContents(ReadableArchive in, WritableArchive out, Vector entriesToSkip) throws IOException { // Copy original jarFile elements if (in != null && in.exists()) { if (entriesToSkip == null) { entriesToSkip = getListOfFilesToSkip(); } else { entriesToSkip.addAll(getListOfFilesToSkip()); } copyJarElements(in, out, entriesToSkip); } // now the deployment descriptors writeDeploymentDescriptors(out); // manifest file if (manifest != null) { OutputStream os = out.putNextEntry(JarFile.MANIFEST_NAME); manifest.write(new DataOutputStream(os)); out.closeEntry(); } }
public void saveRuntimeInfo(File output) throws IOException { // if output file is null, we overwrite the current archive... File outputFile = output; if (outputFile == null) { outputFile = getTempFile(path); } // copy all entries from source to target except the // runtime descriptor file WritableArchive out = archiveFactory.createArchive(outputFile); ReadableArchive in = archiveFactory.openArchive(new File(path)); Vector skipFiles = new Vector(); skipFiles.add(getRuntimeDeploymentDescriptorPath()); copyInto(in, out, skipFiles); in.close(); // now save the runtime deployment descriptor... OutputStream os = out.putNextEntry(getRuntimeDeploymentDescriptorPath()); writeRuntimeDeploymentDescriptors(os); out.closeEntry(); out.close(); // if we overwrote the old archive, need to rename the tmp now if (output == null) { ReadableArchive finalArchive = archiveFactory.openArchive(new File(path)); finalArchive.delete(); ReadableArchive tmpArchive = archiveFactory.openArchive(outputFile); tmpArchive.renameTo(path); } }
throw new IOException("Not able to expand " + archive.getName() + " in " + tmpFile); new OSGiArchiveHandler().expand(archive, targetArchive, dc); logger.logp(Level.INFO, "OSGiDeploymentRequest", "expand", "Expanded at {0}", new Object[]{targetArchive.getURI()}); archive = archiveFactory.openArchive(tmpFile); } else { throw new IOException("Not able to expand " + archive.getName() + " in " + tmpFile);
if (!bundle.isFullFlag()) { if (ddFile != null) { OutputStream os = out.putNextEntry(ddPath); ddFile.write(bundle, os); out.closeEntry(); if (webBundle.hasWebServices()) { if (ddFile != null) { OutputStream os = out.putNextEntry(ddPath); ddFile.write(webBundle, os); out.closeEntry(); DeploymentDescriptorFile confDDFile = moduleArchivist.getConfigurationDDFile(); if (confDDFile!=null) { OutputStream os = out.putNextEntry(runtimeDDPath); confDDFile.write(aModule.getDescriptor(), os); out.closeEntry(); WritableArchive moduleArchive = out.createSubArchive(aModule.getArchiveUri()); ReadableArchive moduleArchive2 = in.getSubArchive(aModule.getArchiveUri()); write((BundleDescriptor)aModule.getDescriptor(), moduleArchivist, moduleArchive2, moduleArchive);
/** * writes an application deployment descriptors * @param the application object * @param the abstract archive */ public void write(Application application, ReadableArchive in, WritableArchive out) throws IOException { if (application.isVirtual()) { ModuleDescriptor aModule = (ModuleDescriptor) application.getModules().iterator().next(); Archivist moduleArchivist = archivistFactory.getArchivist(aModule.getModuleType()); write((BundleDescriptor)aModule.getDescriptor(), moduleArchivist, in, out); } else { // this is a real application. // let's start by writing out all submodules deployment descriptors for (ModuleDescriptor aModule : application.getModules()) { Archivist moduleArchivist = archivistFactory.getArchivist(aModule.getModuleType()); WritableArchive moduleArchive = out.createSubArchive(aModule.getArchiveUri()); ReadableArchive moduleArchive2 = in.getSubArchive(aModule.getArchiveUri()); write((BundleDescriptor)aModule.getDescriptor(), moduleArchivist, moduleArchive2, moduleArchive); } // now let's write the application descriptor ApplicationArchivist archivist = archivistProvider.get(); archivist.setDescriptor(application); archivist.writeDeploymentDescriptors(in, out); } }
Collection<String> directoryEntries = source.getDirectories(); List<String> subModuleEntries = new ArrayList<String>(); List<String> entriesToExclude = new ArrayList<String>(); new FileInputStream(moduleJar)); try { os = target.putNextEntry(moduleJar.getName()); FileUtils.copy(is, os, moduleJar.length()); } finally { if (os!=null) { target.closeEntry(); OutputStream os = null; try { os = target.putNextEntry(entryName); FileUtils.copy(is, os, source.getEntrySize(entryName)); } finally { if (os!=null) { target.closeEntry(); if (m!=null) { processManifest(m, appName); OutputStream os = target.putNextEntry(JarFile.MANIFEST_NAME); m.write(os); target.closeEntry(); source.close(); target.close();
try { File outputFile=null; if (oldArchive != null && oldArchive.exists() && !(oldArchive instanceof WritableArchive)) { outputFile.delete(); out = archiveFactory.createArchive(outputFile); oldArchive.close(); } else { out = archiveFactory.createArchive(new File(outPath)); out.close(); in.close(); out.close();