| 52 | } |
| 53 | |
| 54 | int AbstractProtocolHandler::ValidateRequest(const Json::Value &request) { |
| 55 | int error = 0; |
| 56 | Procedure proc; |
| 57 | if (!this->ValidateRequestFields(request)) { |
| 58 | error = Errors::ERROR_RPC_INVALID_REQUEST; |
| 59 | } else { |
| 60 | map<string, Procedure>::iterator it = this->procedures.find(request[KEY_REQUEST_METHODNAME].asString()); |
| 61 | if (it != this->procedures.end()) { |
| 62 | proc = it->second; |
| 63 | if (this->GetRequestType(request) == RPC_METHOD && proc.GetProcedureType() == RPC_NOTIFICATION) { |
| 64 | error = Errors::ERROR_SERVER_PROCEDURE_IS_NOTIFICATION; |
| 65 | } else if (this->GetRequestType(request) == RPC_NOTIFICATION && proc.GetProcedureType() == RPC_METHOD) { |
| 66 | error = Errors::ERROR_SERVER_PROCEDURE_IS_METHOD; |
| 67 | } else if (!proc.ValdiateParameters(request[KEY_REQUEST_PARAMETERS])) { |
| 68 | error = Errors::ERROR_RPC_INVALID_PARAMS; |
| 69 | } |
| 70 | } else { |
| 71 | error = Errors::ERROR_RPC_METHOD_NOT_FOUND; |
| 72 | } |
| 73 | } |
| 74 | return error; |
| 75 | } |
no test coverage detected