/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#addAsDirectory(org.jboss.shrinkwrap.api.ArchivePath) */ @Override public T addAsDirectory(final ArchivePath path) throws IllegalArgumentException { // Precondition check Validate.notNull(path, "path must be specified"); // Adjust the path to remove any trailing slash ArchivePath adjustedPath = new BasicPath(PathUtil.optionallyRemoveFollowingSlash(path.get())); return addAsset(adjustedPath, null); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#addDirectory(org.jboss.shrinkwrap.api.ArchivePath) */ @Override public T addDirectory(final ArchivePath path) throws IllegalArgumentException { // Precondition check Validate.notNull(path, "path must be specified"); // Adjust the path to remove any trailing slash ArchivePath adjustedPath = new BasicPath(PathUtil.optionallyRemoveFollowingSlash(path.get())); // Check if it exists. If it doesn't, create it and add it. The same with all the // non-existing parents if (!contains(adjustedPath)) { NodeImpl node = new NodeImpl(adjustedPath); content.put(adjustedPath, node); // retrieve the parent and add the node as a child NodeImpl parentNode = obtainParent(adjustedPath.getParent()); if (parentNode != null) { parentNode.addChild(node); } } return covariantReturn(); }