public FileIterator getFileIterator() throws IOException { return new FileIteratorImpl(getContainer().getFiles()){ protected SubProgressMonitor lastSubMon = null; boolean firstVisit = true;
/** * @param earFileURI * The containing EAR -- the absolute file system URI will be determined * automatically * @param looseApplicationResource * The absolute file system URI of a document containing a LooseApplication as its * root */ public void addLooseMapping(Container container, String looseApplicationResource) { if (container != null) addLooseMapping(ArchiveUtil.getOSUri(container.getURI()), looseApplicationResource); }
protected EARFile getEARFile() { if (archive == null) return null; Container parent = archive.getContainer(); if (parent != null && parent.isEARFile()) return (EARFile) parent; return null; }
/** * When looking at the class path of this jar (from the manifest), some of the elements may have * a relative path, thus we need to determine the install location of this jar. If the absolute * path from which the archive was loaded, return the parent directory of that path; otherwise, * see if the containing archive has an absolute path; if neither work, default to the current * working directory */ public String getRootForRelativeDependentJars() { String path = null; Container theContainer = this; while (theContainer != null && path == null) { try { path = theContainer.getAbsolutePath(); } catch (FileNotFoundException ex) { //Ignore } theContainer = theContainer.getLoadingContainer(); } if (path == null) { path = System.getProperty("user.dir");//$NON-NLS-1$ if (path == null) //At this point what else can we do? return "";//$NON-NLS-1$ return new java.io.File(path).getAbsolutePath(); } return new java.io.File(path).getParentFile().getAbsolutePath(); }
protected Archive resolveClasspathEntryInEAR(String entry) { /* * Added to support runtime classpath for loose modules */ Container parent = getContainer(); if (parent == null || !parent.isEARFile()) return null; String aUri = ArchiveUtil.deriveEARRelativeURI(entry, this); if (aUri == null) return null; File aFile = null; try { aFile = parent.getFile(aUri); } catch (FileNotFoundException ex) { return null; } return aFile.isArchive() ? (Archive) aFile : null; }
Archive outermost = openedArchive; Container c = openedArchive.getContainer(); while (c != null && c.isArchive()) { outermost = (Archive) c; c = c.getContainer();
if (!getContainer().isArchive() || isDirectory()) return true; Archive anArchive = (Archive) getContainer(); if (i == 0) { firstContainer = aFile.getLoadingContainer(); if (firstContainer.getLoadStrategy().isDirectory()) return true;
/** * @generated This field/method will be replaced during code generation */ public Container getLoadingContainer() { if (loadingContainer != null && loadingContainer.eIsProxy()) { InternalEObject oldLoadingContainer = (InternalEObject)loadingContainer; loadingContainer = (Container)eResolveProxy(oldLoadingContainer); if (loadingContainer != oldLoadingContainer) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, CommonarchivePackage.FILE__LOADING_CONTAINER, oldLoadingContainer, loadingContainer)); } } return loadingContainer; }
/** * @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); }
protected ZipInputStream getZipInputStream() throws IOException, FileNotFoundException { String uri = getContainer().getURI(); InputStream in = getParent().getInputStream(uri); return new ZipInputStream(in); }
/** * @see com.ibm.etools.commonarchive.ModuleFile */ public EARFile getEARFile() { Container aContainer = getContainer(); if (aContainer == null || !aContainer.isEARFile()) { return null; } return ((EARFile) aContainer); }
/** * Used internally; clients should not need to call */ public FileIterator getFileIterator() throws IOException { return new FileIteratorImpl(getContainer().getFiles()); }
/** * An exception was caught reading the nested jar; throws a runtime exception */ protected void throwNestedJarException(Exception caughtException) { throw new NestedJarException(CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.nested_jar_EXC_, (new Object[]{getContainer().getURI(), getParent().getContainer().getURI()})), caughtException);// = "An error occurred reading {0} from {1}" }
protected static IProject getEARProject(Archive anArchive) { Container c = anArchive.getContainer(); if (!c.isEARFile()) return null; EARFile ear = (EARFile) c; LoadStrategy loader = ear.getLoadStrategy(); if (!(loader instanceof EARComponentLoadStrategyImpl)) return null; return ((EARComponentLoadStrategyImpl) loader).getComponent().getProject(); }
/** * Used internally; clients should not need to call */ public FileIterator getFileIterator() throws IOException { if (((Archive) getContainer()).getOptions().isReadOnly()) return new NestedArchiveIterator(getContainer().getFiles(), getZipInputStream()); return super.getFileIterator(); }
protected void throwResourceLoadException(String resourceUri, Exception ex) throws ResourceLoadException { throw new ResourceLoadException(CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.load_resource_EXC_, (new Object[]{resourceUri, getContainer().getURI()})), ex); // = "Could not load resource "{0}" in archive "{1}"" }
/** * <p>Answer a parent path for use by the receiver. Take into * account wehther the receiver is a loose application or not. * * <p>Answer null in case an error is encountered while determining * the parent path.</p> * * <p>Added for BZ 170532.</p> * * @return A parent path for use by the receiver. Null in case of an error. * * @see getDependencyClassPathAtThisLevel() */ protected String getParentPath() { try { if ( (getLoadStrategy().getLooseArchive() != null) && getContainer().isEARFile() ) { return getEARFile().getBinariesPath(); } else { return new java.io.File(getBinariesPath()).getParentFile().getAbsolutePath(); } } catch (FileNotFoundException e) { return null; } }
public File next() { if(firstVisit){ firstVisit = false; if(monitor != null){ monitor.beginTask(ProjectSupportResourceHandler.getString(ProjectSupportResourceHandler.Exporting_archive, new Object [] { getContainer().getURI() }), files.size() * FILE_SAVE_WORK); } } if(lastSubMon != null){ lastSubMon.done(); lastSubMon = null; } else if(monitor != null){ monitor.worked(FILE_SAVE_WORK); } File file = super.next(); if(monitor != null){ if(file.isContainer() && ComponentLoadStrategyImpl.class.isInstance(((ContainerImpl)file).getLoadStrategy())){ ComponentLoadStrategyImpl ls = (ComponentLoadStrategyImpl)((ContainerImpl)file).getLoadStrategy(); lastSubMon = new SubProgressMonitor(monitor, FILE_SAVE_WORK, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK); ls.setProgressMonitor(lastSubMon); } else { monitor.subTask(file.getURI()); } } return file; } };