@staticmethod
  @gen.coroutine
  def InvokeService(client, obj_store, method_name, user_id, device_id, json_request):
    """Validates the JSON request body and invokes the method as specified
    in the request URI. On completion, the response is returned as a
    JSON-encoded response dictionary.
    """
    # Look up information about the service method.
    method = ServiceHandler.SERVICE_MAP[method_name]

    # Only allow prospective users to access methods that have been explicitly allowed.
    if not base.ViewfinderContext.current().user.IsRegistered() and not method.allow_prospective:
      raise web.HTTPError(403, 'Permission denied; user account is not registered.')

    try:
      request_message = yield gen.Task(base.BaseHandler._CreateRequestMessage,
                                       client,
                                       json_request,
                                       method.request,
                                       migrators=method.request_migrators,
                                       min_supported_version=method.min_supported_version,
                                       max_supported_version=method.max_supported_version)
    except Exception as ex:
      logging.warning(util.FormatLogArgument(json_request))
      raise InvalidRequestError(INVALID_JSON_REQUEST, request=ex.message)

    # Older clients called remove_photos instead of hide_photos, so redirect them.
    if method_name == 'remove_photos' and request_message.original_version < Message.RENAME_PHOTO_LABEL:
      handler = OldRemovePhotos
    else:
      handler = method.handler

    response_dict = yield gen.Task(handler, client, obj_store, user_id, device_id, request_message.dict)

    response_message = yield gen.Task(base.BaseHandler._CreateResponseMessage,
                                      client,
                                      response_dict,
                                      method.response,
                                      request_message.original_version,
                                      migrators=method.response_migrators)

    raise gen.Return(response_message.dict)
dataset/ETHPy150Open viewfinderco/viewfinder/backend/www/service.py/ServiceHandler.InvokeService/original