[Fusionforge-commits] r7048 - in trunk/gforge/www/soap: docman frs tracker

Alain Peyrat aljeux at libremir.placard.fr.eu.org
Tue Feb 24 00:24:06 CET 2009


Author: aljeux
Date: 2009-02-24 00:24:06 +0100 (Tue, 24 Feb 2009)
New Revision: 7048

Modified:
   trunk/gforge/www/soap/docman/docman.php
   trunk/gforge/www/soap/frs/frs.php
   trunk/gforge/www/soap/tracker/query.php
   trunk/gforge/www/soap/tracker/tracker.php
Log:
Merge SOAP fixes and improvements from JaGoSI (provided by khmarbaise)

Modified: trunk/gforge/www/soap/docman/docman.php
===================================================================
--- trunk/gforge/www/soap/docman/docman.php	2009-02-23 22:00:43 UTC (rev 7047)
+++ trunk/gforge/www/soap/docman/docman.php	2009-02-23 23:24:06 UTC (rev 7048)
@@ -640,16 +640,17 @@
 //
 function documentsGroup_to_soap($dg_arr) {
 	$return = array();
-		
-	for ($i=0; $i<count($dg_arr); $i++) {
-		if ($dg_arr[$i]->isError()) {
-				//skip if error
-		} else {	
-			$return[]=array(
-				'doc_group_id'=>$dg_arr[$i]->getID(),
-				'parent_doc_group'=>$dg_arr[$i]->getParentID(),
-				'groupname'=>$dg_arr[$i]->getName()
-			);
+	if (is_array($dg_arr) && count($dg_arr) > 0) {
+		for ($i=0; $i<count($dg_arr); $i++) {
+			if ($dg_arr[$i]->isError()) {
+					//skip if error
+			} else {
+				$return[]=array(
+					'doc_group_id'=>$dg_arr[$i]->getID(),
+					'parent_doc_group'=>$dg_arr[$i]->getParentID(),
+					'groupname'=>$dg_arr[$i]->getName()
+				);
+			}
 		}
 	}
 	return $return;

Modified: trunk/gforge/www/soap/frs/frs.php
===================================================================
--- trunk/gforge/www/soap/frs/frs.php	2009-02-23 22:00:43 UTC (rev 7047)
+++ trunk/gforge/www/soap/frs/frs.php	2009-02-23 23:24:06 UTC (rev 7048)
@@ -24,6 +24,8 @@
 
 require_once $gfcommon.'include/Error.class.php';
 require_once $gfcommon.'frs/FRSFile.class.php';
+require_once $gfcommon.'frs/FRSFileType.class';
+require_once $gfcommon.'frs/FRSFileProcessorType.class';
 require_once $gfcommon.'frs/FRSPackage.class.php';
 require_once $gfcommon.'frs/FRSRelease.class.php';
 
@@ -61,7 +63,64 @@
 		$uri,$uri.'#getPackages','rpc','encoded'
 );
 
+$server->wsdl->addComplexType(
+	'FRSFileType',
+	'complexType',
+	'struct',
+	'sequence',
+	'',
+	array(
+	'type_id' => array('name'=>'type_id', 'type' => 'xsd:int'),
+	'name' => array('name'=>'name', 'type' => 'xsd:string'),
+	)
+);
+$server->wsdl->addComplexType(
+	'ArrayOfFRSFileType',
+	'complexType',
+	'array',
+	'',
+	'SOAP-ENC:Array',
+	array(),
+	array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:FRSFileType[]')),
+	'tns:FRSFileType'
+);
+
 $server->register(
+	'getFileTypes',
+	array('session_ser'=>'xsd:string'),
+	array('getFileTypeResponse'=>'tns:ArrayOfFRSFileType'),
+		$uri,$uri.'#getFileTypes','rpc','encoded'
+);
+
+$server->wsdl->addComplexType(
+	'FRSFileProcessorType',
+	'complexType',
+	'struct',
+	'sequence',
+	'',
+	array(
+	'processor_id' => array('name'=>'processor_id', 'type' => 'xsd:int'),
+	'name' => array('name'=>'name', 'type' => 'xsd:string'),
+	)
+);
+$server->wsdl->addComplexType(
+	'ArrayOfFRSFileProcessorType',
+	'complexType',
+	'array',
+	'',
+	'SOAP-ENC:Array',
+	array(),
+	array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:FRSFileProcessorType[]')),
+	'tns:FRSFileProcessorType'
+);
+$server->register(
+	'getFileProcessorTypes',
+	array('session_ser'=>'xsd:string'),
+	array('getFileProcessorTypeResponse'=>'tns:ArrayOfFRSFileProcessorType'),
+		$uri,$uri.'#getFileProcessorTypes','rpc','encoded'
+);
+
+$server->register(
 	'addPackage',
 	array(
 		'session_ser'=>'xsd:string',
@@ -209,22 +268,35 @@
 function packages_to_soap(&$pkg_arr) {
 	$return = array();
 
-	for ($i=0; $i<count($pkg_arr); $i++) {
-		if ($pkg_arr[$i]->isError()) {
-			//skip if error
-		} else {
-			$return[]=array(
-				'package_id' => $pkg_arr[$i]->getID(), 
-				'name' => $pkg_arr[$i]->getName(),
-				'status_id' => $pkg_arr[$i]->getStatus(), 
-				'is_public' => $pkg_arr[$i]->isPublic()
-			);
+	if (is_array($pkg_arr) && count($pkg_arr) > 0) {
+		for ($i=0; $i<count($pkg_arr); $i++) {
+			if ($pkg_arr[$i]->isError()) {
+				//skip if error
+			} else {
+				$return[]=array(
+					'package_id' => $pkg_arr[$i]->getID(),
+					'name' => $pkg_arr[$i]->getName(),
+					'status_id' => $pkg_arr[$i]->getStatus(),
+					'is_public' => $pkg_arr[$i]->isPublic()
+				);
+			}
 		}
 	}
-	
 	return $return;
 }
 
+function getFileTypes($session_ser) {
+	continue_session($session_ser);
+	$pkg_arr = get_frs_filetypes();
+	return filetypes_to_soap($pkg_arr);
+}
+
+function getFileProcessorTypes($session_ser) {
+	continue_session($session_ser);
+	$pkg_arr = get_frs_fileprocessortypes();
+	return fileprocessortypes_to_soap($pkg_arr);
+}
+
 function addPackage($session_ser,$group_id,$package_name,$is_public) {
 	continue_session($session_ser);
 	$grp =& group_get_object($group_id);
@@ -266,18 +338,20 @@
 function releases_to_soap(&$release_arr) {
 	$return = array();
 
-	for ($i=0; $i<count($release_arr); $i++) {
-		if ($release_arr[$i]->isError()) {
-			//skip if error
-		} else {
-			$return[]=array(
-				'release_id' => $release_arr[$i]->getID(), 
-				'name' => $release_arr[$i]->getName(),
-				'notes' => $release_arr[$i]->getNotes(),
-				'changes' => $release_arr[$i]->getChanges(),
-				'status_id' => $release_arr[$i]->getStatus(), 
-				'release_date' => $release_arr[$i]->getReleaseDate()
-			);
+	if (is_array($release_arr) && count($release_arr) > 0) {
+		for ($i=0; $i<count($release_arr); $i++) {
+			if ($release_arr[$i]->isError()) {
+				//skip if error
+			} else {
+				$return[]=array(
+					'release_id' => $release_arr[$i]->getID(),
+					'name' => $release_arr[$i]->getName(),
+					'notes' => $release_arr[$i]->getNotes(),
+					'changes' => $release_arr[$i]->getChanges(),
+					'status_id' => $release_arr[$i]->getStatus(),
+					'release_date' => $release_arr[$i]->getReleaseDate()
+				);
+			}
 		}
 	}
 	
@@ -341,26 +415,64 @@
 function files_to_soap($files_arr) {
 	$return = array();
 
-	for ($i=0; $i<count($files_arr); $i++) {
-		if ($files_arr[$i]->isError()) {
-			//skip if error
-		} else {
-			$return[]=array(
-				'file_id' => $files_arr[$i]->getID(), 
-				'name' => $files_arr[$i]->getName(),
-				'size' => $files_arr[$i]->getSize(),
-				'type' => $files_arr[$i]->getFileType(),
-				'processor' => $files_arr[$i]->getProcessor(),
-				'downloads' => $files_arr[$i]->getDownloads(),
-				'release' => $files_arr[$i]->getReleaseTime(),
-				'date' => $files_arr[$i]->getPostDate(),
-			);
+	if (is_array($files_arr) && count($files_arr) > 0) {
+		for ($i=0; $i<count($files_arr); $i++) {
+			if ($files_arr[$i]->isError()) {
+				//skip if error
+			} else {
+				$return[]=array(
+					'file_id' => $files_arr[$i]->getID(),
+					'name' => $files_arr[$i]->getName(),
+					'size' => $files_arr[$i]->getSize(),
+					'type' => $files_arr[$i]->getFileType(),
+					'processor' => $files_arr[$i]->getProcessor(),
+					'downloads' => $files_arr[$i]->getDownloads(),
+					'release' => $files_arr[$i]->getReleaseTime(),
+					'date' => $files_arr[$i]->getPostDate(),
+				);
+			}
 		}
 	}
 	
 	return $return;
 }
 
+function filetypes_to_soap($files_arr) {
+	$return = array();
+
+	if (is_array($files_arr) && count($files_arr) > 0) {
+		for ($i=0; $i<count($files_arr); $i++) {
+			if ($files_arr[$i]->isError()) {
+				//skip if error
+			} else {
+				$return[]=array(
+					'type_id' => $files_arr[$i]->getID(),
+					'name' => $files_arr[$i]->getName(),
+				);
+			}
+		}
+	}
+	return $return;
+}
+
+function fileprocessortypes_to_soap($files_arr) {
+	$return = array();
+
+	if (is_array($files_arr) && count($files_arr) > 0) {
+		for ($i=0; $i<count($files_arr); $i++) {
+			if ($files_arr[$i]->isError()) {
+				//skip if error
+			} else {
+				$return[]=array(
+					'processor_id' => $files_arr[$i]->getID(),
+					'name' => $files_arr[$i]->getName(),
+				);
+			}
+		}
+	}
+	return $return;
+}
+
 function getFile($session_ser,$group_id,$package_id,$release_id,$file_id) {
 	continue_session($session_ser);
 	

Modified: trunk/gforge/www/soap/tracker/query.php
===================================================================
--- trunk/gforge/www/soap/tracker/query.php	2009-02-23 22:00:43 UTC (rev 7047)
+++ trunk/gforge/www/soap/tracker/query.php	2009-02-23 23:24:06 UTC (rev 7048)
@@ -140,48 +140,51 @@
 	$result = array();
 //	print_r($queries[1]->getExtraFields());
 //	die();
-	for ($i=0; $i < count($queries); $i++) {
-		$artifactQuery =& $queries[$i];
-		
-		// transform the extra fields data
-		$extra_fields = array();
-		$queryExtraFields = $artifactQuery->getExtraFields();
-		foreach ($queryExtraFields as $extra_field_id => $values) {
-			// $value may be a int. We wrap it in an array.
-			if (!is_array($values)) $values = array($values);
-			$extra_fields[] = array(
-								"extra_field_id"	=> $extra_field_id,
-								"values"			=> $values
-								);
-		}
-		
-		$assignee = $artifactQuery->getAssignee();
-		// this is a hack, ArtifactQuery::getAssignee sometimes returns an int and
-		// sometimes it returns an array
-		if (!is_array($assignee)) {
-			if (is_numeric($assignee)) {	// a single ID
-				$assignee = array($assignee);	// wrap in an array
-			} else {
-				$assignee = array();
+
+	if (is_array($queries) && count($queries) > 0) {
+		for ($i=0; $i < count($queries); $i++) {
+			$artifactQuery =& $queries[$i];
+
+			// transform the extra fields data
+			$extra_fields = array();
+			$queryExtraFields = $artifactQuery->getExtraFields();
+			foreach ($queryExtraFields as $extra_field_id => $values) {
+				// $value may be a int. We wrap it in an array.
+				if (!is_array($values)) $values = array($values);
+				$extra_fields[] = array(
+									"extra_field_id"	=> $extra_field_id,
+									"values"			=> $values
+									);
 			}
+
+			$assignee = $artifactQuery->getAssignee();
+			// this is a hack, ArtifactQuery::getAssignee sometimes returns an int and
+			// sometimes it returns an array
+			if (!is_array($assignee)) {
+				if (is_numeric($assignee)) {	// a single ID
+					$assignee = array($assignee);	// wrap in an array
+				} else {
+					$assignee = array();
+				}
+			}
+
+			$result[] = array(
+						"artifact_query_id"	=> $artifactQuery->getID(),
+						"name"		=> $artifactQuery->getName(),
+						"fields"	=> array(
+										"sortcol"	=> $artifactQuery->getSortCol(),
+										"sortord"	=> $artifactQuery->getSortOrd(),
+										"moddaterange"	=> $artifactQuery->getModDateRange(),
+										"assignee"	=> $assignee,
+										"status"	=> $artifactQuery->getStatus(),
+										"extra_fields"	=> $extra_fields,
+										"opendaterange"	=> $artifactQuery->getOpenDateRange(),
+										"closedaterange"	=> $artifactQuery->getCloseDateRange()
+										),
+						);
 		}
-	
-		$result[] = array(
-					"artifact_query_id"	=> $artifactQuery->getID(),
-					"name"		=> $artifactQuery->getName(),
-					"fields"	=> array(
-									"sortcol"	=> $artifactQuery->getSortCol(),
-									"sortord"	=> $artifactQuery->getSortOrd(),
-									"moddaterange"	=> $artifactQuery->getModDateRange(),
-									"assignee"	=> $assignee,
-									"status"	=> $artifactQuery->getStatus(),
-									"extra_fields"	=> $extra_fields,
-									"opendaterange"	=> $artifactQuery->getOpenDateRange(),
-									"closedaterange"	=> $artifactQuery->getCloseDateRange()
-									),
-					);
 	}
-	
+
 	return $result;
 }
 
@@ -283,7 +286,7 @@
 	'SOAP-ENC:Array',
 	array(),
 	array(
-		array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:int[]')
+		array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:ArrayOfint')
 	),
 	'xsd:int'
 ); 

Modified: trunk/gforge/www/soap/tracker/tracker.php
===================================================================
--- trunk/gforge/www/soap/tracker/tracker.php	2009-02-23 22:00:43 UTC (rev 7047)
+++ trunk/gforge/www/soap/tracker/tracker.php	2009-02-23 23:24:06 UTC (rev 7048)
@@ -517,51 +517,53 @@
 function artifacttype_to_soap($at_arr) {
 	$return = array();
 
-	for ($i=0; $i<count($at_arr); $i++) {
-		if ($at_arr[$i]->isError()) {
-			//skip if error
-		} else {
-			// Get list of extra fields for this artifact
-			$extrafields = array();
-			$tmpextrafields = $at_arr[$i]->getExtraFields();
-			foreach ($tmpextrafields as $extrafield) {
-				$aefobj = new ArtifactExtraField($at_arr[$i], $extrafield["extra_field_id"]);
+	if (is_array($at_arr) && count($at_arr) > 0) {
+		for ($i=0; $i<count($at_arr); $i++) {
+			if ($at_arr[$i]->isError()) {
+				//skip if error
+			} else {
+				// Get list of extra fields for this artifact
+				$extrafields = array();
+				$tmpextrafields = $at_arr[$i]->getExtraFields();
+				foreach ($tmpextrafields as $extrafield) {
+					$aefobj = new ArtifactExtraField($at_arr[$i], $extrafield["extra_field_id"]);
 
-				// array of available values
-				$avtmp = $aefobj->getAvailableValues();
-				$avs = array();
-				for ($j=0; $j < count($avtmp); $j++) {
-					$avs[$j]["element_id"] = $avtmp[$j]["element_id"];
-					$avs[$j]["element_name"] = $avtmp[$j]["element_name"];
-					$avs[$j]["status_id"] = $avtmp[$j]["status_id"];
+					// array of available values
+					$avtmp = $aefobj->getAvailableValues();
+					$avs = array();
+					for ($j=0; $j < count($avtmp); $j++) {
+						$avs[$j]["element_id"] = $avtmp[$j]["element_id"];
+						$avs[$j]["element_name"] = $avtmp[$j]["element_name"];
+						$avs[$j]["status_id"] = $avtmp[$j]["status_id"];
+					}
+
+					$extrafields[] = array(
+						"extra_field_id"=> $aefobj->getID(),
+						"field_name"	=> $aefobj->getName(),
+						"field_type"	=> $aefobj->getType(),
+						"attribute1"	=> $aefobj->getAttribute1(),
+						"attribute2"	=> $aefobj->getAttribute2(),
+						"is_required"	=> $aefobj->isRequired(),
+						"alias"			=> $aefobj->getAlias(),
+						"available_values"	=> $avs,
+						"default_selected_id" => 0		//TODO (not implemented yet)
+					);
 				}
 
-				$extrafields[] = array(
-					"extra_field_id"=> $aefobj->getID(),
-					"field_name"	=> $aefobj->getName(),
-					"field_type"	=> $aefobj->getType(),
-					"attribute1"	=> $aefobj->getAttribute1(),
-					"attribute2"	=> $aefobj->getAttribute2(),
-					"is_required"	=> $aefobj->isRequired(),
-					"alias"			=> $aefobj->getAlias(),
-					"available_values"	=> $avs,
-					"default_selected_id" => 0		//TODO (not implemented yet)
+				$return[]=array(
+					'group_artifact_id'=>$at_arr[$i]->data_array['group_artifact_id'],
+					'group_id'=>$at_arr[$i]->data_array['group_id'],
+					'name'=>$at_arr[$i]->data_array['name'],
+					'description'=>$at_arr[$i]->data_array['description'],
+					'is_public'=>$at_arr[$i]->data_array['is_public'],
+					'allow_anon'=>$at_arr[$i]->data_array['allow_anon'],
+					'due_period'=>$at_arr[$i]->data_array['due_period'],
+					'datatype'=>$at_arr[$i]->data_array['datatype'],
+					'status_timeout'=>$at_arr[$i]->data_array['status_timeout'],
+					'extra_fields' => $extrafields,
+					'custom_status_field' => $at_arr[$i]->data_array['custom_status_field']
 				);
 			}
-
-			$return[]=array(
-				'group_artifact_id'=>$at_arr[$i]->data_array['group_artifact_id'],
-				'group_id'=>$at_arr[$i]->data_array['group_id'],
-				'name'=>$at_arr[$i]->data_array['name'],
-				'description'=>$at_arr[$i]->data_array['description'],
-				'is_public'=>$at_arr[$i]->data_array['is_public'],
-				'allow_anon'=>$at_arr[$i]->data_array['allow_anon'],
-				'due_period'=>$at_arr[$i]->data_array['due_period'],
-				'datatype'=>$at_arr[$i]->data_array['datatype'],
-				'status_timeout'=>$at_arr[$i]->data_array['status_timeout'],
-				'extra_fields' => $extrafields,
-				'custom_status_field' => $at_arr[$i]->data_array['custom_status_field']
-			);
 		}
 	}
 	return $return;
@@ -749,55 +751,54 @@
 //
 function artifacts_to_soap($at_arr) {
 	$return = array();
-	for ($i=0; $i<count($at_arr); $i++) {
-		// return only the first 100
-		if ($i == 100) break;
-		
-		if ($at_arr[$i]->isError()) {
-			//skip if error
-		} else {
-//NEEDS THOROUGH COMMENTS AND EXPLANATION
-	//***********
-	// Retrieving the artifact details
-	//**checks whether there is any artifact details exists for this object, if not continue with next loop
+	if (is_array($at_arr) && count($at_arr) > 0) {
+		for ($i=0; $i<count($at_arr); $i++) {
+			if ($at_arr[$i]->isError()) {
+				//skip if error
+			} else {
+	//NEEDS THOROUGH COMMENTS AND EXPLANATION
+		//***********
+		// Retrieving the artifact details
+		//**checks whether there is any artifact details exists for this object, if not continue with next loop
 
-			if(count($at_arr[$i]) < 1) { continue; }
-			$flddata=array();
-			$fldelementdata=array();
-			$extrafieldsdata=array();
-			$extrafieldsdata=$at_arr[$i]->getExtraFieldData();
+				if(count($at_arr[$i]) < 1) { continue; }
+				$flddata=array();
+				$fldelementdata=array();
+				$extrafieldsdata=array();
+				$extrafieldsdata=$at_arr[$i]->getExtraFieldData();
 
-			//********
-			//** Retrieving the extra field data and the element data
-			//** checks whether there is any extra fields data available for this artifact
-			//** and checks for the extra element data for the multiselect and checkbox type
-			if(is_array($extrafieldsdata) && count($extrafieldsdata)>0) {
-				while(list($ky,$vl)=each($extrafieldsdata)) {
-					$fldarr=array();
-					if(is_array($extrafieldsdata[$ky])) {
-						//** Retrieving the multiselect and checkbox type data element
-						$fldarr=array('extra_field_id'=>$ky,'field_data'=>implode(",",$extrafieldsdata[$ky]));
-					} else {
-						//** Retrieving the extra field data
-						$fldarr=array('extra_field_id'=>$ky,'field_data'=>$vl);
+				//********
+				//** Retrieving the extra field data and the element data
+				//** checks whether there is any extra fields data available for this artifact
+				//** and checks for the extra element data for the multiselect and checkbox type
+				if(is_array($extrafieldsdata) && count($extrafieldsdata)>0) {
+					while(list($ky,$vl)=each($extrafieldsdata)) {
+						$fldarr=array();
+						if(is_array($extrafieldsdata[$ky])) {
+							//** Retrieving the multiselect and checkbox type data element
+							$fldarr=array('extra_field_id'=>$ky,'field_data'=>implode(",",$extrafieldsdata[$ky]));
+						} else {
+							//** Retrieving the extra field data
+							$fldarr=array('extra_field_id'=>$ky,'field_data'=>$vl);
+						}
+						$flddata[]=$fldarr;
+						unset($fldarr);
 					}
-					$flddata[]=$fldarr;
-					unset($fldarr);
 				}
+				$return[]=array(
+					'artifact_id'=>$at_arr[$i]->data_array['artifact_id'],
+					'group_artifact_id'=>$at_arr[$i]->data_array['group_artifact_id'],
+					'status_id'=>$at_arr[$i]->data_array['status_id'],
+					'priority'=>$at_arr[$i]->data_array['priority'],
+					'submitted_by'=>$at_arr[$i]->data_array['submitted_by'],
+					'assigned_to'=>$at_arr[$i]->data_array['assigned_to'],
+					'open_date'=>$at_arr[$i]->data_array['open_date'],
+					'close_date'=>$at_arr[$i]->data_array['close_date'],
+					'summary'=>$at_arr[$i]->data_array['summary'],
+					'details'=>$at_arr[$i]->data_array['details'],
+					'extra_fields'=>$flddata
+				);
 			}
-			$return[]=array(
-				'artifact_id'=>$at_arr[$i]->data_array['artifact_id'],
-				'group_artifact_id'=>$at_arr[$i]->data_array['group_artifact_id'],
-				'status_id'=>$at_arr[$i]->data_array['status_id'],
-				'priority'=>$at_arr[$i]->data_array['priority'],
-				'submitted_by'=>$at_arr[$i]->data_array['submitted_by'],
-				'assigned_to'=>$at_arr[$i]->data_array['assigned_to'],
-				'open_date'=>$at_arr[$i]->data_array['open_date'],
-				'close_date'=>$at_arr[$i]->data_array['close_date'],
-				'summary'=>$at_arr[$i]->data_array['summary'],
-				'details'=>$at_arr[$i]->data_array['details'],
-				'extra_fields'=>$flddata
-			);
 		}
 	}
 	return $return;




More information about the Fusionforge-commits mailing list