You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by ch...@apache.org on 2009/05/11 13:21:37 UTC

svn commit: r773526 - in /incubator/shindig/trunk/php: src/social/service/RestRequestItem.php src/social/servlet/DataServiceServlet.php test/index.php

Author: chabotc
Date: Mon May 11 11:21:37 2009
New Revision: 773526

URL: http://svn.apache.org/viewvc?rev=773526&view=rev
Log:
SHINDIG-1054 by Pan Jie - cannot apply multiple fields in restful api with oauth arguments

Modified:
    incubator/shindig/trunk/php/src/social/service/RestRequestItem.php
    incubator/shindig/trunk/php/src/social/servlet/DataServiceServlet.php
    incubator/shindig/trunk/php/test/index.php

Modified: incubator/shindig/trunk/php/src/social/service/RestRequestItem.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/social/service/RestRequestItem.php?rev=773526&r1=773525&r2=773526&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/social/service/RestRequestItem.php (original)
+++ incubator/shindig/trunk/php/src/social/service/RestRequestItem.php Mon May 11 11:21:37 2009
@@ -42,10 +42,22 @@
     $this->outputConverter = $outputConverter;
   }
 
+  /**
+   * @return RestRequestItem
+   */
   public static function createWithRequest($servletRequest, $token, $inputConverter, $outputConverter) {
     $restfulRequestItem = new RestRequestItem(self::getServiceFromPath($servletRequest['url']), self::getMethod(), $token, $inputConverter, $outputConverter);
     $restfulRequestItem->setUrl($servletRequest['url']);
-    $restfulRequestItem->setParams($restfulRequestItem->createParameterMap());
+    if (isset($servletRequest['params'])) {
+      $restfulRequestItem->setParams($servletRequest['params']);
+    } else {
+      $paramPieces = parse_url($restfulRequestItem->url);
+      if (isset($paramPieces['query'])) {
+        $params = array();
+        parse_str($paramPieces['query'], $params);
+        $restfulRequestItem->setParams($params);
+      }
+    }
     if (isset($servletRequest['postData'])) {
       $restfulRequestItem->setPostData($servletRequest['postData']);
     }
@@ -120,26 +132,6 @@
     }
   }
 
-  protected static function createParameterMap() {
-    $parameters = array_merge($_POST, $_GET);
-    return $parameters;
-  }
-
-  /** 
-   * Use this function to parse out the query array element 
-   * Usually the servlet request code does this for us but the batch request calls have to do it
-   * by hand
-   * 
-   * @param the output of parse_url(). 
-   */
-  private function parseQuery($val) {
-    $params = explode('&', $val);
-    foreach ($params as $param) {
-      $queryParams = explode('=', $param);
-      $this->params[$queryParams[0]] = isset($queryParams[1]) ? $queryParams[1] : '';
-    }
-  }
-
   /**
    * This could definitely be cleaner..
    * TODO: Come up with a cleaner way to handle all of this code.
@@ -148,9 +140,6 @@
    */
   public function applyUrlTemplate($urlTemplate) {
     $paramPieces = @parse_url($this->url);
-    if (isset($paramPieces['query'])) {
-      $this->parseQuery($paramPieces['query']);
-    }
     $actualUrl = explode("/", $paramPieces['path']);
     $expectedUrl = explode("/", $urlTemplate);
     for ($i = 1; $i < count($actualUrl); $i ++) {

Modified: incubator/shindig/trunk/php/src/social/servlet/DataServiceServlet.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/social/servlet/DataServiceServlet.php?rev=773526&r1=773525&r2=773526&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/social/servlet/DataServiceServlet.php (original)
+++ incubator/shindig/trunk/php/src/social/servlet/DataServiceServlet.php Mon May 11 11:21:37 2009
@@ -116,6 +116,7 @@
         $servletRequest['postData'] = stripslashes($servletRequest['postData']);
       }
     }
+    $servletRequest['params'] = array_merge($_GET, $_POST);
     $requestItem = RestRequestItem::createWithRequest($servletRequest, $token, $inputConverter, $outputConverter);
     $responseItem = $this->getResponseItem($this->handleRequestItem($requestItem));
     if ($responseItem->getError() == null) {

Modified: incubator/shindig/trunk/php/test/index.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/index.php?rev=773526&r1=773525&r2=773526&view=diff
==============================================================================
--- incubator/shindig/trunk/php/test/index.php (original)
+++ incubator/shindig/trunk/php/test/index.php Mon May 11 11:21:37 2009
@@ -30,7 +30,7 @@
 function __autoload($className) {
   $basePath = realpath('../');
   $locations = array('src/common', 'src/common/sample', 'src/gadgets', 'src/gadgets/http', 'src/gadgets/oauth', 
-      'src/gadgets/sample', 'src/social', 'src/social/http', 'src/social/service', 
+      'src/gadgets/render', 'src/gadgets/rewrite', 'src/gadgets/sample', 'src/social', 'src/social/http', 'src/social/service', 
       'src/social/converters', 'src/social/opensocial', 'src/social/spi', 'src/social/model', 
       'src/social/sample', 'src/social/oauth');
   $extension_class_paths = Config::get('extension_class_paths');