Author: chirino
Date: Fri Jan 27 02:12:26 2012
New Revision: 1236491
URL: http://svn.apache.org/viewvc?rev=1236491&view=rev
Log:
Fixes the open wire wild card test.
Modified:
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/DestinationParser.scala
activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/DestinationConverter.scala
activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireProtocolHandler.scala
activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/PathParser.scala
Modified:
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/DestinationParser.scala
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/DestinationParser.scala?rev=1236491&r1=1236490&r2=1236491&view=diff
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/DestinationParser.scala
(original)
+++
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/DestinationParser.scala
Fri Jan 27 02:12:26 2012
@@ -28,7 +28,6 @@ import scala.Array
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/
class DestinationParser extends PathParser {
- import PathParser._
var queue_prefix = "queue:"
var topic_prefix = "topic:"
Modified:
activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/DestinationConverter.scala
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/DestinationConverter.scala?rev=1236491&r1=1236490&r2=1236491&view=diff
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/DestinationConverter.scala
(original)
+++
activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/DestinationConverter.scala
Fri Jan 27 02:12:26 2012
@@ -19,7 +19,6 @@ package org.apache.activemq.apollo.openw
import org.apache.activemq.apollo.dto.{TopicDestinationDTO,
QueueDestinationDTO, DestinationDTO}
import org.apache.activemq.apollo.broker.DestinationParser
import org.apache.activemq.apollo.openwire.command._
-import org.apache.activemq.apollo.util.path.PathParser._
/**
* <p>
@@ -43,18 +42,18 @@ object DestinationConverter {
var name = dest.getPhysicalName
Array(dest.getDestinationType match {
case QUEUE_TYPE =>
- var path_parts =
OPENWIRE_PARSER.parts(name).map(sanitize_destination_part(_))
+ var path_parts =
OPENWIRE_PARSER.parts(name).map(OPENWIRE_PARSER.sanitize_destination_part(_,
true))
new QueueDestinationDTO(path_parts)
case TOPIC_TYPE =>
- var path_parts =
OPENWIRE_PARSER.parts(name).map(sanitize_destination_part(_))
+ var path_parts =
OPENWIRE_PARSER.parts(name).map(OPENWIRE_PARSER.sanitize_destination_part(_,
true))
new TopicDestinationDTO(path_parts)
case TEMP_QUEUE_TYPE =>
val (connectionid, rest)= name.splitAt(name.lastIndexOf(':'))
- val real_path = ("temp" :: handler.broker.id ::
sanitize_destination_part(connectionid) ::
sanitize_destination_part(rest.substring(1)) :: Nil).toArray
+ val real_path = ("temp" :: handler.broker.id ::
OPENWIRE_PARSER.sanitize_destination_part(connectionid) ::
OPENWIRE_PARSER.sanitize_destination_part(rest.substring(1)) :: Nil).toArray
new QueueDestinationDTO( real_path ).temp(true)
case TEMP_TOPIC_TYPE =>
val (connectionid, rest)= name.splitAt(name.lastIndexOf(':'))
- val real_path = ("temp" :: handler.broker.id ::
sanitize_destination_part(connectionid) ::
sanitize_destination_part(rest.substring(1)) :: Nil).toArray
+ val real_path = ("temp" :: handler.broker.id ::
OPENWIRE_PARSER.sanitize_destination_part(connectionid) ::
OPENWIRE_PARSER.sanitize_destination_part(rest.substring(1)) :: Nil).toArray
new TopicDestinationDTO( real_path ).temp(true)
})
} else {
@@ -73,16 +72,16 @@ object DestinationConverter {
dest match {
case dest:QueueDestinationDTO =>
if( temp ) {
- new
ActiveMQTempQueue(dest.path.toList.drop(2).map(unsanitize_destination_part(_)).mkString(":"))
+ new
ActiveMQTempQueue(dest.path.toList.drop(2).map(OPENWIRE_PARSER.unsanitize_destination_part(_)).mkString(":"))
} else {
- val name =
OPENWIRE_PARSER.encode_path(asScalaBuffer(dest.path).toList.map(unsanitize_destination_part(_)))
+ val name =
OPENWIRE_PARSER.encode_path(asScalaBuffer(dest.path).toList.map(OPENWIRE_PARSER.unsanitize_destination_part(_)))
new ActiveMQQueue(name)
}
case dest:TopicDestinationDTO =>
if( temp ) {
- new
ActiveMQTempTopic(dest.path.toList.drop(2).map(unsanitize_destination_part(_)).mkString(":"))
+ new
ActiveMQTempTopic(dest.path.toList.drop(2).map(OPENWIRE_PARSER.unsanitize_destination_part(_)).mkString(":"))
} else {
- val name =
OPENWIRE_PARSER.encode_path(asScalaBuffer(dest.path).toList.map(unsanitize_destination_part(_)))
+ val name =
OPENWIRE_PARSER.encode_path(asScalaBuffer(dest.path).toList.map(OPENWIRE_PARSER.unsanitize_destination_part(_)))
new ActiveMQTopic(name)
}
}
Modified:
activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireProtocolHandler.scala
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireProtocolHandler.scala?rev=1236491&r1=1236490&r2=1236491&view=diff
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireProtocolHandler.scala
(original)
+++
activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireProtocolHandler.scala
Fri Jan 27 02:12:26 2012
@@ -40,7 +40,6 @@ import org.apache.activemq.apollo.broker
import protocol._
import security.SecurityContext
import DestinationConverter._
-import org.apache.activemq.apollo.util.path.PathParser._
object OpenwireProtocolHandler extends Log {
def unit:Unit = {}
@@ -427,7 +426,7 @@ class OpenwireProtocolHandler extends Pr
security_context.user = info.getUserName
security_context.password = info.getPassword
- security_context.session_id =
Some(sanitize_destination_part(info.getConnectionId.toString))
+ security_context.session_id =
Some(OPENWIRE_PARSER.sanitize_destination_part(info.getConnectionId.toString))
reset {
if( host.authenticator!=null && host.authorizer!=null ) {
Modified:
activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala?rev=1236491&r1=1236490&r2=1236491&view=diff
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
(original)
+++
activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
Fri Jan 27 02:12:26 2012
@@ -55,7 +55,6 @@ object BufferSupport {
}
import BufferSupport._
-import PathParser._
object StompProtocolHandler extends Log {
@@ -929,7 +928,7 @@ class StompProtocolHandler extends Proto
noop
} else {
this.host=host
- security_context.session_id =
Some("%s-%x-".format(sanitize_destination_part(this.host.config.id),
this.host.session_counter.incrementAndGet))
+ security_context.session_id =
Some("%s-%x-".format(destination_parser.sanitize_destination_part(this.host.config.id),
this.host.session_counter.incrementAndGet))
connection_log = host.connection_log
if( host.authenticator!=null && host.authorizer!=null ) {
suspend_read("authenticating and authorizing connect")
Modified:
activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/PathParser.scala
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/PathParser.scala?rev=1236491&r1=1236490&r2=1236491&view=diff
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/PathParser.scala
(original)
+++
activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/PathParser.scala
Fri Jan 27 02:12:26 2012
@@ -21,7 +21,7 @@ import java.util.regex._
import collection.JavaConversions._
import org.apache.activemq.apollo.util.path.PathParser.PartFilter
import collection.mutable.ListBuffer
-import org.fusesource.hawtbuf.{DataByteArrayOutputStream, AsciiBuffer}
+import org.fusesource.hawtbuf.{Buffer, DataByteArrayOutputStream, AsciiBuffer}
/**
* Holds the delimiters used to parse paths.
@@ -108,25 +108,42 @@ object PathParser {
}
}
+}
+
+class PathParser {
+
+ var any_descendant_wildcard = "**"
+ var any_child_wildcard = "*"
+ var regex_wildcard_start = "{"
+ var regex_wildcard_end = "}"
+ var path_separator = "."
+ var part_pattern = Pattern.compile("[ a-zA-Z0-9\\_\\-\\%\\~\\:]+")
- def sanitize_destination_part(value:String) = {
- val buffer = new AsciiBuffer(value)
+ def copy(other:PathParser) = {
+ any_descendant_wildcard = other.any_descendant_wildcard
+ any_child_wildcard = other.any_child_wildcard
+ path_separator = other.path_separator
+ part_pattern = other.part_pattern
+ this
+ }
+
+ def sanitize_destination_part(value:String, wildcards:Boolean=false) = {
val rc = new StringBuffer(value.length())
- var i = 0
- val l = buffer.length
- while( i < l ) {
- val c = buffer.data(i)
- if(
- ('a' <= c && c <= 'z') ||
- ('A' <= c && c <= 'Z') ||
- ('0' <= c && c <= '9') ||
- c=='_' || c=='-' || c=='~' || c==':'
- ) {
- rc.append(c.toChar)
+ var pos = new Buffer(value.getBytes("UTF-8"))
+ while( pos.length > 0 ) {
+ val c = pos.get(0).toChar
+ val cs = c.toString
+ if((wildcards && (
+ cs == any_descendant_wildcard ||
+ cs == any_child_wildcard ||
+ cs == regex_wildcard_start ||
+ cs == regex_wildcard_end
+ ))|| part_pattern.matcher(cs).matches() ) {
+ rc.append(c)
} else {
- rc.append("%%%02x".format(c))
+ rc.append("%%%02x".format(pos.get(0)))
}
- i += 1
+ pos.moveHead(1)
}
rc.toString
}
@@ -146,25 +163,8 @@ object PathParser {
}
rc.toBuffer.utf8().toString
}
-}
-
-class PathParser {
-
- var any_descendant_wildcard = "**"
- var any_child_wildcard = "*"
- var regex_wildcard_start = "{"
- var regex_wildcard_end = "}"
- var path_separator = "."
- var part_pattern = Pattern.compile("[ a-zA-Z0-9\\_\\-\\%\\~\\:]+")
-
- def copy(other:PathParser) = {
- any_descendant_wildcard = other.any_descendant_wildcard
- any_child_wildcard = other.any_child_wildcard
- path_separator = other.path_separator
- part_pattern = other.part_pattern
- this
- }
-
+
+
def decode_path(subject: java.util.Collection[String]): Path =
decode_path(subject.toIterable)
def decode_path(subject: Iterable[String]): Path = {