/** * Finds a service by name in the client object. Returns null if the service is not found or if * the service is disabled. * * @param clientObject the json object that represents the client. * @param serviceName the service name * @return the service if found. */ private JsonObject getServiceByName(JsonObject clientObject, String serviceName) { JsonObject services = clientObject.getAsJsonObject("services"); if (services == null) return null; JsonObject service = services.getAsJsonObject(serviceName); if (service == null) return null; JsonPrimitive status = service.getAsJsonPrimitive("status"); if (status == null) return null; String statusStr = status.getAsString(); if (STATUS_DISABLED.equals(statusStr)) return null; if (!STATUS_ENABLED.equals(statusStr)) { getLogger() .warn( String.format( "Status with value '%1$s' for service '%2$s' is unknown", statusStr, serviceName)); return null; } return service; }
/** * Finds a service by name in the client object. Returns null if the service is not found * or if the service is disabled. * * @param clientObject the json object that represents the client. * @param serviceName the service name * @return the service if found. */ private JsonObject getServiceByName(JsonObject clientObject, String serviceName) { JsonObject services = clientObject.getAsJsonObject("services"); if (services == null) return null; JsonObject service = services.getAsJsonObject(serviceName); if (service == null) return null; JsonPrimitive status = service.getAsJsonPrimitive("status"); if (status == null) return null; String statusStr = status.getAsString(); if (STATUS_DISABLED.equals(statusStr)) return null; if (!STATUS_ENABLED.equals(statusStr)) { getLogger().warn(String.format("Status with value '%1$s' for service '%2$s' is unknown", statusStr, serviceName)); return null; } return service; }
/** * Finds a service by name in the client object. Returns null if the service is not found or if * the service is disabled. * * @param clientObject the json object that represents the client. * @param serviceName the service name * @return the service if found. */ private JsonObject getServiceByName(JsonObject clientObject, String serviceName) { JsonObject services = clientObject.getAsJsonObject("services"); if (services == null) return null; JsonObject service = services.getAsJsonObject(serviceName); if (service == null) return null; JsonPrimitive status = service.getAsJsonPrimitive("status"); if (status == null) return null; String statusStr = status.getAsString(); if (STATUS_DISABLED.equals(statusStr)) return null; if (!STATUS_ENABLED.equals(statusStr)) { getLogger() .warn( String.format( "Status with value '%1$s' for service '%2$s' is unknown", statusStr, serviceName)); return null; } return service; }