Class Transport


  • public final class Transport
    extends java.lang.Object
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      <T> T addChildEntry​(java.lang.Class<?> parentClass, java.lang.String parentId, T object, RequestParam... params)
      Performs an "add child object" request.
      <T> T addObject​(T object, RequestParam... params)
      Performs an "add object" request.
      void addUserToGroup​(int userId, int groupId)  
      void addWatcherToIssue​(int watcherId, int issueId)  
      <T> void deleteChildId​(java.lang.Class<?> parentClass, java.lang.String parentId, T object, java.lang.Integer value)
      Performs "delete child Id" request.
      <T extends Identifiable>
      void
      deleteObject​(java.lang.Class<T> classs, java.lang.String id)
      Deletes an object.
      <R> R download​(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> T getChildEntry​(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.
      User getCurrentUser​(RequestParam... params)  
      <T> org.json.JSONObject getJsonResponseFromGet​(java.lang.Class<T> objectClass, java.util.Collection<? extends RequestParam> params)
      Use this method if you need direct access to Json results.
      <T> T getObject​(java.lang.Class<T> classs, java.lang.Integer key, RequestParam... params)  
      <T> T getObject​(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.
      void setObjectsPerPage​(int pageSize)
      This number of objects (tasks, projects, users) will be requested from Redmine server in 1 request.
      void setOnBehalfOfUser​(java.lang.String loginName)
      This works only when the main authentication has led to Redmine Admin level user.
      <T> void updateChildEntry​(java.lang.Class<?> parentClass, java.lang.String parentId, T obj, java.lang.String objId, RequestParam... params)  
      <T extends Identifiable>
      void
      updateObject​(T obj, RequestParam... params)  
      java.lang.String upload​(java.io.InputStream content)
      Deprecated.
      java.lang.String upload​(java.io.InputStream content, long contentLength)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • addObject

        public <T> T addObject​(T object,
                               RequestParam... params)
                        throws RedmineException
        Performs 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 RedmineException
        Performs 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.
      • 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 RedmineException
        Performs "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.
      • upload

        @Deprecated
        public java.lang.String upload​(java.io.InputStream content)
                                throws RedmineException
        Deprecated.
        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 content
        contentLength - 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
      • getObjectsList

        public <T> java.util.List<T> getObjectsList​(java.lang.Class<T> objectClass,
                                                    java.util.Collection<? extends RequestParam> params)
                                             throws RedmineException
        Returns 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.JSONException
        Use this method if you need direct access to Json results.
                 Params params = new Params()
                   .add(...)
             getJsonResponseFromGet(Issue.class, params);
                 
        Throws:
        RedmineException
        org.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 RedmineException
        Delivers 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 RedmineException
        Delivers 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.
      • 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