qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhupend...@apache.org
Subject svn commit: r530034 - in /incubator/qpid/branches/M2/java: broker/src/main/java/org/apache/qpid/server/security/access/ management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ management/eclipse-plugin/src/main/java/org/apache/qpid/manag...
Date Wed, 18 Apr 2007 14:32:03 GMT
Author: bhupendrab
Date: Wed Apr 18 07:32:02 2007
New Revision: 530034

URL: http://svn.apache.org/viewvc?view=rev&rev=530034
Log:
AMQUserManagementMBean.java - calling relaod within viewUsers method.
Creating user list on management console instead of typing the user name.

Modified:
    incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/security/access/AMQUserManagementMBean.java
    incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/security/access/UserManagement.java
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ServerRegistry.java
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/OperationData.java
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java

Modified: incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/security/access/AMQUserManagementMBean.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/security/access/AMQUserManagementMBean.java?view=diff&rev=530034&r1=530033&r2=530034
==============================================================================
--- incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/security/access/AMQUserManagementMBean.java
(original)
+++ incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/security/access/AMQUserManagementMBean.java
Wed Apr 18 07:32:02 2007
@@ -259,6 +259,8 @@
         // Table of users
         // Username(string), Access rights Read,Write,Admin(bool,bool,bool)
 
