X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.init%2Fsrc%2Forg%2Fargeo%2Finit%2Fa2%2FFsA2Source.java;h=e0e2e437f58307c50b60e53500634b3111da2f21;hb=8e83ad78ea94ce72672b535ab421bb68b6b3bae3;hp=d4aa863869aa682f3aec5c92e80e8212d8042f2c;hpb=17b708af147e6e2db666dbbef55e14dc2dddfdc0;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.init/src/org/argeo/init/a2/FsA2Source.java b/org.argeo.init/src/org/argeo/init/a2/FsA2Source.java index d4aa86386..e0e2e437f 100644 --- a/org.argeo.init/src/org/argeo/init/a2/FsA2Source.java +++ b/org.argeo.init/src/org/argeo/init/a2/FsA2Source.java @@ -9,6 +9,7 @@ import java.nio.file.Path; import java.util.HashMap; import java.util.Map; import java.util.SortedMap; +import java.util.StringJoiner; import java.util.TreeMap; import org.argeo.init.osgi.OsgiBootUtils; @@ -17,16 +18,16 @@ import org.osgi.framework.Version; /** A file system {@link AbstractProvisioningSource} in A2 format. */ public class FsA2Source extends AbstractProvisioningSource implements A2Source { private final Path base; - private final Map xOr; + private final Map variantsXOr; // public FsA2Source(Path base) { // this(base, new HashMap<>()); // } - public FsA2Source(Path base, Map xOr, boolean useReference) { - super(useReference); + public FsA2Source(Path base, Map variantsXOr, boolean usingReference) { + super(usingReference); this.base = base; - this.xOr = new HashMap<>(xOr); + this.variantsXOr = new HashMap<>(variantsXOr); } void load() throws IOException { @@ -44,7 +45,7 @@ public class FsA2Source extends AbstractProvisioningSource implements A2Source { } else {// variants Path variantPath = null; // is it an explicit variant? - String variant = xOr.get(contributionPath.getFileName().toString()); + String variant = variantsXOr.get(contributionPath.getFileName().toString()); if (variant != null) { variantPath = contributionPath.resolve(variant); } @@ -119,7 +120,16 @@ public class FsA2Source extends AbstractProvisioningSource implements A2Source { URI baseUri = base.toUri(); try { if (baseUri.getScheme().equals("file")) { - return new URI(SCHEME_A2, null, base.toString(), null); + String queryPart = ""; + if (!getVariantsXOr().isEmpty()) { + StringJoiner sj = new StringJoiner("&"); + for (String key : getVariantsXOr().keySet()) { + sj.add(key + "=" + getVariantsXOr().get(key)); + } + queryPart = sj.toString(); + } + return new URI(isUsingReference() ? SCHEME_A2_REFERENCE : SCHEME_A2, null, base.toString(), queryPart, + null); } else { throw new UnsupportedOperationException("Unsupported scheme " + baseUri.getScheme()); } @@ -128,6 +138,10 @@ public class FsA2Source extends AbstractProvisioningSource implements A2Source { } } + protected Map getVariantsXOr() { + return variantsXOr; + } + // public static void main(String[] args) { // if (args.length == 0) // throw new IllegalArgumentException("Usage: ");