in vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/RepositoryAddress.java [83:175]
public RepositoryAddress(@NotNull URI uri) throws URISyntaxException {
// decode uri
String path = uri.getPath();
String workspace;
String prefix = "/";
String localPath = "/";
if (path.length() == 0 || "/".equals(path)) {
workspace = "-";
localPath = "/";
} else if (!uri.isAbsolute()) {
// fix format: /wsp/path
int idx1 = path.indexOf('/', 1);
if (idx1 < 0) {
workspace = path.substring(1);
} else {
workspace = path.substring(1, idx1);
localPath = path.substring(idx1);
}
} else {
if (path.charAt(path.length() -1) != '/') {
path = path + "/";
}
int idx1 = -1;
int idx2 = 0;
int idx3 = path.indexOf('/', 1);
while (idx3 > 0) {
String segment = path.substring(idx2, idx3);
if (segment.equals(JCR_ROOT)) {
break;
}
idx1 = idx2;
idx2 = idx3;
idx3 = path.indexOf('/', idx3 + 1);
}
if (idx3 < 0) {
// no jcr_root found
// special case for rmi backward compatibility
if (uri.getScheme() != null && "rmi".equals(uri.getScheme())) {
idx1 = path.indexOf('/', 1);
idx2 = path.indexOf('/', idx1 + 1);
if (idx2 < 0) {
workspace = "-";
prefix = path.substring(0, idx1);
localPath = "/";
} else {
workspace = path.substring(idx1 + 1, idx2);
prefix = path.substring(0, idx1);
int end = path.length();
if (end != idx2 + 1) {
end--;
}
localPath = path.substring(idx2, end);
}
} else {
workspace = idx1 < 0 ? "-" : path.substring(idx1+1,idx2);
prefix = idx1 <= 0 ? "/" : path.substring(0, idx1);
localPath = "/";
}
} else {
workspace = path.substring(idx1 + 1, idx2);
prefix = path.substring(0, idx1);
int end = path.length();
if (end - idx3 > 1) {
end--;
}
localPath = path.substring(idx3, end);
}
}
// sanitize HTTP address (probably wrong place)
if (uri.getScheme() != null && uri.getScheme().startsWith("http")) {
if ("/".equals(prefix) || "/crx".equals(prefix)) {
prefix = "/crx/server";
workspace = "-";
}
}
if (prefix.length() == 0) {
prefix = "/";
}
this.path = localPath;
this.workspace = workspace;
this.specific = uri.resolve(prefix);
StringBuilder buf = new StringBuilder(specific.toString());
if (buf.charAt(buf.length() - 1) != '/') {
buf.append('/');
}
buf.append(workspace);
buf.append(JCR_ROOT);
if (!"/".equals(localPath)) {
buf.append(escapePath(localPath));
}
this.uri = new URI(buf.toString());
}