diff --git a/src/java/rt/Constants.java b/src/java/rt/Constants.java index 268fb7b..c5f9900 100644 --- a/src/java/rt/Constants.java +++ b/src/java/rt/Constants.java @@ -19,4 +19,6 @@ public class Constants { static final String TEXT = "text"; static final String CUSTOM_FIELD = "custom_field"; + static final String RESOLVED = "resolved"; + } diff --git a/src/java/rt/RT.java b/src/java/rt/RT.java index 95631de..dfed7cd 100644 --- a/src/java/rt/RT.java +++ b/src/java/rt/RT.java @@ -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