private void loadOrCreateConfigurationAsset() throws IOException { Node node = getArchive().get(SWAGGER_CONFIGURATION_PATH); if (node == null && getArchive().getName().endsWith(".war")) { node = getArchive().get("WEB-INF/classes/" + SWAGGER_CONFIGURATION_PATH); } if (node != null) { Asset asset = node.getAsset(); if (asset instanceof SwaggerConfigurationAsset) { this.configurationAsset = (SwaggerConfigurationAsset) asset; } else { this.configurationAsset = new SwaggerConfigurationAsset(asset.openStream()); getArchive().add(this.configurationAsset, node.getPath()); } } else { this.configurationAsset = new SwaggerConfigurationAsset(); if (getArchive().getName().endsWith(".war")) { getArchive().add(this.configurationAsset, "WEB-INF/classes/" + SWAGGER_CONFIGURATION_PATH); } else { getArchive().add(this.configurationAsset, SWAGGER_CONFIGURATION_PATH); } } }
public ServiceActivatorArchive addServiceActivator(Class<? extends ServiceActivator> cls) { if (getArchive().getName().endsWith(".war")) { getArchive().as(WebArchive.class).addClass(cls); } else if (getArchive().getName().endsWith(".jar")) { getArchive().as(JavaArchive.class).addClass(cls); } this.asset.addServiceActivator(cls); return this; }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#addAsDirectories(java.lang.String[]) */ @Override public T addAsDirectories(final String... paths) throws IllegalArgumentException { // Precondition check Validate.notNull(paths, "paths must be specified"); // Represent as array of Paths final Collection<ArchivePath> pathsCollection = new ArrayList<ArchivePath>(paths.length); for (final String path : paths) { pathsCollection.add(ArchivePaths.create(path)); } // Delegate and return return this.addAsDirectories(pathsCollection.toArray(new ArchivePath[] {})); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#addAsDirectories(org.jboss.shrinkwrap.api.ArchivePath[]) */ @Override public T addAsDirectories(final ArchivePath... paths) throws IllegalArgumentException { // Precondition check Validate.notNull(paths, "paths must be specified"); // Add for (final ArchivePath path : paths) { this.addAsDirectory(path); } // Return return covariantReturn(); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#move(org.jboss.shrinkwrap.api.ArchivePath, org.jboss.shrinkwrap.api.ArchivePath) */ @Override public T move(ArchivePath source, ArchivePath target) throws IllegalArgumentException, IllegalArchivePathException { Validate.notNull(source, "The source path was not specified"); Validate.notNull(target, "The target path was not specified"); final Node nodeToMove = get(source); if (null == nodeToMove) { throw new IllegalArchivePathException(source.get() + " doesn't specify any node in the archive to move"); } final Asset asset = nodeToMove.getAsset(); // Directory? if (asset == null) { this.addAsDirectory(target); } else { add(asset, target); } // move children final Set<Node> nodeToMoveChildren = nodeToMove.getChildren(); for (final Node child : nodeToMoveChildren) { final String childName = child.getPath().get().replaceFirst(child.getPath().getParent().get(), ""); final ArchivePath childTargetPath = ArchivePaths.create(target, childName); move(child.getPath(), childTargetPath); } delete(source); return covariantReturn(); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#add(NamedAsset)) */ @Override public T add(NamedAsset namedAsset) { Validate.notNull(namedAsset, "No named asset was specified"); return add(namedAsset, namedAsset.getName()); }
private void loadOrCreateConfigurationAsset() { Node node = getArchive().get(SWAGGER_CONFIGURATION_PATH); if (node != null) { Asset asset = node.getAsset(); if (asset instanceof SwaggerConfigurationAsset) { this.configurationAsset = (SwaggerConfigurationAsset) asset; } else { this.configurationAsset = new SwaggerConfigurationAsset(asset.openStream()); } } else { this.configurationAsset = new SwaggerConfigurationAsset(); getArchive().add(this.configurationAsset, SWAGGER_CONFIGURATION_PATH); } }
super(archive); Node node = getArchive().as(JARArchive.class).get("WEB-INF/web.xml"); if (node == null) { this.asset = new WebXmlAsset(); getArchive().as(JARArchive.class).add(this.asset); } else { NamedAsset asset = (NamedAsset) node.getAsset(); if (!(asset instanceof WebXmlAsset)) { this.asset = new WebXmlAsset(asset.openStream()); getArchive().as(JARArchive.class).add(this.asset); } else { this.asset = (WebXmlAsset) asset; getArchive().as(JARArchive.class).addModule("org.wildfly.swarm.keycloak", "runtime"); getArchive().as(JARArchive.class).addAsServiceProvider("io.undertow.servlet.ServletExtension", "org.wildfly.swarm.keycloak.runtime.SecurityContextServletExtension"); ZipImporterImpl importer = new ZipImporterImpl(archive); importer.importFrom(in); Node jsonNode = archive.get("keycloak.json"); if (jsonNode == null) { jsonNode = archive.get("WEB-INF/keycloak.json"); getArchive().as(JARArchive.class).add(createAsset(keycloakJson), "WEB-INF/keycloak.json"); } else {
addAsDirectory(nodePath); } else { add(node.getAsset(), nodePath); return covariantReturn();
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#get(java.lang.String) */ @Override public Node get(final String path) throws IllegalArgumentException { // Precondition checks Validate.notNullOrEmpty(path, "No path was specified"); // Make a Path final ArchivePath realPath = new BasicPath(path); // Delegate return get(realPath); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#getAsType(java.lang.Class, org.jboss.shrinkwrap.api.ArchivePath) */ @Override public <X extends Archive<X>> X getAsType(Class<X> type, ArchivePath path) { Validate.notNull(type, "Type must be specified"); Validate.notNull(path, "ArchivePath must be specified"); Node content = get(path); if (content == null) { return null; } Asset asset = content.getAsset(); if (asset == null) { return null; } if (asset instanceof ArchiveAsset) { ArchiveAsset archiveAsset = (ArchiveAsset) asset; return archiveAsset.getArchive().as(type); } ArchiveFormat archiveFormat = this.configuration.getExtensionLoader() .getArchiveFormatFromExtensionMapping(type); return getAsType(type, path, archiveFormat); }
private String path() { if (getArchive().getName().endsWith(".war")) { return "WEB-INF/classes/META-INF/services/" + ServiceActivator.class.getName(); } return "META-INF/services/" + ServiceActivator.class.getName(); }
/** * Constructs a new instance using the underlying specified archive, which is required * * @param archive */ public SecuredImpl(ArchiveBase<?> archive) { super(archive); Node node = getArchive().as(JARArchive.class).get("WEB-INF/web.xml"); if (node == null) { this.asset = new WebXmlAsset(); getArchive().as(JARArchive.class).add(this.asset); } else { Asset asset = node.getAsset(); if (!(asset instanceof WebXmlAsset)) { this.asset = new WebXmlAsset(asset.openStream()); getArchive().as(JARArchive.class).add(this.asset); } else { this.asset = (WebXmlAsset) asset; } } // Setup web.xml this.asset.setContextParam("resteasy.scan", "true"); this.asset.setLoginConfig("KEYCLOAK", "ignored"); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#addAsDirectory(java.lang.String) */ @Override public T addAsDirectory(final String path) throws IllegalArgumentException { // Precondition check Validate.notNullOrEmpty(path, "path must be specified"); // Delegate and return return this.addAsDirectory(ArchivePaths.create(path)); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#move(org.jboss.shrinkwrap.api.ArchivePath, org.jboss.shrinkwrap.api.ArchivePath) */ @Override public T move(ArchivePath source, ArchivePath target) throws IllegalArgumentException, IllegalArchivePathException { Validate.notNull(source, "The source path was not specified"); Validate.notNull(target, "The target path was not specified"); final Node nodeToMove = get(source); if (null == nodeToMove) { throw new IllegalArchivePathException(source.get() + " doesn't specify any node in the archive to move"); } final Asset asset = nodeToMove.getAsset(); // Directory? if (asset == null) { this.addAsDirectory(target); } else { add(asset, target); } // move children final Set<Node> nodeToMoveChildren = nodeToMove.getChildren(); for (final Node child : nodeToMoveChildren) { final String childName = child.getPath().get().replaceFirst(child.getPath().getParent().get(), ""); final ArchivePath childTargetPath = ArchivePaths.create(target, childName); move(child.getPath(), childTargetPath); } delete(source); return covariantReturn(); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#add(org.jboss.shrinkwrap.api.asset.Asset, java.lang.String, * java.lang.String) */ @Override public T add(final Asset asset, final String target, final String name) throws IllegalArgumentException { Validate.notNull(target, "target must be specified"); final ArchivePath path = ArchivePaths.create(target); return this.add(asset, path, name); }
addAsDirectory(nodePath); } else { add(node.getAsset(), nodePath); return covariantReturn();
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#get(java.lang.String) */ @Override public Node get(final String path) throws IllegalArgumentException { // Precondition checks Validate.notNullOrEmpty(path, "No path was specified"); // Make a Path final ArchivePath realPath = new BasicPath(path); // Delegate return get(realPath); }