Liron Ar has uploaded a new change for review.

Change subject: core: XmlRpcUtils - add method for getting connection info
......................................................................

core: XmlRpcUtils - add method for getting connection info

The following method will return a pair containing URL object and string
of the url.

Change-Id: Ifd739b890dd40ab23c07d0474f56a31dffec2cdf
Signed-off-by: Liron Aravot <[email protected]>
---
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/xmlrpc/XmlRpcUtils.java
1 file changed, 15 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/26/23526/1

diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/xmlrpc/XmlRpcUtils.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/xmlrpc/XmlRpcUtils.java
index a06f300..9332015 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/xmlrpc/XmlRpcUtils.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/xmlrpc/XmlRpcUtils.java
@@ -79,20 +79,32 @@
      */
     public static <T> Pair<T, HttpClient> getConnection(String hostName, int 
port, int clientTimeOut,
             int connectionTimeOut, int clientRetries, Class<T> type, boolean 
isSecure) {
+        Pair<String, URL> urlInfo = getConnectionUrl(hostName, port, null, 
isSecure);
+        if (urlInfo == null) {
+            return null;
+        }
+
+        return getHttpConnection(urlInfo.getSecond(), clientTimeOut, 
connectionTimeOut, clientRetries, type);
+    }
+
+    public static Pair<String, URL> getConnectionUrl(String hostName, int 
port, String path, boolean isSecure) {
         URL serverUrl;
         String prefix;
+        String url;
         if (isSecure) {
             prefix = HTTPS;
         } else {
             prefix = HTTP;
         }
         try {
-            serverUrl = new URL(prefix + hostName + ":" + port);
+            url = prefix + hostName + ":" + port + (path != null ? "/" + path 
: "");
+            serverUrl = new URL(url);
         } catch (MalformedURLException mfue) {
-            log.error("failed to forme the xml-rpc url", mfue);
+            log.error("failed to form the xml-rpc url", mfue);
             return null;
         }
-        return getHttpConnection(serverUrl, clientTimeOut, connectionTimeOut, 
clientRetries, type);
+
+        return new Pair<>(url, serverUrl);
     }
 
     public static void shutDownConnection(HttpClient httpClient) {


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifd739b890dd40ab23c07d0474f56a31dffec2cdf
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Liron Ar <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to