Author: chabotc
Date: Mon May 11 11:22:10 2009
New Revision: 773527

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

Modified:
    
incubator/shindig/branches/1.0.x-incubating/php/src/social/sample/JsonDbOpensocialService.php
    
incubator/shindig/branches/1.0.x-incubating/php/src/social/service/RestRequestItem.php
    
incubator/shindig/branches/1.0.x-incubating/php/src/social/servlet/DataServiceServlet.php

Modified: 
incubator/shindig/branches/1.0.x-incubating/php/src/social/sample/JsonDbOpensocialService.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/branches/1.0.x-incubating/php/src/social/sample/JsonDbOpensocialService.php?rev=773527&r1=773526&r2=773527&view=diff
==============================================================================
--- 
incubator/shindig/branches/1.0.x-incubating/php/src/social/sample/JsonDbOpensocialService.php
 (original)
+++ 
incubator/shindig/branches/1.0.x-incubating/php/src/social/sample/JsonDbOpensocialService.php
 Mon May 11 11:22:10 2009
@@ -182,7 +182,7 @@
         if (! $token->isAnonymous() && $id == $token->getOwnerId()) {
           $person['isOwner'] = true;
         }
-        if ($fields[0] != '@all') {
+        if (!isset($fields[0]) || $fields[0] != '@all') {
           $newPerson = array();
           $newPerson['isOwner'] = isset($person['isOwner']) ? 
$person['isOwner'] : false;
           $newPerson['isViewer'] = isset($person['isViewer']) ? 
$person['isViewer'] : false;

Modified: 
incubator/shindig/branches/1.0.x-incubating/php/src/social/service/RestRequestItem.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/branches/1.0.x-incubating/php/src/social/service/RestRequestItem.php?rev=773527&r1=773526&r2=773527&view=diff
==============================================================================
--- 
incubator/shindig/branches/1.0.x-incubating/php/src/social/service/RestRequestItem.php
 (original)
+++ 
incubator/shindig/branches/1.0.x-incubating/php/src/social/service/RestRequestItem.php
 Mon May 11 11:22:10 2009
@@ -34,10 +34,28 @@
     $this->outputConverter = $outputConverter;
   }
 
+  /**
+   * Create a RestRequestItem object
+   *
+   * @param array $servletRequest
+   * @param SecurityToken $token
+   * @param InputConverter $inputConverter
+   * @param 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']);
     }
@@ -97,26 +115,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.
@@ -125,9 +123,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/branches/1.0.x-incubating/php/src/social/servlet/DataServiceServlet.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/branches/1.0.x-incubating/php/src/social/servlet/DataServiceServlet.php?rev=773527&r1=773526&r2=773527&view=diff
==============================================================================
--- 
incubator/shindig/branches/1.0.x-incubating/php/src/social/servlet/DataServiceServlet.php
 (original)
+++ 
incubator/shindig/branches/1.0.x-incubating/php/src/social/servlet/DataServiceServlet.php
 Mon May 11 11:22:10 2009
@@ -114,6 +114,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) {


Reply via email to