Merge "Fixed bug when publisher's thread was blocked until all notifications were...
authorEd Warnicke <eaw@cisco.com>
Wed, 12 Feb 2014 06:56:15 +0000 (06:56 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 12 Feb 2014 06:56:15 +0000 (06:56 +0000)
opendaylight/usermanager/api/src/main/java/org/opendaylight/controller/usermanager/AuthenticatedUser.java
opendaylight/usermanager/api/src/test/java/org/opendaylight/controller/usermanager/AuthenticatedUserTest.java
opendaylight/web/troubleshoot/src/main/java/org/opendaylight/controller/troubleshoot/web/Troubleshoot.java
opendaylight/web/troubleshoot/src/main/resources/js/page.js

index 94200e66e077e440fe379711904ca5720dd130f4..809ca134f77cf4cb62e4517d152b0e8b9342f9cd 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.usermanager;
 
 import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 
@@ -47,7 +48,7 @@ public class AuthenticatedUser implements Serializable {
     }
 
     public List<String> getUserRoles() {
-        return userRoles;
+        return userRoles == null ? Collections.<String> emptyList() : new ArrayList<String>(userRoles);
     }
 
     public void addUserRole(String string) {
index b8a1a987694cfec72ae8898256cabe1e12e0fe7f..d32799e3eb7462fc223a1af458a179a5c3a3782d 100644 (file)
@@ -8,15 +8,15 @@
 
 package org.opendaylight.controller.usermanager;
 
+import java.util.Arrays;
+import java.util.List;
+
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.controller.sal.authorization.UserLevel;
 import org.springframework.security.core.GrantedAuthority;
 
-import java.util.Arrays;
-import java.util.List;
-
 public class AuthenticatedUserTest {
 
         static String[] roleArray;
@@ -33,7 +33,7 @@ public class AuthenticatedUserTest {
                 user = new AuthenticatedUser("auser");
 
                 Assert.assertFalse(user.getAccessDate().isEmpty());
-                Assert.assertNull(user.getUserRoles());
+        Assert.assertNotNull(user.getUserRoles());
         }
 
         @Test
index 36b5043dd94ebf6956c499da4ad4909864a9c936..04fbf846b7e820b2f6deaa17f28d0286fc74367a 100644 (file)
@@ -41,6 +41,7 @@ import org.opendaylight.controller.sal.match.Match;
 import org.opendaylight.controller.sal.match.MatchType;
 import org.opendaylight.controller.sal.reader.FlowOnNode;
 import org.opendaylight.controller.sal.reader.NodeConnectorStatistics;
+import org.opendaylight.controller.sal.reader.NodeDescription;
 import org.opendaylight.controller.sal.utils.EtherTypes;
 import org.opendaylight.controller.sal.utils.GlobalConstants;
 import org.opendaylight.controller.sal.utils.HexEncode;
@@ -101,6 +102,30 @@ public class Troubleshoot implements IDaylightWeb {
         return userLevel.ordinal() <= AUTH_LEVEL.ordinal();
     }
 
+    @RequestMapping(value = "/nodeInfo", method = RequestMethod.GET)
+    @ResponseBody
+    public NodeDescription getNodeInfo(HttpServletRequest request, @RequestParam(required = false) String container,
+            @RequestParam(required = true) String nodeId) {
+        List<Map<String, String>> lines = new ArrayList<Map<String, String>>();
+        String containerName = (container == null) ? GlobalConstants.DEFAULT.toString() : container;
+
+        // Derive the privilege this user has on the current container
+        String userName = request.getUserPrincipal().getName();
+        Privilege privilege = DaylightWebUtil.getContainerPrivilege(userName, containerName, this);
+
+        if (privilege != Privilege.NONE) {
+            IStatisticsManager statisticsManager = (IStatisticsManager) ServiceHelper
+                    .getInstance(IStatisticsManager.class, containerName, this);
+            if(statisticsManager != null){
+                Node node = Node.fromString(nodeId);
+                NodeDescription nodeDesc = statisticsManager.getNodeDescription(node);
+                return nodeDesc;
+            }
+        }
+
+        return new NodeDescription();
+    }
+
     @RequestMapping(value = "/existingNodes", method = RequestMethod.GET)
     @ResponseBody
     public TroubleshootingJsonBean getExistingNodes(HttpServletRequest request, @RequestParam(required = false) String container) {
index 4bc4c76fc4c7edadf6f8e4994890a162044d76b7..09c4666d44757de4c338a70037e94c3c36aed6fa 100644 (file)
@@ -1,8 +1,8 @@
-/* 
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved. 
- * 
- * This program and the accompanying materials are made available under the 
- * terms of the Eclipse Public License v1.0 which accompanies this distribution, 
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  *
  */
@@ -63,13 +63,13 @@ $(one.f.menu.right.bottom).each(function(index, value) {
 /**Troubleshoot modules*/
 one.f.troubleshooting = {
     rootUrl: "/controller/web/troubleshoot",
-    rightBottomDashlet: { 
+    rightBottomDashlet: {
         get: function() {
             var $rightBottomDashlet = $("#right-bottom").find(".dashlet");
             return $rightBottomDashlet;
         },
         setDashletHeader: function(label) {
-            $("#right-bottom li a")[0].innerHTML = label; 
+            $("#right-bottom li a")[0].innerHTML = label;
         }
     },
     createTable: function(columnNames, body) {
@@ -92,8 +92,11 @@ one.f.troubleshooting.existingNodes = {
             portsDataGrid: "one_f_troubleshooting_existingNodes_id_portsDataGrid",
             flowsDataGrid: "one_f_troubleshooting_existingNodes_id_flowsDataGrid",
             refreshFlowsButton:"one_f_troubleshooting_existingNodes_id_refreshFlowsButton",
-            refreshPortsButton:"one_f_troubleshooting_existingNodes_id_refreshPortsButton"
-
+            refreshPortsButton:"one_f_troubleshooting_existingNodes_id_refreshPortsButton",
+            modal : {
+                nodeInfo : "one_f_troubleshooting_existingNodes_id_modal_nodeInfo",
+                cancelButton : "one_f_troubleshooting_existingNodes_id_modal_cancelButton",
+            }
         },
         load: {
             main: function($dashlet) {
@@ -171,7 +174,7 @@ one.f.troubleshooting.existingNodes = {
                         $("#" + one.f.troubleshooting.existingNodes.id.portsDataGrid).datagrid({dataSource: dataSource});
                     });
                 } catch(e) {}
-            } 
+            }
         },
         ajax : function(url, callback) {
             $.getJSON(url, function(data) {
@@ -204,7 +207,9 @@ one.f.troubleshooting.existingNodes = {
                     data: data.nodeData,
                     formatter: function(items) {
                         $.each(items, function(index, item) {
-                            item["statistics"] = "<a href=\"javascript:one.f.troubleshooting.existingNodes.load.flows('" + item["nodeId"] + "');\">Flows</a>" + 
+                            item.nodeName = "<a href=\"javascript:one.f.troubleshooting.existingNodes.data.nodeInfo('"
+                                + item.nodeId + "');\">" + item.nodeName + "</a>"
+                            item["statistics"] = "<a href=\"javascript:one.f.troubleshooting.existingNodes.load.flows('" + item["nodeId"] + "');\">Flows</a>" +
                             " <a href=\"javascript:one.f.troubleshooting.existingNodes.load.ports('" + item["nodeId"] + "');\">Ports</a>";
                         });
                     },
@@ -461,6 +466,46 @@ one.f.troubleshooting.existingNodes = {
                     result.push(tr);
                 });
                 return result;
+            },
+            nodeInfo : function(nodeId){
+                $.getJSON(one.main.constants.address.prefix + "/troubleshoot/nodeInfo?nodeId=" + nodeId, function(content) {
+                    var h3 = 'Node Information'
+
+                    var headers = [ 'Description','Specification'];
+
+                    var attributes = ['table-striped', 'table-bordered', 'table-condensed'];
+                    var $table = one.lib.dashlet.table.table(attributes);
+                    var $thead = one.lib.dashlet.table.header(headers);
+                    $table.append($thead);
+
+                    var footer = [];
+
+                    var cancelButton = one.lib.dashlet.button.single("Cancel",
+                            one.f.troubleshooting.existingNodes.id.modal.nodeInfo, "", "");
+                    var $cancelButton = one.lib.dashlet.button.button(cancelButton);
+                    footer.push($cancelButton);
+
+                    var body = []
+                    $.each(content, function(key, value) {
+                        var tr = {};
+                        var entry = [];
+
+                        entry.push(key);
+                        entry.push(value);
+
+                        tr.entry = entry;
+                        body.push(tr);
+                    });
+                    var $tbody = one.lib.dashlet.table.body(body);
+                    $table.append($tbody);
+
+                    var $modal = one.lib.modal.spawn(one.f.troubleshooting.existingNodes.id.modal.nodeInfo, h3, $table , footer);
+                    $modal.modal();
+
+                    $('#'+one.f.troubleshooting.existingNodes.id.modal.nodeInfo, $modal).click(function() {
+                        $modal.modal('hide');
+                    });
+                });
             }
         }
 };
@@ -488,7 +533,7 @@ one.f.troubleshooting.uptime = {
                 $("#" + one.f.troubleshooting.uptime.id.datagrid).datagrid({dataSource: dataSource});
             });
     },
-    
+
     ajax : {
         main : function(url, requestData, callback) {
             $.getJSON(url, requestData, function(data) {
@@ -496,7 +541,7 @@ one.f.troubleshooting.uptime = {
             });
         }
     },
-    
+
     data: {
         uptimeDataGrid: function(data) {
             var source = new StaticDataSource({
@@ -548,7 +593,7 @@ one.f.troubleshooting.statistics = {
         var $p = $(document.createElement('p'));
         $p.text('Please select a Flow or Ports statistics');
         $p.addClass('text-center').addClass('text-info');
-        
+
         $dashlet.append($none)
             .append($p);
     }