public function dispatch(Request &$request)
 {
     $config = ORBConfig::getInstance();
     for ($i = 0, $max = $request->getBodyCount(); $i < $max; $i++) {
         $request->setCurrentBody($i);
         $requestURI = $request->getRequestURI();
         if (LOGGING) {
             Log::log(LoggingConstants::INFO, "requestURI = {$requestURI}");
         }
         $serviceId = substr($requestURI, 0, strrpos($requestURI, "."));
         $methodName = substr($requestURI, strlen($serviceId) + 1);
         $arg = $request->getRequestBodyData();
         if (!is_array($arg)) {
             $arg = array($request->getRequestBodyData());
         }
         try {
             $value = self::handleInvoke($request, $serviceId, $methodName, $arg);
             $namedObject = $arg[0];
             $correlationId = $namedObject->defaultAdapt()->messageId;
             $ackMessage = new AckMessage($correlationId, null, $value);
             $request->setResponseBodyPart($ackMessage);
             $request->setResponseURI("/onResult");
         } catch (Exception $e) {
             $request->setResponseBodyPart($e);
             $request->setResponseURI("/onStatus");
         }
     }
     return true;
 }
Example #2
0
 public function dispatch(Request &$request)
 {
     $config = ORBConfig::getInstance();
     for ($i = 0, $max = $request->getBodyCount(); $i < $max; $i++) {
         $request->setCurrentBody($i);
         $requestURI = $request->getRequestURI();
         if (LOGGING) {
             Log::log(LoggingConstants::INFO, "requestURI = {$requestURI}");
         }
         $serviceId = substr($requestURI, 0, strrpos($requestURI, "."));
         $methodName = substr($requestURI, strlen($serviceId) + 1);
         $arg = $request->getRequestBodyData();
         if (!is_array($arg)) {
             $arg = array($request->getRequestBodyData());
         }
         if (LOGGING) {
             Log::log(LoggingConstants::DEBUG, "requestURI = {$requestURI}, " . "serviceId = {$serviceId}, methodName = {$methodName}, bodyDataType:" . gettype($request->getRequestBodyData()) . " className:" . get_class($request->getRequestBodyData()));
         }
         try {
             $value = self::handleInvoke($request, $serviceId, $methodName, $arg);
             $request->setResponseBodyPart($value);
             $request->setResponseURI("/onResult");
         } catch (Exception $e) {
             $request->setResponseBodyPart($e);
             $request->setResponseURI("/onStatus");
         }
     }
     return true;
 }
 private function isV3Request(Request $request)
 {
     if (strpos($request->getRequestURI(), ".")) {
         return false;
     }
     if (!is_array($request->getRequestBodyData())) {
         return false;
     }
     return true;
 }
Example #4
0
 /**
  * return request path (e.g. /index or /index/something)
  * Also, it removes GET parameters from URI. (/index?something => /index)
  * @return string
  */
 public function getRequestPath()
 {
     $requestUri = explode('/', preg_replace('/\\?.*/', '', Request::getRequestURI()));
     $scriptName = explode('/', Request::getScriptURI());
     for ($i = 0; $i < sizeof($scriptName); $i++) {
         if ($requestUri[$i] == $scriptName[$i]) {
             unset($requestUri[$i]);
         }
     }
     return '/' . implode($requestUri, '/');
 }
Example #5
0
 /**
  * Extracts and returns the path of the current Request, by striping the query string.
  * @param Request $request Request to extract the path from
  * @return string path
  */
 private static function getPath(Request $request)
 {
     $path = $request->getRequestURI();
     //$path = $request->getPathInfo(); // wrong URL encoding
     if ($pos = strpos($path, "?")) {
         $path = substr($path, 0, $pos);
     }
     // strip the query string
     $path = substr($path, 1);
     // strip the leading slash
     return $path;
 }
 /**
  * Parse the framework-object requested into the URL
  *
  * @param Request $pRequest 
  */
 protected function resolveRequest($pRequest)
 {
     $request = $pRequest->getRequestURI();
     if (empty($request)) {
         throw new ResolverException('Empty request URI in Resolver');
     }
     if (preg_match('/^\\/\\/+/', $request)) {
         \OatBox\Common\Logger::w('Multiple leading slashes in request URI: ' . $request);
         $request = '/' . ltrim($request, '/');
     }
     $rootUrlPath = $pRequest->getRootSubPath();
     $absPath = parse_url($request, PHP_URL_PATH);
     if (substr($absPath, 0, strlen($rootUrlPath)) != $rootUrlPath) {
         throw new ResolverException('Request Uri ' . $request . ' outside of TAO path ' . ROOT_URL);
     }
     $relPath = substr($absPath, strlen($rootUrlPath));
     $relPath = ltrim($relPath, '/');
     $tab = explode('/', $relPath);
     if (count($tab) > 0) {
         $this->module = isset($tab[0]) && !empty($tab[0]) ? $tab[0] : null;
         $this->action = isset($tab[1]) && !empty($tab[1]) ? $tab[1] : null;
     } else {
         throw new ResolverException('Empty request Uri ' . $request . ' reached resolver');
     }
 }
Example #7
0
 /**
  * Make a URL from Lobby Base Path.
  * Eg: /hello to http://lobby.dev/hello
  */
 public static function u($path = null, $relative = false)
 {
     if (self::$cli) {
         return null;
     }
     /**
      * The $path var is changed during the process
      * So, original path is stored separately
      */
     $origPath = $path;
     /**
      * The return URL
      */
     $url = $path;
     /**
      * Prettyify $path
      */
     if ($path !== null) {
         $path = ltrim($path, "/");
         $parts = parse_url($path);
         /**
          * Make host along with port:
          * 127.0.0.1:9000
          */
         if (isset($parts['host'])) {
             $urlHost = $parts['host'] . (isset($parts['port']) ? ":{$parts['port']}" : "");
         } else {
             $urlHost = null;
         }
     }
     /**
      * If no path, give the current page URL
      */
     if ($path == null) {
         $pageURL = 'http';
         if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
             $pageURL .= "s";
         }
         $pageURL .= "://";
         $requestURI = $relative === false ? Request::getRequestURI() : $_SERVER["REQUEST_URI"];
         if (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] != "80") {
             $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $requestURI;
         } else {
             $pageURL .= $_SERVER["SERVER_NAME"] . $requestURI;
         }
         $url = $pageURL;
     } else {
         if ($path === self::$url) {
             $url = self::$url;
         } else {
             if (!preg_match("/http/", $path) || $urlHost !== self::$host) {
                 /**
                  * If $origPath is a relative URI
                  */
                 if ($urlHost == null) {
                     $url = self::$url . "/{$path}";
                 } else {
                     if (Apps::isAppRunning()) {
                         $url = Apps::getRunningInstance()->u($origPath);
                     }
                 }
             }
         }
     }
     return $url;
 }