oodt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject svn commit: r1144382 - /oodt/trunk/filemgr/src/main/php/
Date Fri, 08 Jul 2011 16:54:56 GMT
Author: gabe
Date: Fri Jul  8 16:54:56 2011
New Revision: 1144382

URL: http://svn.apache.org/viewvc?rev=1144382&view=rev
Log:
OODT-165: Adding improvements made to the File Manager PHP data structures in the JPL repo
to the Apache repo.  This includes a few new files that have been added since the Apache repo
was created.

Added:
    oodt/trunk/filemgr/src/main/php/BooleanQueryCriteria.class.php
    oodt/trunk/filemgr/src/main/php/Element.class.php
    oodt/trunk/filemgr/src/main/php/ProductPage.class.php
    oodt/trunk/filemgr/src/main/php/Query.class.php
    oodt/trunk/filemgr/src/main/php/RangeQueryCriteria.class.php
    oodt/trunk/filemgr/src/main/php/TermQueryCriteria.class.php
Modified:
    oodt/trunk/filemgr/src/main/php/Product.class.php
    oodt/trunk/filemgr/src/main/php/ProductType.class.php
    oodt/trunk/filemgr/src/main/php/XmlRpcFilemgrClient.class.php

Added: oodt/trunk/filemgr/src/main/php/BooleanQueryCriteria.class.php
URL: http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/php/BooleanQueryCriteria.class.php?rev=1144382&view=auto
==============================================================================
--- oodt/trunk/filemgr/src/main/php/BooleanQueryCriteria.class.php (added)
+++ oodt/trunk/filemgr/src/main/php/BooleanQueryCriteria.class.php Fri Jul  8 16:54:56 2011
@@ -0,0 +1,140 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+require_once("XML/RPC.php");
+
+/**
+ * @author resneck
+ *
+ * <p>A PHP port of the core filemgr data structure.</p>
+ */
+ class CAS_Filemgr_BooleanQueryCriteria {
+ 
+ 	// These variables will function as constants to define boolean operators
+ 	public static $AND_OP = 0;
+    public static $OR_OP = 1;
+    public static $NOT_OP = 2;
+    
+    public $operator;
+    public $terms;
+    
+     /**
+     * Default constructor. Uses the AND operator.
+     */
+	function __construct(){
+    	$this->operator = self::$AND_OP;
+    	$this->terms = array();
+	}
+	
+	/**
+     * This query is a boolean combination of term,
+     * range, and other boolean queries. The supported operators are AND, OR and
+     * NOT. Note that the NOT operator can only be used with one (1) term. This
+     * function will not operate if more than one term is used with the NOT
+     * operator.
+     * 
+     * @param terms
+     *            The criteria onto which to apply the boolean operator
+     * @param op
+     *            The boolean operator to be applied
+     */
+	function __init($terms, $op){
+		if(!($op == self::$NOT_OP && count($terms) > 1)){
+			$this->terms = $terms;
+			$this->operator = $op;
+		}
+	}
+	
+	function __initXmlRpc($xmlRpcData){
+    	$this->operator = (isset($xmlRpcData['operator']))
+			? intval($xmlRpcData['operator']) 
+			: self::$AND_OP;
+		$this->terms = (isset($xmlRpcData['terms']))
+			? $xmlRpcData['terms'] 
+			: array();
+	}
+	
+	/**
+     * Method to add a term to the boolean query. Note that a NOT operator can
+     * only be applied to one term. This function will not operate if more than 
+     * one term is used with the NOT operator.
+     * 
+     * @param t
+     *            Term to be added to the query
+     */
+	function addTerm($t){
+		if(!($this->operator == self::$NOT_OP && count($this->terms))){
+			array_push($this->terms, $t);
+		}
+	}
+	
+	/**
+     * Accessor method for the list of terms in the query.
+     * 
+     * @return The list of terms
+     */
+    function getTerms() {
+        return $this->terms;
+    }
+
+    /**
+     * Mutator method for the boolean operator. This function will not operate if more than

+     * one term is used with the NOT operator.
+     * 
+     * @param op
+     *            Boolean operator
+     */
+    function setOperator($op){
+    	if(!($op == self::$NOT_OP && count($this->terms) > 1)){
+    		$this->operator = $op;
+    	}
+    }
+
+    /**
+     * Accessor method for the boolean operator.
+     * 
+     * @return the boolean operator
+     */
+    function getOperator() {
+        return $this->operator;
+    }
+    
+    function toAssocArray(){
+		$assocArray = array(
+			'operator' => $this->operator,
+			'terms' => array());
+		foreach($this->terms as $t){
+			array_push($assocArray['terms'], $t->toAssocArray());
+		}
+		return $assocArray;
+	}
+	
+	function toXmlRpcStruct(){
+		$termArray = array();
+		foreach($this->terms as $t){
+			array_push($termArray, $t->toXmlRpcStruct());
+		}
+		return new XML_RPC_Value(array(
+			'class' => new XML_RPC_Value('org.apache.oodt.cas.filemgr.structs.BooleanQueryCriteria',
'string'),
+			'terms' => new XML_RPC_Value($termArray, 'array'),
+			'operator' => new XML_RPC_Value($this->operator, 'int')), 'struct');
+	}
+ 
+ }
+ 
+ ?>

