@Override public List<Item> getChildren() { return new FileSearcher().searchFiles(path, "glob:**/*", false).stream().map(p -> (Item)new FileSystemFolder(p, this)).collect(Collectors.toList()); }
@Override public List<Item> getChildren() { return new FileSearcher().iterateFiles(itemPath, "glob:**/*", "glob:**/*.{svn,folder}", false).map(p -> new DeploymentItemImpl(p, DeploymentItemImpl.this)).collect(Collectors.toList()); } @Override
@SuppressWarnings("hiding") public static <T> Stream<T> asStream(Iterator<T> sourceIterator) { return asStream(sourceIterator, false); }
public static void main(String[] args) { Path p1 = Paths.get("!/AMDOCS_HLAPIv8_IO.aar!/Adapters/AMDOCS_HLAPIv8_IO.adapter"); Path p2 = Paths.get("!/AMDOCS_HLAPIv8_IO.aar!//Adapters/AMDOCS_HLAPIv8_IO.adapter"); System.out.println(p1 +" "+ p2+" " + p1.equals(p2)); FileSearcher s = new FileSearcher(); // s.searchFiles(Paths.get("T:/temp/compare/ears"), "glob:**/ERMS_API_IO.ear", false).forEach(p -> { // Path p1 = p.getParent().getParent().resolve("init-build").resolve("FILENET_API_IO.ear"); // System.out.println(p + " " + p1); // new EARComparer().compare(p,p1).forEach(r -> System.out.println(r));; // });; new EARComparer().compare(Paths.get("T:/temp/EPC_PISA_CORE.old.ear"), Paths.get("T:/temp/EPC_PISA_CORE.new.ear")).forEach(r -> System.out.println(r));; Date started = new Date(); //-old t:\temp\compare\_deployed\ENV_EAI_PRD\AP_TIBOR_IN.ear -new t:\temp\compare\build\R171126\tibor\AP_TIBOR_IN.ear // s.searchFiles(Paths.get("t:\\temp\\compare\\build\\R171126\\adb\\"), "glob:**/*.ear", true).forEach(p -> { // new EARComparer().compare(Paths.get("t:\\temp\\compare\\_deployed\\ENV_EAI_PRD").resolve(p.getFileName()), p).forEach(r -> System.out.println(r));; // // }); System.out.println(new Date().getTime() - started.getTime()); } private List<String> ignoreList = Lists.asList("library.manifest");
public Stream<Path> iterateFiles(Path path, String filePattern, String excludeFilePattern, boolean recursive) { PathMatcher excludeMatcher = FileSystems.getDefault().getPathMatcher(excludeFilePattern); return iterateFiles(path, filePattern, recursive).filter(p -> !excludeMatcher.matches(p)); } public class FilesIterator implements Iterator<Path> {
public boolean fileContain(Path file, String pattern) { return fileContain(file, Pattern.compile(pattern)); }
private void load() { availableAdapters = new FileSearcher(). searchFiles(tibcoAdaptersPath, "glob:**/*", false). stream(). map(p -> p.getFileName().toString()). map(s -> T.V(s, new FileSearcher().searchFiles(tibcoAdaptersPath.resolve(s), "glob:**/*", false).stream().sorted((a,b) -> b.toString().compareTo(a.toString())).findFirst().get())). map(adPath -> new FileSearcher().searchFiles(adPath.getB().resolve("lib"), "glob:**/*.jar", true). stream(). map(p -> new LoadZipFile().load(p).stream().filter(v -> v.getA().matches(".*com.tibco.deployment.*xml")) adaptersPropertiesNames = getPropertiesNamesAndValues(adapterProperties); List<Path> BWPaths = new FileSearcher().searchFiles(tibcoBWPath, "glob:**/*", false).stream().sorted((a,b) -> b.toString().compareTo(a.toString())).collect(Collectors.toList()); Map<String, NodeBuilder> bwProperties = BWPaths. stream().
public Stream<Path> iterateFiles(Path path, String filePattern, boolean recursive) { PathMatcher matcher = FileSystems.getDefault().getPathMatcher(filePattern); return asStream(new FilesIterator(path, recursive)).filter(p -> matcher.matches(p)); } public Stream<Path> iterateFiles(Path path, String filePattern, String excludeFilePattern, boolean recursive) {
ConfigComparer configComparer = new ConfigComparer(loader); List<Path> builtEars = new FileSearcher().searchFiles(built, "glob:**/*"+mask+"*.ear", false); List<Path> initBuiltEars = new FileSearcher().searchFiles(initBuilt, "glob:**/*"+mask+"*.ear", false);
@Override public boolean hasNext() { if (iterator.hasNext()) return true; else if (recursive) { try { DirectoryStream<Path> dirs = Files.newDirectoryStream(currentPath); try { asStream(dirs.iterator()).filter(p -> p.toFile().isDirectory()).forEach(p -> stack.addLast(p)); } finally { dirs.close(); } } catch (IOException e) { throw new RuntimeException("Cannot read sub dirs", e); } while (!stack.isEmpty()) { initStream(stack.removeFirst()); if (iterator.hasNext()) return true; } } if (files != null) { try { files.close(); } catch (IOException e) { throw new RuntimeException("Cannot close files reader", e); } files = null; } return false; }
public static void main(String[] args) { ArgumentParser argParser = ArgumentParsers.newArgumentParser("EAR Version Extractor", true, "-") .description("Extracts version from ear files in given directory."); argParser.addArgument("-directory").type(String.class).required(true).help("Path to directory with ears"); argParser.addArgument("-out").choices("LIST", "FILES").required(true).help("Output type - LIST or FILES"); Namespace res = argParser.parseArgsOrFail(args); String directory = res.get("directory"); String out = res.getString("out"); List<T.V2<Path, String>> output = new FileSearcher().searchFiles(Paths.get(directory), "glob:**/*.ear", false). stream().parallel(). map(p -> getVersionFromEAR(p)). collect(Collectors.toList()); if ("LIST".equals(out)) { output.forEach(v -> System.out.println(v.getA().getFileName() + "\t" + v.getB())); } else { output.forEach(v -> { Path versionPath = Paths.get(v.getA().toString().replace(".ear", ".version")); try(FileWriter ww = new FileWriter(versionPath.toFile()); BufferedWriter w = new BufferedWriter(ww)) { w.write(v.getB()); } catch(IOException e) { throw new RuntimeException("Could not write version to file: " + v.getA(), e); } }); } }
public FullConfigsModel(Repository repo, SDKPropertiesLoader loader) { this.repo = repo; this.bwPropertiesNames = loader.getBwPropertiesNames(); this.adaptersPropertiesNames = loader.getAdaptersPropertiesNames(); this.availableAdapters = loader.getAvailableAdapters(); Path configPath = repo.getPath().getParent().resolve("_config"); availableArchives = repo.findAll(i -> i.getItemType() == ItemType.Archive).stream().map(i -> new Archive(i)).collect(Collectors.toList()); availableEnvironemnts = new FileSearcher().searchFiles(configPath, "glob:**/*", false).stream().filter(p -> p.toFile().isDirectory()).map(p -> new Environment(p)).collect(Collectors.toList()); availableArchives.forEach(archive -> { availableEnvironemnts.stream(). map(e -> T.V(e,archive, getConfigPath(archive, e))). filter(fc -> fc.getC().toFile().exists()). map(fc -> T.V(fc.getA(), fc.getB(), new XmlBuilderFactory().loadFromFile(fc.getC()))). forEach(fc -> { configs.put(T.V(fc.getA(), fc.getB()), fc.getC()); origConfigs.put(T.V(fc.getA(), fc.getB()), fc.getC().copy()); }); ; }); }
List<T.V2<StreamSource, NodeBuilder>> wsdls= new FileSearcher().searchFiles(wsdlsPath, "glob:**/*.wsdl", true). stream().flatMap(p -> loadSchemasFromWSDL(p)). collect(Collectors.toList());
XmlBuilderFactory fac = new XmlBuilderFactory(); NormalizeConfig norm = new NormalizeConfig(loader); new FileSearcher().searchFiles(Paths.get("T:/source/R170624/_config/ENV_EAI_TST/"), "glob:**/*.xml", true). stream().map(p -> T.V(p, p.getParent().getParent().getParent().getParent().resolve("R170903/_config/ENV_EAI_TST2/").resolve(p.getFileName()))). filter(v -> v.getB().toFile().exists()).
Path deploymentListPath = configPath.resolve("deploymentList.xml"); NodeBuilder deploymentList = new XmlBuilderFactory().loadFromFile(deploymentListPath); new FileSearcher().searchFiles(branchPath, "glob:**/vcrepo.dat", true).stream(). parallel(). map(p -> checkVariables(sdkLoader, p.getParent(), prefFilePath, branchPath, configPath, exportPath, deploymentList)).
public static void main(String[] args) { ArgumentParser argParser = ArgumentParsers.newArgumentParser("EAR Version Updater", true, "-") .description("Updates version in ear files in given directory."); argParser.addArgument("-directory").type(String.class).required(true).help("Path to directory with ears"); argParser.addArgument("-version").type(String.class).required(true).help("Version that will be written in Tibco.xml"); Namespace res = argParser.parseArgsOrFail(args); String directory = res.get("directory"); String version = res.getString("version"); new FileSearcher().searchFiles(Paths.get(directory), "glob:**/*.ear", false). stream().parallel(). map(p -> T.V(p, new LoadZipFile().load(p))). map(v -> T.V(v.getA(), getVersion(v), v.getB())). filter(v -> v.getB().isPresent()). map(v -> T.V(v.getA(), new XmlBuilderFactory().parseDocument(new ByteArrayInputStream(v.getB().get().getB())), v.getB(), v.getC())). forEach(v -> { v.getB().search("version").forEach(vnode -> { System.out.println(v.getA() + " " + vnode.getTextContent() + " -> " + version); vnode.setTextContent(version); }); byte[] bytes = v.getB().toString().getBytes(); V3<String, byte[], ZipEntry> zipFileEntry = v.getC().get(); zipFileEntry.setB(bytes); new LoadZipFile().updateFile(v.getA(), v.getD()); }); }