/** * {@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);
/** * {@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()); }
addAsDirectory(nodePath); } else { add(node.getAsset(), nodePath);
/** * {@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()); }
/** * {@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); }
public ServiceActivatorArchive setAsset(ServiceActivatorAsset asset) { this.asset = asset; getArchive().add(this.asset, path()); return this; }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#add(java.lang.String, org.jboss.shrinkwrap.api.asset.Asset) */ @Override public T add(final Asset asset, final String target) throws IllegalArgumentException { // Precondition checks Validate.notNullOrEmpty(target, "target must be specified"); Validate.notNull(asset, "asset must be specified"); // Make a Path from the target final ArchivePath path = new BasicPath(target); // Delegate return this.add(asset, path); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#add(java.lang.String, org.jboss.shrinkwrap.api.asset.Asset) */ @Override public T add(final Asset asset, final String target) throws IllegalArgumentException { // Precondition checks Validate.notNullOrEmpty(target, "target must be specified"); Validate.notNull(asset, "asset must be specified"); // Make a Path from the target final ArchivePath path = new BasicPath(target); // Delegate return this.add(asset, path); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#add(org.jboss.shrinkwrap.api.ArchivePath, java.lang.String, * org.jboss.shrinkwrap.api.asset.Asset) */ @Override public T add(final Asset asset, final ArchivePath path, final String name) { // Precondition checks Validate.notNull(path, "No path was specified"); Validate.notNullOrEmpty(name, "No target name name was specified"); Validate.notNull(asset, "No asset was was specified"); // Make a relative path final ArchivePath resolvedPath = new BasicPath(path, name); // Delegate return this.add(asset, resolvedPath); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#add(org.jboss.shrinkwrap.api.ArchivePath, java.lang.String, * org.jboss.shrinkwrap.api.asset.Asset) */ @Override public T add(final Asset asset, final ArchivePath path, final String name) { // Precondition checks Validate.notNull(path, "No path was specified"); Validate.notNullOrEmpty(name, "No target name name was specified"); Validate.notNull(asset, "No asset was was specified"); // Make a relative path final ArchivePath resolvedPath = new BasicPath(path, name); // Delegate return this.add(asset, resolvedPath); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.impl.base.ArchiveBase#add(org.jboss.shrinkwrap.api.Archive, * org.jboss.shrinkwrap.api.ArchivePath, java.lang.Class) */ @Override public T add(final Archive<?> archive, final ArchivePath path, final Class<? extends StreamExporter> exporter) { // Add archive asset super.add(archive, path, exporter); // Expected Archive Path final ArchivePath archivePath = new BasicPath(path, archive.getName()); // Get the Asset that was just added final Node node = get(archivePath); // Make sure it is an ArchiveAsset if (node.getAsset() != null && node.getAsset() instanceof ArchiveAsset) { final ArchiveAsset archiveAsset = ArchiveAsset.class.cast(node.getAsset()); // Add asset to ArchiveAsset Map nestedArchives.put(archivePath, archiveAsset); } return covariantReturn(); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.impl.base.ArchiveBase#add(org.jboss.shrinkwrap.api.Archive, * org.jboss.shrinkwrap.api.ArchivePath, java.lang.Class) */ @Override public T add(final Archive<?> archive, final ArchivePath path, final Class<? extends StreamExporter> exporter) { // Add archive asset super.add(archive, path, exporter); // Expected Archive Path final ArchivePath archivePath = new BasicPath(path, archive.getName()); // Get the Asset that was just added final Node node = get(archivePath); // Make sure it is an ArchiveAsset if (node.getAsset() != null && node.getAsset() instanceof ArchiveAsset) { final ArchiveAsset archiveAsset = ArchiveAsset.class.cast(node.getAsset()); // Add asset to ArchiveAsset Map nestedArchives.put(archivePath, archiveAsset); } return covariantReturn(); }
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); } } }
/** * Constructs a new instance using the underlying specified archive, which is required * * @param archive */ public ServiceActivatorArchiveImpl(ArchiveBase<?> archive) { super(archive); if (getArchive().getName().endsWith(".war")) { Node node = getArchive().get("WEB-INF/classes/META-INF/services/" + ServiceActivator.class.getName()); if (node != null) { Asset maybeCorrect = node.getAsset(); if (maybeCorrect instanceof ServiceActivatorAsset) { this.asset = (ServiceActivatorAsset) maybeCorrect; } else { this.asset = new ServiceActivatorAsset(maybeCorrect.openStream()); } } else { this.asset = new ServiceActivatorAsset(); getArchive().add(this.asset, "WEB-INF/classes/META-INF/services/" + ServiceActivator.class.getName()); } } else if (getArchive().getName().endsWith(".jar")) { Node node = getArchive().get("META-INF/services/" + ServiceActivator.class.getName()); if (node != null) { this.asset = (ServiceActivatorAsset) node.getAsset(); } else { this.asset = new ServiceActivatorAsset(); getArchive().add(this.asset, "META-INF/services/" + ServiceActivator.class.getName()); } } }
@Override public DatasourceArchive dataSource(DataSource ds) { if (ds.jndiName() == null) { ds.jndiName("java:jboss/datasources/" + ds.getKey()); } String name = ds.getKey() + "-ds.xml"; getArchive().add(new DSXmlAsset(ds), "META-INF/" + name); return this; } }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#add(org.jboss.shrinkwrap.api.Archive, org.jboss.shrinkwrap.api.ArchivePath, * java.lang.Class) */ @Override public T add(final Archive<?> archive, final ArchivePath path, Class<? extends StreamExporter> exporter) { // Precondition checks Validate.notNull(path, "No path was specified"); Validate.notNull(archive, "No archive was specified"); Validate.notNull(exporter, "No exporter was specified"); // Make a Path final String archiveName = archive.getName(); final ArchivePath contentPath = new BasicPath(path, archiveName); // Create ArchiveAsset final ArchiveAsset archiveAsset = new ArchiveAsset(archive, exporter); // Delegate return add(archiveAsset, contentPath); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#add(org.jboss.shrinkwrap.api.Archive, org.jboss.shrinkwrap.api.ArchivePath, * java.lang.Class) */ @Override public T add(final Archive<?> archive, final ArchivePath path, Class<? extends StreamExporter> exporter) { // Precondition checks Validate.notNull(path, "No path was specified"); Validate.notNull(archive, "No archive was specified"); Validate.notNull(exporter, "No exporter was specified"); // Make a Path final String archiveName = archive.getName(); final ArchivePath contentPath = new BasicPath(path, archiveName); // Create ArchiveAsset final ArchiveAsset archiveAsset = new ArchiveAsset(archive, exporter); // Delegate return add(archiveAsset, contentPath); }
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); } }