public < T > List < T > getObjectsList ( Class < T > objectClass , Collection < ? extends NameValuePair > params ) throws RedmineException { final EntityConfig < T > config = getConfig ( objectClass ) ; final List < T > result = new ArrayList < T > ( ) ; final List < NameValuePair > newParams = new ArrayList < NameValuePair > ( params ) ; newParams . add ( new BasicNameValuePair ( "limit" , String . valueOf ( objectsPerPage ) ) ) ; int offset = 0 ; int totalObjectsFoundOnServer ; do { List < NameValuePair > paramsList = new ArrayList < NameValuePair > ( newParams ) ; paramsList . add ( new BasicNameValuePair ( "offset" , String . valueOf ( offset ) ) ) ; final URI uri = getURIConfigurator ( ) . getObjectsURI ( objectClass , paramsList ) ; logger . debug ( uri . toString ( ) ) ; final HttpGet http = new HttpGet ( uri ) ; final String response = getCommunicator ( ) . sendRequest ( http ) ; logger . debug ( "received: " + response ) ; final List < T > foundItems ; try { final JSONObject responseObject = RedmineJSONParser . getResponse ( response ) ; foundItems = JsonInput . getListOrNull ( responseObject , config . multiObjectName , config . parser ) ; result . addAll ( foundItems ) ; /* Necessary for trackers */ if ( ! responseObject . has ( KEY_TOTAL_COUNT ) ) { break ; } totalObjectsFoundOnServer = JsonInput . getInt ( responseObject , KEY_TOTAL_COUNT ) ; } catch ( JSONException e ) { throw new RedmineFormatException ( e ) ; } if ( foundItems . size ( ) == 0 ) { break ; } offset += foundItems . size ( ) ; } while ( offset < totalObjectsFoundOnServer ) ; return result ; }
Returns an object list .