/** * Concatenates the two strings and ensures the correct separator is used in the path */ public static String getOSUri(String directoryname, String filename) { String osDirName = getOSUri(directoryname); String osFileName = getOSUri(filename); return concatUri(osDirName, osFileName, File.separatorChar); }
/** * @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 void addWebLibs(String absolutePath, List entries) { /******************************************************************************************* * Optimization*********** We could have used the helper getlibs here; however, that could * drag down performance as the full file list would have to get built, and this is runtime; * if the classes portion is huge then building the file list would be slow; moreover, we * would then have to clear the index from this war file. therefore, we'll do a little extra * work to get the libs ******************************************************************************************/ java.io.File aFile = new java.io.File(ArchiveUtil.getOSUri(absolutePath, ArchiveConstants.WEBAPP_LIB_URI)); List libs = getAllFileEntriesRecursive(aFile, new ArrayList()); for (int i = 0; i < libs.size(); i++) { String libPath = (String) libs.get(i); entries.add(createLibClasspathEntry(libPath)); } addLooseLibsToRuntimeClasspath(entries); }
protected void setTimestampAfterSaving(org.eclipse.jst.j2ee.commonarchivecore.internal.File aFile) { long lastMod = aFile.getLastModified(); if (lastMod == 0) return; String absPath = ArchiveUtil.getOSUri(getDirectoryName(), aFile.getURI()); File ioFile = new File(absPath); ioFile.setLastModified(lastMod); }
/** * Convert all the classpath entries to absolute paths */ protected List getEntriesAsAbsolutePaths(String[] entries, String parentPath) { List aList = new ArrayList(entries.length); for (int i = 0; i < entries.length; i++) { String entry = entries[i]; /* * Added for loose module support - if the cananonicalized entry resolves to an archive * in the containing ear, then add the absolute path of that archive */ Archive dependentJar = resolveClasspathEntryInEAR(entry); if (dependentJar != null) { try { aList.add(dependentJar.getAbsolutePath()); continue; } catch (FileNotFoundException shouldntHappenInRuntime) { //Ignore } } //Otherwise, compute the absolute path of the entry relative to // this jar java.io.File aFile = new java.io.File(entry); if (aFile.isAbsolute()) aList.add(aFile.getAbsolutePath()); else aList.add(ArchiveUtil.getOSUri(parentPath, entry)); } return aList; }
java.io.File aFile = new java.io.File(pathEntry); if (!aFile.isAbsolute()) { pathEntry = getOSUri(uriRoot, pathEntry); aFile = new java.io.File(pathEntry);
/** * By default just test the extension of the uri for one of the known archive types; subclasses * may which to override. * * @see com.ibm.etools.commonarchive.Archive */ public boolean isNestedArchive(java.lang.String aUri) { //110390.3 Error loading alt-bindings /* * Don't infer that a folder which ends with .jar is an exploded archive; EAR file will do * that IF the folder is declared as a module in the EAR */ if (getLoadStrategy().isDirectory()) { try { String path = ArchiveUtil.getOSUri(getAbsolutePath(), aUri); java.io.File ioFile = new java.io.File(path); if (!ioFile.exists() || (ioFile.isDirectory() && aUri.startsWith(J2EEConstants.ALT_INF))) return false; } catch (IOException ex) { return false; } } return ArchiveTypeDiscriminatorRegistry.INSTANCE.isKnownArchiveType(aUri); }
/** * @see com.ibm.etools.archive.impl.SaveStrategyImpl */ protected SaveStrategy createNestedDirectoryStrategy(Archive anArchive) { String uri = org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil.getOSUri(getDirectoryName(), "");//$NON-NLS-1$ return new ConnectorDirectorySaveStrategyImpl(uri, getExpansionFlags()); }
/** * Overridden from superclass to include the claseses and libs of a WARFile There also is an * assumption that this is an exploded war file The following is what should be returned: * * 1) WAR directory + /WEB-INF/classes 2) all JAR files contained in [WAR directory + * /WEB-INF/lib] 3) WAR directory */ public RuntimeClasspathEntry[] getLocalRuntimeClassPath() { String absolutePath; try { absolutePath = getLoadStrategy().getBinariesPath(); } catch (IOException ex) { return new RuntimeClasspathEntry[0]; } List entries = new ArrayList(); if (getLoadStrategy().isDirectory()) { String classesPath = ArchiveUtil.getOSUri(absolutePath, ArchiveConstants.WEBAPP_CLASSES_URI); entries.add(createRuntimeClasspathEntry(classesPath)); addWebLibs(absolutePath, entries); } entries.add(createRuntimeClasspathEntry(absolutePath)); return (RuntimeClasspathEntry[]) entries.toArray(new RuntimeClasspathEntry[entries.size()]); }
absPath = aFile.getAbsolutePath(); else { absPath = ArchiveUtil.getOSUri(parentPath, entry); absPath = ClasspathUtil.normalizePath(absPath);
/** * @see com.ibm.etools.archive.impl.SaveStrategyImpl */ protected SaveStrategy createNestedDirectoryStrategy(Archive anArchive) { String uri = org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil.getOSUri(getDirectoryName(), anArchive.getURI()); return new DirectorySaveStrategyImpl(uri, getExpansionFlags()); }
public LoadStrategy createChildLoadStrategy(String uri, LoadStrategy parent) throws java.io.IOException, java.io.FileNotFoundException { LoadStrategy childStrategy = null; if (parent.isDirectory()) { String dirName = ((DirectoryArchiveLoadStrategy) parent).getDirectoryUri(); String qualifiedUri = ArchiveUtil.getOSUri(dirName, uri); childStrategy = createLoadStrategy(qualifiedUri); } else { childStrategy = createNestedLoadStrategy(uri, parent); } return childStrategy; }
public LooseArchive getLooseArchive() { if (looseArchive == null && getContainer().isEARFile()) { String osString = ArchiveUtil.getOSUri(getContainer().getURI()); setLooseArchive(LooseConfigRegister.singleton().findLooseApplication(osString)); } return looseArchive; }