Commit 50fd94044dca0f28ab0bb82ed982a7c56dfa3433

Authored by Elena.Budnik
1 parent 1ba8d04c

getDataset()

php/classes/WebServer.php
... ... @@ -784,55 +784,57 @@ class WebServer
784 784 $this->throwError("requestError", "Cannot parse request");
785 785 }
786 786  
787   - $resMgr = $this->initUserMgr();
  787 + $this->initUserMgr();
788 788  
789 789 $vars = $res['vars'];
790 790  
791 791 if (strtotime($vars["stopTime"]) <= strtotime($vars["startTime"])){
792 792 $this->throwError("requestError", "Requested time interval should be greater than 0");
793 793 }
794   -
  794 +
  795 + $dataSetXml = WSConfigClass::getDataSetInfoDir().$vars['datasetID'].".xml";
  796 +
  797 + if (!file_exists($dataSetXml))
  798 + $this->throwError("systemError", "Cannot find info file for dataset ".$vars['datasetID']);
  799 +
  800 + $dataSetDom = new DomDocument("1.0");
  801 +
  802 + if (!@$dataSetDom->load($dataSetXml))
  803 + $this->throwError("systemError", "Cannot load info file for dataset ".$vars['datasetID']);
  804 +
  805 + $params = $dataSetDom->getElementsByTagName("parameter");
  806 +
  807 + if ($params->length == 0)
  808 + $this->throwError("systemError", "Cannot find parameter list for dataset ".$vars['datasetID']);
  809 +
795 810 $paramId = array();
796   - $localData = simplexml_load_file(USERPATH.$this->userID.'/WS/LocalParams.xml');
  811 +
  812 + foreach ($params as $p)
  813 + $paramId[] = $p->nodeValue;
