@Test public void testGetCreateMetaData(){ String projectKey = "PSAA"; String issueType = "Story"; JSONObject fields= jiraHttpClient.getCreateMetaData(projectKey,issueType); Assert.assertNotNull(fields); }
public JSONObject getCreateMetaData(String projectKey, String issueType){ try{ Map<String, String> params = new HashMap(); params.put("expand", "projects.issuetypes.fields"); params.put("projectKeys", projectKey); params.put("issuetypeNames", issueType); HttpGet httpGet = new HttpGet(JiraHttpHelper.metaDataUri(params)); HttpResponse httpResponse = request(httpGet); if(httpResponse.getStatusLine().getStatusCode()!=200){ handleJiraException(httpResponse); } String json = EntityUtils.toString(httpResponse.getEntity()); JSONObject jsonObject = JiraConverter.objectMapper .readValue(json,JSONObject.class); List<Project> projects = JiraConverter.objectMapper.readValue(jsonObject.get("projects").toString(),new TypeReference<List<Project>>(){}); if(projects.isEmpty() || projects.get(0).getIssuetypes().isEmpty()) { throw new BentenJiraException("Project '"+ projectKey + "' or issue type '" + issueType + "' missing from create metadata. Do you have enough permissions?"); } return projects.get(0).getIssuetypes().get(0).getFields(); }catch(Exception ex){ throw new RuntimeException(ex); } }
JiraHttpClient extends BentenHttpClient { public JSONObject getCreateMetaData(String projectKey, String issueType){ try{ Map<String, String> params = new HashMap(); params.put("expand", "projects.issuetypes.fields"); params.put("projectKeys", projectKey); params.put("issuetypeNames", issueType); HttpGet httpGet = new HttpGet(JiraHttpHelper.metaDataUri(params)); HttpResponse httpResponse = request(httpGet); if(httpResponse.getStatusLine().getStatusCode()!=200){ handleJiraException(httpResponse); } String json = EntityUtils.toString(httpResponse.getEntity()); JSONObject jsonObject = JiraConverter.objectMapper .readValue(json,JSONObject.class); List<Project> projects = JiraConverter.objectMapper.readValue(jsonObject.get("projects").toString(),new TypeReference<List<Project>>(){}); if(projects.isEmpty() || projects.get(0).getIssuetypes().isEmpty()) { throw new BentenJiraException("Project '"+ projectKey + "' or issue type '" + issueType + "' missing from create metadata. Do you have enough permissions?"); } return projects.get(0).getIssuetypes().get(0).getFields(); }catch(Exception ex){ throw new RuntimeException(ex); } } }
JiraHttpClient extends BentenHttpClient { public JSONObject getCreateMetaData(String projectKey, String issueType){ try{ Map<String, String> params = new HashMap(); params.put("expand", "projects.issuetypes.fields"); params.put("projectKeys", projectKey); params.put("issuetypeNames", issueType); HttpGet httpGet = new HttpGet(JiraHttpHelper.metaDataUri(params)); HttpResponse httpResponse = request(httpGet); if(httpResponse.getStatusLine().getStatusCode()!=200){ handleJiraException(httpResponse); } String json = EntityUtils.toString(httpResponse.getEntity()); JSONObject jsonObject = JiraConverter.objectMapper .readValue(json,JSONObject.class); List<Project> projects = JiraConverter.objectMapper.readValue(jsonObject.get("projects").toString(),new TypeReference<List<Project>>(){}); if(projects.isEmpty() || projects.get(0).getIssuetypes().isEmpty()) { throw new BentenJiraException("Project '"+ projectKey + "' or issue type '" + issueType + "' missing from create metadata. Do you have enough permissions?"); } return projects.get(0).getIssuetypes().get(0).getFields(); }catch(Exception ex){ throw new RuntimeException(ex); } }  }
JiraHttpClient extends BentenHttpClient { public JSONObject getCreateMetaData(String projectKey, String issueType){ try{ Map<String, String> params = new HashMap(); params.put("expand", "projects.issuetypes.fields"); params.put("projectKeys", projectKey); params.put("issuetypeNames", issueType); HttpGet httpGet = new HttpGet(JiraHttpHelper.metaDataUri(params)); HttpResponse httpResponse = request(httpGet); if(httpResponse.getStatusLine().getStatusCode()!=200){ handleJiraException(httpResponse); } String json = EntityUtils.toString(httpResponse.getEntity()); JSONObject jsonObject = JiraConverter.objectMapper .readValue(json,JSONObject.class); List<Project> projects = JiraConverter.objectMapper.readValue(jsonObject.get("projects").toString(),new TypeReference<List<Project>>(){}); if(projects.isEmpty() || projects.get(0).getIssuetypes().isEmpty()) { throw new BentenJiraException("Project '"+ projectKey + "' or issue type '" + issueType + "' missing from create metadata. Do you have enough permissions?"); } return projects.get(0).getIssuetypes().get(0).getFields(); }catch(Exception ex){ throw new RuntimeException(ex); } }  List<Issue> searchIssues(String jql,String expandedFields,int maxResults); Issue getIssueDetails(String issueKey,String expandedFields); void updateIssue(String issueKey,Map<String,Object> fields); void logWork(String issueKey,JSONObject jsonObject); void transitionIssue(String issueKey,JSONObject jsonObject); List<Transition> getPossibleTransitions(String issueKey); void comment(String issueKey,JSONObject jsonObject); JSONObject getCreateMetaData(String projectKey, String issueType); String createIssue(Map<String,Object> fields); }
JiraHttpClient extends BentenHttpClient { public JSONObject getCreateMetaData(String projectKey, String issueType){ try{ Map<String, String> params = new HashMap(); params.put("expand", "projects.issuetypes.fields"); params.put("projectKeys", projectKey); params.put("issuetypeNames", issueType); HttpGet httpGet = new HttpGet(JiraHttpHelper.metaDataUri(params)); HttpResponse httpResponse = request(httpGet); if(httpResponse.getStatusLine().getStatusCode()!=200){ handleJiraException(httpResponse); } String json = EntityUtils.toString(httpResponse.getEntity()); JSONObject jsonObject = JiraConverter.objectMapper .readValue(json,JSONObject.class); List<Project> projects = JiraConverter.objectMapper.readValue(jsonObject.get("projects").toString(),new TypeReference<List<Project>>(){}); if(projects.isEmpty() || projects.get(0).getIssuetypes().isEmpty()) { throw new BentenJiraException("Project '"+ projectKey + "' or issue type '" + issueType + "' missing from create metadata. Do you have enough permissions?"); } return projects.get(0).getIssuetypes().get(0).getFields(); }catch(Exception ex){ throw new RuntimeException(ex); } }  List<Issue> searchIssues(String jql,String expandedFields,int maxResults); Issue getIssueDetails(String issueKey,String expandedFields); void updateIssue(String issueKey,Map<String,Object> fields); void logWork(String issueKey,JSONObject jsonObject); void transitionIssue(String issueKey,JSONObject jsonObject); List<Transition> getPossibleTransitions(String issueKey); void comment(String issueKey,JSONObject jsonObject); JSONObject getCreateMetaData(String projectKey, String issueType); String createIssue(Map<String,Object> fields);  }