Пример #1
0
 def check_filed_range(self, value, low, high, name):
     if not isinstance(value, int):
         raise GalaxyEmqServiceException(
             errMsg="Bad request, wrong date type of %s!" % name)
     if value < low or value > high:
         raise GalaxyEmqServiceException(
             errMsg="Bad request, the attribute value of %s is out of range!"
             % name)
 def validate_queue_name(self, queue_name, allow_slash=True, is_prefix=False, param_name="queue name"):
   chars = list(queue_name)
   if (queue_name == "" or queue_name is None) and not is_prefix:
     raise GalaxyEmqServiceException(errMsg="Bad request, %s shouldn't be empty." % param_name)
   for c in chars:
     if not self.isJavaIdentifierPart(c) or (not allow_slash and c == "/"):
       raise GalaxyEmqServiceException(errMsg="Bad request, Invalid characters in %s." % param_name)
   if allow_slash and len(queue_name.split("/")) != 2 and not is_prefix:
     raise GalaxyEmqServiceException(errMsg="Bad request, please check your '/' in %s." % param_name)
   if is_prefix and len(queue_name.split("/")) != 1 and len(queue_name.split("/")) != 2:
     raise GalaxyEmqServiceException(errMsg="Bad request, please check your '/' in %s." % param_name)
 def check_message_attribute(self, attribute, allow_empty):
   self.validate_not_none(attribute, "messageAttribute")
   if attribute.type.lower().startswith("string"):
     if attribute.stringValue is None:
       raise GalaxyEmqServiceException(errMsg="stringValue cannot be None when type is STRING")
   elif attribute.type.lower().startswith("binary"):
     if attribute.binaryValue is None:
       raise GalaxyEmqServiceException(errMsg="binaryValue cannot be None when type is BINARY")
   elif allow_empty and attribute.type.lower() == "empty":
     return
   else:
     raise GalaxyEmqServiceException(errMsg="Attribute type must start with \"STRING\" or \"BINARY\"")
   for c in attribute.type:
     if not c in string.ascii_letters and not c in string.digits and c != '.':
       raise GalaxyEmqServiceException(errMsg="Invalid character \'" + c + "\' in attribute type")
Пример #4
0
 def validate_not_empty(self, param, name):
     if not param:
         raise GalaxyEmqServiceException(
             errMsg="Bad request, the %s shouldn't be empty!" % name)
Пример #5
0
 def validate_not_none(self, param, name):
     if param is None:
         raise GalaxyEmqServiceException(
             errMsg="Bad request, the %s is required!" % name)
Пример #6
0
 def check_arg(self):
     if len(self.__args) > 1:
         errMsg = "Unknown request"
         raise GalaxyEmqServiceException(errMsg=errMsg)
     elif len(self.__args) == 1:
         self.check_request_params(self.__args[0])
Пример #7
0
 def check_list_duplicate(self, l, name):
     if len(l) != len({}.fromkeys(l).keys()):
         raise GalaxyEmqServiceException(
             errMsg="Bad request, %s shouldn't be duplicate." % name)