[jboss-cvs] JBoss Messaging SVN: r7492 - in trunk/src/main/org/jboss/messaging: jms/server/management/impl and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jun 29 07:50:01 EDT 2009


Author: jmesnil
Date: 2009-06-29 07:50:00 -0400 (Mon, 29 Jun 2009)
New Revision: 7492

Modified:
   trunk/src/main/org/jboss/messaging/core/management/impl/QueueControlImpl.java
   trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControlImpl.java
Log:
JBMESSAGING-1673: MBean operations which requires a filter should treat an empty string as a null filter

Modified: trunk/src/main/org/jboss/messaging/core/management/impl/QueueControlImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/QueueControlImpl.java	2009-06-29 09:47:07 UTC (rev 7491)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/QueueControlImpl.java	2009-06-29 11:50:00 UTC (rev 7492)
@@ -78,6 +78,20 @@
       }
       return array.toString();
    }
+   
+   /**
+    * Returns null if the string is null or empty
+    */
+   public static Filter createFilter(final String filterStr) throws MessagingException
+   {
+      if (filterStr == null || filterStr.length() == 0)
+      {
+         return null;
+      } else
+      {
+         return new FilterImpl(new SimpleString(filterStr));
+      }
+   }
 
    // Constructors --------------------------------------------------
 
@@ -240,10 +254,10 @@
    }
 
    public Map<String, Object>[] listMessages(final String filterStr) throws Exception
-   {
+   {     
       try
       {
-         Filter filter = FilterImpl.createFilter(filterStr);
+         Filter filter = createFilter(filterStr);
          List<MessageReference> refs = queue.list(filter);
          Map<String, Object>[] messages = new Map[refs.size()];
          int i = 0;
@@ -267,7 +281,7 @@
 
    public int countMessages(final String filterStr) throws Exception
    {
-      Filter filter = FilterImpl.createFilter(filterStr);
+      Filter filter = createFilter(filterStr);
       List<MessageReference> refs = queue.list(filter);
       return refs.size();
    }
@@ -298,8 +312,7 @@
 
    public int removeMatchingMessages(final String filterStr) throws Exception
    {
-      Filter filter = FilterImpl.createFilter(filterStr);
-
+      Filter filter = createFilter(filterStr);
       return queue.deleteMatchingReferences(filter);
    }
 
@@ -312,8 +325,7 @@
    {
       try
       {
-         Filter filter = FilterImpl.createFilter(filterStr);
-
+         Filter filter = createFilter(filterStr);
          return queue.expireReferences(filter);
       }
       catch (MessagingException e)
@@ -336,7 +348,7 @@
 
    public int moveMatchingMessages(final String filterStr, final String otherQueueName) throws Exception
    {
-      Filter filter = FilterImpl.createFilter(filterStr);
+      Filter filter = createFilter(filterStr);
 
       Binding binding = postOffice.getBinding(new SimpleString(otherQueueName));
 
@@ -355,7 +367,7 @@
 
    public int sendMessagesToDeadLetterAddress(final String filterStr) throws Exception
    {
-      Filter filter = filterStr == null ? null : new FilterImpl(new SimpleString(filterStr));
+      Filter filter = createFilter(filterStr);
 
       List<MessageReference> refs = queue.list(filter);
 
@@ -374,7 +386,7 @@
 
    public int changeMessagesPriority(String filterStr, int newPriority) throws Exception
    {
-      Filter filter = filterStr == null ? null : new FilterImpl(new SimpleString(filterStr));
+      Filter filter = createFilter(filterStr);
 
       List<MessageReference> refs = queue.list(filter);
 

Modified: trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControlImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControlImpl.java	2009-06-29 09:47:07 UTC (rev 7491)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControlImpl.java	2009-06-29 11:50:00 UTC (rev 7492)
@@ -61,9 +61,12 @@
 
    // Static --------------------------------------------------------
 
+   /**
+    * Returns null if the string is null or empty
+    */
    public static String createFilterFromJMSSelector(final String selectorStr) throws MessagingException
    {
-      return (selectorStr == null) ? null : SelectorTranslator.convertToJBMFilterString(selectorStr);
+      return (selectorStr == null || selectorStr.length() == 0) ? null : SelectorTranslator.convertToJBMFilterString(selectorStr);
    }
 
    private static String createFilterForJMSMessageID(String jmsMessageID) throws Exception




More information about the jboss-cvs-commits mailing list