Util.java
1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.day.cq.replication.ReplicationException
*/
package com.adobe.cq.dam.aod.replication;
import com.day.cq.replication.ReplicationException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Util {
private static final Pattern HTTP_SCHEME = Pattern.compile("^https?://.+");
public static <T> T initRef() {
return null;
}
public static URL serverUrl(String transportUri) throws ReplicationException {
try {
URI uri;
URI tUri = new URI(transportUri);
String authority = tUri.getSchemeSpecificPart();
if (!HTTP_SCHEME.matcher(authority).matches()) {
authority = "http:" + authority;
}
Util.require((uri = new URI(authority)).getHost() != null, "Host must be specified in transport URI: " + transportUri);
return new URL(uri.getScheme(), uri.getHost(), uri.getPort(), uri.getPath() + "/publish-receiver");
}
catch (URISyntaxException e) {
throw new ReplicationException("Invalid transport URI: '" + transportUri + "', caused by: " + e);
}
catch (MalformedURLException e) {
throw new AssertionError(e);
}
}
private static void require(boolean cond, String message) {
if (!cond) {
throw new IllegalArgumentException(message);
}
}
}