Source of file GetRecordByIdCommand.php
Size: 2,067 Bytes - Last Modified: 2021-12-23T10:31:40+00:00
/var/www/docs.ssmods.com/process/src/code/commands/GetRecordByIdCommand.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 | <?php /** * @author Rainer Spittel (rainer at silverstripe dot com) * @package geocatalog * @subpackage commands */ /** * Retrieve the full metadata record of a specific record from the GeoNetwork node. * * This command sends a request to the GeoNetwork node to retrieve a single metadata * record. It returns a XML string which is the plain XML catalogue response. */ class GetRecordByIdCommand extends GnAuthenticationCommand { public static $catalogue_url = 'srv/en/csw'; public static function get_catalogue_url() { return self::$catalogue_url; } public static function set_catalogue_url($value) { self::$catalogue_url = $value; } /** * Command execute * * Performs the command to retrieve a single metadata record. This command creates a * request (initiates a sub-command) and uses this to send of the * OGC request to GeoNetwork. * * @see CreateRecordByIdRequestCommand * * @return string OGC CSW response */ public function execute() { $data = $this->getParameters(); // generate GeoNetwork HTTP request (query metadata). $cmd = null; $cmd = $this->getController()->getCommand("CreateRecordByIdRequest", $data); $xml = $cmd->execute(); // send requrest to GeoNetwork $this->restfulService = new GeoNetworkRestfulService($this->getController()->getGeoNetworkBaseURL(), 0); if ($this->getUsername()) { $this->restfulService->setUsername($this->getUsername()); $this->restfulService->setPassword($this->getPassword()); $this->restfulService->setRequireAuthentication(true); } $headers = array('Content-Type: application/xml'); $response = $this->restfulService->request(self::get_catalogue_url(), 'POST', $xml, $headers); // @todo better error handling $responseXML = $response->getBody(); return $responseXML; } } |