Skip to content

Commit

Permalink
Merge pull request #10 from anrchen/rt-issue-closure
Browse files Browse the repository at this point in the history
#17 Issue closure for RT
  • Loading branch information
anrchen authored Mar 24, 2018
2 parents 3cd93dc + f1df7f4 commit a530738
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/java/rt/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ public class Constants {
static final String TEXT = "text";
static final String CUSTOM_FIELD = "custom_field";

static final String RESOLVED = "resolved";

}
52 changes: 52 additions & 0 deletions src/java/rt/RT.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,58 @@ public String createIssue() {
return null;
}

}
/**
* ISplints does not have an issue closure method and the documentation for RT does not provide anything regarding
* issue closure therefore it is assumed that closing an issue is done by using the Resolved parameter along with
* id to identify the issue.
*/
public void closeIssue(){

String uri = Config.BASE_URI+"/ticket/new?user="+Config.AGENT_USERNAME+"&pass="+Config.AGENT_PASSWORD;

HttpPost httppost = new HttpPost(uri);
HttpClient httpclient = HttpClientBuilder.create().build();
HttpEntity responseEntity = null;
HttpResponse response = null;

try {

StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("id: " + Constants.ID);
stringBuilder.append("Resolved: "+Constants.RESOLVED);


StringBody content = new StringBody(stringBuilder.toString(),ContentType.TEXT_PLAIN);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addPart("content", content);
httppost.setEntity(builder.build());
System.out.println("Request: " + httppost.getRequestLine()+"\n");

response = httpclient.execute(httppost);
responseEntity = response.getEntity();

}
catch(Exception e){
System.out.println(e.getMessage());
}

if (response !=null){
System.out.println(response.getStatusLine()+"\n");
}
else {
System.out.println("An error occurred");
}

if (responseEntity != null) {
System.out.println(responseEntity.getContentType()+"\nContent-Length: "+responseEntity.getContentLength());
System.out.println("Response for issue closure received: " + responseEntity.toString());
}
else {
System.out.println("An error occurred");
}


}

@Override
Expand Down

0 comments on commit a530738

Please sign in to comment.