<?php
/*
- * This file is (c) Copyright 2009 by Olivier BERGER, Institut
+ * This file is (c) Copyright 2009 by Olivier BERGER & 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.
/* $Id$ */
-// Generate a OSLC-CM V1 Change Management Service Description document (http://open-services.net/bin/view/Main/CmServiceDescriptionV1)
+// Generate an OSLC-CM V2 Service Description document
-function project_to_service_description($base_url, $project) {
+function project_to_service_description($base_url, $project, $tracker) {
$doc = new DOMDocument();
$doc->formatOutput = true;
- $root = $doc->createElementNS("http://open-services.net/xmlns/cm/1.0/", "oslc_cm:ServiceDescriptor");
+ $root = $doc->createElementNS("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf:RDF");
$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("Demo OSLC CM services");
- $child = $title->appendChild($child);
-
- // changeRequests
- $child = $doc->createElementNS("http://open-services.net/xmlns/cm/1.0/", "oslc_cm:changeRequests");
- $cr = $root->appendChild($child);
-
- $child = $doc->createAttribute("version");
- $version = $cr->appendChild($child);
- $child = $doc->createTextNode("1.0");
- $child = $version->appendChild($child);
-
- // Simple GET-based 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("Simple Project 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 = $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");
- $crdl = $cr->appendChild($child);
-
- $child = $doc->createAttribute("oslc_cm:default");
- $option = $crdl->appendChild($child);
- $child = $doc->createTextNode("true");
- $child = $option->appendChild($child);
-
- $child = $doc->createElementNS("http://purl.org/dc/terms/", "dc:title");
- $title = $crdl->appendChild($child);
- $child = $doc->createTextNode("Location for creation of change requests");
- $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 = $url->appendChild($child);
-
- //creation dialog
-
- $child = $doc->createElementNS("http://open-services.net/xmlns/cm/1.0/", "oslc_cm:creationDialog");
- $crdl = $cr->appendChild($child);
-
- $child = $doc->createAttribute("oslc_cm:default");
- $option = $crdl->appendChild($child);
- $child = $doc->createTextNode("true");
- $child = $option->appendChild($child);
-
- $child = $doc->createAttribute("oslc_cm:hintWidth");
- $option = $crdl->appendChild($child);
- $child = $doc->createTextNode("740px");
- $child = $option->appendChild($child);
-
- $child = $doc->createAttribute("oslc_cm:hintHeight");
- $option = $crdl->appendChild($child);
- $child = $doc->createTextNode("540px");
- $child = $option->appendChild($child);
-
- $child = $doc->createElementNS("http://purl.org/dc/terms/", "dc:title");
- $title = $crdl->appendChild($child);
- $child = $doc->createTextNode("New Change Request Creation Dialog");
- $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.'/ui/creation');
- $child = $url->appendChild($child);
-
- //selection dialog
-
- $child = $doc->createElementNS("http://open-services.net/xmlns/cm/1.0/", "oslc_cm:selectionDialog");
- $sldl = $cr->appendChild($child);
-
- $child = $doc->createAttribute("oslc_cm:default");
- $option = $sldl->appendChild($child);
- $child = $doc->createTextNode("true");
- $child = $option->appendChild($child);
-
- $child = $doc->createAttribute("oslc_cm:hintWidth");
- $option = $sldl->appendChild($child);
- $child = $doc->createTextNode("800px");
- $child = $option->appendChild($child);
-
- $child = $doc->createAttribute("oslc_cm:hintHeight");
- $option = $sldl->appendChild($child);
- $child = $doc->createTextNode("600px");
- $child = $option->appendChild($child);
-
- $child = $doc->createElementNS("http://purl.org/dc/terms/", "dc:title");
- $title = $sldl->appendChild($child);
- $child = $doc->createTextNode("Change Request Selection Dialog");
- $child = $title->appendChild($child);
-
- $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 = $url->appendChild($child);
+ // namespaces
+ $root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
+ $root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:dcterms', 'http://purl.org/dc/terms/');
+ $root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:foaf', 'http://xmlns.com/foaf/0.1/');
+ $root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:oslc', 'http://open-services.net/ns/core#');
+ $root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:oslc_cm', 'http://open-services.net/ns/cm#');
+
+ $provider = $doc->createElement("oslc:ServiceProvider");
+ // rdf:about
+ $provider->setAttribute("rdf:about", $base_url.'/cm/oslc-cm-service/'.$project.'/tracker/'.$tracker);
+
+ // rdf:type
+
+ // oslc:Publisher ressource inside a dcterms:publisher node.
+ $publishernode = $doc->createElement("dcterms:publisher");
+ $publishernodecontent = $doc->createElement("oslc:Publisher");
+ $publishernodecontentid = $doc->createElement("dcterms:identifier", $base_url);
+ $publishernodecontenttitle = $doc->createElement("dcterms:title", "FusionForge OSLC V2 plugin");
+ $publishernodecontent->appendChild($publishernodecontentid);
+ $publishernodecontent->appendChild($publishernodecontenttitle);
+ $publishernode->appendChild($publishernodecontent);
+ // Add created dcterms:publisher node in the ServiceProvider node.
+ $provider->appendChild($publishernode);
+
+ // dcterms:title
+ $title = $doc->createElement("dcterms:title","OSLC-CM V2 service description document");
+ $provider->appendChild($title);
+
+ //dcterms:description
+ $desc = $doc->createElement("dcterms:description","FusionForge Tracker services");
+ $provider->appendChild($desc);
+
+ /**
+ * Services description
+ */
+
+ $servicenode = $doc->createElement("oslc:service");
+
+ $service = $doc->createElement("oslc:Service");
+
+ // oslc:domain
+ $sdomain = $doc->createElement("oslc:domain");
+ $sdomain->setAttribute("rdf:resource", "http://open-services.net/ns/cm#");
+ $service->appendChild($sdomain);
+
+ // Creation Factory.
+ $cfactnode = $doc->createElement("oslc:creationFactory");
+ $cfact = $doc->createElement("oslc:CreationFactory");
+
+ $cfacttitle = $doc->createElement("dcterms:title", "Location for creation of change Requests with a POST HTTP request");
+ $cfactlabel = $doc->createElement("oslc:label", "New Tracker items Creation");
+ $cfactcreation = $doc->createElement("oslc:creation");
+ $cfactcreation->setAttribute("rdf:resource", $base_url.'/cm/project/'.$project.'/tracker/'.$tracker);
+ $cfact->appendChild($cfacttitle);
+ $cfact->appendChild($cfactlabel);
+ $cfact->appendChild($cfactcreation);
+
+ $cfactnode->appendChild($cfact);
+ $service->appendChild($cfactnode);
+
+ // Query capabilities.
+ $qcnode = $doc->createElement("oslc:queryCapability");
+ $qc = $doc->createElement("oslc:QueryCapability");
+
+ $qctitle = $doc->createElement("dcterms:title", "GET-Based Tracker items query");
+ $qclabel = $doc->createElement("oslc:label", "Tracker items query");
+ $qcqbase = $doc->createElement("oslc:queryBase");
+ $qcqbase->setAttribute("rdf:resource",$base_url.'/cm/project/'.$project.'/tracker/'.$tracker);
+ $qc->appendChild($qctitle);
+ $qc->appendChild($qclabel);
+ $qc->appendChild($qcqbase);
+
+ $qcnode->appendChild($qc);
+ $service->appendChild($qcnode);
+
+ // Delegated Selection UI.
+ $sD = $doc->createElement("oslc:selectionDialog");
+ $d = $doc->createElement("oslc:Dialog");
+ $dtitle = $doc->createElement("dcterms:title", "Change Requests Selection Dialog");
+ $dlabel = $doc->createElement("oslc:label", "Tracker items selection UI");
+ $ddialog = $doc->createElement("oslc:dialog", $base_url.'/cm/project/'.$project.'/tracker/'.$tracker.'/ui/selection');
+ $dwidth = $doc->createElement("oslc:hintWidth", "800px");
+ $dheight = $doc->createElement("oslc:hintHeight", "600px");
+ $d->appendChild($dtitle);
+ $d->appendChild($dlabel);
+ $d->appendChild($ddialog);
+ $d->appendChild($dwidth);
+ $d->appendChild($dheight);
+ $sD->appendChild($d);
+ $service->appendChild($sD);
+
+ // Delegated Creation UI.
+ $cD = $doc->createElement("oslc:creationDialog");
+ $dialog = $doc->createElement("oslc:Dialog");
+ $dialogtitle = $doc->createElement("dcterms:title", "Change Requests Creation Dialog");
+ $dialoglabel = $doc->createElement("oslc:label", "Tracker items creation UI");
+ $dialogdialog = $doc->createElement("oslc:dialog", $base_url.'/cm/project/'.$project.'/tracker/'.$tracker.'/ui/creation');
+ $dialogwidth = $doc->createElement("oslc:hintWidth", "800px");
+ $dialogheight = $doc->createElement("oslc:hintHeight", "600px");
+ $dialog->appendChild($dialogtitle);
+ $dialog->appendChild($dialoglabel);
+ $dialog->appendChild($dialogdialog);
+ $dialog->appendChild($dialogwidth);
+ $dialog->appendChild($dialogheight);
+ $cD->appendChild($dialog);
+ $service->appendChild($cD);
+
+ $servicenode->appendChild($service);
+
+ $provider->appendChild($servicenode);
+
+ $root->appendChild($provider);
return $doc->saveXML();
-}
\ No newline at end of file
+}