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,8 +632,9 @@ class WebServer
632 } 632 }
633 633
634 $ttID = $res['vars']['ttID']; 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,8 +652,9 @@ class WebServer
651 } 652 }
652 653
653 $catID = $res['vars']['catID']; 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,7 +663,7 @@ class WebServer
661 * 663 *
662 * get Time Table : shared for anonymous user (impex) ; user' for user 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 $this->initUserMgr(); 668 $this->initUserMgr();
667 669
@@ -676,7 +678,11 @@ class WebServer @@ -676,7 +678,11 @@ class WebServer
676 $this->throwError("workspaceError", "No such object ".$id." for user ".$this->userID); 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 if (!isset($this->requestManager)) 687 if (!isset($this->requestManager))
682 $this->requestManager = new RequestManagerClass(); 688 $this->requestManager = new RequestManagerClass();
@@ -684,7 +690,7 @@ class WebServer @@ -684,7 +690,7 @@ class WebServer
684 try { 690 try {
685 $obj = array( 691 $obj = array(
686 'inputFile' => $objSrc, 692 'inputFile' => $objSrc,
687 - 'outputFormat' => 'VOTABLE', 693 + 'outputFormat' => $format,
688 'outputFileName' => $objDst, 694 'outputFileName' => $objDst,
689 ); 695 );
690 $res = $this->requestManager->runWSRequest($this->userID, $this->IPclient, FunctionTypeEnumClass::TTCONVERT, $this->service, $obj); 696 $res = $this->requestManager->runWSRequest($this->userID, $this->IPclient, FunctionTypeEnumClass::TTCONVERT, $this->service, $obj);
php/rest/getCatalog.php
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 * @apiParam {String} catID Identifier of the Catalog, as defined in the file returned by the « getCatalogsList » service. 9 * @apiParam {String} catID Identifier of the Catalog, as defined in the file returned by the « getCatalogsList » service.
10 * @apiParam {String} [userID] Identifier of the user in AMDA (*mandatory for user owned data*) 10 * @apiParam {String} [userID] Identifier of the user in AMDA (*mandatory for user owned data*)
11 * @apiParam {String} [password] Password of the user in AMDA (*mandatory for user owned data*) 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 * @apiSuccess {String} success `true` 14 * @apiSuccess {String} success `true`
14 * @apiSuccess {String} catFileURL URL of the XML file containing the Catalog (VOTable format) 15 * @apiSuccess {String} catFileURL URL of the XML file containing the Catalog (VOTable format)
php/rest/getTimeTable.php
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 * @apiParam {String} ttID Identifier of the Time Table, as defined in the file returned by the « getTimeTableList » service. 9 * @apiParam {String} ttID Identifier of the Time Table, as defined in the file returned by the « getTimeTableList » service.
10 * @apiParam {String} [userID] Identifier of the user in AMDA (*mandatory for user owned data*) 10 * @apiParam {String} [userID] Identifier of the user in AMDA (*mandatory for user owned data*)
11 * @apiParam {String} [password] Password of the user in AMDA (*mandatory for user owned data*) 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 * @apiSuccess {String} success `true` 14 * @apiSuccess {String} success `true`
14 * @apiSuccess {String} ttFileURL URL of the XML file containing the Time Table (VOTable format) 15 * @apiSuccess {String} ttFileURL URL of the XML file containing the Time Table (VOTable format)