Skip to content

Commit 69b0b88

Browse files
Adding rest into wildfly
1 parent 4355ca6 commit 69b0b88

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

src/main/java/org/clebert/GitParser.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,17 @@ private JsonObject restJIRA(String JIRA) throws Exception {
186186
return lastJIRAObject;
187187
}
188188
if (restLocation != null) {
189-
URL url = new URL(restLocation + JIRA);
190-
InputStream stream = url.openStream();
191-
192-
lastJIRA = JIRA;
193-
lastJIRAObject = Json.createReader(stream).readObject();
189+
try {
190+
URL url = new URL(restLocation + JIRA);
191+
InputStream stream = url.openStream();
192+
193+
lastJIRA = JIRA;
194+
lastJIRAObject = Json.createReader(stream).readObject();
195+
} catch (Throwable e) {
196+
e.printStackTrace();
197+
lastJIRAObject = null;
198+
lastJIRA = null;
199+
}
194200
return lastJIRAObject;
195201
}
196202
return null;
@@ -242,7 +248,7 @@ public void parse(PrintStream output, String from, String to) throws Exception {
242248

243249
StringBuffer interestingChanges[] = new StringBuffer[interestingFolder.size()];
244250

245-
output.print("<thead><tr><th>#</th><th>Commit</th><th>Date</th><th>Author</th><th>Short Message</th><th>Jira Status</th><th>Adds</th><th>Updates</th><th>Deletes</th>");
251+
output.print("<thead><tr><th>#</th><th>Commit</th><th>Date</th><th>Author</th><th>Short Message</th><th>Jira Status</th><th>Add</th><th>Rep</th><th>Del</th><th>Tot</th>");
246252

247253
for (int i = 0; i < interestingFolder.size(); i++) {
248254
output.print("<th>" + interestingFolder.get(i) + "</th>");
@@ -276,8 +282,12 @@ public void parse(PrintStream output, String from, String to) throws Exception {
276282
for (int i = 0; i < currentJiras.length; i++) {
277283

278284
String jiraIteration = currentJiras[i];
285+
JsonObject object = null;
279286
if (restLocation != null) {
280-
JsonObject object = restJIRA(jiraIteration);
287+
object = restJIRA(jiraIteration);
288+
}
289+
// it could happen the object is returning null for security or something else
290+
if (object != null) {
281291
String issuetype = getField(object, "issuetype");
282292
String status = getField(object, "status");
283293
String resolution = getField(object, "resolution");
@@ -377,7 +387,7 @@ public void parse(PrintStream output, String from, String to) throws Exception {
377387
}
378388
}
379389
}
380-
output.print("<td>" + addition + "</td><td>" + replacement + "</td><td>" + deletion + "</td>");
390+
output.print("<td>" + addition + "</td><td>" + replacement + "</td><td>" + deletion + "</td><td>" + (addition + replacement - deletion) + "</td>");
381391

382392
for (int i = 0; i < interestingChanges.length; i++) {
383393
output.print("<td>" + interestingChanges[i].toString() + "</td>");

src/main/java/org/clebert/WildflyParser.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public static void main(String arg[]) {
3939
setSampleJQL("https://issues.jboss.org/browse/WFLY-1?jql=project%20%3D%20WildFly%20AND%20KEY%20IN");
4040
parser.addInterestingfolder("test").addInterestingfolder("docs/");
4141
PrintStream stream = new PrintStream(new FileOutputStream(arg[1]));
42+
43+
parser.setRestLocation("https://issues.jboss.org/rest/api/2/issue/");
44+
4245
parser.parse(stream, arg[2], arg[3]);
4346

4447
} catch (Exception e) {

0 commit comments

Comments
 (0)