activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1063598 - in /activemq/activemq-apollo/trunk: apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/ apollo-util/src/test/scala/org/apache/activemq/apollo/util/path/ apollo-website/src/documentation/
Date Wed, 26 Jan 2011 04:32:42 GMT
Author: chirino
Date: Wed Jan 26 04:32:42 2011
New Revision: 1063598

URL: http://svn.apache.org/viewvc?rev=1063598&view=rev
Log:
Enforce and document restrictions to supported destination names.

Modified:
    activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/PathParser.java
    activemq/activemq-apollo/trunk/apollo-util/src/test/scala/org/apache/activemq/apollo/util/path/PathMapMemoryTest.java
    activemq/activemq-apollo/trunk/apollo-util/src/test/scala/org/apache/activemq/apollo/util/path/PathMapTest.java
    activemq/activemq-apollo/trunk/apollo-website/src/documentation/user-manual.md

Modified: activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/PathParser.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/PathParser.java?rev=1063598&r1=1063597&r2=1063598&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/PathParser.java
(original)
+++ activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/PathParser.java
Wed Jan 26 04:32:42 2011
@@ -21,9 +21,10 @@ import org.fusesource.hawtbuf.ByteArrayO
 
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.LinkedList;
+import java.util.regex.*;
+
 import static org.apache.activemq.apollo.util.path.Part.*;
 
 /**
@@ -33,13 +34,18 @@ import static org.apache.activemq.apollo
  */
 public class PathParser {
 
+    public static class PathException extends RuntimeException {
+        public PathException(String message) {
+            super(message);
+        }
+    }
+
     public static final PathParser DEFAULT = new PathParser();
 
     public AsciiBuffer any_descendant_wildcard = new AsciiBuffer("**");
     public AsciiBuffer any_child_wildcard = new AsciiBuffer("*");
     public AsciiBuffer path_seperator = new AsciiBuffer(".");
-
-
+    public Pattern part_pattern = Pattern.compile("[a-zA-Z0-9\\_\\-\\%\\~]+");
 
     public Path parsePath(AsciiBuffer subject) {
     	ArrayList<Part> list = new ArrayList<Part>(10);
@@ -65,7 +71,11 @@ public class PathParser {
         } else if( value.equals(any_descendant_wildcard) ) {
             return ANY_DESCENDANT;
         } else {
-            return new LiteralPart(value);
+            if( part_pattern==null || part_pattern.matcher(value.toString()).matches() )
{
+                return new LiteralPart(value);
+            } else {
+                throw new PathException(String.format("Invalid destination path part: '%s',
it does not match regex: %s", value, part_pattern));
+            }
         }
     }
 

Modified: activemq/activemq-apollo/trunk/apollo-util/src/test/scala/org/apache/activemq/apollo/util/path/PathMapMemoryTest.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/test/scala/org/apache/activemq/apollo/util/path/PathMapMemoryTest.java?rev=1063598&r1=1063597&r2=1063598&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/src/test/scala/org/apache/activemq/apollo/util/path/PathMapMemoryTest.java
(original)
+++ activemq/activemq-apollo/trunk/apollo-util/src/test/scala/org/apache/activemq/apollo/util/path/PathMapMemoryTest.java
Wed Jan 26 04:32:42 2011
@@ -66,11 +66,11 @@ public class PathMapMemoryTest {
         Object value = new Object();
         int count = 1000;
         for (int i = 0; i < count; i++) {
-            Path queue = createDestination("connection:"+i);
+            Path queue = createDestination("connection-"+i);
             map.put(queue, value);
         }
         for (int i = 0; i < count; i++) {
-            Path queue = createDestination("connection:"+i);
+            Path queue = createDestination("connection-"+i);
             map.remove(queue, value);
             Set<Object> set = map.get(queue);
             assertTrue(set.isEmpty());

Modified: activemq/activemq-apollo/trunk/apollo-util/src/test/scala/org/apache/activemq/apollo/util/path/PathMapTest.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/test/scala/org/apache/activemq/apollo/util/path/PathMapTest.java?rev=1063598&r1=1063597&r2=1063598&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/src/test/scala/org/apache/activemq/apollo/util/path/PathMapTest.java
(original)
+++ activemq/activemq-apollo/trunk/apollo-util/src/test/scala/org/apache/activemq/apollo/util/path/PathMapTest.java
Wed Jan 26 04:32:42 2011
@@ -47,16 +47,6 @@ public class PathMapTest {
     protected String v6 = "value6";
 
     @Test()
-	public void testCompositePaths() throws Exception {
-        Path d1 = createDestination("TEST.BAR.D2");
-        Path d2 = createDestination("TEST.BAR.D3");
-        PathMap<String> map = new PathMap<String>();
-        map.put(d1, v1);
-        map.put(d2, v2);
-        map.get(createDestination("TEST.BAR.D2,TEST.BAR.D3"));
-    }
-
-    @Test()
 	public void testSimplePaths() throws Exception {
         PathMap<String> map = new PathMap<String>();
         map.put(d1, v1);

Modified: activemq/activemq-apollo/trunk/apollo-website/src/documentation/user-manual.md
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-website/src/documentation/user-manual.md?rev=1063598&r1=1063597&r2=1063598&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-website/src/documentation/user-manual.md (original)
+++ activemq/activemq-apollo/trunk/apollo-website/src/documentation/user-manual.md Wed Jan
26 04:32:42 2011
@@ -1015,5 +1015,11 @@ header in the STOMP `SUBSCRIBE` frame to
     
     ^@
 
+### Destination Name Restrictions
+
+Destination names are restricted to using the characters `a-z`, `A-Z`, `0-9`,
+`_`, `-` `%`, `~`, or `.` in addition to composite separator `,` and the wild
+card `*`.
+
 
 



Mime
View raw message