Tomas Jelinek has uploaded a new change for review.

Change subject: core: calculate the engine base url if not provided
......................................................................

core: calculate the engine base url if not provided

If the engine base URL is not provided, calculate it from data available in
EngineLocalConfig.

Change-Id: Ibb6eba8a1becce0d08596db20886361258289c09
Signed-off-by: Tomas Jelinek <tjeli...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ConfigureConsoleOptionsQuery.java
M 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/EngineLocalConfig.java
2 files changed, 22 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/62/42262/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ConfigureConsoleOptionsQuery.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ConfigureConsoleOptionsQuery.java
index bda542e..754e1e2 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ConfigureConsoleOptionsQuery.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ConfigureConsoleOptionsQuery.java
@@ -16,6 +16,7 @@
 import org.ovirt.engine.core.common.queries.VdcQueryParametersBase;
 import org.ovirt.engine.core.common.queries.VdcQueryReturnValue;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
+import org.ovirt.engine.core.utils.EngineLocalConfig;
 
 import java.net.MalformedURLException;
 import java.net.URI;
@@ -126,7 +127,7 @@
             return;
         }
 
-        String engineBaseUrlString = 
sanitizeUrl(getParameters().getEngineBaseUrl());
+        String engineBaseUrlString = 
calculateEngineBaseUrl(sanitizeUrl(getParameters().getEngineBaseUrl()));
         String consoleClientResourcesUrl = 
sanitizeUrl(getParameters().getConsoleClientResourcesUrl());
 
         
options.setRemoteViewerSupportedVersions(remoteViewerSupportedVersions);
@@ -134,6 +135,21 @@
         fillRemoteViewerUrl(options, remoteViewerNewerVersionUrl, 
engineBaseUrlString, consoleClientResourcesUrl);
     }
 
+    /**
+     * If passed explicitly, just return it. If not, return the one calculated 
from ENGINE_FQDN and ENGINE_PROXY_HTTPS_PORT
+     */
+    private String calculateEngineBaseUrl(String passedUrl) {
+        if (!StringUtils.isEmpty(passedUrl)) {
+            return passedUrl;
+        }
+
+        try {
+            return 
EngineLocalConfig.getInstance().getExternalHttpsBaseUrl("").toString();
+        } catch (MalformedURLException e) {
+            return "";
+        }
+    }
+
     private String sanitizeUrl(String url) {
         if (StringUtils.isEmpty(url)) {
             return "";
diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/EngineLocalConfig.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/EngineLocalConfig.java
index ee00fce..8b0b7a0 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/EngineLocalConfig.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/EngineLocalConfig.java
@@ -189,7 +189,11 @@
      *     number of the URL
      */
     public URL getExternalHttpsUrl(String path) throws MalformedURLException {
-        return new URL("https", getHost(), getExternalHttpsPort(), 
getEngineURI() + path);
+        return getExternalHttpsBaseUrl(getEngineURI() + path);
+    }
+
+    public URL getExternalHttpsBaseUrl(String path) throws 
MalformedURLException {
+        return new URL("https", getHost(), getExternalHttpsPort(), path);
     }
 
     public File getPKIDir() {


-- 
To view, visit https://gerrit.ovirt.org/42262
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibb6eba8a1becce0d08596db20886361258289c09
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Tomas Jelinek <tjeli...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to