Changeset 487
- Timestamp:
- 04/12/07 23:08:36 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/websites/processors/stubJsonRpcProcessor.php
r486 r487 22 22 * @todo Make methods testable 23 23 * @todo Check for annotations 24 * @todo Do not validate the RAW POST Data using a regexp, as json_decode does enough validation 24 25 */ 25 26 class stubJsonRpcProcessor extends stubAbstractProcessor { … … 43 44 * Regexp to validate json param 44 45 */ 45 const JSON_PATTERN = '^{\"method\":\"(.*)\",\"params\"(.*),\"id\":\"\d{6,7}\"}$'; 46 47 /** 48 * The JSON response 49 * 50 * @var array 51 */ 52 protected $jsonRpcResponse = array ( 53 'id' => null, 54 'result' => null, 55 'error' => null, 56 ); 57 46 const JSON_PATTERN = '^{\"method\":\"(.*)\",\"params\"(.*),\"id\":\"\d{1,10}\"}$'; 58 47 59 48 /** … … 111 100 112 101 try { 113 $this->checkRequestId($phpJsonObj->id);114 102 $result = $this->invokeServiceMethod($phpJsonObj->method, $phpJsonObj->params); 115 103 $this->sendResponse($phpJsonObj->id, $result); … … 137 125 138 126 $method = $clazz->getMethod($methodName); 127 if ($method == null) { 128 throw new stubException('Unknown method ' . $className . '.' . $methodName . '.'); 129 } 139 130 if ($method->getNumberOfRequiredParameters() > count($params)) { 140 131 throw new stubException('Invalid amount of parameters passed.'); … … 165 156 166 157 $params = $this->retrieveGETParams($classAndMethod); 167 168 $this->checkRequestId($requestId);169 158 $result = $this->invokeServiceMethod($classAndMethod, $params); 170 159 $this->sendResponse($requestId, $result); … … 216 205 } 217 206 return $paramValues; 218 }219 220 protected function checkRequestId($id) {221 if (!isset($id)) {222 $this->setError('id has to have 6-7 digits');223 }224 207 } 225 208
