This is an automated email from the ASF dual-hosted git repository. heneveld pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git
commit eaf265e9b81791150a4e15c2f6a4f121bfb6747f Author: Alex Heneveld <[email protected]> AuthorDate: Thu Mar 23 17:33:56 2023 +0000 notes on supporting a zip url scheme --- .../apache/brooklyn/util/core/ResourceUtils.java | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/brooklyn/util/core/ResourceUtils.java b/core/src/main/java/org/apache/brooklyn/util/core/ResourceUtils.java index 08a9f06ce3..253e4d3b95 100644 --- a/core/src/main/java/org/apache/brooklyn/util/core/ResourceUtils.java +++ b/core/src/main/java/org/apache/brooklyn/util/core/ResourceUtils.java @@ -402,7 +402,33 @@ public class ResourceUtils { if (u!=null) return u.openStream(); else throw new IOException(subUrl+" not found on classpath"); } - + + private InputStream getResourceZip(String url) throws IOException { + // TODO would be nice to support ZIP-wrapping from classpath, either as a protocol or DSL or both + // something like the below (also cf pax wrap:mvn... but i think our need is sufficiently different) + // zip://output-file.zip?contents=/foo/bar + /* contents as string (source) or map (with includes, excludes) or list (of maps); + also available as DSL,as: + $brooklyn:zip: + name: output-file.zip + contents: + - source: /foo/bar + includes: [ ** /sub/**, ** /okay/** ] + excludes: [ ** /*.bak ] + target: "" + - source: / + includes: [ /foo/bar/** ] + excludes: [ ** /*.bak ] + target: "" + */ + assert url.startsWith("zip:"); + String subUrl = url.substring("classpath:".length()); + while (subUrl.startsWith("/")) subUrl = subUrl.substring(1); + URL u = getLoader().getResource(subUrl); + if (u!=null) return u.openStream(); + else throw new IOException(subUrl+" not found on classpath"); + } + private InputStream getResourceViaSftp(String url) throws IOException { assert url.startsWith("sftp://"); String subUrl = url.substring("sftp://".length());