797 814  
798 815 if (!$vars["sampling"])
799   - {
800   - $xpath = "//dataset[@xml:id='".$vars['datasetID']."']/@sampling";
801   - $tmp = $localData->xpath($xpath);
802   - $vars["sampling"] = (string)$tmp[0];
803   -
804   - $matches=array();
805   - preg_match("/([a-z])$/", $vars["sampling"], $matches);
  816 + {
  817 + $sampling = $dataSetDom->getElementsByTagName('min_sampling')->item(0)->nodeValue;
806 818  
807   - $dataFileName = $this->getDataFileName($vars, true);
808   -
809   - if ($dataFileName['success']) {
810   - $this->dataFileName = $dataFileName['fileName'];
811   - }
812   - else {
813   - $this->throwError("requestError",$dataFileName['message']);
814   - }
815   -
816   - $vars["sampling"] = strtr($vars["sampling"], array($matches[1] => ""));
817   - switch ($matches[1]) {
818   - case 's':
819   - $sampling = floatval($vars["sampling"]);
820   - break;
821   - case 'm':
822   - $sampling = floatval($vars["sampling"])*60;
  819 + $units = substr($sampling,-1);
  820 + $sampling = substr($sampling,0,strlen($sampling)-1);
  821 +
  822 + switch ($units) {
  823 +// case 'S':
  824 +// $sampling = floatval($sampling);
  825 +// break;
  826 + case 'M':
  827 + $sampling = floatval($sampling)*60;
823 828 break;
824   - case 'h':
825   - $sampling = floatval($vars["sampling"])*60*60;
  829 + case 'H':
  830 + $sampling = floatval($sampling)*60*60;
826 831 break;
827 832 default:
828 833 }
829 834 }
830   -
831   - $xpath = "//dataset[@xml:id='".$vars['datasetID']."']/parameter/@*[namespace-uri()='http://www.w3.org/XML/1998/namespace' and local-name()='id']";
832   - $pars = $localData->xpath($xpath);
833   -
834   - foreach ($pars as $p)
835   - $paramId[] = (string)$p[0];
  835 + else {
  836 + $sampling = $vars["sampling"];
  837 + }
836 838  
837 839 if (!$vars["timeFormat"])
838 840 $timeFormat = "ISO8601";
... ... @@ -844,6 +846,13 @@ class WebServer
844 846 else
845 847 $gzip = $vars["gzip"];
846 848  
  849 + if (!$vars["stream"])
  850 + $stream = 0;
  851 + else
  852 + $stream = $vars["stream"];
  853 +
  854 + $this->service = strtolower(__FUNCTION__);
  855 +
847 856 $res = $this->doDownloadRequest(
848 857 array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $sampling),
849 858 array("params" => $paramId),
... ...
php/rest/getDataset.php 0 โ†’ 100644
... ... @@ -0,0 +1,21 @@
  1 +<?php
  2 +/**
  3 + * @file getDataset.php
  4 + * @brief REST interface for service getDataset
  5 + */
  6 +
  7 +//ini_set("allow_url_fopen", true);
  8 +require_once '../config.php';
  9 +
  10 +$amda_ws = new WebServer();
  11 +
  12 +if (!key_exists("token", $_GET)) {
  13 + $result = array('success' => false, 'message' => "Authentication is required for this webservice.");
  14 +} else if ($amda_ws->getNewToken()['token'] != $_GET["token"]) {
  15 + $result = array('success' => false, 'status' => 'expired', 'message' => "Token expired. Please authenticate again.");
  16 +} else {
  17 + $result = $amda_ws->getDataset($_GET);
  18 +}
  19 +
  20 +echo json_encode($result);
  21 +?>
... ...
php/rest/getDatasetData.php deleted
... ... @@ -1,44 +0,0 @@
1   -<?php
2   -/**
3   - * @file getParameter.php
4   - * @brief REST interface for service getParameter
5   - *
6   - *
7   - * @version $Id: $
8   - */
9   -ini_set("allow_url_fopen", true);
10   -require_once '../config.php';
11   -
12   -$amda_ws = new WebServer();
13   -
14   -if (!key_exists("token", $_GET)) {
15   - $result = array('success' => false, 'message' => "E01: Authentication is required for this webservice.");
16   -} else if ($amda_ws->getNewToken()['token'] != $_GET["token"]) {
17   - $result = array('success' => false, 'message' => "E02: Token expired. Please authenticate again.");
18   -} else {
19   - $result = $amda_ws->getDataset($_GET);
20   -}
21   -
22   -if ($result['success']) {
23   - $file = str_replace("http://oberoi.cesr.fr/AMDA-WS/", BASE_PATH, $result['dataFileURLs']);
24   -
25   - if ($file) {
26   -// header('Content-type: text/xml');
27   -// $contenu = file_get_contents($file);
28   -// error_log($contenu,3,'/home/natacha/TMP/tmp.xml');
29   -// echo $contenu;
30   -
31   - header('Content-type: text/xml');
32   - $doc = new DOMDocument();
33   - $doc->load($file);
34   - echo $doc->saveXML();
35   -
36   -
37   - }
38   -} else {
39   - $success = "false";
40   - echo '<?xml version="1.0" encoding="UTF-8"?><getParameterResponse>';
41   - echo '<success>' . $success . '</success>';
42   - echo '<message>' . $result['message'] . '</message></getParameterResponse>';
43   -}
44   -?>
public/wsdl/Methods_AMDA.wsdl
... ... @@ -879,6 +879,22 @@ of a set of typically orthogonal axes.
879 879 required parameters</xs:documentation>
880 880 </xs:annotation>
881 881 </xs:element>
  882 + <xs:element maxOccurs="1" minOccurs="0" name="status">
  883 + <xs:annotation>
  884 + <xs:documentation></xs:documentation>
  885 + </xs:annotation>
  886 + <xs:simpleType>
  887 + <xs:restriction base="xs:string">
  888 + <xs:enumeration value="in progress"/>
  889 + <xs:enumeration value="error"/>
  890 + </xs:restriction>
  891 + </xs:simpleType>
  892 + </xs:element>
  893 + <xs:element maxOccurs="1" minOccurs="0" name="id" type="xs:string">
  894 + <xs:annotation>
  895 + <xs:documentation>process ID</xs:documentation>
  896 + </xs:annotation>
  897 + </xs:element>
882 898 </xs:sequence>
883 899 </xs:complexType>
884 900  
... ...