IFile getIResourceFromJarDirectoryAndEntryName(IDirectory jarFS, String entryName) { return jarFS.file(entryName); }
@Override public IFile file(String path) { return _delegate.file(path); }
IFile getIResourceFromJarDirectoryAndEntryName(IDirectory jarFS, String entryName) { return jarFS.file(entryName); }
private IFile findFirstFile(String resourceName, List<? extends IDirectory> searchPath) { for (IDirectory dir : searchPath) { IFile file = dir.file(resourceName); if (file != null && file.exists()) { return file; } } return null; }
public static boolean containsManifest(IDirectory dir) { IFile manifestFile = dir.file( "META-INF/MANIFEST.MF" ); return manifestFile != null && manifestFile.exists(); }
private IFile findFirstFile(String resourceName, List<? extends IDirectory> searchPath) { for (IDirectory dir : searchPath) { IFile file = dir.file(resourceName); if (file != null && file.exists()) { return file; } } return null; }
public static boolean containsManifest(IDirectory dir) { IFile manifestFile = dir.file( "META-INF/MANIFEST.MF" ); return manifestFile != null && manifestFile.exists(); }
private static List<? extends IFile> findAllFiles(String resourceName, List<? extends IDirectory> searchPath) { List<IFile> results = new ArrayList<IFile>(); for (IDirectory dir : searchPath) { IFile file = dir.file(resourceName); if (file != null && file.exists()) { results.add(file); } } return results; }
public static IFile file(IJarFileDirectory root, String path) { List<String> pathComponents = IDirectoryUtil.splitPath(path); if (pathComponents.size() == 0) { throw new IllegalArgumentException("Cannot call file() with an empty path"); } else if (pathComponents.size() == 1) { return root.getOrCreateFile(pathComponents.get(0)); } else { String fileName = pathComponents.remove(pathComponents.size() - 1); IDirectory parentDir = findParentDirectory(root, pathComponents); return parentDir.file(fileName); } }
public static IFile file(IJarFileDirectory root, String path) { List<String> pathComponents = IDirectoryUtil.splitPath(path); if (pathComponents.size() == 0) { throw new IllegalArgumentException("Cannot call file() with an empty path"); } else if (pathComponents.size() == 1) { return root.getOrCreateFile(pathComponents.get(0)); } else { String fileName = pathComponents.remove(pathComponents.size() - 1); IDirectory parentDir = findParentDirectory(root, pathComponents); return parentDir.file(fileName); } }
private IFile findFirstFile(String resourceName) { List<IDirectory> javaClassPath = _typeLoader.getModule().getJavaClassPath(); for (IDirectory dir : javaClassPath) { IFile file = dir.file(resourceName); if (file != null && file.exists()) { return file; } } throw new RuntimeException(new FileNotFoundException(resourceName)); }
public ManifestVerifyUtil(IDirectory dir, String expectedVersion) { InputStream in = null; try { in = dir.file("META-INF/MANIFEST.MF").openInputStream(); _mf = new Manifest(in); } catch (IOException e) { throw new RuntimeException(e); } finally { try { StreamUtil.close(in); } catch (IOException e) { // ignore } } _expectedVersion = expectedVersion; }
private IFile getFileMatchCase( IDirectory dir, String strFileName ) { IFile file = dir.file( strFileName ); return file != null && file.exists() && IFileUtil.getBaseName( strFileName ).equals( file.getBaseName() ) ? file : null; }
private IFile getFileMatchCase( IDirectory dir, String strFileName ) { if (dir.hasChildFile(strFileName)) { IFile file = dir.file( strFileName ); try { if( doesFileMatchCase( strFileName, file ) ) { return file; } else { return null; } } catch( IOException e ) { throw new RuntimeException( e ); } } else { return null; } }
public static Set<String> getCodegenSchemasForDir(IDirectory dir) { TypeSystem.lock(); try { Set<String> schemas = _codegenSchemasByModuleRoot.get( dir ); if ( schemas == null ) { schemas = new HashSet<String>(); IFile configFile = dir.file( "gw/internal/xml/config/xsd-codegen.xml" ); if ( configFile == null || !configFile.exists() ) { return Collections.emptySet(); } XmlElement config; try { config = XmlElement.parse( configFile.openInputStream() ); } catch ( IOException ex ) { throw new RuntimeException( ex ); } List<XmlElement> schemaElements = config.getChildren( new QName( "http://guidewire.com/config/xml/xsd-codegen", "schema" ) ); for ( XmlElement schemaElement : schemaElements ) { schemas.add( schemaElement.getAttributeValue( "namespace" ) ); } _codegenSchemasByModuleRoot.put( dir, schemas ); } return schemas; } finally { TypeSystem.unlock(); } }
public static void getExtensions(Collection<String> result, IDirectory dir, String headerName) { IFile manifestFile = dir.file( "META-INF/MANIFEST.MF" ); if (manifestFile == null || !manifestFile.exists()) { return; } InputStream in = null; try { in = manifestFile.openInputStream(); Manifest manifest = new Manifest(in); scanManifest(result, manifest, headerName); } catch (Exception e) { // FIXME: For some reason, WebSphere changes JARs in WEB-INF/lib, breaking signatures. So ignore errors. ResourcePath path = dir.getPath(); String str = path != null ? path.getFileSystemPathString() : dir.toString(); CommonServices.getEntityAccess().getLogger().warn("Cannot read manifest from jar " + str + ", ignoring"); } finally { if (in != null) { try { in.close(); } catch (IOException e) { // Ignore } } } }
public static void getExtensions(Collection<String> result, IDirectory dir, String headerName) { IFile manifestFile = dir.file( "META-INF/MANIFEST.MF" ); if (manifestFile == null || !manifestFile.exists()) { return; } InputStream in = null; try { in = manifestFile.openInputStream(); Manifest manifest = new Manifest(in); scanManifest(result, manifest, headerName); } catch (Exception e) { // FIXME: For some reason, WebSphere changes JARs in WEB-INF/lib, breaking signatures. So ignore errors. ResourcePath path = dir.getPath(); String str = path != null ? path.getFileSystemPathString() : dir.toString(); CommonServices.getEntityAccess().getLogger().warn("Cannot read manifest from jar " + str + ", ignoring"); } finally { if (in != null) { try { in.close(); } catch (IOException e) { // Ignore } } } }
private static IDirectory executeOnSourceDirectory(IDirectory dir, SourceDirectoryBlock block){ IFile moduleFile = dir.file("pom.xml"); IDirectory foundModule = null; if (moduleFile != null && moduleFile.exists()) { // This entry is itself a module, so return that block.doIt(dir, moduleFile); } else if (!dir.getName().endsWith(".jar")) { IDirectory parentDir = dir.getParent(); if (parentDir != null) { IFile parentModuleFile = parentDir.file("pom.xml"); if (parentModuleFile.exists() && moduleContainsSourceDir(parentModuleFile, dir)) { // Module.xml file in the parent directory, so that directory is a module block.doIt(parentDir, parentModuleFile); } else { // No module.xml file in the parent directory either, the original directory is the module block.doIt(dir, null); } } else { // No parent directory at all, so just the original directory is the module block.doIt(dir, null); } } else { // It's a jar file with no module.xml inside, so the jar is the module block.doIt(dir, null); } return foundModule; }
private static IDirectory executeOnSourceDirectory(IDirectory dir, SourceDirectoryBlock block){ IFile moduleFile = dir.file("pom.xml"); IDirectory foundModule = null; if (moduleFile != null && moduleFile.exists()) { // This entry is itself a module, so return that block.doIt(dir, moduleFile); } else if (!dir.getName().endsWith(".jar")) { IDirectory parentDir = dir.getParent(); if (parentDir != null) { IFile parentModuleFile = parentDir.file("pom.xml"); if (parentModuleFile.exists() && moduleContainsSourceDir(parentModuleFile, dir)) { // Module.xml file in the parent directory, so that directory is a module block.doIt(parentDir, parentModuleFile); } else { // No module.xml file in the parent directory either, the original directory is the module block.doIt(dir, null); } } else { // No parent directory at all, so just the original directory is the module block.doIt(dir, null); } } else { // It's a jar file with no module.xml inside, so the jar is the module block.doIt(dir, null); } return foundModule; }
private ISourceFileHandle findSourceFile() { IJavaClassInfo csr = this; while( csr.getEnclosingClass() != null ) { csr = csr.getEnclosingClass(); } List<IDirectory> backingSourcePath = getModule().getBackingSourcePath(); if( backingSourcePath != null ) { String classFileName = makeClassFileName(); for( IDirectory dir: backingSourcePath ) { IFile child = dir.file( classFileName ); if( child.exists() ) { return new AsmBackingSourceFileHandle( child, ((AsmClassJavaClassInfo)csr).getAsmType(), false ); } } } return null; }