1
0
Fork 0

Added support for fetching remote links

master
Arno van Lumig 2014-12-18 12:24:30 +01:00 committed by Arno van Lumig
parent db94f05235
commit 41e4271d85
3 changed files with 76 additions and 0 deletions

View File

@ -201,6 +201,23 @@ public final class Field {
return results;
}
/**
* Gets a list of remote links from the given object.
*
* @param c a JSONObject instance
* @param restclient REST client instance
*
* @return a list of remote links found in c
*/
public static List<RemoteLink> getRemoteLinks(Object c, RestClient restclient) {
List<RemoteLink> results = new ArrayList<RemoteLink>();
if (c instanceof JSONArray)
results = getResourceArray(RemoteLink.class, c, restclient);
return results;
}
/**
* Gets a date from the given object.
@ -319,6 +336,8 @@ public final class Field {
result = (T)new Priority(restclient, (JSONObject)r);
else if (type == Project.class)
result = (T)new Project(restclient, (JSONObject)r);
else if (type == RemoteLink.class)
result = (T)new RemoteLink(restclient, (JSONObject)r);
else if (type == Resolution.class)
result = (T)new Resolution(restclient, (JSONObject)r);
else if (type == Status.class)

View File

@ -1121,6 +1121,20 @@ public class Issue extends Resource {
public User getReporter() {
return reporter;
}
public List<RemoteLink> getRemoteLinks() throws JiraException {
JSONArray obj;
try {
URI uri = restclient.buildURI(getRestUri(key) + "/remotelink");
JSON json = restclient.get(uri);
obj = (JSONArray) json;
} catch (Exception ex) {
throw new JiraException("Failed to get remote links for issue "
+ key, ex);
}
return Field.getRemoteLinks(obj, restclient);
}
public Resolution getResolution() {
return resolution;

View File

@ -0,0 +1,43 @@
package net.rcarz.jiraclient;
import java.util.Map;
import net.sf.json.JSONObject;
public class RemoteLink extends Resource {
private String remoteUrl;
private String title;
public RemoteLink(RestClient restclient, JSONObject json) {
super(restclient);
if (json != null)
deserialise(json);
}
private void deserialise(JSONObject json) {
Map map = json;
self = Field.getString(map.get("self"));
id = Field.getString(map.get("id"));
Map object = (Map)map.get("object");
remoteUrl = Field.getString(object.get("url"));
title = Field.getString(object.get("title"));
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getRemoteUrl() {
return remoteUrl;
}
public void setRemoteUrl(String remoteUrl) {
this.remoteUrl = remoteUrl;
}
}