qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tr...@apache.org
Subject svn commit: r1057814 - in /qpid/trunk/qpid/cpp/src/qmf: AgentEvent.cpp AgentEventImpl.h AgentSession.cpp
Date Tue, 11 Jan 2011 19:24:14 GMT
Author: tross
Date: Tue Jan 11 19:24:14 2011
New Revision: 1057814

URL: http://svn.apache.org/viewvc?rev=1057814&view=rev
Log:
Added argument/type check for output arguments on methods.

Modified:
    qpid/trunk/qpid/cpp/src/qmf/AgentEvent.cpp
    qpid/trunk/qpid/cpp/src/qmf/AgentEventImpl.h
    qpid/trunk/qpid/cpp/src/qmf/AgentSession.cpp

Modified: qpid/trunk/qpid/cpp/src/qmf/AgentEvent.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qmf/AgentEvent.cpp?rev=1057814&r1=1057813&r2=1057814&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qmf/AgentEvent.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qmf/AgentEvent.cpp Tue Jan 11 19:24:14 2011
@@ -21,6 +21,7 @@
 
 #include "qmf/AgentEventImpl.h"
 #include "qmf/PrivateImplRef.h"
+#include "qmf/SchemaImpl.h"
 
 using namespace std;
 using namespace qmf;
@@ -64,6 +65,8 @@ Data AgentEventImpl::dequeueData()
 
 void AgentEventImpl::addReturnArgument(const string& key, const Variant& val, const
string& subtype)
 {
+    if (schema.isValid() && !SchemaImplAccess::get(schema).isValidMethodOutArg(methodName,
key, val))
+        throw QmfException("Output argument is unknown or the type is incompatible");
     outArguments[key] = val;
     if (!subtype.empty())
         outArgumentSubtypes[key] = subtype;

Modified: qpid/trunk/qpid/cpp/src/qmf/AgentEventImpl.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qmf/AgentEventImpl.h?rev=1057814&r1=1057813&r2=1057814&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qmf/AgentEventImpl.h (original)
+++ qpid/trunk/qpid/cpp/src/qmf/AgentEventImpl.h Tue Jan 11 19:24:14 2011
@@ -29,6 +29,7 @@
 #include "qmf/Query.h"
 #include "qmf/DataAddr.h"
 #include "qmf/Data.h"
+#include "qmf/Schema.h"
 #include <queue>
 
 namespace qmf {
@@ -45,6 +46,7 @@ namespace qmf {
         void setArguments(const qpid::types::Variant::Map& a) { arguments = a; }
         void setArgumentSubtypes(const qpid::types::Variant::Map& a) { argumentSubtypes
= a; }
         void setReplyTo(const qpid::messaging::Address& r) { replyTo = r; }
+        void setSchema(const Schema& s) { schema = s; }
         const qpid::messaging::Address& getReplyTo() { return replyTo; }
         void setCorrelationId(const std::string& c) { correlationId = c; }
         const std::string& getCorrelationId() { return correlationId; }
@@ -73,6 +75,7 @@ namespace qmf {
         std::string correlationId;
         Query query;
         DataAddr dataAddr;
+        Schema schema;
         std::string methodName;
         qpid::types::Variant::Map arguments;
         qpid::types::Variant::Map argumentSubtypes;

Modified: qpid/trunk/qpid/cpp/src/qmf/AgentSession.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qmf/AgentSession.cpp?rev=1057814&r1=1057813&r2=1057814&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qmf/AgentSession.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qmf/AgentSession.cpp Tue Jan 11 19:24:14 2011
@@ -650,16 +650,19 @@ void AgentSessionImpl::handleMethodReque
             return;
         }
 
-        if (DataImplAccess::get(iter->second).getSchema().isValid())
+        Schema schema(DataImplAccess::get(iter->second).getSchema());
+        if (schema.isValid()) {
+            eventImpl->setSchema(schema);
             for (Variant::Map::const_iterator aIter = eventImpl->getArguments().begin();
                  aIter != eventImpl->getArguments().end(); aIter++) {
                 const Schema& schema(DataImplAccess::get(iter->second).getSchema());
                 if (!SchemaImplAccess::get(schema).isValidMethodInArg(eventImpl->getMethodName(),
aIter->first, aIter->second)) {
-                AgentEvent event(eventImpl.release());
-                raiseException(event, "Invalid argument: " + aIter->first);
-                return;
+                    AgentEvent event(eventImpl.release());
+                    raiseException(event, "Invalid argument: " + aIter->first);
+                    return;
                 }
             }
+        }
     }
 
     enqueueEvent(AgentEvent(eventImpl.release()));



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message