/** * Construct the object to handle requests. This will instantiate * the NDB_BVL_Instrument object and call toJSON to return the * JSON to the client. * * @param string $method The HTTP method used for the request * @param string $Instrument The instrument to be serialized */ function __construct($method, $Instrument) { $this->AutoHandleRequestDelegation = false; parent::__construct($method); try { $this->Instrument = \NDB_BVL_Instrument::factory($Instrument, null, null, true); } catch (\Exception $e) { $this->header("HTTP/1.1 404 Not Found"); $this->error("Invalid Instrument"); $this->safeExit(0); } // JSON is used by both calculateETag and handleGET, so do it // before either is called. $this->JSONString = $this->Instrument->toJSON(); $this->handleRequest(); }
/** * Construct class to handle request * * @param string $method HTTP method of request * @param string $CandID CandID of candidate to be serialized */ public function __construct($method, $CandID) { $requestDelegationCascade = $this->AutoHandleRequestDelegation; $this->AutoHandleRequestDelegation = false; $this->CandID = $CandID; parent::__construct($method); if (!is_numeric($CandID) || $CandID < 100000 || $CandID > 999999) { $this->header("HTTP/1.1 400 Bad Request"); $this->error("Invalid CandID format"); $this->safeExit(0); } try { $this->Candidate = $this->Factory->Candidate($CandID); } catch (\Exception $e) { $this->header("HTTP/1.1 404 Not Found"); $this->error("Unknown CandID"); $this->safeExit(0); } if ($requestDelegationCascade) { $this->handleRequest(); } }
/** * Constructs an object to handle JSON serialization * * @param string $method The HTTP method of the request * @param string $projectName The project to be serialized * @param boolean $bCandidates If true, candidates for project * should be included in serialization * be included in serialization be * included in serialization * @param boolean $bInstruments If true, list of instruments for * project should be included in * serialization should be included * in serialization should be included * in serialization * @param boolean $bVisits If true, visits for project should be * included in serialization included in * serialization included in serialization * @param boolean $bInstrumentDetails If true, InstrumentDetails are populated * instead of instrument names */ public function __construct($method, $projectName, $bCandidates, $bInstruments, $bVisits, $bInstrumentDetails = false) { $this->AutoHandleRequestDelegation = false; parent::__construct($method); $this->bCandidates = $bCandidates; $this->bInstruments = $bInstruments; $this->bInstrumentDetails = $bInstrumentDetails; $this->bVisits = $bVisits; $this->ProjectName = $projectName; include_once 'Utility.class.inc'; if ($projectName === 'loris') { $this->ProjectID = 0; } else { $this->ProjectID = $this->getProjectID($projectName); } if (!is_numeric($this->ProjectID)) { $this->header("HTTP/1.1 404 Not Found"); $this->error(['error' => 'Invalid project']); $this->safeExit(0); } $this->handleRequest(); }