Alon Bar-Lev has uploaded a new change for review.

Change subject: bll: provider: foreman: cleanup: reduce complexity of constants
......................................................................

bll: provider: foreman: cleanup: reduce complexity of constants

cleanup super abstraction of constants use that made it very difficult
to understand what actually is sent to the API.

cleanup use of related unneeded one time temp variable.

Change-Id: Ic5eb3ee187f938412f1e2aebc74a8fcf674707bd
Signed-off-by: Alon Bar-Lev <alo...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/host/provider/foreman/ForemanHostProviderProxy.java
1 file changed, 11 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/13/20913/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/host/provider/foreman/ForemanHostProviderProxy.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/host/provider/foreman/ForemanHostProviderProxy.java
index fbf1eaa..603fc80 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/host/provider/foreman/ForemanHostProviderProxy.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/host/provider/foreman/ForemanHostProviderProxy.java
@@ -33,17 +33,15 @@
 
 public class ForemanHostProviderProxy extends BaseProviderProxy implements 
HostProviderProxy {
 
+    private static final String API_URI = "/api";
+    private static final String HOSTS_SEARCH_QUERY = 
"/hosts?search=%1$s&format=json";
+    private static final String HOSTS_QUERY = "/hosts?format=json";
+
     private Provider hostProvider;
 
     private HttpClient httpClient = new HttpClient();
 
     private ObjectMapper objectMapper = new ObjectMapper();
-    private static final String API_ENTRY_POINT = "/api";
-    private static final String HOSTS_ENTRY_POINT = API_ENTRY_POINT + "/hosts";
-    private static final String JSON_FORMAT = "format=json";
-    private static final String ALL_HOSTS_QUERY = HOSTS_ENTRY_POINT + "?" + 
JSON_FORMAT;
-    private static final String SEARCH_SECTION_FORMAT = "search=%1$s";
-    private static final String SEARCH_QUERY_FORMAT = "?" + 
SEARCH_SECTION_FORMAT + "&" + JSON_FORMAT;
 
     public ForemanHostProviderProxy(Provider hostProvider) {
         super(hostProvider);
@@ -53,8 +51,9 @@
 
     @Override
     public List<VDS> getAll() {
-        HttpMethod method = new GetMethod(ALL_HOSTS_QUERY);
-        return runHostListMethod(method);
+        return runHostListMethod(
+            new GetMethod(API_URI + HOSTS_QUERY)
+        );
     }
 
     private List<VDS> runHostListMethod(HttpMethod httpMethod) {
@@ -84,15 +83,14 @@
 
     @Override
     public List<VDS> getFiltered(String filter) {
-        String url = HOSTS_ENTRY_POINT + String.format(SEARCH_QUERY_FORMAT, 
filter);
-        HttpMethod method = new GetMethod(url);
-        return runHostListMethod(method);
+        return runHostListMethod(
+            new GetMethod(API_URI + String.format(HOSTS_SEARCH_QUERY, filter))
+        );
     }
 
     @Override
     public void testConnection() {
-        HttpMethod httpMethod = new GetMethod(API_ENTRY_POINT);
-        runHttpMethod(httpClient, httpMethod);
+        runHttpMethod(httpClient, new GetMethod(API_URI));
     }
 
     @Override


-- 
To view, visit http://gerrit.ovirt.org/20913
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic5eb3ee187f938412f1e2aebc74a8fcf674707bd
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <alo...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to