/** * {@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); }
/** * 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()); } } }
/** * {@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); }
/** * {@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); }
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); } } }
/** * {@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 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); } }
protected void prepareAsset() { Node node = getArchive().get(path()); if (node != null) { Asset maybeCorrect = node.getAsset(); if (maybeCorrect instanceof ServiceActivatorAsset) { setAsset((ServiceActivatorAsset) maybeCorrect); } else { ServiceActivatorAsset read = new ServiceActivatorAsset(maybeCorrect.openStream()); setAsset(read); } } else { setAsset(new ServiceActivatorAsset()); } }
Node content = get(path); if (content == null) { return null;
Node content = get(path); if (content == null) { return null;
/** * {@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#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(); }