Relativize paths in java/14/checksums.properties and java/14/fqn2files.properties.
1.1 --- a/remoting/server/indexer/impl/src/org/netbeans/modules/jackpot30/backend/impl/OptionProcessorImpl.java Thu Nov 29 18:54:05 2012 +0100
1.2 +++ b/remoting/server/indexer/impl/src/org/netbeans/modules/jackpot30/backend/impl/OptionProcessorImpl.java Thu Nov 29 19:33:30 2012 +0100
1.3 @@ -46,7 +46,9 @@
1.4 import java.io.FileOutputStream;
1.5 import java.io.IOException;
1.6 import java.io.InputStream;
1.7 +import java.io.OutputStream;
1.8 import java.util.Arrays;
1.9 +import java.util.Collection;
1.10 import java.util.Collections;
1.11 import java.util.HashMap;
1.12 import java.util.HashSet;
1.13 @@ -211,7 +213,7 @@
1.14
1.15 try {
1.16 out = new JarOutputStream(new FileOutputStream(cache));
1.17 - pack(out, cacheTemp, "index", new StringBuilder(categoryId));
1.18 + pack(out, cacheTemp, null, "index", new StringBuilder(categoryId));
1.19
1.20 segments = cacheFolder.getFileObject("segments").getInputStream();
1.21 Properties in = new Properties();
1.22 @@ -292,7 +294,7 @@
1.23
1.24 local = new JarOutputStream(out);
1.25
1.26 - pack(local, s, "", new StringBuilder(""));
1.27 + pack(local, s, baseDir.toURI().toString(), "", new StringBuilder(""));
1.28 } finally {
1.29 if (local != null) {
1.30 local.finish();
1.31 @@ -447,7 +449,7 @@
1.32 }
1.33 }
1.34
1.35 - private void pack(JarOutputStream target, FileObject index, String name, StringBuilder relPath) throws IOException {
1.36 + private void pack(JarOutputStream target, FileObject index, String baseURL, String name, StringBuilder relPath) throws IOException {
1.37 int len = relPath.length();
1.38 boolean first = relPath.length() == 0;
1.39
1.40 @@ -464,7 +466,11 @@
1.41 InputStream in = index.getInputStream();
1.42
1.43 try {
1.44 - FileUtil.copy(in, target);
1.45 + if (baseURL != null && ("java/14/checksums.properties".contentEquals(relPath) || "java/14/fqn2files.properties".contentEquals(relPath))) {
1.46 + fixAbsolutePath(in, target, baseURL, "rel:/");
1.47 + } else {
1.48 + FileUtil.copy(in, target);
1.49 + }
1.50 } finally {
1.51 in.close();
1.52 }
1.53 @@ -472,10 +478,30 @@
1.54
1.55 for (FileObject c : index.getChildren()) {
1.56 if (first && c.getNameExt().equals("segments")) continue;
1.57 - pack(target, c, c.getNameExt(), relPath);
1.58 + pack(target, c, baseURL, c.getNameExt(), relPath);
1.59 }
1.60
1.61 relPath.delete(len, relPath.length());
1.62 }
1.63
1.64 + private void fixAbsolutePath(InputStream original, OutputStream target, String origPrefix, String targetPrefix) throws IOException {
1.65 + Properties inProps = new Properties();
1.66 +
1.67 + inProps.load(original);
1.68 +
1.69 + Properties outProps = new Properties();
1.70 +
1.71 + for (String k : (Collection<String>) (Collection) inProps.keySet()) {
1.72 + String orig = inProps.getProperty(k);
1.73 +
1.74 + //XXX: should only change key or value as appropriate:
1.75 + if (k.startsWith(origPrefix)) k = targetPrefix + k.substring(origPrefix.length());
1.76 + if (orig.startsWith(origPrefix)) orig = targetPrefix + orig.substring(origPrefix.length());
1.77 +
1.78 + outProps.setProperty(k, orig);
1.79 + }
1.80 +
1.81 +
1.82 + outProps.store(target, "");
1.83 + }
1.84 }