com.lesstif.jira.services.ProjectService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jira-rest-api Show documentation
Show all versions of jira-rest-api Show documentation
A Java client library for integrating with the JIRA issue and bug tracking software.
The newest version!
package com.lesstif.jira.services;
import java.io.IOException;
import java.util.List;
import org.apache.commons.configuration.ConfigurationException;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import com.lesstif.jira.Constants;
import com.lesstif.jira.JIRAHTTPClient;
import com.lesstif.jira.project.Project;
import com.sun.jersey.api.client.ClientResponse;
import lombok.Data;
/**
* @see /rest/api/2/project
*
* @author lesstif
*
*/
@Data
public class ProjectService {
private JIRAHTTPClient client = null;
public ProjectService() throws ConfigurationException {
client = new JIRAHTTPClient();
}
public List getProjectList() throws IOException {
if (client == null)
throw new IllegalStateException("HTTP Client not Initailized");
client.setResourceName(Constants.JIRA_RESOURCE_PROJECT);
ClientResponse response = client.get();
String content = response.getEntity(String.class);
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, true);
TypeReference> ref = new TypeReference>(){};
List prj = mapper.readValue(content, ref);
return prj;
}
// get Full project Information
public Project getProjectDetail(String idOrKey) throws IOException {
if (client == null)
throw new IllegalStateException("HTTP Client not Initailized");
client.setResourceName(Constants.JIRA_RESOURCE_PROJECT + "/" + idOrKey);
ClientResponse response = client.get();
String content = response.getEntity(String.class);
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, true);
TypeReference ref = new TypeReference(){};
Project prj = mapper.readValue(content, ref);
return prj;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy