fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [6917] Changed url handling


From: Petur Thorsteinsson
Subject: [Fmsystem-commits] [6917] Changed url handling
Date: Thu, 03 Feb 2011 19:21:28 +0000

Revision: 6917
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=6917
Author:   peturbjorn
Date:     2011-02-03 19:21:28 +0000 (Thu, 03 Feb 2011)
Log Message:
-----------
Changed url handling

Modified Paths:
--------------
    branches/dev-bim2/property/inc/class.sobim_converter.inc.php

Modified: branches/dev-bim2/property/inc/class.sobim_converter.inc.php
===================================================================
--- branches/dev-bim2/property/inc/class.sobim_converter.inc.php        
2011-02-03 19:20:46 UTC (rev 6916)
+++ branches/dev-bim2/property/inc/class.sobim_converter.inc.php        
2011-02-03 19:21:28 UTC (rev 6917)
@@ -11,10 +11,11 @@
  */
 interface sobim_converter {
        public function getFacilityManagementXml();
+       public function setBaseUrl($url);
 }
 
 class sobim_converter_impl implements sobim_converter {
-       private $baseUrl = 
"http://localhost:8080/BIM_Facility_Management/rest/";;
+       private $baseUrl = "http://localhost:8080/bm/rest/";;
        private $fileToSend;
        
        public function __construct() {
@@ -27,6 +28,7 @@
        }
        
        public function getFacilityManagementXml() {
+               $this->checkArgumentsForXmlDownload();
                $restCall = "uploadIfc";
                $url = $this->baseUrl.$restCall;
                $verb = "POST";
@@ -35,13 +37,32 @@
                );
                
                $rest = new RestRequest($url, $verb, $data);
+               
                $rest->setAcceptType("application/xml");
                $rest->execute();
+               //echo "SObim converter: response info\n";
+               //print_r($rest->getResponseInfo());
                if( $rest->isError()) {
+                       $info = $rest->getResponseInfo();
+                       $http_code = $info["http_code"];
+                       if($http_code == 0) {
+                               throw new NoResponseException();
+                       }
                        throw new Exception("Rest call error : 
".var_export($rest->getResponseInfo()));
                }
                return $rest->getResponseBody();
        }
+       public function checkArgumentsForXmlDownload() {
+               if(empty($this->fileToSend)) {
+                       throw new InvalidArgumentException("File to send has 
not been specified");
+               }
+               if(!file_exists($this->fileToSend)) {
+                       throw new InvalidArgumentException("File to send not 
found in filesystem");
+               }
+               if(empty($this->baseUrl) || strlen($this->baseUrl) < 2) {
+                       throw new InvalidArgumentException("Base url not set!");
+               }
+       }
        public function getRepositoryCountJson() {
                
                $url = $this->baseUrl."uploadIfc";
@@ -52,6 +73,12 @@
                $output = $rest->getResponseBody();
                echo $output;
        }
+       public function setBaseUrl($url) {
+               if(substr($url, -1) != "/") {
+                       $url = $url . "/";
+               }
+               $this->baseUrl = $url;
+       }
        
        public function getRepositoryNames() {
                $url = $this->baseUrl."/names";




reply via email to

[Prev in Thread] Current Thread [Next in Thread]