Class Transport
- java.lang.Object
-
- com.taskadapter.redmineapi.internal.Transport
-
public final class Transport extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Transport(URIConfigurator configurator, Communicator communicator)Transport(URIConfigurator configurator, org.apache.http.client.HttpClient client)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <T> TaddChildEntry(java.lang.Class<?> parentClass, java.lang.String parentId, T object, RequestParam... params)Performs an "add child object" request.<T> TaddObject(T object, RequestParam... params)Performs an "add object" request.voidaddUserToGroup(int userId, int groupId)voidaddWatcherToIssue(int watcherId, int issueId)<T> voiddeleteChildId(java.lang.Class<?> parentClass, java.lang.String parentId, T object, java.lang.Integer value)Performs "delete child Id" request.<T extends Identifiable>
voiddeleteObject(java.lang.Class<T> classs, java.lang.String id)Deletes an object.<R> Rdownload(java.lang.String uri, ContentHandler<BasicHttpResponse,R> handler)Downloads redmine content.<T> java.util.List<T>getChildEntries(java.lang.Class<?> parentClass, int parentId, java.lang.Class<T> classs)<T> java.util.List<T>getChildEntries(java.lang.Class<?> parentClass, java.lang.String parentKey, java.lang.Class<T> classs)Delivers a list of a child entries.<T> TgetChildEntry(java.lang.Class<?> parentClass, java.lang.String parentId, java.lang.Class<T> classs, java.lang.String childId, RequestParam... params)Delivers a single child entry by its identifier.UsergetCurrentUser(RequestParam... params)<T> org.json.JSONObjectgetJsonResponseFromGet(java.lang.Class<T> objectClass, java.util.Collection<? extends RequestParam> params)Use this method if you need direct access to Json results.<T> TgetObject(java.lang.Class<T> classs, java.lang.Integer key, RequestParam... params)<T> TgetObject(java.lang.Class<T> classs, java.lang.String key, RequestParam... params)<T> java.util.List<T>getObjectsList(java.lang.Class<T> objectClass, RequestParam... params)<T> java.util.List<T>getObjectsList(java.lang.Class<T> objectClass, java.util.Collection<? extends RequestParam> params)Returns all objects found using the provided parameters.<T> ResultsWrapper<T>getObjectsListNoPaging(java.lang.Class<T> objectClass, java.util.Collection<? extends RequestParam> params)Returns an object list.voidsetObjectsPerPage(int pageSize)This number of objects (tasks, projects, users) will be requested from Redmine server in 1 request.voidsetOnBehalfOfUser(java.lang.String loginName)This works only when the main authentication has led to Redmine Admin level user.<T> voidupdateChildEntry(java.lang.Class<?> parentClass, java.lang.String parentId, T obj, java.lang.String objId, RequestParam... params)<T extends Identifiable>
voidupdateObject(T obj, RequestParam... params)java.lang.Stringupload(java.io.InputStream content)Deprecated.java.lang.Stringupload(java.io.InputStream content, long contentLength)
-
-
-
Constructor Detail
-
Transport
public Transport(URIConfigurator configurator, org.apache.http.client.HttpClient client)
-
Transport
public Transport(URIConfigurator configurator, Communicator communicator)
-
-
Method Detail
-
getCurrentUser
public User getCurrentUser(RequestParam... params) throws RedmineException
- Throws:
RedmineException
-
addObject
public <T> T addObject(T object, RequestParam... params) throws RedmineExceptionPerforms an "add object" request.- Parameters:
object- object to use.params- name params.- Returns:
- object to use.
- Throws:
RedmineException- if something goes wrong.
-
addChildEntry
public <T> T addChildEntry(java.lang.Class<?> parentClass, java.lang.String parentId, T object, RequestParam... params) throws RedmineExceptionPerforms an "add child object" request.- Parameters:
parentClass- parent object id.object- object to use.params- name params.- Returns:
- object to use.
- Throws:
RedmineException- if something goes wrong.
-
updateObject
public <T extends Identifiable> void updateObject(T obj, RequestParam... params) throws RedmineException
- Throws:
RedmineException
-
updateChildEntry
public <T> void updateChildEntry(java.lang.Class<?> parentClass, java.lang.String parentId, T obj, java.lang.String objId, RequestParam... params) throws RedmineException- Throws:
RedmineException
-
deleteChildId
public <T> void deleteChildId(java.lang.Class<?> parentClass, java.lang.String parentId, T object, java.lang.Integer value) throws RedmineExceptionPerforms "delete child Id" request.- Parameters:
parentClass- parent object id.object- object to use.value- child object id.- Throws:
RedmineException- if something goes wrong.
-
deleteObject
public <T extends Identifiable> void deleteObject(java.lang.Class<T> classs, java.lang.String id) throws RedmineException
Deletes an object.- Parameters:
classs- object class.id- object id.- Throws:
RedmineException- if something goes wrong.
-
getObject
public <T> T getObject(java.lang.Class<T> classs, java.lang.String key, RequestParam... params) throws RedmineException- Parameters:
classs- target classkey- item keyparams- extra arguments.- Throws:
RedmineAuthenticationException- invalid or no API access key is used with the server, which requires authorization. Check the constructor arguments.NotFoundException- the object with the given key is not foundRedmineException
-
download
public <R> R download(java.lang.String uri, ContentHandler<BasicHttpResponse,R> handler) throws RedmineExceptionDownloads redmine content.- Parameters:
uri- target uri.handler- content handler.- Returns:
- handler result.
- Throws:
RedmineException- if something goes wrong.
-
upload
@Deprecated public java.lang.String upload(java.io.InputStream content) throws RedmineExceptionDeprecated.Deprecated because Redmine server can return invalid string depending on its configuration. See https://github.com/taskadapter/redmine-java-api/issues/78 .Use
upload(InputStream, long)instead.Uploads content on a server. This method calls
upload(InputStream, long)with -1 as content length.- Parameters:
content- the content stream.- Returns:
- uploaded item token.
- Throws:
RedmineException- if something goes wrong.
-
upload
public java.lang.String upload(java.io.InputStream content, long contentLength) throws RedmineException- Parameters:
content- the contentcontentLength- the length of the content in bytes. you can provide -1 but be aware that some users reported Redmine configuration problems that prevent it from processing -1 correctly. See https://github.com/taskadapter/redmine-java-api/issues/78 for details.- Returns:
- the string token of the uploaded item. see
Attachment.getToken() - Throws:
RedmineException
-
getObject
public <T> T getObject(java.lang.Class<T> classs, java.lang.Integer key, RequestParam... params) throws RedmineException- Parameters:
classs- target classkey- item keyparams- extra arguments.- Throws:
RedmineAuthenticationException- invalid or no API access key is used with the server, which requires authorization. Check the constructor arguments.NotFoundException- the object with the given key is not foundRedmineException
-
getObjectsList
public <T> java.util.List<T> getObjectsList(java.lang.Class<T> objectClass, RequestParam... params) throws RedmineException- Throws:
RedmineException
-
getObjectsList
public <T> java.util.List<T> getObjectsList(java.lang.Class<T> objectClass, java.util.Collection<? extends RequestParam> params) throws RedmineExceptionReturns all objects found using the provided parameters. This method IGNORES "limit" and "offset" parameters and handles paging AUTOMATICALLY for you. Please use getObjectsListNoPaging() method if you want to control paging yourself with "limit" and "offset" parameters.- Returns:
- objects list, never NULL
- Throws:
RedmineException- See Also:
getObjectsListNoPaging(Class, Collection)
-
getObjectsListNoPaging
public <T> ResultsWrapper<T> getObjectsListNoPaging(java.lang.Class<T> objectClass, java.util.Collection<? extends RequestParam> params) throws RedmineException
Returns an object list. Provide your own "limit" and "offset" parameters if you need those, otherwise this method will return the first page of some default size only (this default is controlled by your Redmine configuration).- Returns:
- objects list, never NULL
- Throws:
RedmineException
-
getJsonResponseFromGet
public <T> org.json.JSONObject getJsonResponseFromGet(java.lang.Class<T> objectClass, java.util.Collection<? extends RequestParam> params) throws RedmineException, org.json.JSONExceptionUse this method if you need direct access to Json results.Params params = new Params() .add(...) getJsonResponseFromGet(Issue.class, params);- Throws:
RedmineExceptionorg.json.JSONException
-
getChildEntries
public <T> java.util.List<T> getChildEntries(java.lang.Class<?> parentClass, int parentId, java.lang.Class<T> classs) throws RedmineException- Throws:
RedmineException
-
getChildEntries
public <T> java.util.List<T> getChildEntries(java.lang.Class<?> parentClass, java.lang.String parentKey, java.lang.Class<T> classs) throws RedmineExceptionDelivers a list of a child entries.- Parameters:
classs- target class.- Throws:
RedmineException
-
getChildEntry
public <T> T getChildEntry(java.lang.Class<?> parentClass, java.lang.String parentId, java.lang.Class<T> classs, java.lang.String childId, RequestParam... params) throws RedmineExceptionDelivers a single child entry by its identifier.- Throws:
RedmineException
-
setObjectsPerPage
public void setObjectsPerPage(int pageSize)
This number of objects (tasks, projects, users) will be requested from Redmine server in 1 request.
-
addUserToGroup
public void addUserToGroup(int userId, int groupId) throws RedmineException- Throws:
RedmineException
-
addWatcherToIssue
public void addWatcherToIssue(int watcherId, int issueId) throws RedmineException- Throws:
RedmineException
-
setOnBehalfOfUser
public void setOnBehalfOfUser(java.lang.String loginName)
This works only when the main authentication has led to Redmine Admin level user. The given user name will be sent to the server in "X-Redmine-Switch-User" HTTP Header to indicate that the action (create issue, delete issue, etc) must be done on behalf of the given user name.- Parameters:
loginName- Redmine user login name to provide to the server- See Also:
- Redmine issue 11755
-
-