use of org.jboss.shrinkwrap.api.Node in project camel by apache.
the class ManagedSEDeployableContainer method getSystemProperties.
private Properties getSystemProperties(final Archive<?> archive) throws DeploymentException {
Node systemPropertiesNode = archive.get(ClassPath.SYSTEM_PROPERTIES_ARCHIVE_PATH);
if (systemPropertiesNode != null) {
try (InputStream in = systemPropertiesNode.getAsset().openStream()) {
Properties systemProperties = new Properties();
systemProperties.load(in);
return systemProperties;
} catch (IOException e) {
throw new DeploymentException("Could not load system properties", e);
}
}
return null;
}
use of org.jboss.shrinkwrap.api.Node in project camel by apache.
the class FileDeploymentUtils method materializeSubdirectories.
public static void materializeSubdirectories(File entryDirectory, Node node) throws DeploymentException, IOException {
for (Node child : node.getChildren()) {
if (child.getAsset() == null) {
materializeSubdirectories(entryDirectory, child);
} else {
if (ClassPathDirectory.isMarkerFileArchivePath(child.getPath())) {
// Do not materialize the marker file
continue;
}
// E.g. META-INF/my-super-descriptor.xml
File resourceFile = new File(entryDirectory, child.getPath().get().replace(DELIMITER_RESOURCE_PATH, File.separatorChar));
File resoureDirectory = resourceFile.getParentFile();
if (!resoureDirectory.exists() && !resoureDirectory.mkdirs()) {
throw new DeploymentException("Could not create class path directory: " + entryDirectory);
}
resourceFile.createNewFile();
try (InputStream in = child.getAsset().openStream();
OutputStream out = new FileOutputStream(resourceFile)) {
copy(in, out);
}
child.getPath().get();
}
}
}
use of org.jboss.shrinkwrap.api.Node in project wildfly-swarm by wildfly-swarm.
the class ContextPathArchivePreparerTest method testExternalMount.
@SuppressWarnings("unchecked")
@Test
public void testExternalMount() throws Exception {
WARArchive archive = DefaultWarDeploymentFactory.archiveFromCurrentApp();
assertThat(archive.getContextRoot()).isNull();
URL url = getClass().getClassLoader().getResource("mounts.yml");
ConfigViewFactory factory = new ConfigViewFactory(new Properties());
factory.load("test", url);
factory.withProfile("test");
ConfigViewImpl view = factory.get(true);
List<String> mounts = view.resolve("swarm.context.mounts").as(List.class).getValue();
ContextPathArchivePreparer preparer = new ContextPathArchivePreparer(archive);
preparer.mounts = mounts;
preparer.process();
Node externalMount = archive.get(WARArchive.EXTERNAL_MOUNT_PATH);
assertThat(externalMount).isNotNull();
assertThat(externalMount.getAsset()).isInstanceOf(UndertowExternalMountsAsset.class);
UndertowExternalMountsAsset externalMountAsset = (UndertowExternalMountsAsset) externalMount.getAsset();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(externalMountAsset.openStream()))) {
assertThat(reader.readLine()).endsWith("external1");
assertThat(reader.readLine()).endsWith("external2");
}
}
use of org.jboss.shrinkwrap.api.Node in project wildfly-swarm by wildfly-swarm.
the class SecuredArchivePreparer method getKeycloakJson.
private InputStream getKeycloakJson() {
InputStream keycloakJson = Thread.currentThread().getContextClassLoader().getResourceAsStream("keycloak.json");
if (keycloakJson == null) {
String appArtifact = System.getProperty(BootstrapProperties.APP_ARTIFACT);
if (appArtifact != null) {
try (InputStream in = ClassLoader.getSystemClassLoader().getResourceAsStream("_bootstrap/" + appArtifact)) {
Archive tmpArchive = ShrinkWrap.create(JARArchive.class);
tmpArchive.as(ZipImporter.class).importFrom(in);
Node jsonNode = tmpArchive.get("keycloak.json");
if (jsonNode == null) {
jsonNode = tmpArchive.get("WEB-INF/keycloak.json");
}
if (jsonNode != null && jsonNode.getAsset() != null) {
keycloakJson = jsonNode.getAsset().openStream();
}
} catch (IOException e) {
// ignore
}
}
}
return keycloakJson;
}
use of org.jboss.shrinkwrap.api.Node in project wildfly-swarm by wildfly-swarm.
the class SecuredTest method testExistingWebXml.
@Test
public void testExistingWebXml() {
WARArchive archive = ShrinkWrap.create(WARArchive.class);
ClassLoaderAsset asset = new ClassLoaderAsset("test-web.xml");
archive.addAsWebInfResource(asset, "web.xml");
archive.as(Secured.class).protect("/cheddar");
Node webXml = archive.get("WEB-INF/web.xml");
Asset newAsset = webXml.getAsset();
InputStream in = newAsset.openStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
List<String> lines = reader.lines().map(String::trim).collect(Collectors.toList());
assertThat(lines).contains("<servlet-name>comingsoon</servlet-name>");
assertThat(lines).contains("<url-pattern>/cheddar</url-pattern>");
}
Aggregations