Repository: stratos
Updated Branches:
  refs/heads/master 4631b1d07 -> 27e438410


Fixing access URL generation logic by using java.net.URL


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/27e43841
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/27e43841
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/27e43841

Branch: refs/heads/master
Commit: 27e4384100f815fefa50af7f5f1ac87efabfddde
Parents: 4631b1d
Author: Imesh Gunaratne <[email protected]>
Authored: Thu Jan 29 10:05:35 2015 +0530
Committer: Imesh Gunaratne <[email protected]>
Committed: Thu Jan 29 10:05:46 2015 +0530

----------------------------------------------------------------------
 .../impl/CloudControllerServiceImpl.java        | 30 ++++++++++++--------
 1 file changed, 18 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/27e43841/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
index c0259a9..ae5c78d 100644
--- 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
+++ 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
@@ -44,6 +44,8 @@ import org.apache.stratos.common.Property;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.event.topology.MemberReadyToShutdownEvent;
 
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.*;
 import java.util.Map.Entry;
 import java.util.concurrent.Callable;
@@ -1056,18 +1058,22 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
                                                List<String> 
accessUrlPerCluster = new ArrayList();
                                                List<PortMapping> portMappings 
= cartridge.getPortMappings();
                                                for (PortMapping portMap : 
portMappings) {
-                                                       if 
(portMap.isKubernetesServicePortMapping()) {
-                                                               String 
accessUrl =
-                                                                               
portMap.getProtocol() + "\\://" + appClusterCtxt.getHostName() + ":" +
-                                                                               
portMap.getKubernetesServicePort();
-                                                               
accessUrlPerCluster.add(accessUrl);
-                                                       } else {
-                                                               String 
accessUrl =
-                                                                               
portMap.getProtocol() + "\\://" + appClusterCtxt.getHostName() + ":" +
-                                                                               
portMap.getProxyPort();
-                                                               
accessUrlPerCluster.add(accessUrl);
-                                                       }
-                                               }
+                                try {
+                                    if 
(portMap.isKubernetesServicePortMapping()) {
+                                        URL accessUrl = new 
URL(portMap.getProtocol(), appClusterCtxt.getHostName(),
+                                                
portMap.getKubernetesServicePort(), "");
+                                        
accessUrlPerCluster.add(accessUrl.toString());
+                                    } else {
+                                        URL accessUrl = new 
URL(portMap.getProtocol(), appClusterCtxt.getHostName(),
+                                                portMap.getProxyPort(), "");
+                                        
accessUrlPerCluster.add(accessUrl.toString());
+                                    }
+                                } catch (MalformedURLException e) {
+                                    String message = "Could not generate 
access URL";
+                                    log.error(message, e);
+                                    throw new 
ApplicationClusterRegistrationException(message, e);
+                                }
+                            }
                                                
accessUrls.put(dependencyClusterIDs[i], accessUrlPerCluster);
                                        }
                                }

Reply via email to