Added: oodt/trunk/filemgr/src/main/php/Element.class.php
URL: http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/php/Element.class.php?rev=1144382&view=auto
==============================================================================
--- oodt/trunk/filemgr/src/main/php/Element.class.php (added)
+++ oodt/trunk/filemgr/src/main/php/Element.class.php Fri Jul  8 16:54:56 2011
@@ -0,0 +1,150 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+require_once("XML/RPC.php");
+
+/**
+ * @author resneck
+ *
+ * <p>A PHP port of the core filemgr data structure.</p>
+ */
+class CAS_Filemgr_Element {
+
+	/* the element id */
+	public $elementId;
+
+    /* the element name */
+    public $elementName;
+
+    /* the corresponding DC element for this CAS element */
+    public $dcElement;
+
+    /* the element's string description. */
+    public $description;
+    
+    /**
+	 * <p>Default Constructor.</p>
+	 */
+	function __construct(){
+		$this->elementId = null;
+		$this->elementName = null;
+		$this->dcElement = null;
+		$this->description = null;
+	}
+	
+	function __init($elementId, $elementName, $dcElement, $description){
+		$this->elementId = $elementId;
+		$this->elementName = $elementName;
+		$this->dcElement = $dcElement;
+		$this->description = $description;
+	}
+	
+	function __initXmlRpc($xmlRpcData){
+		$this->elementId = (isset($xmlRpcData['id']))
+			? $xmlRpcData['id']
+			: null;
+		$this->elementName = (isset($xmlRpcData['name']))
+			? $xmlRpcData['name']
+			: null;
+		$this->dcElement = (isset($xmlRpcData['dcElement']))
+			? $xmlRpcData['dcElement']
+			: null;
+		$this->description = (isset($xmlRpcData['description']))
+			? $xmlRpcData['description']
+			: null;
+	}
+	
+	/**
+     * @return The ID of this Element.
+     */
+	function getElementID(){
+		return $this->elementId;
+	}
+	
+	/**
+     * @param elementId
+     *            The new ID for this Element.
+     */
+	function setElementID($elementId){
+		$this->elementId = $elementId;
+	}
+	
+	/**
+     * @return The name of this Element.
+     */
+	function getElementName(){
+		return $this->elementName;
+	}
+	
+	/**
+     * @param elementName
+     *            The new name for this Element.
+     */
+	function setElementName($elementName){
+		$this->elementName = $elementName;
+	}
+
+	/**
+     * @return The dcElement of this Element...whatever that means.
+     */
+	function getDcElement(){
+		return $this->dcElement;
+	}
+	
+	/**
+     * @param dcElement
+     *            The new dcElement for this Element.
+     */
+	function setDcElement($dcElement){
+		$this->dcElement = $dcElement;
+	}
+	
+	/**
+     * @return The description of this Element.
+     */
+	function getDescription(){
+		return $this->description;
+	}
+	
+	/**
+     * @param description
+     *            The new description for this Element.
+     */
+	function setDescription($description){
+		$this->description = $description;
+	}
+	
+	function toAssocArray(){
+    	return array(
+			'elementId' => $this->elementId,
+			'elementName' => $this->elementName,
+			'dcElement' => $this->dcElement,
+			'description' => $this->description);
+    }
+	
+	function toXmlRpcStruct(){
+    	return new XML_RPC_Value(array(
+			'elementId' => new XML_RPC_Value($this->elementId,'string'),
+			'elementName' => new XML_RPC_Value($this->elementName,'string'),
+			'dcElement' => new XML_RPC_Value($this->dcElement,'string'),
+			'description' => new XML_RPC_Value($this->description, 'string')), 'struct');
+    }
+
+}
+
+?>