+        reloadData();
+        
         if (_userlistDataType == null)
         {
             _logger.warn("TabluarData not setup correctly");

Modified: incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/security/access/UserManagement.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/security/access/UserManagement.java?view=diff&rev=530034&r1=530033&r2=530034
==============================================================================
--- incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/security/access/UserManagement.java
(original)
+++ incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/security/access/UserManagement.java
Wed Apr 18 07:32:02 2007
@@ -97,8 +97,8 @@
      *
      * @return The result of the operation
      */
-    @MBeanOperation(name = "reloadData", description = "Reload the authentication file from
disk.")
-    boolean reloadData();
+//    @MBeanOperation(name = "reloadData", description = "Reload the authentication file
from disk.")
+//    boolean reloadData();
 
     /**
      * View users returns all the users that are currently available to the system.

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java?view=diff&rev=530034&r1=530033&r2=530034
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java
(original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java
Wed Apr 18 07:32:02 2007
@@ -61,6 +61,10 @@
     public final static String OPERATION_CREATE_BINDING = "createNewBinding";
     public final static String OPERATION_MOVE_MESSAGES = "moveMessages";
     
+    public final static String OPERATION_CREATEUSER = "createUser";
+    public final static String OPERATION_VIEWUSERS = "viewUsers";
+    public final static String OPERATION_PARAM_USERNAME = "username";
+    
     public final static String OPERATION_SUCCESSFUL = "Operation successful";
     public final static String OPERATION_UNSUCCESSFUL = "Operation unsuccessful";
     
@@ -69,6 +73,7 @@
     public final static String NAVIGATION_ROOT = "Qpid Connections";
     public final static String DESCRIPTION = " Description";
     
+    public final static String ADMIN_MBEAN_TYPE = "UserManagement";
     public final static String QUEUE  = "Queue";
     public final static String CONNECTION ="Connection";
     public final static String EXCHANGE = "Exchange";

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java?view=diff&rev=530034&r1=530033&r2=530034
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java
(original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java
Wed Apr 18 07:32:02 2007
@@ -20,6 +20,7 @@
  */
 package org.apache.qpid.management.ui;
 
+import static org.apache.qpid.management.ui.Constants.*;
 import java.util.HashMap;
 
 /**
@@ -50,7 +51,7 @@
         this._properties = properties;
         setName(getProperty("name"));
         setType(getProperty("type"));
-        _virtualHostName = getProperty(Constants.VIRTUAL_HOST);
+        _virtualHostName = getProperty(VIRTUAL_HOST);
     }
     public String getDomain()
     {
@@ -89,7 +90,7 @@
     public String getVirtualHostName()
     {
         // To make it work with the broker with no virtual host implementation
-        return _virtualHostName == null ? Constants.DEFAULT_VH : _virtualHostName;
+        return _virtualHostName == null ? DEFAULT_VH : _virtualHostName;
     }
     
     /**
@@ -106,21 +107,26 @@
     
     public boolean isQueue()
     {
-        return _type.endsWith(Constants.QUEUE);
+        return _type.endsWith(QUEUE);
     }
     
     public boolean isConnection()
     {
-        return _type.endsWith(Constants.CONNECTION);
+        return _type.endsWith(CONNECTION);
     }
     
     public boolean isExchange()
     {
-        return _type.endsWith(Constants.EXCHANGE);
+        return _type.endsWith(EXCHANGE);
     }
     
     public boolean isTempQueue()
     {
         return (isQueue() && getName().startsWith("tmp_"));
+    }
+    
+    public boolean isAdmin()
+    {
+        return _type.endsWith(ADMIN_MBEAN_TYPE);
     }
 }

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ServerRegistry.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ServerRegistry.java?view=diff&rev=530034&r1=530033&r2=530034
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ServerRegistry.java
(original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ServerRegistry.java
Wed Apr 18 07:32:02 2007
@@ -128,6 +128,10 @@
         return _virtualHosts;
     }
     
+    public abstract void setUserList(List<String> list);
+    
+    public abstract List<String> getUsernames();
+    
     public abstract void addManagedObject(ManagedBean key);
     
     public abstract List<ManagedBean> getMBeans();

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java?view=diff&rev=530034&r1=530033&r2=530034
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java
(original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java
Wed Apr 18 07:32:02 2007
@@ -61,6 +61,7 @@
     private JMXConnector _jmxc = null;
     private MBeanServerConnection _mbsc = null;
     
+    private List<String> _usersList;
     // When an mbean gets removed from mbean server, then the notification listener
     // will add that mbean in this list.
     private List<ManagedBean> _mbeansToBeRemoved = new ArrayList<ManagedBean>();
@@ -565,6 +566,16 @@
             connections[i++] = mbean.getName();
         }
         return connections;
+    }
+    
+    public void setUserList(List<String> list)
+    {
+        _usersList = list;
+    }
+    
+    public List<String> getUsernames()
+    {
+        return _usersList;
     }
 
     public ClientNotificationListener getNotificationListener()

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/OperationData.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/OperationData.java?view=diff&rev=530034&r1=530033&r2=530034
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/OperationData.java
(original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/OperationData.java
Wed Apr 18 07:32:02 2007
@@ -80,5 +80,13 @@
         this._returnType = returnType;
     }
     
+    public boolean isReturnTypeBoolean()
+    {
+        return (_returnType.equals("boolean") || _returnType.equals("java.lang.Boolean"));
+    }
     
+    public boolean isReturnTypeVoid()
+    {
+        return (_returnType.equals("void") || _returnType.equals("java.lang.Void"));
+    }
 }

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java?view=diff&rev=530034&r1=530033&r2=530034
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java
(original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java
Wed Apr 18 07:32:02 2007
@@ -20,10 +20,16 @@
  */
 package org.apache.qpid.management.ui.views;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map.Entry;
 
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularDataSupport;
+
 import static org.apache.qpid.management.ui.Constants.*;
 import org.apache.qpid.management.ui.ApplicationRegistry;
 import org.apache.qpid.management.ui.ManagedBean;
@@ -271,6 +277,15 @@
             {
                 items = EXCHANGE_TYPE_VALUES;
             }
+            else if (_mbean.isAdmin() && param.getName().equals(OPERATION_PARAM_USERNAME)
+                                      && !_opData.getName().equals(OPERATION_CREATEUSER))
+            {
+                List<String> list = ApplicationRegistry.getServerRegistry(_mbean).getUsernames();
+                if (list != null && !list.isEmpty())
+                {
+                    items = list.toArray(new String[0]);
+                }
+            }
             
             if (items != null)
             {
@@ -633,6 +648,17 @@
             return;
         }
         
+        // Custom code for Admin mbean operation
+        /* These custome codes here are to make the GUI look more user friendly. 
+         * Here we are adding the users to a list, which will be used to list username to
be selected on
+         * pages like "delete user", "set password" instead of typing the username
+        */
+        if (_mbean.isAdmin() && _opData.getName().equals(OPERATION_VIEWUSERS))
+        {
+            ApplicationRegistry.getServerRegistry(_mbean).setUserList(extractUserList(result));
+        }
+        // end of custom code
+        
         // Some mbeans have only "type" and no "name".
         String title = _mbean.getType();
         if (_mbean.getName() != null && _mbean.getName().length() != 0)
@@ -640,11 +666,11 @@
             title = _mbean.getName();
         }
         
-        if (_opData.getReturnType().equals("void") || _opData.getReturnType().equals("java.lang.Void"))
+        if (_opData.isReturnTypeVoid())
         {
             ViewUtility.popupInfoMessage(title, OPERATION_SUCCESSFUL);
         }
-        else if (_opData.getReturnType().equals("boolean") || _opData.getReturnType().equals("java.lang.Boolean"))
+        else if (_opData.isReturnTypeBoolean())
         {
             boolean success = Boolean.parseBoolean(result.toString());
             String message = success ? OPERATION_SUCCESSFUL : OPERATION_UNSUCCESSFUL;
@@ -662,6 +688,24 @@
             _form.layout();
         }
 
+    }
+    
+    private List<String> extractUserList(Object result)
+    {
+        if (!(result instanceof TabularDataSupport))
+        {
+            return null;
+        }
+        
+        TabularDataSupport tabularData = (TabularDataSupport)result;
+        Collection<CompositeData> records = tabularData.values();
+        List<String> list = new ArrayList<String>();
+        for (CompositeData data : records)
+        {
+            list.add(data.get(USERNAME).toString());
+        }
+        Collections.sort(list);
+        return list;
     }
     
     /**

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java?view=diff&rev=530034&r1=530033&r2=530034
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java
(original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java
Wed Apr 18 07:32:02 2007
@@ -596,8 +596,14 @@
         {
             if (data1.getKey() instanceof List)
             {
-                String str1 = ((List)data1.getKey()).get(0).toString();                
-                String str2 = ((List)data2.getKey()).get(0).toString();
+                Object obj1 = ((List)data1.getKey()).get(0);                
+                Object obj2 = ((List)data2.getKey()).get(0);
+                String str1 = obj1.toString();
+                String str2 = obj2.toString();
+                if (obj1 instanceof String)
+                {
+                    return str1.compareTo(str2);
+                }
                 
                 try
                 {



Mime
View raw message