diff options
12 files changed, 59 insertions, 62 deletions
diff --git a/ceilometer-client/src/main/java/com/woorea/openstack/ceilometer/Ceilometer.java b/ceilometer-client/src/main/java/com/woorea/openstack/ceilometer/Ceilometer.java index aa089df..6c18858 100644 --- a/ceilometer-client/src/main/java/com/woorea/openstack/ceilometer/Ceilometer.java +++ b/ceilometer-client/src/main/java/com/woorea/openstack/ceilometer/Ceilometer.java @@ -24,14 +24,14 @@ import com.woorea.openstack.ceilometer.v2.api.ResourcesResource; public class Ceilometer extends OpenStackClient { - private final MetersResource METERS; + private final MetersResource meters; - private final ResourcesResource RESOURCES; + private final ResourcesResource resources; public Ceilometer(String endpoint, OpenStackClientConnector connector) { super(endpoint, connector); - METERS = new MetersResource(this); - RESOURCES = new ResourcesResource(this); + meters = new MetersResource(this); + resources = new ResourcesResource(this); } public Ceilometer(String endpoint) { @@ -40,11 +40,11 @@ public class Ceilometer extends OpenStackClient { } public ResourcesResource resources() { - return RESOURCES; + return resources; } public MetersResource meters() { - return METERS; + return meters; } } diff --git a/ceilometer-client/src/main/java/com/woorea/openstack/ceilometer/v2/api/MetersResource.java b/ceilometer-client/src/main/java/com/woorea/openstack/ceilometer/v2/api/MetersResource.java index df17c82..ae8f085 100644 --- a/ceilometer-client/src/main/java/com/woorea/openstack/ceilometer/v2/api/MetersResource.java +++ b/ceilometer-client/src/main/java/com/woorea/openstack/ceilometer/v2/api/MetersResource.java @@ -18,16 +18,15 @@ package com.woorea.openstack.ceilometer.v2.api; import com.woorea.openstack.base.client.OpenStackClient; -import com.woorea.openstack.base.client.OpenStackRequest; import com.woorea.openstack.ceilometer.QueriableCeilometerCommand; import com.woorea.openstack.ceilometer.v2.model.Sample; public class MetersResource { - private final OpenStackClient CLIENT; + private final OpenStackClient client; public MetersResource(OpenStackClient client) { - CLIENT = client; + this.client = client; } public List list() { @@ -52,30 +51,30 @@ public class MetersResource { private String name; + public Show() { + + } + public Show name(String name) { this.name = name; return this; } - public Show() { - - } - } public class Statistics extends QueriableCeilometerCommand<Statistics, java.util.List<Statistics>> { private String name; + public Statistics() { + + } + public Statistics name(String name) { this.name = name; return this; } - public Statistics() { - - } - } }
\ No newline at end of file diff --git a/ceilometer-client/src/main/java/com/woorea/openstack/ceilometer/v2/api/ResourcesResource.java b/ceilometer-client/src/main/java/com/woorea/openstack/ceilometer/v2/api/ResourcesResource.java index 9d392f7..3fac7b8 100644 --- a/ceilometer-client/src/main/java/com/woorea/openstack/ceilometer/v2/api/ResourcesResource.java +++ b/ceilometer-client/src/main/java/com/woorea/openstack/ceilometer/v2/api/ResourcesResource.java @@ -25,10 +25,10 @@ import com.woorea.openstack.ceilometer.v2.model.Resource; public class ResourcesResource { - private final OpenStackClient CLIENT; + private final OpenStackClient client; public ResourcesResource(OpenStackClient client) { - CLIENT = client; + this.client = client; } public class ResourceList extends QueriableCeilometerCommand<ResourceList, List<Resource>> { @@ -44,15 +44,15 @@ public class ResourcesResource { private String id; + public ResourceShow(OpenStackClient client) { + + } + public ResourceShow id(String id) { this.id = id; return this; } - public ResourceShow(OpenStackClient client) { - - } - } }
\ No newline at end of file diff --git a/openstack-client-connectors/http-connector/src/main/java/com/woorea/openstack/connector/HttpClientConnector.java b/openstack-client-connectors/http-connector/src/main/java/com/woorea/openstack/connector/HttpClientConnector.java index c266f20..d43e6c9 100644 --- a/openstack-client-connectors/http-connector/src/main/java/com/woorea/openstack/connector/HttpClientConnector.java +++ b/openstack-client-connectors/http-connector/src/main/java/com/woorea/openstack/connector/HttpClientConnector.java @@ -29,7 +29,6 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.UnknownHostException; import java.util.List; -import java.util.Map; import java.util.Map.Entry; import org.apache.http.HttpEntity; @@ -66,7 +65,7 @@ public class HttpClientConnector implements OpenStackClientConnector { public static final ObjectMapper DEFAULT_MAPPER; public static final ObjectMapper WRAPPED_MAPPER; - private static Logger LOGGER = LoggerFactory.getLogger(HttpClientConnector.class); + private static Logger logger = LoggerFactory.getLogger(HttpClientConnector.class); static { DEFAULT_MAPPER = new ObjectMapper(); @@ -120,7 +119,7 @@ public class HttpClientConnector implements OpenStackClientConnector { String entityJson = mapper.writeValueAsString (request.entity().getEntity()); entity = new StringEntity(entityJson, ContentType.create(request.entity().getContentType())); - LOGGER.debug ("Request JSON Body: " + entityJson.replaceAll("\"password\":\"[^\"]*\"", "\"password\":\"***\"")); + logger.debug ("Request JSON Body: " + entityJson.replaceAll("\"password\":\"[^\"]*\"", "\"password\":\"***\"")); } catch (JsonProcessingException e) { throw new HttpClientException ("Json processing error on request entity", e); @@ -142,7 +141,7 @@ public class HttpClientConnector implements OpenStackClientConnector { httpRequest.addHeader(h.getKey(), sb.toString()); } - LOGGER.debug ("Sending HTTP request: " + httpRequest.toString()); + logger.debug ("Sending HTTP request: " + httpRequest.toString()); // Get the Response. But don't get the body entity yet, as this response // will be wrapped in an HttpClientResponse. The HttpClientResponse @@ -155,7 +154,7 @@ public class HttpClientConnector implements OpenStackClientConnector { try { httpResponse = httpClient.execute(httpRequest); - LOGGER.debug ("Response status: " + httpResponse.getStatusLine().getStatusCode()); + logger.debug ("Response status: " + httpResponse.getStatusLine().getStatusCode()); httpClientResponse = new HttpClientResponse (httpResponse); @@ -180,7 +179,7 @@ public class HttpClientConnector implements OpenStackClientConnector { } catch (Exception e) { // Catchall for anything else, must throw as a RuntimeException - LOGGER.error ("Unexpected client exception: " +e.getMessage()); + logger.error ("Unexpected client exception: " +e.getMessage()); throw new RuntimeException("Unexpected client exception", e); } finally { @@ -189,7 +188,7 @@ public class HttpClientConnector implements OpenStackClientConnector { try { httpResponse.close(); } catch (IOException e) { - LOGGER.warn("Unable to close HTTP Response: " + e); + logger.warn("Unable to close HTTP Response: " + e); } } diff --git a/openstack-client-connectors/http-connector/src/main/java/com/woorea/openstack/connector/HttpClientResponse.java b/openstack-client-connectors/http-connector/src/main/java/com/woorea/openstack/connector/HttpClientResponse.java index 99421b8..f1c8c78 100644 --- a/openstack-client-connectors/http-connector/src/main/java/com/woorea/openstack/connector/HttpClientResponse.java +++ b/openstack-client-connectors/http-connector/src/main/java/com/woorea/openstack/connector/HttpClientResponse.java @@ -34,7 +34,7 @@ import java.util.Map; public class HttpClientResponse implements OpenStackResponse { - private static Logger LOGGER = LoggerFactory.getLogger(HttpClientConnector.class); + private static Logger logger = LoggerFactory.getLogger(HttpClientConnector.class); private HttpResponse response = null; private String entityBody = null; @@ -46,7 +46,7 @@ public class HttpClientResponse implements OpenStackResponse { // Read the body so InputStream can be closed if (response.getEntity() == null) { // No body - LOGGER.debug ("No Response Body"); + logger.debug ("No Response Body"); return; } @@ -57,7 +57,7 @@ public class HttpClientResponse implements OpenStackResponse { throw new HttpClientException ("Error Reading Response Body", e); } entityBody = responseBody.toString(); - LOGGER.debug (entityBody); + logger.debug (entityBody); } @@ -94,7 +94,7 @@ public class HttpClientResponse implements OpenStackResponse { public Map<String, String> headers() { Map<String, String> headers = new HashMap<>(); - Header responseHeaders[] = response.getAllHeaders(); + Header[] responseHeaders = response.getAllHeaders(); for (Header h : responseHeaders) { headers.put(h.getName(), h.getValue()); } diff --git a/openstack-client/src/main/java/com/woorea/openstack/base/client/Entity.java b/openstack-client/src/main/java/com/woorea/openstack/base/client/Entity.java index c68a308..1e2dfcc 100644 --- a/openstack-client/src/main/java/com/woorea/openstack/base/client/Entity.java +++ b/openstack-client/src/main/java/com/woorea/openstack/base/client/Entity.java @@ -24,6 +24,12 @@ public class Entity<T> { private String contentType; + public Entity(T entity, String contentType) { + super(); + this.entity = entity; + this.contentType = contentType; + } + public static <T> Entity<T> json(T entity) { return new Entity<>(entity, "application/json"); } @@ -32,12 +38,6 @@ public class Entity<T> { return new Entity<>(entity, "application/octet-stream"); } - public Entity(T entity, String contentType) { - super(); - this.entity = entity; - this.contentType = contentType; - } - /** * @return the entity */ diff --git a/openstack-client/src/main/java/com/woorea/openstack/base/client/OpenStackClient.java b/openstack-client/src/main/java/com/woorea/openstack/base/client/OpenStackClient.java index 23ee8dc..a111975 100644 --- a/openstack-client/src/main/java/com/woorea/openstack/base/client/OpenStackClient.java +++ b/openstack-client/src/main/java/com/woorea/openstack/base/client/OpenStackClient.java @@ -29,38 +29,38 @@ public class OpenStackClient { protected OpenStackTokenProvider tokenProvider; - protected static int AUTHENTICATION_RETRIES = 1; + protected static int authenticationRetries = 1; protected OpenStackClientConnector connector; protected Properties properties = new Properties(); - protected static OpenStackClientConnector DEFAULT_CONNECTOR; + protected static OpenStackClientConnector defaultConnector; static { ServiceLoader<OpenStackClientConnector> connectorLoader; connectorLoader = ServiceLoader.load(OpenStackClientConnector.class); for (OpenStackClientConnector clientConnector : connectorLoader) { - DEFAULT_CONNECTOR = clientConnector; + defaultConnector = clientConnector; break; } } public OpenStackClient(String endpoint) { this.endpoint = endpoint; - this.connector = DEFAULT_CONNECTOR; + this.connector = defaultConnector; } public OpenStackClient(String endpoint, OpenStackClientConnector connector) { this.endpoint = endpoint; - this.connector = (connector == null) ? DEFAULT_CONNECTOR : connector; + this.connector = (connector == null) ? defaultConnector : connector; } public <T> OpenStackResponse request(OpenStackRequest<T> request) { OpenStackResponseException authException = null; - for (int i = 0; i <= AUTHENTICATION_RETRIES; i++) { + for (int i = 0; i <= authenticationRetries; i++) { request.endpoint(endpoint); if (tokenProvider != null) { diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/GatewayInfo.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/GatewayInfo.java index 9ef68ff..88fb6a4 100644 --- a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/GatewayInfo.java +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/GatewayInfo.java @@ -16,8 +16,6 @@ package com.woorea.openstack.quantum.model; -import java.util.List; - import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Router.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Router.java index 722bb0d..d180a12 100644 --- a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Router.java +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Router.java @@ -36,7 +36,7 @@ public class Router implements Serializable { private String name; @JsonProperty("admin_state_up") - private String admin_state_up; + private String adminStateUp; @JsonProperty("tenant_id") private String tenantId; @@ -59,11 +59,11 @@ public class Router implements Serializable { public void setRoutes(List<HostRoute> routes) { this.routes = routes; } - public String getAdmin_state_up() { - return admin_state_up; + public String getAdminStateUp() { + return adminStateUp; } - public void setAdmin_state_up(String admin_state_up) { - this.admin_state_up = admin_state_up; + public void setAdminStateUp(String adminStateUp) { + this.adminStateUp = adminStateUp; } public String getStatus() { return status; diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterForCreate.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterForCreate.java index c524ef5..6f5ddae 100644 --- a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterForCreate.java +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterForCreate.java @@ -32,7 +32,7 @@ public class RouterForCreate implements Serializable { private List<HostRoute> routes; @JsonProperty("admin_state_up") - private String admin_state_up; + private String adminStateUp; @JsonProperty("status") private String status; @@ -58,11 +58,12 @@ public class RouterForCreate implements Serializable { public void setRoutes(List<HostRoute> routes) { this.routes = routes; } - public String getAdmin_state_up() { - return admin_state_up; + public String getAdminStateUp() { + return adminStateUp; } - public void setAdmin_state_up(String admin_state_up) { - this.admin_state_up = admin_state_up; + + public void setAdminStateUp(String adminStateUp) { + this.adminStateUp = adminStateUp; } public String getStatus() { return status; diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/RouterForCreateTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/RouterForCreateTest.java index b84e639..31a0373 100644 --- a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/RouterForCreateTest.java +++ b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/RouterForCreateTest.java @@ -84,9 +84,9 @@ public class RouterForCreateTest { Assert.assertEquals(2, routes.size()); routerforcreate.setRoutes(routes); - String admin_state_up = routerforcreate.getAdmin_state_up(); + String admin_state_up = routerforcreate.getAdminStateUp(); Assert.assertNotNull(admin_state_up); - routerforcreate.setAdmin_state_up(admin_state_up); + routerforcreate.setAdminStateUp(admin_state_up); String name = routerforcreate.getName(); Assert.assertNotNull(name); diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/RouterTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/RouterTest.java index b75cac8..81573df 100644 --- a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/RouterTest.java +++ b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/RouterTest.java @@ -84,9 +84,9 @@ public class RouterTest { Assert.assertEquals(2, routes.size()); router.setRoutes(routes); - String admin_state_up = router.getAdmin_state_up(); + String admin_state_up = router.getAdminStateUp(); Assert.assertNotNull(admin_state_up); - router.setAdmin_state_up(admin_state_up); + router.setAdminStateUp(admin_state_up); String name = router.getName(); Assert.assertNotNull(name); |