Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (C) 2013 Stefan Niederhauser ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package guru.nidi.atlassian.remote.jira.rest;
import com.atlassian.jira.rpc.soap.beans.*;
import guru.nidi.atlassian.remote.jira.RemoteIssueExt;
import guru.nidi.atlassian.remote.rest.RestException;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.HttpGet;
import java.io.IOException;
import java.io.InputStream;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
*
*/
public class JiraRestService {
private final JiraRestAccess access;
public JiraRestService(String baseUrl, String username, String password) {
access = new JiraRestAccess(baseUrl, username, password);
}
public Object executePost(String command, Object parameters) throws RestException, IOException {
return access.executePost(command, parameters);
}
public Object executeGet(String command) throws RestException, IOException {
return access.executeGet(command);
}
public List getIssueLinkTypes() throws IOException, RestException {
HttpGet method = access.get("issueLinkType");
HttpResponse response = access.executeMethod(method);
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
Map errorMsg = access.readResponse(response, JiraRestAccess.MAP_TYPE_REFERENCE);
throw new RestException(errorMsg);
}
Map> res = access.readResponse(response, JiraRestAccess.MAP_WITH_LINKTYPES_TYPE_REFERENCE);
return res.get("issueLinkTypes");
}
public void linkIssues(IssueLink issueLink) throws IOException, RestException {
access.executePost("issueLink", issueLink);
}
public InputStream loadAttachment(RemoteAttachment attachment) throws IOException, RestException {
Map info = (Map) access.executeGet("attachment/" + attachment.getId());
String url = (String) info.get("content");
HttpGet get = new HttpGet(url);
HttpResponse response = access.executeMethod(get);
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
throw new IOException("Could not load attachment. Status: " + response.getStatusLine().getStatusCode() + ", " + response.getStatusLine().getReasonPhrase());
}
return response.getEntity().getContent();
}
public List getAllProjects() throws IOException, RestException {
final List