Modified: oodt/trunk/filemgr/src/main/php/Product.class.php
URL: http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/php/Product.class.php?rev=1144382&r1=1144381&r2=1144382&view=diff
==============================================================================
--- oodt/trunk/filemgr/src/main/php/Product.class.php (original)
+++ oodt/trunk/filemgr/src/main/php/Product.class.php Fri Jul  8 16:54:56 2011
@@ -20,6 +20,7 @@ require_once("XML/RPC.php");
 
 /**
  * @author ahart
+ * @author gabe
  * <p>The core file manager data structure, ported
  * to PHP.
  * </p>
@@ -42,8 +43,8 @@ class CAS_Filemgr_Product {
 			? $xmlRpcData['name'] 
 			: '';
 		$this->type = (isset($xmlRpcData['type']))
-			? new ProductType($xmlRpcData['type']) 
-			: new ProductType();
+			? new CAS_Filemgr_ProductType($xmlRpcData['type']) 
+			: new CAS_Filemgr_ProductType();
 		$this->structure = (isset($xmlRpcData['structure']))
 			? $xmlRpcData['structure'] 
 			: '';

Added: oodt/trunk/filemgr/src/main/php/ProductPage.class.php
URL: http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/php/ProductPage.class.php?rev=1144382&view=auto
==============================================================================
--- oodt/trunk/filemgr/src/main/php/ProductPage.class.php (added)
+++ oodt/trunk/filemgr/src/main/php/ProductPage.class.php Fri Jul  8 16:54:56 2011
@@ -0,0 +1,225 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+require_once("XML/RPC.php");
+
+/**
+ * @author mattmann
+ * @version $Revision$
+ * 
+ * A Page of {@link Product}s returned from the <code>File Manager</code>.
+ * 
+ */
+class CAS_Filemgr_ProductPage {
+
+	/* the number of this page */
+	private $pageNum = -1;
+
+	/* the total number of pages in the set */
+	private $totalPages = -1;
+	
+	/* the number of total hits for the query */
+	private $numOfHits = -1;
+	
+	/* the size of the number of products on this page */
+	private $pageSize = -1;
+
+	/* the list of produdcts associated with this page */
+	private $pageProducts = null;
+
+	/**
+	 * <p>
+	 * Default Constructor
+	 * </p>.
+	 */
+	function __construct() {
+		$this->pageProducts = array ();
+	}
+
+	/**
+	 * @param pageNum
+	 *            The number of this page.
+	 * @param totalPages
+	 *            The total number of pages in the set.
+	 * @param pageSize
+	 *            The size of this page.
+	 * @param pageProducts
+	 *            The products associated with this page.
+	 */
+	function __init($pageNum, $totalPages, $numOfHits, $pageSize, $pageProducts) {
+		$this->pageNum = $pageNum;
+		$this->totalPages = $totalPages;
+		$this->numOfHits = $numOfHits;
+		$this->pageSize = $pageSize;
+		$this->pageProducts = $pageProducts;
+	}
+
+    function __initXmlRpc($xmlRpcData){
+		$this->pageNum = (isset($xmlRpcData['pageNum']))
+			? intval($xmlRpcData['pageNum'])
+			: -1;
+		$this->totalPages = (isset($xmlRpcData['totalPages']))
+			? intval($xmlRpcData['totalPages']) 
+			: -1;
+		$this->numOfHits = (isset($xmlRpcData['numOfHits']))
+			? intval($xmlRpcData['numOfHits']) 
+			: -1;
+		$this->pageSize = (isset($xmlRpcData['pageSize']))
+			? intval($xmlRpcData['pageSize']) 
+			: -1;
+		$this->pageProducts = array();
+		if(isset($xmlRpcData['pageProducts'])){
+			foreach($xmlRpcData['pageProducts'] as $p){
+				array_push($this->pageProducts, new CAS_Filemgr_Product($p));
+			}
+		}
+    }
+    
+    
+	/**
+	 * @return Returns the pageNum.
+	 */
+	public function getPageNum() {
+		return $this->pageNum;
+	}
+
+	/**
+	 * @param pageNum
+	 *            The pageNum to set.
+	 */
+	public function setPageNum($pageNum) {
+		$this->pageNum = $pageNum;
+	}
+
+	/**
+	 * @return Returns the pageProducts.
+	 */
+	public function getPageProducts() {
+		return $this->pageProducts;
+	}
+
+	/**
+	 * @param pageProducts
+	 *            The pageProducts to set.
+	 */
+	public function setPageProducts($pageProducts) {
+		$this->pageProducts = $pageProducts;
+	}
+
+	/**
+	 * @return Returns the pageSize.
+	 */
+	public function getPageSize() {
+		return $this->pageSize;
+	}
+
+	/**
+	 * @param pageSize
+	 *            The pageSize to set.
+	 */
+	public function setPageSize($pageSize) {
+		$this->pageSize = $pageSize;
+	}
+
+	/**
+	 * @return Returns the totalPages.
+	 * If totalPages is not set check to see if numOfHits is used instead
+	 */
+	public function getTotalPages() {
+		if ($this->totalPages != -1 ) {
+			return $this->totalPages;
+		} elseif ( $this->numOfHits > 0 ) {
+			return (ceil($this->numOfHits/$this->pageSize));
+		}
+		return $this->totalPages;
+	}
+
+	/**
+	 * @param totalPages
+	 *            The totalPages to set.
+	 */
+	public function setTotalPages($totalPages) {
+		$this->totalPages = $totalPages;
+	}
+
+	/**
+	 * @return Returns the numOfHits.
+	 */
+	public function getNumOfHits() {
+		return $this->numOfHits;
+	}
+
+	/**
+	 * @param totalPages
+	 *            The totalPages to set.
+	 */
+	public function setNumOfHits($numOfHits) {
+		$this->numOfHits = $numOfHits;
+	}	
+
+	/**
+	 * 
+	 * @return True if this is the last page in the set, false otherwise.
+	 */
+	public function isLastPage() {
+		return $this->pageNum == $this->totalPages;
+	}
+
+	/**
+	 * 
+	 * @return True if this is the fist page of the set, false otherwise.
+	 */
+	public function isFirstPage() {
+		return $this->pageNum == 1;
+	}
+
+	public function toXmlRpcStruct() {
+	  return new XML_RPC_Value(array(
+					 'pageNum' => new XML_RPC_Value($this->pageNum,'int'),
+					 'pageSize' => new XML_RPC_Value($this->pageSize,'int'),
+					 'totalPages' => new XML_RPC_Value($this->totalPages,'int'),
+					 'numOfHits' => new XML_RPC_Value($this->numOfHits,'int'),
+	  				 'pageProducts' => $this->toXmlRpcProductList($this->pageProducts)), 'struct');
+	}
+
+	/**
+	 * 
+	 * @return A blank, unpopulated {@link ProductPage}.
+	 */
+	public static function blankPage() {
+		$blank = new CAS_Filemgr_ProductPage();
+		$blank->setPageNum(0);
+		$blank->setTotalPages(0);
+		$blank->setNumOfHits(0);
+		$blank->setPageSize(0);
+		return $blank;
+	}
+	
+	
+	private function toXmlRpcProductList($prodList){
+		$prodEncodedArr = array();
+		
+		foreach ($prodList as $product){
+			$prodEncodedArr[] = $product->toXmlRpcStruct();
+		}
+		
+		return new XML_RPC_Value($prodEncodedArr, 'array');
+	}
+
+}
+?>

Modified: oodt/trunk/filemgr/src/main/php/ProductType.class.php
URL: http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/php/ProductType.class.php?rev=1144382&r1=1144381&r2=1144382&view=diff
==============================================================================
--- oodt/trunk/filemgr/src/main/php/ProductType.class.php (original)
+++ oodt/trunk/filemgr/src/main/php/ProductType.class.php Fri Jul  8 16:54:56 2011
@@ -17,7 +17,7 @@
  */
 
 require_once("XML/RPC.php");
