[Fusionforge-commits] r12220 - in branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application: controllers models views/scripts/fusionforgecm

Olivier Berger olberger at libremir.placard.fr.eu.org
Thu Feb 10 16:10:58 CET 2011


Author: olberger
Date: 2011-02-10 16:10:55 +0100 (Thu, 10 Feb 2011)
New Revision: 12220

Added:
   branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/oslc-service-catalog-project.phtml
Modified:
   branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/controllers/CmController.php
   branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeCmController.php
   branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeOSLCConnector.php
   branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/models/fusionforge.inc.php
   branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/_service-catalog_xml.php
   branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/_service-document_xml.php
   branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/oslc-cm-service-document.phtml
   branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/oslc-cm-service-document.xml.phtml
Log:
Fix service catalog and service documents for fusionforge

Modified: branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/controllers/CmController.php
===================================================================
--- branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/controllers/CmController.php	2011-02-10 15:10:40 UTC (rev 12219)
+++ branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/controllers/CmController.php	2011-02-10 15:10:55 UTC (rev 12220)
@@ -248,7 +248,19 @@
 	}
 
 	public function indexAction(){
-
+		switch (TRACKER_TYPE) {
+			case 'mantis':
+				$this->_forward('index','mantiscm');
+				break;	
+			case 'fusionforge':
+				$this->_forward('index','fusionforgecm');
+				break;
+			case 'Codendi':
+				$this->_forward('index', 'codendicm');
+				break;
+			default:
+				break;				
+		}
 	}
 
 	public function putAction(){

Modified: branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeCmController.php
===================================================================
--- branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeCmController.php	2011-02-10 15:10:40 UTC (rev 12219)
+++ branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeCmController.php	2011-02-10 15:10:55 UTC (rev 12220)
@@ -40,12 +40,18 @@
 	 * @var array
 	 */
 	private static $supportedAcceptMimeTypes = array();
-
+	private static $fusionforgeSupportedAcceptMimeTypes = array(
+		'oslcServiceCatalogProject' => array(
+			'application/x-oslc-disc-service-provider-catalog+xml' => 'xml',
+		 	'application/xml' => 'xml',
+			'application/json' => 'json'
+		),
+	);
 	/**
 	 * Init FusionForge REST controller.
 	 */
 	public function init(){
-		self::$supportedAcceptMimeTypes = parent::getSupportedAcceptMimeTypes();
+		self::$supportedAcceptMimeTypes = array_merge(parent::getSupportedAcceptMimeTypes(), self::$fusionforgeSupportedAcceptMimeTypes);
 		
 		// TODO : render this path configurable
 		//		$writer = new Zend_Log_Writer_Stream('/tmp/zend-log.txt');
@@ -115,12 +121,21 @@
 
 		// handle OSLC services catalog access (http://open-services.net/bin/view/Main/OslcServiceProviderCatalogV1)
 		if ( isset($params['id']) && ($params['id'] == "oslc-services")) {
-			$this->_forward('oslcServiceCatalog');
+				$this->_forward('oslcServiceCatalog');
+				return;
+		}
+		
+		// Handle OSLC-CM services catalog for specific project
+		// An OSLC-CM services catalog in FusionForge lists all the trackers 
+		// of a specific project.
+		elseif (isset($params['oslc-cm-services'])){
+			$this->_forward('oslcServiceCatalogProject');
 			return;
 		}
 		
 		// handle OSLC-CM service document access
-		elseif (isset($params['oslc-cm-service'])) {
+		// An OSLC-CM service document describes capabilities of a FusionForge tracker.
+		elseif (isset($params['oslc-cm-service']) && isset($params['tracker'])) {
 			$this->_forward('oslcCmServiceDocument');
 			return;
 		}
@@ -474,6 +489,8 @@
 	
 	/**
 	 * Handle OSLC services catalog access (http://open-services.net/bin/view/Main/OslcServiceProviderCatalogV1)
+	 * Will show the list of prjects.
+	 * 
 	 */
 	public function oslcservicecatalogAction() {
 		
@@ -491,6 +508,31 @@
 		
 		$this->getResponse()->setHeader('Content-Type', $content_type);
 	}
+	
+	/**
+	 * Handle OSLC services catalog access per project.
+	 * Accessed by uris like ".../cm/oslc-services/project/x"
+	 * where x is a project id.
+	 * 
+	 */
+	public function oslcservicecatalogprojectAction() {
+		$content_type = parent::checkSupportedActionMimeType(self::$supportedAcceptMimeTypes, $this->getRequest()->getActionName());
+		if (! $content_type) {
+			$this->_forward('UnknownAcceptType','error');
+			return;
+		}
+		
+		$req = $this->getRequest();
+		$params = $req->getParams();
+		
+		$project = $params['oslc-cm-services'];
+		$trackers = $this->oslc->getProjectTrackers($project);
+		
+		$this->view->project = $project;
+		$this->view->trackers = $trackers;
+		
+		$this->getResponse()->setHeader('Content-Type', $content_type);
+	}
 
 	/**
 	 * 
@@ -500,16 +542,16 @@
 	public function oslccmservicedocumentAction() {
 		$content_type = parent::checkSupportedActionMimeType(self::$supportedAcceptMimeTypes, $this->getRequest()->getActionName());
 		if (! $content_type) {
-		  //			print_r("error");
-		  $this->_forward('UnknownAcceptType','error');
-		  return;
+			$this->_forward('UnknownAcceptType','error');
+			return;
 		}
 		
 		$req = $this->getRequest();
 		$params = $req->getParams();
-		$project = $params['oslc-cm-service'];
-		$this->view->project = $project;
 
+		$this->view->project = $params['oslc-cm-service'];
+		$this->view->tracker = $params['tracker'];
+
 		$this->getResponse()->setHeader('Content-Type', $content_type);
 
 	}

Modified: branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeOSLCConnector.php
===================================================================
--- branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeOSLCConnector.php	2011-02-10 15:10:40 UTC (rev 12219)
+++ branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeOSLCConnector.php	2011-02-10 15:10:55 UTC (rev 12220)
@@ -40,6 +40,7 @@
 require_once $gfwww.'include/pre.php';
 
 require_once $gfwww.'tracker/include/ArtifactTypeHtml.class.php';
+require_once $gfcommon.'tracker/ArtifactTypeFactory.class.php';
 require_once $gfcommon.'tracker/ArtifactType.class.php';
 require_once $gfcommon.'tracker/ArtifactFactory.class.php';
 require_once $gfcommon.'include/Group.class.php';
@@ -673,6 +674,31 @@
 	
 	}
 	
+	/**
+	 * 
+	 * Returns a formatted array of trackers of a project
+	 * Trackers Array is indexed by tracker ids and for each one we set
+	 * the id, name and description.
+	 * 
+	 * @param int $project project id.
+	 * 
+	 * @return Array of trackers
+	 */
+	public function getProjectTrackers($project) {
+		$group = group_get_object($project);
+		$trackers = array();
+		$atf = new ArtifactTypeFactory($group);
+		foreach($atf->getArtifactTypes() as $at) {
+			$trackers[$at->getID()] = array(
+				'id'          => $at->getID(),
+				'group_id'    => $project,
+				'name'        => $at->getName(),
+				'description' => $at->getDescription()
+			);
+		}
+		return $trackers;
+	}
+	
 	public function getHttpAuthBasicResolver($login, $password) {
 		$basicResolver = new FusionForge_Http_Auth_Resolver($login, $password);
 		return $basicResolver;

Modified: branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/models/fusionforge.inc.php
===================================================================
--- branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/models/fusionforge.inc.php	2011-02-10 15:10:40 UTC (rev 12219)
+++ branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/models/fusionforge.inc.php	2011-02-10 15:10:55 UTC (rev 12220)
@@ -33,6 +33,8 @@
  * For FusionForge
  *  
  * @package FusionForgeModel 
+ * 
+ * @TODO: Replace helios_bt by OSLC ontology
  */
 
 /**
@@ -113,6 +115,7 @@
 							$resource[$field] = $value;
 						}
 					}
+					//TODO: Replace helios_bt by OSLC ontology
 					foreach ($changerequest->children('http://heliosplatform.sourceforge.net/ontologies/2010/05/helios_bt.owl') as $child) {
 						$field = $child->getName();
 						if(!$field){

Modified: branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/_service-catalog_xml.php
===================================================================
--- branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/_service-catalog_xml.php	2011-02-10 15:10:40 UTC (rev 12219)
+++ branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/_service-catalog_xml.php	2011-02-10 15:10:55 UTC (rev 12220)
@@ -27,6 +27,58 @@
 
 // Generate a OSLC-CM V1 Service Catalog document (http://open-services.net/bin/view/Main/OslcServiceProviderCatalogV1)
 
+function project_trackers_to_service_catalog($base_url, $trackers, $project) {
+	$doc = new DOMDocument();
+	$doc->formatOutput = true;
+	
+	$root = $doc->createElementNS("http://open-services.net/xmlns/discovery/1.0/", "oslc_disc:ServiceProviderCatalog");
+	$root = $doc->appendChild($root);
+
+	$child = $doc->createAttributeNS("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf:about");
+	$about = $root->appendChild($child);
+	$child = $doc->createTextNode("");
+	$child = $about->appendChild($child);
+
+	$child = $doc->createElementNS("http://purl.org/dc/terms/", "dc:title");
+	$title = $root->appendChild($child);
+
+	$child = $doc->createTextNode(TRACKER_TYPE. " Change management service provider catalog for project " . $project);
+	$child = $title->appendChild($child);
+
+	foreach ($trackers as $tracker) {
+			// entry
+			$child = $doc->createElementNS("http://open-services.net/xmlns/discovery/1.0/", "oslc_disc:entry");
+			$entry = $root->appendChild($child);
+
+			$child = $doc->createElementNS("http://open-services.net/xmlns/discovery/1.0/", "oslc_disc:ServiceProvider");
+			$sp = $entry->appendChild($child);
+			
+			$child = $doc->createElementNS("http://purl.org/dc/terms/", "dc:identifier");
+			$title = $sp->appendChild($child);
+			$child = $doc->createTextNode($tracker['id']);
+			$child = $title->appendChild($child);
+
+			$child = $doc->createElementNS("http://purl.org/dc/terms/", "dc:title");
+			$title = $sp->appendChild($child);
+			$child = $doc->createTextNode($tracker['name']);
+			$child = $title->appendChild($child);
+			
+			$child = $doc->createElementNS("http://purl.org/dc/terms/", "dc:description");
+			$title = $sp->appendChild($child);
+			$child = $doc->createTextNode($tracker['description']);
+			$child = $title->appendChild($child);
+
+			$child = $doc->createElementNS("http://open-services.net/xmlns/discovery/1.0/", "oslc_disc:services");
+			$services = $sp->appendChild($child);
+			$child = $doc->createAttributeNS("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf:resource");
+			$resource = $services->appendChild($child);
+			$child = $doc->createTextNode($base_url.'/cm/oslc-cm-service/'.$tracker['group_id'].'/tracker/'.$tracker['id']);
+			$child = $resource->appendChild($child);
+		
+	}
+	return $doc->saveXML();
+}
+
 function projects_to_service_catalog($base_url, $projects) {
 
 	$doc = new DOMDocument();
@@ -68,7 +120,7 @@
 			$services = $sp->appendChild($child);
 			$child = $doc->createAttributeNS("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf:resource");
 			$resource = $services->appendChild($child);
-			$child = $doc->createTextNode($base_url.'/cm/oslc-cm-service/'.$proj['id']);
+			$child = $doc->createTextNode($base_url.'/cm/oslc-cm-services/'.$proj['id']);
 			$child = $resource->appendChild($child);
 
 

Modified: branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/_service-document_xml.php
===================================================================
--- branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/_service-document_xml.php	2011-02-10 15:10:40 UTC (rev 12219)
+++ branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/_service-document_xml.php	2011-02-10 15:10:55 UTC (rev 12220)
@@ -27,7 +27,7 @@
 
 // Generate a OSLC-CM V1 Change Management Service Description document (http://open-services.net/bin/view/Main/CmServiceDescriptionV1)
 
-function project_to_service_description($base_url, $project) {
+function project_to_service_description($base_url, $project, $tracker) {
 
 	$doc = new DOMDocument();
 	$doc->formatOutput = true;
@@ -61,29 +61,14 @@
 	
 	$child = $doc->createElementNS("http://purl.org/dc/terms/", "dc:title");
 	$title = $sq->appendChild($child);
-	$child = $doc->createTextNode("Simple Project Query");
+	$child = $doc->createTextNode("Simple Tracker Query");
 	$child = $title->appendChild($child);
 	
 	$child = $doc->createElementNS("http://open-services.net/xmlns/cm/1.0/", "oslc_cm:url");
 	$url = $sq->appendChild($child);
-	$child = $doc->createTextNode($base_url.'/cm/project/'.$project);
+	$child = $doc->createTextNode($base_url.'/cm/project/'.$project.'/tracker/'.$tracker);
 	$child = $url->appendChild($child);
 	
-	// OSLC URL-encoded query
-
-	$child = $doc->createElementNS("http://open-services.net/xmlns/cm/1.0/", "oslc_cm:simpleQuery");
-	$sq = $cr->appendChild($child);
-	
-	$child = $doc->createElementNS("http://purl.org/dc/terms/", "dc:title");
-	$title = $sq->appendChild($child);
-	$child = $doc->createTextNode("OSLC Change Request Queries");
-	$child = $title->appendChild($child);
-	
-	$child = $doc->createElementNS("http://open-services.net/xmlns/cm/1.0/", "oslc_cm:url");
-	$url = $sq->appendChild($child);
-	$child = $doc->createTextNode($base_url.'/cm/bugs');
-	$child = $url->appendChild($child);
-	
 	//creation factory
 	
 	$child = $doc->createElementNS("http://open-services.net/xmlns/cm/1.0/", "oslc_cm:factory");
@@ -96,12 +81,12 @@
 	
 	$child = $doc->createElementNS("http://purl.org/dc/terms/", "dc:title");
 	$title = $crdl->appendChild($child);
-	$child = $doc->createTextNode("Location for creation of change requests");
+	$child = $doc->createTextNode("Location for creation of change requests (with a POST HTTP request)");
 	$child = $title->appendChild($child);
 
 	$child = $doc->createElementNS("http://open-services.net/xmlns/cm/1.0/", "oslc_cm:url");
 	$url = $crdl->appendChild($child);
-	$child = $doc->createTextNode($base_url.'/cm/project/'.$project);
+	$child = $doc->createTextNode($base_url.'/cm/project/'.$project.'/tracker/'.$tracker);
 	$child = $url->appendChild($child);
 	
 	//creation dialog
@@ -131,7 +116,7 @@
 
 	$child = $doc->createElementNS("http://open-services.net/xmlns/cm/1.0/", "oslc_cm:url");
 	$url = $crdl->appendChild($child);
-	$child = $doc->createTextNode($base_url.'/cm/project/'.$project.'/ui/creation');
+	$child = $doc->createTextNode($base_url.'/cm/project/'.$project.'/tracker/'.$tracker.'/ui/creation');
 	$child = $url->appendChild($child);
 	
 	//selection dialog
@@ -161,7 +146,7 @@
 
 	$child = $doc->createElementNS("http://open-services.net/xmlns/cm/1.0/", "oslc_cm:url");
 	$url = $sldl->appendChild($child);
-	$child = $doc->createTextNode($base_url.'/cm/project/'.$project.'/ui/selection');
+	$child = $doc->createTextNode($base_url.'/cm/project/'.$project.'/tracker/'.$tracker.'/ui/selection');
 	$child = $url->appendChild($child);
 
 	return $doc->saveXML();

Modified: branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/oslc-cm-service-document.phtml
===================================================================
--- branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/oslc-cm-service-document.phtml	2011-02-10 15:10:40 UTC (rev 12219)
+++ branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/oslc-cm-service-document.phtml	2011-02-10 15:10:55 UTC (rev 12220)
@@ -48,7 +48,7 @@
 <h1>OSLC-CM V1 Service Description document</h1>
 <pre>
 <?php
-	$xml = project_to_service_description($this->baseUrl(), $this->project);
+	$xml = project_to_service_description($this->baseUrl(), $this->project, $this->tracker);
 	$text = str_replace('>', '>', str_replace('<', '<', $xml));
 	$text = add_links($text, "http");
 	$text = add_links($text, $this->baseUrl());

Modified: branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/oslc-cm-service-document.xml.phtml
===================================================================
--- branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/oslc-cm-service-document.xml.phtml	2011-02-10 15:10:40 UTC (rev 12219)
+++ branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/oslc-cm-service-document.xml.phtml	2011-02-10 15:10:55 UTC (rev 12220)
@@ -27,4 +27,4 @@
 
 require('_service-document_xml.php');
 
-print project_to_service_description($this->baseUrl(), $this->project);
\ No newline at end of file
+print project_to_service_description($this->baseUrl(), $this->project, $this->tracker);
\ No newline at end of file

Copied: branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/oslc-service-catalog-project.phtml (from rev 12219, branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/oslc-cm-service-document.xml.phtml)
===================================================================
--- branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/oslc-service-catalog-project.phtml	                        (rev 0)
+++ branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/oslc-service-catalog-project.phtml	2011-02-10 15:10:55 UTC (rev 12220)
@@ -0,0 +1,41 @@
+<?php
+/**
+ * This file is (c) Copyright 2010 by Sabri LABBENE, Institut
+ * TELECOM
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * This program has been developed in the frame of the HELIOS
+ * project with financial support of its funders.
+ *
+ */
+
+require_once('_service-catalog_xml.php');
+require_once('_add_hyperlinks.php');
+
+?>
+<body>
+<h1>OSLC-CM V1 Service Catalog document</h1>
+<pre>
+<?php
+	$xml = project_trackers_to_service_catalog($this->baseUrl(), $this->trackers, $this->project);
+	//print $xml;
+	$text = str_replace('>', '>', str_replace('<', '<', $xml));
+	$text = add_links($text, "http");
+	$text = add_links($text, $this->baseUrl());
+	echo $text;
+?>
+</pre>
+</body>




More information about the Fusionforge-commits mailing list