1
0
Fork 0

moved deleteComponent to Component class for consistency, replaced getComponent with a passthrough to Component.get, and cleaned up URIs

master
Bob Carroll 2014-05-12 20:34:24 -07:00
parent c15648e30e
commit 869ee63552
2 changed files with 16 additions and 27 deletions

View File

@ -171,7 +171,7 @@ public class Component extends Resource {
JSON result = null; JSON result = null;
try { try {
result = restclient.get(getBaseUri() + "component/" + id); result = restclient.get(getRestUri(id));
} catch (Exception ex) { } catch (Exception ex) {
throw new JiraException("Failed to retrieve component " + id, ex); throw new JiraException("Failed to retrieve component " + id, ex);
} }
@ -198,7 +198,7 @@ public class Component extends Resource {
private static String getRestUri(String id) { private static String getRestUri(String id) {
return getBaseUri() + "component/" + (id != null ? id : ""); return getBaseUri() + "component/" + (id != null ? id : "");
} }
/** /**
* Creates a new JIRA component. * Creates a new JIRA component.
* *
@ -211,5 +211,18 @@ public class Component extends Resource {
FluentCreate fc = new FluentCreate(restclient, project); FluentCreate fc = new FluentCreate(restclient, project);
return fc; return fc;
} }
/**
* Deletes a component from a project.
*
* @throws JiraException failed to delete the component
*/
public void delete() throws JiraException {
try {
restclient.delete(getRestUri(id));
} catch (Exception ex) {
throw new JiraException("Failed to delete component " + id, ex);
}
}
} }

View File

@ -421,30 +421,6 @@ public class JiraClient {
* @throws JiraException failed to obtain the component * @throws JiraException failed to obtain the component
*/ */
public Component getComponent(String id) throws JiraException { public Component getComponent(String id) throws JiraException {
try { return Component.get(restclient, id);
URI uri = restclient.buildURI(Resource.getBaseUri() + "/component/"
+ id);
JSON response = restclient.get(uri);
return new Component(restclient, ((JSONObject) response));
} catch (Exception ex) {
throw new JiraException(ex.getMessage(), ex);
}
}
/**
* Deletes a component from a project.
*
* @param id the component ID
*
* @throws JiraException failed to delete the component
*/
public void deleteComponent(String id) throws JiraException {
try {
URI uri = restclient.buildURI(Resource.getBaseUri() + "component/"
+ id);
JSON response = restclient.delete(uri);
} catch (Exception ex) {
throw new JiraException(ex.getMessage(), ex);
}
} }
} }