'''
if resp_code == 0:
+ topic = self.extract_topic_from_path()
content_len = int(self.headers.getheader('content-length', 0))
post_body = self.rfile.read(content_len)
indx = post_body.index("{")
if indx != 0:
post_body = post_body[indx:]
-
- if not enque_event(post_body):
+
+ event = "\""+topic+"\":" + post_body
+ if not enque_event(event):
print "enque event fails"
global EvtSchema
try:
if EvtSchema is None:
- with open(DcaeVariables.CommonEventSchemaV5) as opened_file:
+ with open(DcaeVariables.CommonEventSchema) as opened_file:
EvtSchema = json.load(opened_file)
decoded_body = json.loads(post_body)
jsonschema.validate(decoded_body, EvtSchema)
'''
return
+ def extract_topic_from_path(self):
+ return self.path["/events/".__len__():]
+
def do_GET(self):
"""Serve a GET request."""
f = self.send_head()
def test(handler_class=DMaaPHandler, server_class=BaseHTTPServer.HTTPServer, protocol="HTTP/1.0", port=3904):
- print "Load event schema file: " + DcaeVariables.CommonEventSchemaV5
- with open(DcaeVariables.CommonEventSchemaV5) as opened_file:
+ print "Load event schema file: " + DcaeVariables.CommonEventSchema
+ with open(DcaeVariables.CommonEventSchema) as opened_file:
global EvtSchema
EvtSchema = json.load(opened_file)
else:
port = 3904
- print "Load event schema file: " + DcaeVariables.CommonEventSchemaV5
- with open(DcaeVariables.CommonEventSchemaV5) as opened_file:
+ print "Load event schema file: " + DcaeVariables.CommonEventSchema
+ with open(DcaeVariables.CommonEventSchema) as opened_file:
global EvtSchema
EvtSchema = json.load(opened_file)