You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2013/05/10 18:26:09 UTC

svn commit: r1481078 - /sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/TopologyWebConsolePlugin.java

Author: cziegeler
Date: Fri May 10 16:26:09 2013
New Revision: 1481078

URL: http://svn.apache.org/r1481078
Log:
SLING-2865 :  Topology web console is not context path aware 

Modified:
    sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/TopologyWebConsolePlugin.java

Modified: sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/TopologyWebConsolePlugin.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/TopologyWebConsolePlugin.java?rev=1481078&r1=1481077&r2=1481078&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/TopologyWebConsolePlugin.java (original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/TopologyWebConsolePlugin.java Fri May 10 16:26:09 2013
@@ -153,19 +153,19 @@ public class TopologyWebConsolePlugin ex
 
         if (pathInfo.equals("")) {
             if ( this.currentView != null ) {
-                renderOverview(pw,  currentView);
+                renderOverview(pw,  req.getContextPath(), currentView);
             }
         } else {
             StringTokenizer st = new StringTokenizer(pathInfo, "/");
             final String nodeId = st.nextToken();
-            renderProperties(pw, nodeId);
+            renderProperties(pw, req.getContextPath(), nodeId);
         }
     }
 
     /**
      * Render the properties page of a particular instance
      */
-    private void renderProperties(final PrintWriter pw, final String nodeId) {
+    private void renderProperties(final PrintWriter pw, final String contextPath, final String nodeId) {
     	if (logger.isDebugEnabled()) {
     		logger.debug("renderProperties: nodeId=" + nodeId);
     	}
@@ -178,8 +178,7 @@ public class TopologyWebConsolePlugin ex
                     public boolean accept(InstanceDescription instance) {
                         String slingId = instance.getSlingId();
                     	if (logger.isDebugEnabled()) {
-	                        logger.debug("renderProperties/picks: slingId="
-	                                + slingId);
+	                        logger.debug("renderProperties/picks: slingId={}", slingId);
                     	}
                         return (slingId.equals(nodeId));
                     }
@@ -218,10 +217,12 @@ public class TopologyWebConsolePlugin ex
     /**
      * Render the overview of the entire topology
      */
-    private void renderOverview(final PrintWriter pw, final TopologyView topology) {
+    private void renderOverview(final PrintWriter pw, final String contextPath, final TopologyView topology) {
         pw.println("<p class=\"statline ui-state-highlight\">Configuration</p>");
         pw.println("<br/>");
-        pw.println("<a href=\"/system/console/configMgr/org.apache.sling.discovery.impl.Config\">Configure Discovery Service</a>");
+        pw.print("<a href=\"");
+        pw.print(contextPath);
+        pw.println("/system/console/configMgr/org.apache.sling.discovery.impl.Config\">Configure Discovery Service</a>");
         pw.println("<br/>");
         pw.println("<br/>");
         final String changing;
@@ -250,7 +251,7 @@ public class TopologyWebConsolePlugin ex
         Set<ClusterView> clusters = topology.getClusterViews();
         ClusterView myCluster = topology.getLocalInstance().getClusterView();
         boolean odd = true;
-        renderCluster(pw, myCluster, odd);
+        renderCluster(pw, contextPath, myCluster, odd);
 
         for (Iterator<ClusterView> it = clusters.iterator(); it.hasNext();) {
             ClusterView clusterView = it.next();
@@ -259,7 +260,7 @@ public class TopologyWebConsolePlugin ex
                 continue;
             }
             odd = !odd;
-            renderCluster(pw, clusterView, odd);
+            renderCluster(pw, contextPath, clusterView, odd);
         }
 
         pw.println("</tbody>");
@@ -295,7 +296,7 @@ public class TopologyWebConsolePlugin ex
     /**
      * Render a particular cluster (into table rows)
      */
-    private void renderCluster(final PrintWriter pw, final ClusterView cluster, final boolean odd) {
+    private void renderCluster(final PrintWriter pw, final String contextPath, final ClusterView cluster, final boolean odd) {
         final Collection<Announcement> announcements = announcementRegistry
                 .listAnnouncements(ListScope.AllInSameCluster);
 
@@ -326,14 +327,22 @@ public class TopologyWebConsolePlugin ex
                 pw.println("<tr class=\"" + oddEven + " ui-state-error\">");
             }
             final boolean isLocal = instanceDescription.isLocal();
-            String slingId = instanceDescription.getSlingId();
-            slingId = "<a href=\"/system/console/topology/" + slingId + "\">"
-                    + slingId + "</a>";
-            if (isLocal) {
-                slingId = "<b>" + slingId + "</b>";
+            final String slingId = instanceDescription.getSlingId();
+            pw.print("<td>");
+            if ( isLocal) {
+                pw.print("<b>");
+            }
+            pw.print("<a href=\"");
+            pw.print(contextPath);
+            pw.print("/system/console/topology/");
+            pw.print(slingId);
+            pw.print("\">");
+            pw.print(slingId);
+            pw.print("</a>");
+            if ( isLocal) {
+                pw.print("</b>");
             }
-
-            pw.println("<td>" + slingId + "</td>");
+            pw.println("</td>");
             pw.println("<td>"
                     + (instanceDescription.getClusterView() == null ? "null"
                             : instanceDescription.getClusterView().getId())
@@ -407,7 +416,7 @@ public class TopologyWebConsolePlugin ex
                 final String tooltipText;
                 switch(statusCode) {
                 case HttpServletResponse.SC_UNAUTHORIZED:
-                    tooltipText = HttpServletResponse.SC_UNAUTHORIZED + 
+                    tooltipText = HttpServletResponse.SC_UNAUTHORIZED +
                         ": possible setup issue of discovery.impl on target instance";
                     break;
                 case HttpServletResponse.SC_NOT_FOUND: