Clover Coverage Report - JDBC Support Utilities 1.0.22
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
../img/srcFileCovDistChart0.png 0% of files have more coverage
40   79   9   5.71
2   68   0.22   7
7     1.29  
1    
 
  Deploy       Line # 11 40 0% 9 49 0% 0.0
 
No Tests
 
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   
 
11    public class Deploy {
12    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd.hhmmss");
13   
 
14  0 toggle public static void main(String[] args) {
15  0 Deploy deploy = new Deploy();
16  0 deploy.run();
17    }
18   
 
19  0 toggle 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   
 
28  0 toggle 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   
 
36  0 toggle 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   
 
53  0 toggle 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   
 
67  0 toggle 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   
 
72  0 toggle 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    }