-require_once("CAS/Filemgr/Metadata.class.php");
+require_once("Metadata.class.php");
 
 /**
  * Ports the core file manager data structure, 
@@ -25,6 +25,7 @@ require_once("CAS/Filemgr/Metadata.class
  * 
  * @author ahart
  * @author mattmann
+ * @author gabe
  * 
  */
 class CAS_Filemgr_ProductType {
@@ -53,8 +54,8 @@ class CAS_Filemgr_ProductType {
 			? $xmlRpcData['versionerClass'] 
 			: '';
 		$this->typeMetadata = (isset($xmlRpcData['typeMetadata'])) 
-		    ? new Metadata($xmlRpcData['typeMetadata'])
-		    : new Metadata();
+		    ? new CAS_Filemgr_Metadata($xmlRpcData['typeMetadata'])
+		    : new CAS_Filemgr_Metadata();
 	}
 	
 	function __destruct(){

Added: oodt/trunk/filemgr/src/main/php/Query.class.php
URL: http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/php/Query.class.php?rev=1144382&view=auto
==============================================================================
--- oodt/trunk/filemgr/src/main/php/Query.class.php (added)
+++ oodt/trunk/filemgr/src/main/php/Query.class.php Fri Jul  8 16:54:56 2011
@@ -0,0 +1,93 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+require_once("XML/RPC.php");
+
+/**
+ * @author resneck
+ *
+ * <p>A PHP port of the core filemgr data structure.</p>
+ */
+class CAS_Filemgr_Query {
+
+	/**
+	 *<p>The set of QueryCriteria for this Query.</p>
+	 */
+	public $criteria = null;
+	
+	/**
+	 * <p>Default Constructor.</p>
+	 */
+	function __construct(){
+		$this->criteria = array();
+	}
+	
+	function __init($criteria){
+		$this->criteria = $criteria;
+	}
+	
+	function __initXmlRpc($xmlRpcData){
+		$this->criteria = (isset($xmlRpcData['criteria']))
+			? $xmlRpcData['criteria']
+			: array();
+	}
+	
+	/**
+     * @return Returns the criteria.
+     */
+	function getCriteria(){
+		return $this->criteria;
+	}
+	
+	/**
+     * @param criteria
+     *            The criteria to set.
+     */
+	function setCriteria($criteria){
+		$this->criteria = $criteria;
+	}
+	
+	/**
+     * @param criterion
+     *            The criterion to add to the query.
+     */
+	function addCriterion($criterion){
+		array_push($this->criteria, $criterion);
+	}
+	
+	function toAssocArray(){
+		$assocArray = array(
+			'criteria' => array());
+		foreach($this->criteria as $c){
+			array_push($assocArray['criteria'], $c->toAssocArray());
+		}
+		return $assocArray;
+	}
+	
+	function toXmlRpcStruct(){
+		$critArray = array();
+		foreach($this->criteria as $c){
+			array_push($critArray, $c->toXmlRpcStruct());
+		}
+		return new XML_RPC_Value(array(
+			'criteria' => new XML_RPC_Value($critArray,'array')), 'struct');
+	}
+
+}
+
+?>

Added: oodt/trunk/filemgr/src/main/php/RangeQueryCriteria.class.php
URL: http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/php/RangeQueryCriteria.class.php?rev=1144382&view=auto
==============================================================================
--- oodt/trunk/filemgr/src/main/php/RangeQueryCriteria.class.php (added)
+++ oodt/trunk/filemgr/src/main/php/RangeQueryCriteria.class.php Fri Jul  8 16:54:56 2011
@@ -0,0 +1,178 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+require_once("XML/RPC.php");
+
+/**
+ * @author resneck
+ *
+ * <p>A PHP port of the core filemgr data structure.</p>
+ */
+ class CAS_Filemgr_RangeQueryCriteria {
+ 
+ 	public $elementName;
+    public $startValue;
+    public $endValue;
+    public $inclusive;
+ 
+ 	/**
+	 * <p>
+	 * Default Constructor
+	 * </p>.
+	 */
+	function __construct(){
+		$this->elementName = '';
+		$this->startValue = '';
+		$this->endValue = '';
+		$this->inclusive = true;
+	}
+	
+	/**
+     * @param elementName
+     *            The name of the element to search on.
+     * @param start
+     *            The start value for the range search as a String.
+     * @param end
+     *            The end value for the range search as a String.
+     * @param inclusive
+     *            Boolean: true for inclusive, false for exclusive.
+     */
+	function __init($elementName, $start, $end, $inclusive){
+		$this->elementName = $elementName;
+		$this->startValue = $start;
+		$this->endValue = $end;
+		$this->inclusive = $inclusive;
+	}
+	
+	function __initXmlRpc($xmlRpcData){
+		$this->elementName = (isset($xmlRpcData['elementName']))
+			? $xmlRpcData['elementName'] 
+			: '';
+		$this->value = (isset($xmlRpcData['start']))
+			? $xmlRpcData['start'] 
+			: '';
+		$this->value = (isset($xmlRpcData['end']))
+			? $xmlRpcData['end'] 
+			: '';
+		$this->value = (isset($xmlRpcData['inclusive']))
+			? (bool)$xmlRpcData['inclusive'] 
+			: true;
+	}
+	
+	/**
+     * Accessor method for the start value of the element to search on.
+     * 
+     * @return The start value of the element to search on as a String.
+     */
+    function getStartValue() {
+        return $this->startValue;
+    }
+
+    /**
+     * Mutator method for the start value fo the element to search on.
+     * 
+     * @param value
+     *            The start value of the range as a String.
+     */
+    function setStartValue($value) {
+        $this->startValue = $value;
+    }
+
+    /**
+     * Accessor method for the end value of the element to search on.
+     * 
+     * @return The end value of the element to search on as a String.
+     */
+    function getEndValue() {
+        return $this->endValue;
+    }
+
+    /**
+     * Mutator method for the end value fo the element to search on.
+     * 
+     * @param value
+     *            The end value of the range as a String.
+     */
+    function setEndValue($value) {
+        $this->endValue = $value;
+    }
+
+    /**
+     * Accessor method for the inclusive setting for the range.
+     * 
+     * @return The boolean inclusive/exclusive flag.
+     */
+    function getInclusive() {
+        return $this->inclusive;
+    }
+
+    /**
+     * Mutator method for the inclusive setting for the range. Note that flag
+     * should be set to true for inclusive, false for exclusive.
+     * 
+     * @param inclusive
+     *            The boolean inclusive/exclusive flag.
+     */
+    function setInclusive($flag) {
+        $this->inclusive = $flag;
+    }
+
+    /**
+     * Implementation of the abstract method inherited from QueryCriteria for
+     * accessing the element name to search on.
+     * 
+     * @return The element name to search on as a String.
+     */
+    function getElementName() {
+        return $this->elementName;
+    }
+
+    /**
+     * Implementation of the abstract method inherited from QueryCriteria for
+     * mutating the element name to search on.
+     * 
+     * @param elementName
+     *            The element name to search on as a String.
+     */
+    function setElementName($elementName) {
+        $this->elementName = $elementName;
+    }
+    
+    function toAssocArray(){
+    	return array(
+			'startValue' => $this->startValue,
+			'endValue' => $this->endValue,
+			'elementName' => $this->elementName,
+			'inclusive' => $this->inclusive);
+    }
+    
+    function toXmlRpcStruct(){
+    	$inclusiveStr = ($this->inclusive)
+			? 'true'
+			: 'false';
+    	return new XML_RPC_Value(array(
+    		'class' => new XML_RPC_Value('org.apache.oodt.cas.filemgr.structs.RangeQueryCriteria',
'string'),
+			'elementStartValue' => new XML_RPC_Value($this->startValue,'string'),
+			'elementEndValue' => new XML_RPC_Value($this->endValue,'string'),
+			'elementName' => new XML_RPC_Value($this->elementName,'string'),
+			'inclusive' => new XML_RPC_Value($inclusiveStr, 'string')), 'struct');
+    }
+ 
+ }
+ 
+ ?>

Added: oodt/trunk/filemgr/src/main/php/TermQueryCriteria.class.php
URL: http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/php/TermQueryCriteria.class.php?rev=1144382&view=auto
==============================================================================
--- oodt/trunk/filemgr/src/main/php/TermQueryCriteria.class.php (added)
+++ oodt/trunk/filemgr/src/main/php/TermQueryCriteria.class.php Fri Jul  8 16:54:56 2011
@@ -0,0 +1,116 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+require_once("XML/RPC.php");
+
+/**
+ * @author resneck
+ *
+ * <p>A PHP port of the core filemgr data structure.</p>
+ */
+class CAS_Filemgr_TermQueryCriteria {
+
+	public $elementName;
+	public $value;
+	
+	/**
+	 * <p>
+	 * Default Constructor
+	 * </p>.
+	 */
+	function __construct(){
+		$this->elementName = '';
+		$this->value = '';
+	}
+	
+	/**
+     * @param elementName
+     *            The name of the element to search on.
+     * @param v
+     *            The value of the term.
+     */
+	function __init($elementName, $value){
+		$this->elementName = $elementName;
+		$this->value = $value;
+	}
+	
+	function __initXmlRpc($xmlRpcData){
+		$this->elementName = (isset($xmlRpcData['elementName']))
+			? $xmlRpcData['elementName'] 
+			: '';
+		$this->value = (isset($xmlRpcData['value']))
+			? $xmlRpcData['value'] 
+			: '';
+	}
+	
+	/**
+     * Accessor method for the value of the element to search on.
+     * 
+     * @return The value of the element to search on as a String.
+     */
+    function getValue() {
+        return $this->value;
+    }
+
+    /**
+     * Mutator method for the value of the element to search on
+     * 
+     * @param value
+     *            The value of the element to search on as a String.
+     */
+    function setValue($value) {
+        $this->value = $value;
+    }
+
+    /**
+     * Implementation of the abstract method inherited from QueryCriteria for
+     * accessing the element name to search on.
+     * 
+     * @return The element name to search on as a String.
+     */
+    function getElementName() {
+        return $this->elementName;
+    }
+
+    /**
+     * Implementation of the abstract method inherited from QueryCriteria for
+     * mutating the element name to search on.
+     * 
+     * @param elementName
+     *            The element name to search on as a String.
+     */
+    function setElementName($elementName) {
+        $this->elementName = $elementName;
+    }
+    
+    function toAssocArray(){
+    	return array(
+			'value' => $this->value,
+			'elementName' => $this->elementName);
+    }
+    
+    function toXmlRpcStruct(){
+    	return new XML_RPC_Value(array(
+    		'class' => new XML_RPC_Value('org.apache.oodt.cas.filemgr.structs.TermQueryCriteria',
'string'),
+			'elementValue' => new XML_RPC_Value($this->value,'string'),
+			'elementName' => new XML_RPC_Value($this->elementName,'string')), 'struct');
+    }
+
+}
+
+?>

Modified: oodt/trunk/filemgr/src/main/php/XmlRpcFilemgrClient.class.php
URL: http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/php/XmlRpcFilemgrClient.class.php?rev=1144382&r1=1144381&r2=1144382&view=diff
==============================================================================
--- oodt/trunk/filemgr/src/main/php/XmlRpcFilemgrClient.class.php (original)
+++ oodt/trunk/filemgr/src/main/php/XmlRpcFilemgrClient.class.php Fri Jul  8 16:54:56 2011
@@ -25,6 +25,7 @@ require_once("XML/RPC.php");
  * but this is a good start.
  * 
  * @author ahart
+ * @author resneck
  * 
  */
 class CAS_Filemgr_XmlRpcFilemgrClient {
@@ -38,139 +39,414 @@ class CAS_Filemgr_XmlRpcFilemgrClient {
 		try {
 			$this->client = new XML_RPC_Client($this->serverPath,$this->serverURL);
 		} catch (Exception $e) {
-			echo "<h4>Error creating XMLRPC client: " . $e.getMessage();
+			echo "<h4>Error creating XMLRPC client: " . $e.getMessage() . "</h4>";
 			exit();
 		}
 	}
 	
-	function __destruct(){
+	function __destruct(){}
 
-	}
-
-
-	function getProductById($productID){
-		$params = array(new XML_RPC_Value($productID,'string'));
-		$message = new XML_RPC_Message('filemgr.getProductById',$params);
+	/**
+	 * @param methodStr
+     *		The string for the method to be invoked on ther server.
+	 *
+	 * @param params
+     *		An array of XML-RPC encoded parameters to the method that will be invoked on the
server.
+     *
+     * @param falseOnFail
+     *		If set to true, sendMessage will return false on a failure, rather than exiting.
+	 *
+	 * @return The un-decoded data from the method invoked on the server.
+	 */
+	private function sendMessage($methodStr, $params){
+		$message = new XML_RPC_Message($methodStr, $params);
 		$response = $this->client->send($message);
-		
 		if (!$response){
-			echo "<h4>Communication Error: {$this->client->errstr}</h4>";
-			exit(); 
+			throw new XmlRpcFilemgrException("No response was received from Xml-Rpc Client\nError
msg: " . $this->client->errstr);
 		}
-		
 		if (!$response->faultCode()) {
 			$value = $response->value();
 			$data = XML_RPC_decode($value);
+			if(isset($data->faultString)){
+				throw new XmlRpcFilemgrException("Fault String in Xml-Rpc response: " . $data["faultString"]);
+			}
 			return $data;
 		} else {
-			echo "<h4>Fault Code Returned: (" . $response->faultCode . ") </h4>";
-			exit();
+			throw new XmlRpcFilemgrException("Fault Code in Xml-Rpc response: " . $response->faultCode);
 		}
 	}
-	function getProductReferences($product){
-		$params = array($product->toXmlRpcStruct());
-		$message = new XML_RPC_Message('filemgr.getProductReferences',$params);
-		$response = $this->client->send($message);
-		
-		if (!$response){
-			echo "<h4>Communication Error: {$this->client->errstr}</h4>";
-			exit(); 
-		}
-		
-		if (!$response->faultCode()) {
-			$value = $response->value();
-			$data = XML_RPC_decode($value);
+	
+	/**
+	 * Throws an XmlRpcFilemgrException that gives more information than the one given.
+	 * 
+	 * @param e
+	 * 		The exception that needs more info included.
+	 * 
+	 * @param funcName
+	 * 		The name of the function in which this the original erroe/exception occurred.
+	 */
+	private function reportError($e, $funcName){
+		throw new XmlRpcFilemgrException("An error occurred while performing function " . $funcName
. "\n" . $e->getMessage());
+	}
+	
+	/**
+	 * @return A boolean indicating whether the FileManager is still running.
+	 */
+	public function isAlive( $returnObject = true ) {
+       	$params = array();
+       	try{
+	       	$data = $this->sendMessage("filemgr.isAlive", $params, $returnObject);
+       	}catch(XmlRpcFilemgrException $e){
+       		$this->reportError($e, "isAlive");
+       	}
+       	return $data;
+    }
+
+	/**
+	 * @param productID
+     *		The id of the desired Product.
+     *
+     * @param returnObject
+     *		Whether data should be returned as an object as opposed to an associative array.
+	 *
+	 * @return The Product corresponding to the given id.
+	 */
+	function getProductById($productID, $returnObject = true){
+		$params = array(new XML_RPC_Value($productID,'string'));
+		try{
+			$data = $this->sendMessage("filemgr.getProductById", $params);
+		}catch(XmlRpcFilemgrException $e){
+       		$this->reportError($e, "getProductById");
+       	}
+		if($returnObject){
+			$product = new CAS_Filemgr_Product($data);
+			return $product;
+		}else{
 			return $data;
-		} else {
-			echo "<h4>Fault Code Returned: (" . $response->faultCode . ") </h4>";
-			exit();
 		}
 	}
 	
-	function getMetadata($product){	
+	/**
+	 * @param product
+     *		The product containing the desired references.
+	 *
+	 * @return An associative array specifying the references contained in the given Product.
+	 */
+	function getProductReferences($product){
 		$params = array($product->toXmlRpcStruct());
-		$message = new XML_RPC_Message('filemgr.getMetadata',$params);
-		$response = $this->client->send($message);
-		
-		if (!$response){
-			echo "<h4>Communication Error: {$this->client->errstr}</h4>";
-			exit(); 
-		}
-		
-		if (!$response->faultCode()) {
-			$value = $response->value();
-			$data = XML_RPC_decode($value);
+		try{
+			$data = $this->sendMessage("filemgr.getProductReferences", $params);
+		}catch(XmlRpcFilemgrException $e){
+       		$this->reportError($e, "getProductReferences");
+       	}
+		return $data;
+	}
+	
+	/**
+	 * @param product
+     *		The product specified by the desired metadata.
+     *
+     * @param returnObject
+     *		Whether data should be returned as an object as opposed to an associative array.
+	 *
+	 * @return The metadata specifiying the given Product.
+	 */
+	function getMetadata($product, $returnObject = true){	
+		$params = array($product->toXmlRpcStruct());
+		try{
+			$data = $this->sendMessage("filemgr.getMetadata", $params);
+		}catch(XmlRpcFilemgrException $e){
+       		$this->reportError($e, "getMetadata");
+       	}
+		if($returnObject){
+			$metadata = new CAS_Filemgr_Metadata($data);
+			return $metadata;
+		}else{
 			return $data;
-		} else {
-			echo "<h4>Fault Code Returned: (" . $response->faultCode . ") </h4>";
-			exit();
 		}
 	}
 	
-	function getProductTypeById($typeID){
+	/**
+	 * @param typeID
+     *		The ID of the desired ProductType defined for this instance of the File Manager.
+     *
+     * @param returnObject
+     *		Whether data should be returned as an object as opposed to an associative array.
+	 *
+	 * @return The ProductType coresponding to the given ID.
+	 */
+	function getProductTypeById($typeID, $returnObject = true){
 		$params = array(new XML_RPC_Value($typeID,'string'));
-		$message = new XML_RPC_Message("filemgr.getProductTypeById", $params);
-		$response = $this->client->send($message);
-		
-		if (!$response->faultCode()) {
-			$value = $response->value();
-			$data = XML_RPC_decode($value);
+		try{
+			$data = $this->sendMessage("filemgr.getProductTypeById", $params);
+		}catch(XmlRpcFilemgrException $e){
+       		$this->reportError($e, "getProductTypeById");
+       	}
+		if($returnObject){
+			$pt = new CAS_Filemgr_ProductType($data);
+			return $pt;
+		}else{
 			return $data;
-		} else {
-			echo "<h4>Fault Code Returned: (" . $response->faultCode . ") </h4>";
-			exit();
-		}		
-		
+		}
+	}
+	
+	/**
+	 * @param typeName
+     *		The name of the desired ProductType defined for this instance of the File Manager.
+     *
+     * @param returnObject
+     *		Whether data should be returned as an object as opposed to an associative array.
+	 *
+	 * @return The ProductType coresponding to the given name.
+	 */
+	function getProductTypeByName($typeName, $returnObject = true){
+		$params = array(new XML_RPC_Value($typeName,'string'));
+		try{
+			$data = $this->sendMessage("filemgr.getProductTypeByName", $params);
+		}catch(XmlRpcFilemgrException $e){
+       		$this->reportError($e, "getProductTypeByName");
+       	}
+		if($returnObject){
+			$pt = new CAS_Filemgr_ProductType($data);
+			return $pt;
+		}else{
+			return $data;
+		}
 	}
 	
-	function getProductsByProductType($type){
+	/**
+	 * @param type
+     *		The desired ProductType defined for this instance of the File Manager.
+     *
+     * @param returnObject
+     *		Whether data should be returned as an object as opposed to an associative array.
+	 *
+	 * @return An array of all Products in the repository of the given ProductType.
+	 */
+	function getProductsByProductType($type, $returnObject = true){
 		$params = array($type->toXmlRpcStruct());
-		$message = new XML_RPC_Message("filemgr.getProductsByProductType", $params);
-		$response = $this->client->send($message);
-		
-		if (!$response->faultCode()) {
-			$value = $response->value();
-			$data = XML_RPC_decode($value);
+		try{
+			$data = $this->sendMessage("filemgr.getProductsByProductType", $params);
+		}catch(XmlRpcFilemgrException $e){
+       		$this->reportError($e, "getProductsByProductType");
+       	}
+		if($returnObject){
+			$products = array();
+			foreach($data as $d){
+				$p = new CAS_Filemgr_Product($d);
+				array_push($products, $p);
+			}
+			return $products;
+		}else{
 			return $data;
-		} else {
-			echo "<h4>Fault Code Returned: (" . $response->faultCode . ") </h4>";
-			exit();
-		}		
-		
+		}
 	}
 
-	function getProductTypes(){
+	/**
+	 * @param returnObject
+     *		Whether data should be returned as an object as opposed to an associative array.
+	 *
+	 * @return An array of all ProductTypes defined for this instance of the File Manager.
+	 */
+	function getProductTypes($returnObject = true){
 		$params = array();
-		$message = new XML_RPC_Message("filemgr.getProductTypes", $params);
-		$response = $this->client->send($message);
-		
-		if (!$response->faultCode()) {
-			$value = $response->value();
-			$data = XML_RPC_decode($value);
+		try{
+			$data = $this->sendMessage("filemgr.getProductTypes", $params);
+		}catch(XmlRpcFilemgrException $e){
+       		$this->reportError($e, "getProductTypes");
+       	}
+		if($returnObject){
+			$types = array();
+			foreach($data as $d){
+				$pt = new CAS_Filemgr_ProductType($d);
+				array_push($types, $pt);
+			}
+			return $types;
+		}else{
 			return $data;
-		} else {
-			echo "<h4>Fault Code Returned: (" . $response->faultCode . ") </h4>";
-			exit();
-		}		
-		
+		}
 	}
-		
-	
 	
+	/**
+	 * @param type
+     *		The desired ProductType defined for this instance of the File Manager.
+	 *
+	 * @return The number of products of the given ProductType in the repository.
+	 */
     function getNumProducts($type){
 		$params = array($type->toXmlRpcStruct());
-		$message = new XML_RPC_Message("filemgr.getNumProducts", $params);
-		$response = $this->client->send($message);
-		
-		if (!$response->faultCode()) {
-			$value = $response->value();
-			$data = XML_RPC_decode($value);
+		try{
+			$data = $this->sendMessage("filemgr.getNumProducts", $params);
+		}catch(XmlRpcFilemgrException $e){
+       		$this->reportError($e, "getNumProducts");
+       	}
+		return $data;
+	}
+	
+	/**
+	 * @param query
+     *		A Query object containing QueryCrteria objects defining the search.
+	 *
+	 * @param type
+     *		A ProductType object defining what types to search.
+     *
+     * @param pageNum
+     *		The desired number of the page in the set of query results.
+     *
+     * @param returnObject
+     *		Whether data should be returned as an object as opposed to an associative array.
+	 *
+	 * @return A ProductPage object containing query results
+	 */
+	function pagedQuery($query, $type, $pageNum, $returnObject = true){
+		$params = array(
+			$query->toXmlRpcStruct(),
+			$type->toXmlRpcStruct(),
+			new XML_RPC_Value($pageNum,'int'));
+		try{
+			$data = $this->sendMessage("filemgr.pagedQuery", $params);
+		}catch(XmlRpcFilemgrException $e){
+       		$this->reportError($e, "pagedQuery");
+       	}
+		if($returnObject){
+			$productPage = new CAS_Filemgr_ProductPage();
+			$productPage->__initXmlRpc($data);
+			return $productPage;
+		}else{
+			return $data;
+		}
+	}
+	
+	/**
+	 * @param query
+     *		A Query object containing QueryCrteria objects defining the search.
+	 *
+	 * @param type
+     *		A ProductType object defining what types to search.
+     *
+     * @param returnObject
+     *		Whether data should be returned as an object as opposed to an associative array.
+	 *
+	 * @return An array of Product objects as query results.
+	 */
+	function query($query, $type, $returnObject = true){
+		$params = array(
+			$query->toXmlRpcStruct(),
+			$type->toXmlRpcStruct());
+		try{
+			$data = $this->sendMessage("filemgr.query", $params);
+		}catch(XmlRpcFilemgrException $e){
+       		$this->reportError($e, "query");
+       	}
+		if($returnObject){
+			$products = array();
+			foreach($data as $d){
+				$p = new CAS_Filemgr_Product($d);
+				array_push($products, $p);
+			}
+			return $products;
+		}else{
+			return $data;
+		}
+	}
+	
+	/**
+	 * @param type
+     *		The desired ProductType defined for this instance of the File Manager.
+     *
+     * @param returnObject
+     *		Whether data should be returned as an object as opposed to an associative array.
+	 *
+	 * @return An array of Element objects that are mapped to the given ProductType.
+	 */
+	function getElementsByProductType($type, $returnObject = true){
+		$params = array($type->toXmlRpcStruct());
+		try{
+			$data = $this->sendMessage("filemgr.getElementsByProductType", $params);
+		}catch(XmlRpcFilemgrException $e){
+       		$this->reportError($e, "getElementsByProductType");
+       	}
+		if($returnObject){
+			$elements = array();
+			foreach($data as $d){
+				$e = new CAS_Filemgr_Element();
+				$e->__initXmlRpc($d);
+				array_push($elements, $e);
+			}
+			return $elements;
+		}else{
+			return $data;
+		}
+	}
+	
+	/* Pagination API */
+	
+	function getFirstPage($type, $returnObject = true){
+		$params = array($type->toXmlRpcStruct());
+		try{
+			$data = $this->sendMessage("filemgr.getFirstPage", $params);
+		}catch(XmlRpcFilemgrException $e){
+       		$this->reportError($e, "getFirstPage");
+       	}
+		if($returnObject){
+			$page = new CAS_Filemgr_ProductPage();
+			$page->__initXmlRpc($data);
+			return $page;
+		}else{
+			return $data;
+		}
+	}
+	
+	function getNextPage($type, $page, $returnObject = true){
+		$params = array($type->toXmlRpcStruct(), $page->toXmlRpcStruct());
+		try{
+			$data = $this->sendMessage("filemgr.getNextPage", $params);
+		}catch(XmlRpcFilemgrException $e){
+       		$this->reportError($e, "getNextPage");
+       	}
+		if($returnObject){
+			$page = new CAS_Filemgr_ProductPage();
+			$page->__initXmlRpc($data);
+			return $page;
+		}else{
+			return $data;
+		}	
+	}
+	
+	function getPrevPage($type, $page, $returnObject = true){
+		$params = array($type->toXmlRpcStruct(), $page->toXmlRpcStruct());
+		try{
+			$data = $this->sendMessage("filemgr.getPrevPage", $params);
+		}catch(XmlRpcFilemgrException $e){
+       		$this->reportError($e, "getPrevPage");
+       	}
+		if($returnObject){
+			$page = new CAS_Filemgr_ProductPage();
+			$page->__initXmlRpc($data);
+			return $page;
+		}else{
+			return $data;
+		}			
+	}
+	
+	function getLastPage($type, $returnObject = true){
+		$params = array($type->toXmlRpcStruct());
+		try{
+			$data = $this->sendMessage("filemgr.getLastPage", $params);
+		}catch(XmlRpcFilemgrException $e){
+       		$this->reportError($e, "getLastPage");
+       	}
+		if($returnObject){
+			$page = new CAS_Filemgr_ProductPage();
+			$page->__initXmlRpc($data);
+			return $page;
+		}else{
 			return $data;
-		} else {
-			echo "<h4>Fault Code Returned: (" . $response->faultCode . ") </h4>";
-			exit();
 		}		
-		
 	}
+	
 }
+
+class XmlRpcFilemgrException extends Exception{}
+
 ?>



Mime
View raw message