protected final ArchiveOptions getArchiveOptions() { ArchiveOptions opts = new ArchiveOptions(); opts.setIsReadOnly(true); return opts; }
protected ArchiveOptions defaultOptions(LoadStrategy aLoadStrategy) { ArchiveOptions options = new ArchiveOptions(); options.setLoadStrategy(aLoadStrategy); return options; }
public ArchiveOptions cloneWith(LoadStrategy aLoadStrategy, String uri) { ArchiveOptions result = cloneWith(aLoadStrategy); result.setIsReadOnly(isReadOnly(uri)); return result; }
public void initializeNewArchive(Archive anArchive, String uri, ArchiveOptions options) { if (options.getLoadStrategy() == null) { try { options.setLoadStrategy(createEmptyLoadStrategy()); } catch (Exception ex) { Logger.getLogger().logError(ex); } } anArchive.setURI(uri); anArchive.setSize(0); anArchive.setLastModified(System.currentTimeMillis()); anArchive.setDirectoryEntry(false); anArchive.setLoadStrategy(options.getLoadStrategy()); anArchive.setOptions(options); }
public org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveOptions getOptions() { if (options == null) { options = new ArchiveOptions(); } return options; }
/** * Make a copy of the reciever, setting the loadStrategy to null */ public ArchiveOptions cloneWith(LoadStrategy aLoadStrategy) { try { ArchiveOptions result = (ArchiveOptions) super.clone(); result.setLoadStrategy(aLoadStrategy); result.readOnlyFlags = null; return result; } catch (CloneNotSupportedException ignore) { return null; } }
public void setLoadStrategy(org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.LoadStrategy newLoadStrategy) { loadStrategy = newLoadStrategy; loadStrategy.setReadOnly(isReadOnly()); loadStrategy.setRendererType(getRendererType()); }
/** * @see com.ibm.etools.archive.SaveStrategy */ public void save(org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest aManifest) throws SaveFailureException { try { OutputStream out = getUriConverter().createOutputStream(URI.createURI(J2EEConstants.MANIFEST_URI)); aManifest.write(out); out.close(); if (getArchive().getOptions().isReadOnly()) setTimestampAfterSaving(J2EEConstants.MANIFEST_URI); } catch (IOException iox) { throw new SaveFailureException(J2EEConstants.MANIFEST_URI, iox); } }
public void validateManifestCase(Archive anArchive) { String mfuri = J2EEConstants.MANIFEST_URI; //Indicates a manifest file with the valid name exists, //nothing left to do if (anArchive.containsFile(mfuri)) return; //Otherwise iterate the list of files //Ensure the archive is read-only first anArchive.getOptions().setIsReadOnly(true); List files = anArchive.getFiles(); String uri = null; for (int i = 0; i < files.size(); i++) { File aFile = (File) files.get(i); uri = aFile.getURI(); if (mfuri.equalsIgnoreCase(uri) && !mfuri.equals(uri)) { String[] params = {uri, anArchive.getURI()}; IResource target = earHelper.getProject().getFile(J2EEConstants.MANIFEST_URI); String msg = NLS.bind(EARValidationMessageResourceHandler.INVALID_CASE_FOR_MANIFEST_ERROR_, params); addLocalizedError(msg, target); } } }
/** * @see CommonarchiveFactory */ public Archive openNestedArchive(String uri, Archive parent) throws OpenFailureException { try { LoadStrategy childStrategy = createChildLoadStrategy(uri, parent.getLoadStrategy()); ArchiveOptions options = parent.getOptions().cloneWith(childStrategy, uri); if (options.shouldDiscriminateNestedArchives()) return openArchive(options, uri); return primOpenArchive(options, uri); } catch (IOException ex) { throw new OpenFailureException(CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.open_nested_EXC_, (new Object[]{uri, parent.getURI()})), ex); // = "Could not open the nested archive "{0}" in "{1}"" } }
return !anArchive.getOptions().isReadOnly(); else if (anArchive.getOptions().isSaveLibrariesAsFiles() && anArchive.getLoadingContainer() != null) { if (anArchive.isIndexed()) { List files = anArchive.getFiles();
/** * Make a copy of the reciever, setting the loadStrategy to null */ public Object clone() { return cloneWith(null); }
public WarFileDynamicClassLoader(Archive anArchive, ClassLoader parentCl, ClassLoader extraCl, ProtectionDomain pDomain) { super(anArchive, parentCl, extraCl, pDomain); allowLoadingFromWAR = anArchive.getOptions().getClassLoadingMode() == ArchiveOptions.LOAD_MODE_COMPAT; }
protected boolean shouldSave(Resource res) { if (!res.isModified() && getArchive().getOptions().saveOnlyDirtyMofResources()) return false; return shouldSave(res.getURI().toString()); }
/** * @see com.ibm.etools.commonarchive.File */ public java.io.InputStream getInputStream() throws java.io.FileNotFoundException, java.io.IOException { if (getLoadingContainer() != null || getLoadStrategy() == null || getLoadStrategy().isDirectory()) return super.getInputStream(); //This archive was copied in; this operation is not supported for // module files if (isModuleFile() || !getOptions().isSaveLibrariesAsFiles()) throw new IOException("Undefined state of nested archive"); //$NON-NLS-1$ //We have to find the absolute path of the original archive from which // this was copied, //if it is known List list = getFiles(); String absolutePath = null; for (int i = 0; i < list.size(); i++) { File aFile = (File) list.get(i); if (aFile.isArchive()) continue; absolutePath = aFile.getLoadingContainer().getAbsolutePath(); } return new FileInputStream(absolutePath); }
/** * open the archive, setting up the appropriate strategies, using the loadStrategy passed in; * URI still necessary so the archive has a name, but it will not be used for io. */ public Archive primOpenArchive(ArchiveOptions options, String uri) throws OpenFailureException { if (options.getLoadStrategy() == null) { try { options.setLoadStrategy(createLoadStrategy(uri)); } catch (IOException ex) { throw new OpenFailureException(CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.could_not_open_EXC_, (new Object[]{uri})), ex); // = "Could not open " } } Archive anArchive = createArchive(); anArchive.setURI(uri); anArchive.setOriginalURI(uri); anArchive.setLoadStrategy(options.getLoadStrategy()); anArchive.setOptions(options); ArchiveTypeDiscriminatorRegistry.getInstance().contributeTypes(anArchive); return anArchive; }
/** * @see com.ibm.etools.commonarchive.CommonarchiveFactory */ public Archive primOpenArchive(String uri) throws OpenFailureException { return primOpenArchive(new ArchiveOptions(), uri); }
public synchronized IReferenceCountedArchive openArchive(EnterpriseBinaryComponentHelper helper) throws OpenFailureException { ArchiveOptions options = helper.getArchiveOptions(); String archiveURI = helper.getArchiveURI(); options.setLoadStrategy(createBinaryLoadStrategy(helper)); Archive anArchive = CommonarchiveFactory.eINSTANCE.primOpenArchive(options, archiveURI); ArchiveTypeDiscriminator discriminator = helper.getDiscriminator(); if (!discriminator.canImport(anArchive)) { anArchive.close(); throw new OpenFailureException(discriminator.getUnableToOpenMessage()); } IReferenceCountedArchive specificArchive = (IReferenceCountedArchive) discriminator.openArchive(anArchive); specificArchive.setEnterpriseBinaryComponentHelper(helper); specificArchive.initializeAfterOpen(); specificArchive.access(); componentsToArchives.put(helper.getComponent(), specificArchive); return specificArchive; } }
/** * Create a load strategy for a nested archive; by default will extract the nested archive to a * temp file for performance reasons. This is because random access to the zip entries in a * nested archive is not supported by the java.util.zip package, and if the archive's contents * are being modified, copied, etc, this is much faster. If a temp file can not be created, or * if the archive is opened read only (for runtime), then use a NestedArchiveLoadStrategy, which * retrieves the contents of a zip entry by sequentially searching a zip input stream */ public LoadStrategy createNestedLoadStrategy(String uri, LoadStrategy parent) { LoadStrategy loadStrategy = null; ArchiveOptions options = ((Archive) parent.getContainer()).getOptions(); if (!options.isReadOnly(uri)) loadStrategy = createTempZipFileStrategyIfPossible(uri, parent); if (loadStrategy == null) return new NestedArchiveLoadStrategyImpl(parent); return loadStrategy; }
protected ArchiveOptions getOptionsForOpening(String aUri) throws IOException { LoadStrategy strategy = getCommonArchiveFactory().createChildLoadStrategy(aUri, getLoadStrategy()); return getOptions().cloneWith(strategy, aUri); }