@ Override public Set < AppdynamicsApplication > getApplications ( String instanceUrl ) { Set < AppdynamicsApplication > returnSet = new HashSet <> ( ) ; try { String url = joinURL ( instanceUrl , APPLICATION_LIST_PATH ) ; ResponseEntity < String > responseEntity = makeRestCall ( url ) ; String returnJSON = responseEntity . getBody ( ) ; JSONParser parser = new JSONParser ( ) ; try { JSONArray array = ( JSONArray ) parser . parse ( returnJSON ) ; for ( Object entry : array ) { JSONObject jsonEntry = ( JSONObject ) entry ; String appName = getString ( jsonEntry , "name" ) ; String appId = String . valueOf ( getLong ( jsonEntry , "id" ) ) ; String desc = getString ( jsonEntry , "description" ) ; if ( StringUtils . isEmpty ( desc ) ) { desc = appName ; } AppdynamicsApplication app = new AppdynamicsApplication ( ) ; app . setAppID ( appId ) ; app . setAppName ( appName ) ; app . setAppDesc ( desc ) ; app . setDescription ( desc ) ; returnSet . add ( app ) ; } } catch ( ParseException e ) { LOG . error ( "Parsing applications on instance: " + instanceUrl , e ) ; } } catch ( RestClientException rce ) { LOG . error ( "client exception loading applications" , rce ) ; throw rce ; } catch ( MalformedURLException mfe ) { LOG . error ( "malformed url for loading applications" , mfe ) ; } return returnSet ; }
Retrieves a JSON array of all of the applications that are registered in AppDynamics .