1 |
|
import java.io.IOException; |
2 |
|
import java.text.ParseException; |
3 |
|
import java.text.SimpleDateFormat; |
4 |
|
|
5 |
|
import org.apache.commons.httpclient.HttpClient; |
6 |
|
import org.apache.commons.httpclient.HttpException; |
7 |
|
import org.apache.commons.httpclient.HttpMethod; |
8 |
|
import org.apache.commons.httpclient.methods.GetMethod; |
9 |
|
import org.apache.commons.lang.StringUtils; |
10 |
|
|
|
|
| 0% |
Uncovered Elements: 49 (49) |
Complexity: 9 |
Complexity Density: 0.22 |
|
11 |
|
public class Deploy { |
12 |
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd.hhmmss"); |
13 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
14 |
0
|
public static void main(String[] args) {... |
15 |
0
|
Deploy deploy = new Deploy(); |
16 |
0
|
deploy.run(); |
17 |
|
} |
18 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
19 |
0
|
public void run() {... |
20 |
0
|
try { |
21 |
0
|
String url = getCurlUrl(); |
22 |
0
|
System.out.println("\n" + url); |
23 |
|
} catch (Throwable t) { |
24 |
0
|
t.printStackTrace(); |
25 |
|
} |
26 |
|
} |
27 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
28 |
0
|
protected String getCurlUrl() throws Exception {... |
29 |
0
|
String url = getUrl("maven-metadata.xml"); |
30 |
0
|
String xml = getContents(url); |
31 |
0
|
BuildInfo bi = getBuildInfo(xml); |
32 |
0
|
String filename = getFilename(bi); |
33 |
0
|
return getUrl(filename); |
34 |
|
} |
35 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 2 |
Complexity Density: 0.15 |
|
36 |
0
|
protected String getFilename(BuildInfo bi) {... |
37 |
0
|
StringBuffer sb = new StringBuffer(); |
38 |
0
|
sb.append(bi.getArtifactId()); |
39 |
0
|
sb.append("-"); |
40 |
0
|
String version = bi.getVersion(); |
41 |
0
|
if (version.endsWith("-SNAPSHOT")) { |
42 |
0
|
version = StringUtils.replace(version, "-SNAPSHOT", ""); |
43 |
|
} |
44 |
0
|
sb.append(version); |
45 |
0
|
sb.append("-"); |
46 |
0
|
sb.append(sdf.format(bi.getTimestamp())); |
47 |
0
|
sb.append("-"); |
48 |
0
|
sb.append(bi.getBuildNumber()); |
49 |
0
|
sb.append(".war"); |
50 |
0
|
return sb.toString(); |
51 |
|
} |
52 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
|
53 |
0
|
protected BuildInfo getBuildInfo(String contents) throws ParseException {... |
54 |
0
|
String artifactId = StringUtils.substringBetween(contents, "<artifactId>", "</artifactId>"); |
55 |
0
|
String version = StringUtils.substringBetween(contents, "<version>", "</version>"); |
56 |
0
|
String buildNumber = StringUtils.substringBetween(contents, "<buildNumber>", "</buildNumber>"); |
57 |
0
|
String timestamp = StringUtils.substringBetween(contents, "<timestamp>", "</timestamp>"); |
58 |
|
|
59 |
0
|
BuildInfo bi = new BuildInfo(); |
60 |
0
|
bi.setArtifactId(artifactId); |
61 |
0
|
bi.setVersion(version); |
62 |
0
|
bi.setBuildNumber(new Integer(buildNumber)); |
63 |
0
|
bi.setTimestamp(sdf.parse(timestamp)); |
64 |
0
|
return bi; |
65 |
|
} |
66 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
67 |
0
|
protected String getUrl(String filename) {... |
68 |
0
|
String base = "http://maven.kuali.org/snapshot/org/kuali/student/web/ks-embedded/1.1.0-M9-SNAPSHOT/"; |
69 |
0
|
return base + filename; |
70 |
|
} |
71 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
72 |
0
|
protected String getContents(String url) throws IOException, HttpException {... |
73 |
0
|
HttpClient client = new HttpClient(); |
74 |
0
|
HttpMethod method = new GetMethod(url); |
75 |
0
|
client.executeMethod(method); |
76 |
0
|
return method.getResponseBodyAsString(); |
77 |
|
} |
78 |
|
|
79 |
|
} |