Commit 26dbe95d416b5f595ed157edb0d76a830079ab8d

Authored by Benjamin Renard
1 parent 0123b9fe

outputFormat for getTimeTable & getCatalog API

php/WebServices/WebServer.php
... ... @@ -632,8 +632,9 @@ class WebServer
632 632 }
633 633  
634 634 $ttID = $res['vars']['ttID'];
  635 + $format = !empty($res['vars']['outputFormat']) ? $res['vars']['outputFormat'] : 'VOTable';
635 636  
636   - return $this->getTimeTableCatalog('timeTable', $ttID);
  637 + return $this->getTimeTableCatalog('timeTable', $ttID, $format);
637 638 }
638 639  
639 640 /*
... ... @@ -651,8 +652,9 @@ class WebServer
651 652 }
652 653  
653 654 $catID = $res['vars']['catID'];
  655 + $format = !empty($res['vars']['outputFormat']) ? $res['vars']['outputFormat'] : 'VOTable';
654 656  
655   - return $this->getTimeTableCatalog('catalog', $catID);
  657 + return $this->getTimeTableCatalog('catalog', $catID, $format);
656 658 }
657 659  
658 660 /*
... ... @@ -661,7 +663,7 @@ class WebServer
661 663 *
662 664 * get Time Table : shared for anonymous user (impex) ; user' for user
663 665 */
664   - private function getTimeTableCatalog($type, $id)
  666 + private function getTimeTableCatalog($type, $id, $format)
665 667 {
666 668 $this->initUserMgr();
667 669  
... ... @@ -676,7 +678,11 @@ class WebServer
676 678 $this->throwError("workspaceError", "No such object ".$id." for user ".$this->userID);
677 679 }
678 680  
679   - $objDst = substr(strtolower(__FUNCTION__), 3)."_".$this->userID."_".$this->requestTime."_$id.xml";
  681 + $prefix = ($type == 'catalog') ? 'catalog' : 'timetable';
  682 +
  683 + $extension = (strtolower($format) == 'votable') ? "xml" : "txt";
  684 +
  685 + $objDst = $prefix."_".$this->userID."_".$this->requestTime."_$id.$extension";
680 686  
681 687 if (!isset($this->requestManager))
682 688 $this->requestManager = new RequestManagerClass();
... ... @@ -684,7 +690,7 @@ class WebServer
684 690 try {
685 691 $obj = array(
686 692 'inputFile' => $objSrc,
687   - 'outputFormat' => 'VOTABLE',
  693 + 'outputFormat' => $format,
688 694 'outputFileName' => $objDst,
689 695 );
690 696 $res = $this->requestManager->runWSRequest($this->userID, $this->IPclient, FunctionTypeEnumClass::TTCONVERT, $this->service, $obj);
... ...
php/rest/getCatalog.php
... ... @@ -9,6 +9,7 @@
9 9 * @apiParam {String} catID Identifier of the Catalog, as defined in the file returned by the « getCatalogsList » service.
10 10 * @apiParam {String} [userID] Identifier of the user in AMDA (*mandatory for user owned data*)
11 11 * @apiParam {String} [password] Password of the user in AMDA (*mandatory for user owned data*)
  12 + * @apiParam {String} [outputFormat] Format of the returned file (VOTable by default). Available options: `VOTable`, `ASCII` and `HPEvent`.
12 13 *
13 14 * @apiSuccess {String} success `true`
14 15 * @apiSuccess {String} catFileURL URL of the XML file containing the Catalog (VOTable format)
... ...
php/rest/getTimeTable.php
... ... @@ -9,6 +9,7 @@
9 9 * @apiParam {String} ttID Identifier of the Time Table, as defined in the file returned by the « getTimeTableList » service.
10 10 * @apiParam {String} [userID] Identifier of the user in AMDA (*mandatory for user owned data*)
11 11 * @apiParam {String} [password] Password of the user in AMDA (*mandatory for user owned data*)
  12 + * @apiParam {String} [outputFormat] Format of the returned file (VOTable by default). Available options: `VOTable`, `ASCII` and `HPEvent`.
12 13 *
13 14 * @apiSuccess {String} success `true`
14 15 * @apiSuccess {String} ttFileURL URL of the XML file containing the Time Table (VOTable format)
... ...