public boolean syncApplications ( NewRelicCache cache ) { boolean ret = true ; if ( apiClient == null ) throw new IllegalArgumentException ( "null API client" ) ; // Get the application configuration using the REST API if ( cache . isApmEnabled ( ) || cache . isBrowserEnabled ( ) || cache . isMobileEnabled ( ) ) { ret = false ; if ( cache . isApmEnabled ( ) ) { logger . info ( "Getting the applications" ) ; Collection < Application > applications = apiClient . applications ( ) . list ( ) ; for ( Application application : applications ) { cache . applications ( ) . add ( application ) ; logger . fine ( "Getting the hosts for application: " + application . getId ( ) ) ; cache . applications ( ) . applicationHosts ( application . getId ( ) ) . add ( apiClient . applicationHosts ( ) . list ( application . getId ( ) ) ) ; logger . fine ( "Getting the instances for application: " + application . getId ( ) ) ; cache . applications ( ) . applicationHosts ( application . getId ( ) ) . addApplicationInstances ( apiClient . applicationInstances ( ) . list ( application . getId ( ) ) ) ; logger . fine ( "Getting the deployments for application: " + application . getId ( ) ) ; cache . applications ( ) . deployments ( application . getId ( ) ) . add ( apiClient . deployments ( ) . list ( application . getId ( ) ) ) ; } // Get the key transaction configuration using the REST API try { logger . info ( "Getting the key transactions" ) ; cache . applications ( ) . addKeyTransactions ( apiClient . keyTransactions ( ) . list ( ) ) ; } catch ( ErrorResponseException e ) { if ( e . getStatus ( ) == 403 ) // throws 403 if not allowed by subscription logger . warning ( "Error in get key transactions: " + e . getMessage ( ) ) ; else throw e ; } } if ( cache . isBrowserEnabled ( ) ) { logger . info ( "Getting the browser applications" ) ; cache . browserApplications ( ) . add ( apiClient . browserApplications ( ) . list ( ) ) ; } if ( cache . isBrowserEnabled ( ) ) { logger . info ( "Getting the mobile applications" ) ; cache . mobileApplications ( ) . add ( apiClient . mobileApplications ( ) . list ( ) ) ; } cache . setUpdatedAt ( ) ; ret = true ; } return ret ; }
Synchronise the application configuration with the cache .