Permalink
Browse files

Fix issue w/ default binding name space declaration

  • Loading branch information...
1 parent 0af8acf commit 6419781bd198363e01e867fed0dfee4a1fb8dd67 @grze grze committed Feb 27, 2013
@@ -90,7 +90,7 @@ public void handle( ExceptionMessage muleMsg )
{
Object requestMsg = muleMsg.getPayload();
String requestString = requestMsg.toString();
- BaseMessage msg = ( BaseMessage ) BindingManager.getBinding( "msgs_eucalyptus_com" ).fromOM( requestString );
+ BaseMessage msg = ( BaseMessage ) BindingManager.getDefaultBinding( ).fromOM( requestString );
Throwable ex = muleMsg.getException().getCause();
BaseMessage errMsg;
@@ -93,7 +93,7 @@ public void handle( ExceptionMessage muleMsg )
{
Object requestMsg = muleMsg.getPayload();
String requestString = requestMsg.toString();
- BaseMessage msg = ( BaseMessage ) BindingManager.getBinding( "msgs_eucalyptus_com" ).fromOM( requestString );
+ BaseMessage msg = ( BaseMessage ) BindingManager.getDefaultBinding( ).fromOM( requestString );
Throwable ex = muleMsg.getException().getCause();
StorageErrorMessageType errMsg = null;
@@ -541,7 +541,7 @@ public void processClass( Class klass ) {
e.printStackTrace( System.err );
System.exit( -1 );//GRZE: special case to fail build
}
- this.bindingName = this.ns.replaceAll( "(http://)|(/$)", "" ).replaceAll( "/[^/]*$", "" ).replaceAll( "[./-]", "_" );
+ this.bindingName = this.ns.replaceAll( "(http://)|(/$)", "" ).replaceAll( "[./-]", "_" );
this.out.write( "<binding xmlns:euca=\"" + this.ns + "\" name=\"" + this.bindingName + "\">\n" );
this.out.write( " <namespace uri=\"" + this.ns + "\" default=\"elements\" prefix=\"euca\"/>\n" );
this.out.flush( );
@@ -65,6 +65,7 @@
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
+import com.eucalyptus.bootstrap.BillOfMaterials;
import com.eucalyptus.bootstrap.BootstrapException;
import com.eucalyptus.records.EventRecord;
import com.eucalyptus.records.EventType;
@@ -74,7 +75,7 @@
private static Logger LOG = Logger.getLogger( BindingManager.class );
private static Map<String, Binding> bindingMap = new HashMap<String, Binding>( );
- private static final String DEFAULT_BINDING_NAMESPACE = "http://msgs.eucalyptus.com";
+ private static final String DEFAULT_BINDING_NAMESPACE = "http://msgs.eucalyptus.com/" + BillOfMaterials.getVersion( );
private static final String DEFAULT_BINDING_NAME = BindingManager.sanitizeNamespace( defaultBindingNamespace( ) );
private static Binding DEFAULT = null;
@@ -155,7 +155,7 @@
private static final ChannelHandler soapHandler = new SoapHandler( );
private static final ChannelHandler addressingHandler = new AddressingHandler( );
private static final ConcurrentMap<String, BindingHandler> bindingHandlers = new MapMaker( ).makeComputingMap( BindingHandlerLookup.INSTANCE );
- private static final ChannelHandler bindingHandler = new BindingHandler( );
+ private static final ChannelHandler bindingHandler = new BindingHandler( BindingManager.getDefaultBinding( ) );
private static final HashedWheelTimer timer = new HashedWheelTimer( ); //TODO:GRZE: configurable
enum ServerPipelineFactory implements ChannelPipelineFactory {
@@ -295,6 +295,10 @@ public BindingHandler apply( String bindingName ) {
}
+ public static ChannelHandler bindingHandler( ) {
+ return bindingHandler;
+ }
+
public static ChannelHandler bindingHandler( final String bindingName ) {
return bindingHandlers.get( bindingName );
}
@@ -549,12 +553,8 @@ public static ChannelHandler queryTimestamphandler( ) {
return queryTimestampHandler;
}
- public static ChannelHandler bindinghandler( ) {
- return bindingHandler;
- }
-
public static ChannelHandler internalWsSecHandler( ) {
return internalWsSecHandler;
}
-
+
}
@@ -124,7 +124,7 @@ public void incomingMessage( final MessageEvent event ) throws Exception {
if ( namespacePattern != null && !namespacePattern.matcher( namespace ).matches() ) {
throw new WebServicesException( "Invalid request" );
}
- this.binding = BindingManager.getBinding( BindingManager.sanitizeNamespace( namespace ) );
+ this.binding = BindingManager.getBinding( namespace );
msgType = this.binding.getElementClass( httpMessage.getOmMessage( ).getLocalName( ) );
} catch ( BindingException ex ) {
if ( this.defaultBinding != null ) {
@@ -122,7 +122,7 @@ public RestfulMarshallingHandler( String namespacePattern ) {
public RestfulMarshallingHandler( String namespacePattern, String defaultVersion ) {
this( namespacePattern );
this.defaultBindingNamespace = String.format( namespacePattern, defaultVersion );
- this.defaultBinding = BindingManager.getBinding( BindingManager.sanitizeNamespace( this.defaultBindingNamespace ) );
+ this.defaultBinding = BindingManager.getBinding( this.defaultBindingNamespace );
}
@Override
@@ -149,7 +149,7 @@ public void incomingMessage( MessageEvent event ) throws Exception {
protected void setNamespace( String namespace ) {
this.namespace = namespace;
- this.binding = BindingManager.getBinding( BindingManager.sanitizeNamespace( this.namespace ) );
+ this.binding = BindingManager.getBinding( this.namespace );
}
private void setNamespaceVersion( String bindingVersion ) {
@@ -246,7 +246,7 @@ public ChannelPipeline addHandlers( final ChannelPipeline pipeline ) {
pipeline.addLast( "ws-security", Handlers.internalWsSecHandler() );
pipeline.addLast( "ws-addressing", Handlers.addressingHandler( ) );
pipeline.addLast( "build-soap-envelope", Handlers.soapHandler( ) );
- pipeline.addLast( "binding", Handlers.bindinghandler() );
+ pipeline.addLast( "binding", Handlers.bindingHandler( ) );
return pipeline;
}
@@ -110,7 +110,7 @@ private BaseMessage parsePayload( final Object payload ) throws PayloadParseExce
return ( BaseMessage ) payload;
} else if ( payload instanceof String ) {
try {
- return ( BaseMessage ) BindingManager.getBinding( BindingManager.sanitizeNamespace( namespace ) ).fromOM( ( String ) payload );
+ return ( BaseMessage ) BindingManager.getBinding( namespace ).fromOM( ( String ) payload );
} catch ( Exception e ) {
throw new PayloadParseException( e );
}
@@ -118,7 +118,7 @@ private BaseMessage convert( Object payload ) {
ret = ( ( HasRequest ) payload ).getRequest( );
} else if ( payload instanceof String ) {
try {
- ret = ( BaseMessage ) BindingManager.getBinding( "msgs_eucalyptus_com" ).fromOM( ( String ) payload );
+ ret = ( BaseMessage ) BindingManager.getDefaultBinding( ).fromOM( ( String ) payload );
} catch ( Exception ex ) {
LOG.error( ex , ex );
}
@@ -130,7 +130,7 @@ private BaseMessage convert( Object payload ) {
// ret = ( ( Allocation ) payload ).getRequest( );
} else if ( payload instanceof String ) {
try {
- ret = ( BaseMessage ) BindingManager.getBinding( "msgs_eucalyptus_com" ).fromOM( ( String ) payload );
+ ret = ( BaseMessage ) BindingManager.getDefaultBinding( ).fromOM( ( String ) payload );
} catch ( Exception ex ) {
LOG.error( ex , ex );
}
@@ -75,6 +75,7 @@
import org.jibx.runtime.JiBXException;
import com.eucalyptus.auth.principal.Principals;
import com.eucalyptus.auth.principal.User;
+import com.eucalyptus.binding.BindingManager;
import com.eucalyptus.empyrean.ServiceId;
import com.eucalyptus.http.MappingHttpMessage;
import com.eucalyptus.util.Classes;
@@ -231,7 +232,7 @@ public String getEffectiveUserId( ) {
}
public String toString( ) {
- String str = this.toString( "msgs_eucalyptus_com" );
+ String str = this.toString( BindingManager.defaultBindingName( ) );
str = ( str != null )
? str
: this.toString( "eucalyptus_ucsb_edu" );
@@ -84,7 +84,7 @@ private static BaseMessage parsePayload( final Object payload ) throws PayloadPa
return ( BaseMessage ) payload;
} else if ( payload instanceof String ) {
try {
- return ( BaseMessage ) BindingManager.getBinding( BindingManager.sanitizeNamespace( ReportingQueryBinding.REPORTING_DEFAULT_NAMESPACE ) ).fromOM( ( String ) payload );
+ return ( BaseMessage ) BindingManager.getBinding( ReportingQueryBinding.REPORTING_DEFAULT_NAMESPACE ).fromOM( ( String ) payload );
} catch ( Exception e ) {
throw new PayloadParseException( e );
}
@@ -100,7 +100,7 @@ public ChannelPipeline getPipeline( ) throws Exception {
pipeline.addLast( "wssec", InternalClientPipeline.wssecHandler );
pipeline.addLast( "addressing", Handlers.addressingHandler( ) );
pipeline.addLast( "soap", Handlers.soapHandler( ) );
- pipeline.addLast( "binding", Handlers.bindingHandler( "msgs_eucalyptus_com" ) );
+ pipeline.addLast( "binding", Handlers.bindingHandler( ) );
return pipeline;
}
@@ -104,7 +104,7 @@ public void incomingMessage( final MessageEvent event ) throws Exception {
String namespace = omNs.getNamespaceURI( );
Class msgType = null;
try {
- this.binding = BindingManager.getBinding( BindingManager.sanitizeNamespace( namespace ) );
+ this.binding = BindingManager.getBinding( namespace );
msgType = this.binding.getElementClass( httpMessage.getOmMessage( ).getLocalName( ) );
} catch ( Exception e1 ) {
if ( this.binding == null ) {
@@ -217,12 +217,12 @@ public void outgoingMessage( ChannelHandlerContext ctx, MessageEvent event ) thr
Binding binding;
if(!(msg instanceof EucalyptusErrorMessageType)&&!(msg instanceof ExceptionResponseType)) {
- binding = BindingManager.getBinding( BindingManager.sanitizeNamespace( super.getNamespace( ) ) );
+ binding = BindingManager.getBinding( super.getNamespace( ) );
if(putQueue != null) {
putQueue = null;
}
} else {
- binding = BindingManager.getBinding( BindingManager.sanitizeNamespace( "http://msgs.eucalyptus.com" ) );
+ binding = BindingManager.getDefaultBinding( );
if(putQueue != null) {
putQueue = null;
}
@@ -339,7 +339,7 @@ public Object bind( final MappingHttpRequest httpRequest ) throws Exception {
LOG.info(groovyMsg.toString());
try
{
- Binding binding = BindingManager.getBinding( BindingManager.sanitizeNamespace( "http://msgs.eucalyptus.com" ) );
+ Binding binding = BindingManager.getDefaultBinding( );
msg = binding.toOM( groovyMsg );
}
catch ( RuntimeException e )
@@ -159,7 +159,7 @@ private BaseMessage parsePayload( Object payload ) throws Exception {
if ( payload instanceof BaseMessage ) {
return ( BaseMessage ) payload;
} else if ( payload instanceof String ) {
- return ( BaseMessage ) BindingManager.getBinding( BindingManager.sanitizeNamespace( "http://iam.amazonaws.com/doc/2010-05-08/" ) ).fromOM( ( String ) payload );
+ return ( BaseMessage ) BindingManager.getBinding( "http://iam.amazonaws.com/doc/2010-05-08/" ).fromOM( ( String ) payload );
}
return new EucalyptusErrorMessageType( "ReplyQueue", LogUtil.dumpObject( payload ) );
}

0 comments on commit 6419781

Please sign in to comment.