String p = n.getPath().get(); if (callback != null) { callback.accept(p);
@Override public boolean equals(Object obj) { if (obj instanceof Node) { Node node = (Node) obj; if (path.equals(node.getPath())) { return true; } } return false; }
@Override public boolean equals(Object obj) { if (obj instanceof Node) { Node node = (Node) obj; if (path.equals(node.getPath())) { return true; } } return false; }
private ITemplateSourceEntry addJarEntry(Map<String, ITemplateSourceEntry> entries, Node jarEntry) { String name = jarEntry.getPath().get().substring(basePathLength); if(name.isEmpty()) { name = "/"; } ITemplateSourceEntry entry = new JarTemplateSourceEntry(name, jarEntry); entries.put(name, entry); return entry; }
protected void filter(Set<ArchivePath> remove, Node node, ResolvedDependencies resolvedDependencies) { String path = node.getPath().get(); if (path.startsWith("/WEB-INF/lib") && path.endsWith(".jar")) { if (path.contains("thorntail-runner")) { remove.add(node.getPath()); } if (resolvedDependencies.isRemovable(node)) { remove.add(node.getPath()); } } for (Node each : node.getChildren()) { filter(remove, each, resolvedDependencies); } } }
protected void filter(Set<ArchivePath> remove, Node node, ResolvedDependencies resolvedDependencies) { String path = node.getPath().get(); if (path.startsWith("/WEB-INF/lib") && path.endsWith(".jar")) { if (resolvedDependencies.isRemovable(node)) { remove.add(node.getPath()); } } for (Node each : node.getChildren()) { filter(remove, each, resolvedDependencies); } } }
private static boolean hasApplicationPathAnnotation(Archive<?> archive) { Map<ArchivePath, Node> content = archive.getContent(); for (Map.Entry<ArchivePath, Node> entry : content.entrySet()) { Node node = entry.getValue(); Asset asset = node.getAsset(); if (hasApplicationPathAnnotation(node.getPath(), asset)) { return true; } } return false; }
public static boolean isJAXRS(Archive<?> archive) { Map<ArchivePath, Node> content = archive.getContent(); for (Map.Entry<ArchivePath, Node> entry : content.entrySet()) { Node node = entry.getValue(); Asset asset = node.getAsset(); if (isJAXRS(node.getPath(), asset)) { return true; } } return false; }
private void format(StringBuilder sb, Node node) { sb.append(node.getPath().get()); if (node.getAsset() == null) { sb.append(FormattingConstants.SLASH); } sb.append(FormattingConstants.NEWLINE); for (Node child : node.getChildren()) { format(sb, child); } }
private void format(StringBuilder sb, Node node) { sb.append(node.getPath().get()); if (node.getAsset() == null) { sb.append(FormattingConstants.SLASH); } sb.append(FormattingConstants.NEWLINE); for (Node child : node.getChildren()) { format(sb, child); } }
@Override protected Archive<?> filter(Archive<?> archive) { final Set<ArtifactSpec> moduleSpecs = dependencyManager.getModuleDependencies(); final Set<ArtifactSpec> nonSwarmSpecs = dependencyManager.getNonSwarmDependencies(); archive.getContent().values().stream() .filter(node -> node.getPath().get().startsWith(WEB_INF_LIB)) .filter(node -> !nodeIsInArtifactList(node, nonSwarmSpecs, false) && (nodeIsInArtifactList(node, moduleSpecs, true) || nodeIsSwarmArtifact(node))) .forEach(node -> archive.delete(node.getPath())); return archive; }
private void unpack(File destination, JavaArchive file) throws IOException { final Node rootDir = file.get("/"); final Set<Node> contractFiles = rootDir.getChildren(); for (Node contractFile : contractFiles) { final String filename = contractFile.getPath().get().substring(1); final Asset asset = contractFile.getAsset(); try (final InputStream in = asset.openStream()) { Files.copy(in, new File(destination, filename).toPath()); } } }
@Override public void process(Archive<?> archive) { if ("arquillian-core.jar".equals(archive.getName())) { Node node = archive.get("org/jboss/shrinkwrap/descriptor"); if (node != null) archive.delete(node.getPath()); } } }
/** * Recursive call to process all the node hierarchy * * @param node */ private void processNode(final Node node) { processNode(node.getPath(), node); Set<Node> children = node.getChildren(); for (Node child : children) { processNode(child); } }
/** * Recursive call to process all the node hierarchy * * @param node */ private void processNode(final Node node) { processNode(node.getPath(), node); Set<Node> children = node.getChildren(); for (Node child : children) { processNode(child); } }
private static void copyDir(Archive<?> sourceArchive, Archive<?> targetArchive, String source, String target) { Node sourceNode = sourceArchive.get(source); if (sourceNode.getAsset() != null) { targetArchive.add(sourceNode.getAsset(), target); } else { for (Node child : sourceNode.getChildren()) { String childName = child.getPath().get().replaceFirst(child.getPath().getParent().get(), ""); copyDir(sourceArchive, targetArchive, child.getPath().get(), ArchivePaths.create(target, childName).get()); } } } }
public static WebArchive createDeployment(String packageName) throws IOException { WebArchive war = createPortletDeployment(packageName); Node node = war.get("WEB-INF/portlet.xml"); ArchivePath path = node.getPath(); String s = Tools.read(node.getAsset().openStream(), Tools.UTF_8); s = s.replace("<portlet-info>", "<resource-bundle>bundle</resource-bundle>" + "<portlet-info>"); war.delete(path); war.add(new StringAsset(s), path); war.addAsResource(new StringAsset("abc=def"), "bundle_fr_FR.properties"); return war; }
public static WebArchive createDeployment(String packageName) throws IOException { WebArchive war = createPortletDeployment(packageName); Node node = war.get("WEB-INF/portlet.xml"); ArchivePath path = node.getPath(); String s = Tools.read(node.getAsset().openStream(), Tools.UTF_8); s = s.replace("<portlet-info>", "<resource-bundle>bundle</resource-bundle>" + "<portlet-info>"); war.delete(path); war.add(new StringAsset(s), path); war.addAsResource(new StringAsset("abc=def"), "bundle_fr_FR.properties"); return war; }
public static WebArchive createDeployment(String packageName) throws IOException { WebArchive war = createServletDeployment(true, packageName); Node node = war.get("/WEB-INF/web.xml"); ArchivePath path = node.getPath(); String s = Tools.read(node.getAsset().openStream(), Tools.UTF_8); s = s.replace("<async-supported>true</async-supported>", "<init-param><param-name>juzu.resource_bundle</param-name><param-value>bundle</param-value></init-param>" + "<async-supported>true</async-supported>"); war.delete(path); war.add(new StringAsset(s), path); war.addAsResource(new StringAsset("abc=def"), "bundle_fr_FR.properties"); return war; }
public static WebArchive createDeployment(String packageName) throws IOException { WebArchive war = createServletDeployment(true, packageName); Node node = war.get("/WEB-INF/web.xml"); ArchivePath path = node.getPath(); String s = Tools.read(node.getAsset().openStream(), Tools.UTF_8); s = s.replace("<async-supported>true</async-supported>", "<init-param><param-name>juzu.resource_bundle</param-name><param-value>bundle</param-value></init-param>" + "<async-supported>true</async-supported>"); war.delete(path); war.add(new StringAsset(s), path); war.addAsResource(new StringAsset("abc=def"), "bundle_fr_FR.properties"); return war; }