[icinga-checkins] icinga.org: icinga-web/master: * Fixed API to not return metaData if parameter "withMeta" is not set or set to false/0..

git at icinga.org git at icinga.org
Thu Mar 24 09:25:56 CET 2011


Module: icinga-web
Branch: master
Commit: c6fc3ff4236f3e1692bc18cc9d92759b489f8f62
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=c6fc3ff4236f3e1692bc18cc9d92759b489f8f62

Author: Eric Lippmann <eric.lippmann at netways.de>
Date:   Wed Mar 23 15:03:48 2011 +0100

* Fixed API to not return metaData if parameter "withMeta" is not set or set to false/0..
* Fixed runSuite.sh

---

 app/modules/Api/validate/ApiSearch.xml             |    3 +-
 .../Api/views/ApiSearchSuccessView.class.php       |   22 +++++++++++--------
 app/modules/Web/validate/Icinga/ApiSearch.xml      |    7 ++---
 .../views/Icinga/ApiSearchSuccessView.class.php    |   22 +++++++++++--------
 etc/tests/runSuite.sh                              |    7 +++--
 5 files changed, 34 insertions(+), 27 deletions(-)

diff --git a/app/modules/Api/validate/ApiSearch.xml b/app/modules/Api/validate/ApiSearch.xml
index 3aff89e..197a661 100755
--- a/app/modules/Api/validate/ApiSearch.xml
+++ b/app/modules/Api/validate/ApiSearch.xml
@@ -108,9 +108,8 @@
 				<ae:parameter name="export">filters</ae:parameter>
 			</validator>
 			
-			<validator name="withMeta" class="set" required="false">
+			<validator name="withMeta" class="boolean" required="false">
 				<argument>withMeta</argument>
-
 			</validator>
 		</validators>
 		
diff --git a/app/modules/Api/views/ApiSearchSuccessView.class.php b/app/modules/Api/views/ApiSearchSuccessView.class.php
index c678abf..017da04 100755
--- a/app/modules/Api/views/ApiSearchSuccessView.class.php
+++ b/app/modules/Api/views/ApiSearchSuccessView.class.php
@@ -10,20 +10,24 @@ class Api_ApiSearchSuccessView extends IcingaApiBaseView
 	
 	public function executeJson(AgaviRequestDataHolder $rd) 
 	{
-		$count = $rd->getParameter("searchCount");
-		// just return the entities
-		if(!$rd->getParameter("withMeta",false) && !$count)
-			return json_encode($rd->getParameter("searchResult",null));
-		
-		// provide meta data for ExtJs stores
 		$searchResult = $rd->getParameter("searchResult");
-		$meta = $this->getMetaDataArray($rd); 
+		
+		$result = array(
+			"result" => $searchResult,
+			"success" => "true"
+		);
+			
+		if (false !== $rd->getParameter("withMeta", false)) {
+			// Configure ExtJS' JsonReader
+			$result["metaData"] = $this->getMetaDataArray($rd);
+		}
+		
 		$count = $rd->getParameter("searchCount");
-		$result = array("metaData" => $meta,"result"=>$searchResult,"success"=>"true");
-		if($count) {
+		if ($count) {
 			$count = array_values($count[0]);
 			$result["total"] = $count[0];
 		}
+
 		return json_encode($result);
 	}
 
diff --git a/app/modules/Web/validate/Icinga/ApiSearch.xml b/app/modules/Web/validate/Icinga/ApiSearch.xml
index 3aff89e..c3e6a8f 100755
--- a/app/modules/Web/validate/Icinga/ApiSearch.xml
+++ b/app/modules/Web/validate/Icinga/ApiSearch.xml
@@ -108,10 +108,9 @@
 				<ae:parameter name="export">filters</ae:parameter>
 			</validator>
 			
-			<validator name="withMeta" class="set" required="false">
-				<argument>withMeta</argument>
-
-			</validator>
+            <validator name="withMeta" class="boolean" required="false">
+                <argument>withMeta</argument>
+            </validator>
 		</validators>
 		
 		<validators method="read">
diff --git a/app/modules/Web/views/Icinga/ApiSearchSuccessView.class.php b/app/modules/Web/views/Icinga/ApiSearchSuccessView.class.php
index ada93cd..7b53da9 100755
--- a/app/modules/Web/views/Icinga/ApiSearchSuccessView.class.php
+++ b/app/modules/Web/views/Icinga/ApiSearchSuccessView.class.php
@@ -10,20 +10,24 @@ class Web_Icinga_ApiSearchSuccessView extends IcingaWebBaseView
 	
 	public function executeJson(AgaviRequestDataHolder $rd) 
 	{
-		$count = $rd->getParameter("searchCount");
-		// just return the entities
-		if(!$rd->getParameter("withMeta",false) && !$count)
-			return json_encode($rd->getParameter("searchResult",null));
-		
-		// provide meta data for ExtJs stores
 		$searchResult = $rd->getParameter("searchResult");
-		$meta = $this->getMetaDataArray($rd); 
+		
+		$result = array(
+			"result" => $searchResult,
+			"success" => "true"
+		);
+			
+		if (false !== $rd->getParameter("withMeta", false)) {
+			// Configure ExtJS' JsonReader
+			$result["metaData"] = $this->getMetaDataArray($rd);
+		}
+		
 		$count = $rd->getParameter("searchCount");
-		$result = array("metaData" => $meta,"result"=>$searchResult,"success"=>"true");
-		if($count) {
+		if ($count) {
 			$count = array_values($count[0]);
 			$result["total"] = $count[0];
 		}
+
 		return json_encode($result);
 	}
 
diff --git a/etc/tests/runSuite.sh b/etc/tests/runSuite.sh
index 4da894e..3a84b9d 100755
--- a/etc/tests/runSuite.sh
+++ b/etc/tests/runSuite.sh
@@ -1,7 +1,8 @@
 #!/bin/sh
-if type -P phpunit &> /dev/null == 0
+PHPUNIT=$(which phpunit)
+if [ -x ${PHPUNIT} ]
 then
-	phpunit --verbose --configuration=config/suites.xml 
+	${PHPUNIT} --verbose --configuration=config/suites.xml 
 else
-	echo "You need the newest phpunit package from pear in order to run the tests!"
+	echo "Sorry, PHPUnit not found."
 fi





More information about the icinga-checkins mailing list