private static Optional<T.V3<String, byte[], ZipEntry>> getVersion(V2<Path, List<V3<String, byte[], ZipEntry>>> v) { return v.getB().stream().filter(vv -> "!/TIBCO.xml".equals(vv.getA())).findFirst(); }
private static Optional<T.V3<String, byte[], ZipEntry>> getVersion(V2<Path, List<V3<String, byte[], ZipEntry>>> v) { return v.getB().stream().filter(vv -> "!/TIBCO.xml".equals(vv.getA())).findFirst(); }
public boolean isServiceInstanceVariableDefinedInAllConfigs(GlobalVariable variable) { return configs.entrySet().stream(). map(v -> getServices(v.getKey().getA(), v.getKey().getB()). stream().map(s -> T.V(v.getKey().getA(),v.getKey().getB(),s)) ). flatMap(v -> v). map(v -> getInstances(v.getA(), v.getB(), v.getC()). stream().map(instance -> getInstanceConfig(v.getA(), v.getB(), v.getC(), instance).get())). flatMap(n -> n). filter(checkServiceInstanceVariableInConfig(variable)). count() == 0; }
private List<CompareResult> compareArchives(Path oldArchive, XmlBuilderFactory fac, List<T.V3<String, byte[], ZipEntry>> oldFiles, List<T.V3<String, byte[], ZipEntry>> newFiles) { List<Path> oldEarFilesString = oldFiles.stream().map(t -> t.getA()).sorted().map(p -> Paths.get(p)).collect(Collectors.toList());; List<Path> newEarFilesString = newFiles.stream().map(t -> t.getA()).sorted().map(p -> Paths.get(p)).collect(Collectors.toList()); if (oldEarFilesString.equals(newEarFilesString)) { return compareTwoLists(oldArchive, fac, oldFiles, newFiles); results.add(new CompareResult(f, CompareResultStatus.DifferentParsSarsAarsDeletedFile, "Deleted file: " + f)); if (isArchiveFile(f.toString())) { List<V3<String, byte[], ZipEntry>> oldArchiveFiles = new LoadZipFile().load(f.toString(), oldFiles.stream().filter(v -> v.getA().equals(f.toString().replace("\\", "/"))).map(v -> v.getB()).findAny().get()); results.addAll(compareArchives(f, fac, oldArchiveFiles, Arrays.asList())); results.add(new CompareResult(f, CompareResultStatus.DifferentParsSarsAarsAddedFile, "Added file: " + f)); if (isArchiveFile(f.toString())) { List<V3<String, byte[], ZipEntry>> newArchiveFiles = new LoadZipFile().load(f.toString(), newFiles.stream().filter(v -> v.getA().equals(f.toString().replace("\\", "/"))).map(v -> v.getB()).findAny().get()); results.addAll(compareArchives(f, fac, Arrays.asList(), newArchiveFiles)); List<T.V3<String, byte[], ZipEntry>> oldF = oldFiles.stream().filter(f -> newFiles.stream().anyMatch(v -> v.getA().equals(f.getA())) ).collect(Collectors.toList()); List<T.V3<String, byte[], ZipEntry>> newF = newFiles.stream().filter(f -> oldFiles.stream().anyMatch(v -> v.getA().equals(f.getA())) ).collect(Collectors.toList());
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")) .filter(v -> filterXmlPropertyFile(adPath, v) ) .map(v -> new XmlBuilderFactory().parseDocument(new String(v.getB())))).
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()); }); }
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()); }); ; }); }
public void removeDuplicateProcesses(Archive archive) { Set<String> duplicated = getDuplicateProcesses(archive); Map<V2<String, String>, List<V3<V2<Environment, Archive>, String, NodeBuilder>>> toRemove = configs. entrySet().stream().filter(v -> v.getKey().getB().equals(archive)). map(v -> v.getValue().search(true, "bwprocess").map(nn -> T.V(v.getKey(), nn.getAttribute("name"), nn))). flatMap(n -> n). filter(v -> duplicated.contains(v.getB())). collect(Collectors.groupingBy(t -> (V2<String, String>)T.V(t.getA().getA().getValue(), t.getB()))); toRemove. entrySet().stream(). forEach(v -> { v.getValue().stream().skip(1).forEach(n -> n.getC().getParent().removeChild(n.getC())); }); }
public void removeDuplicateVariables() { Set<String> duplicated = getDuplicateVariables(); Map<V3<String, String, String>, List<V3<V2<Environment, Archive>, String, NodeBuilder>>> toRemove = configs. entrySet().stream(). map(v -> v.getValue().searchFirstByName("NVPairs").search(true, "name").map(nn -> T.V(v.getKey(), nn.getTextContent(), nn.getParent()))). // search all name elements from NVPairs //map(v -> v.getValue().search(true, "bwprocess").map(nn -> T.V(v.getKey(), nn.getAttribute("name"), nn))). flatMap(n -> n). filter(v -> duplicated.contains(v.getB())). collect(Collectors.groupingBy(t -> (V3<String, String, String>)T.V(t.getA().getA().getValue(), t.getA().getB().getValue(), t.getB()))); toRemove. entrySet().stream(). forEach(v -> { v.getValue().stream().skip(1).forEach(n -> n.getC().getParent().removeChild(n.getC())); }); }
public static <A, B, C, D> V4<A, B, C, D> copyAndAdd(V3<A, B, C> v, D d) { return new V4<A, B, C, D>(v.getA(), v.getB(), v.getC(), d); } public static <A, B, C, D, E> V5<A, B, C, D, E> copyAndAdd(V4<A, B, C, D> v, E e) {
private Stream<V2<Service, NodeBuilder>> loadServicesStream(Archive archive) { return archive.getArchive().loadAsXml(). search(true, n -> ARCHIVES_ELEMENT_NAMES.contains(n.getName())). map(n -> T.V(SERVICE_TYPES.get(n.getName()), n.getAttribute("name"), n)). map(v -> T.V(new Service(v.getB(), v.getA()), v.getC())); }