[Fusionforge-commits] r9749 - in trunk/plugins/coclico/soapadmin: . coreapi

Laurent HUET laurent35 at libremir.placard.fr.eu.org
Mon May 17 22:57:49 CEST 2010


Author: laurent35
Date: 2010-05-17 22:57:48 +0200 (Mon, 17 May 2010)
New Revision: 9749

Added:
   trunk/plugins/coclico/soapadmin/README.txt
   trunk/plugins/coclico/soapadmin/coreapi/
   trunk/plugins/coclico/soapadmin/coreapi/FusionforgeCoreApi.wsdl
   trunk/plugins/coclico/soapadmin/coreapi/coreapi.php
   trunk/plugins/coclico/soapadmin/coreapi/coreapiobjects.php
   trunk/plugins/coclico/soapadmin/coreapi/coreapiservice.php
Log:
First core api SOAP implementation

Added: trunk/plugins/coclico/soapadmin/README.txt
===================================================================
--- trunk/plugins/coclico/soapadmin/README.txt	                        (rev 0)
+++ trunk/plugins/coclico/soapadmin/README.txt	2010-05-17 20:57:48 UTC (rev 9749)
@@ -0,0 +1,26 @@
+Soap Admin
+
+This plugin is a full rewrite of the older NuSOAP API.
+There is a Web Service for each functionnality family :
+- Core 
+- (Document manager) - Not implemented yet
+- (File Release System) - Not implemented yet
+- (Project Manager) - Not implemented yet
+- (Reporting) - Not implemented yet
+- (Tracker) - Not implemented yet
+
+==== INSTALLATION ===
+
+Copy all the php script in the <fugionforge_www>/api directory.
+The Web Service endpoints are the scripts :
+- coreapi.php
+- ...
+- ...
+
+
+==== SECURITY CONSIDERATIONS ====
+
+No security controls are implemented Yet.
+A new RBAC (Role Based Access Control) system is currently studied by the fusionforge team.
+(http://wiki.planetforge.org/index.php/RBAC_API)
+

Added: trunk/plugins/coclico/soapadmin/coreapi/FusionforgeCoreApi.wsdl
===================================================================
--- trunk/plugins/coclico/soapadmin/coreapi/FusionforgeCoreApi.wsdl	                        (rev 0)
+++ trunk/plugins/coclico/soapadmin/coreapi/FusionforgeCoreApi.wsdl	2010-05-17 20:57:48 UTC (rev 9749)
@@ -0,0 +1,305 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://soap.api.fusionforge.org/"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/"
+	targetNamespace="http://soap.api.fusionforge.org/" name="CoreApiService">
+	<types>
+		<xsd:schema version="1.0" targetNamespace="http://soap.api.fusionforge.org/">
+			<xsd:element name="getGroups" type="tns:getGroups" />
+			<xsd:element name="getGroupsByName" type="tns:getGroupsByName" />
+			<xsd:element name="getGroupsByNameResponse" type="tns:getGroupsByNameResponse" />
+			<xsd:element name="getGroupsResponse" type="tns:getGroupsResponse" />
+			<xsd:element name="getPublicProjectNames" type="tns:getPublicProjectNames" />
+			<xsd:element name="getPublicProjectNamesResponse" type="tns:getPublicProjectNamesResponse" />
+			<xsd:element name="getSCMData" type="tns:getSCMData" />
+			<xsd:element name="getSCMDataResponse" type="tns:getSCMDataResponse" />
+			<xsd:element name="getUsers" type="tns:getUsers" />
+			<xsd:element name="getUsersByName" type="tns:getUsersByName" />
+			<xsd:element name="getUsersByNameResponse" type="tns:getUsersByNameResponse" />
+			<xsd:element name="getUsersResponse" type="tns:getUsersResponse" />
+			<xsd:element name="getVersion" type="tns:getVersion" />
+			<xsd:element name="getVersionResponse" type="tns:getVersionResponse" />
+			<xsd:element name="userGetGroups" type="tns:userGetGroups" />
+			<xsd:element name="userGetGroupsResponse" type="tns:userGetGroupsResponse" />
+			<xsd:complexType name="getSCMData">
+				<xsd:sequence>
+					<xsd:element name="group_id" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+				</xsd:sequence>
+			</xsd:complexType>
+			<xsd:complexType name="getSCMDataResponse">
+				<xsd:sequence>
+					<xsd:element name="scm_data" type="tns:scmData"/>
+				</xsd:sequence>
+			</xsd:complexType>
+			<xsd:complexType name="scmData">
+				<xsd:sequence>
+					<xsd:element name="allow_anonymous" type="xsd:int" />
+					<xsd:element name="box" type="xsd:string"/>
+					<xsd:element name="connection_string" type="xsd:string"/>
+					<xsd:element name="module" type="xsd:string"/>
+					<xsd:element name="root" type="xsd:string"/>
+					<xsd:element name="type" type="xsd:string"/>
+					<xsd:element name="public" type="xsd:int"/>
+				</xsd:sequence>
+			</xsd:complexType>
+			<xsd:complexType name="getVersion">
+				<xsd:sequence />
+			</xsd:complexType>
+			<xsd:complexType name="getVersionResponse">
+				<xsd:sequence>
+					<xsd:element name="version" type="xsd:string"/>
+				</xsd:sequence>
+			</xsd:complexType>
+			<xsd:complexType name="getGroups">
+				<xsd:sequence>
+					<xsd:element name="group_id" type="xsd:string" minOccurs="1" maxOccurs="unbounded" />
+				</xsd:sequence>
+			</xsd:complexType>
+			<xsd:complexType name="getGroupsResponse">
+				<xsd:sequence>
+					<xsd:element name="group" type="tns:group" maxOccurs="unbounded" />
+				</xsd:sequence>
+			</xsd:complexType>
+			<xsd:complexType name="group">
+				<xsd:sequence>
+					<xsd:element name="group_id" type="xsd:int" />
+					<xsd:element name="group_name" type="xsd:string" minOccurs="0" />
+					<xsd:element name="homepage" type="xsd:string" minOccurs="0" />
+					<xsd:element name="is_public" type="xsd:boolean" />
+					<xsd:element name="register_time" type="xsd:dateTime" minOccurs="0" />
+					<xsd:element name="scm_box" type="xsd:string" minOccurs="0" />
+					<xsd:element name="short_description" type="xsd:string" minOccurs="0" />
+					<xsd:element name="status" type="xsd:string" minOccurs="0" />
+					<xsd:element name="unix_group_name" type="xsd:string" minOccurs="0" />
+				</xsd:sequence>
+			</xsd:complexType>
+			<xsd:complexType name="getPublicProjectNames">
+				<xsd:sequence />
+			</xsd:complexType>
+			<xsd:complexType name="getPublicProjectNamesResponse">
+				<xsd:sequence>
+					<xsd:element name="project_name" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
+				</xsd:sequence>
+			</xsd:complexType>
+			<xsd:complexType name="userGetGroups">
+				<xsd:sequence>
+					<xsd:element name="user_id" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+				</xsd:sequence>
+			</xsd:complexType>
+			<xsd:complexType name="userGetGroupsResponse">
+				<xsd:sequence>
+					<xsd:element name="group" type="tns:group" minOccurs="0" maxOccurs="unbounded"/>
+				</xsd:sequence>
+			</xsd:complexType>
+			<xsd:complexType name="getUsers">
+				<xsd:sequence>
+					<xsd:element name="user_id" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
+				</xsd:sequence>
+			</xsd:complexType>
+			<xsd:complexType name="getUsersResponse">
+				<xsd:sequence>
+					<xsd:element name="user" type="tns:user" minOccurs="0" maxOccurs="unbounded" />
+				</xsd:sequence>
+			</xsd:complexType>
+			<xsd:complexType name="user">
+				<xsd:sequence>
+					<xsd:element name="add_date" type="xsd:dateTime" minOccurs="0" />
+					<xsd:element name="address" type="xsd:string" minOccurs="0" />
+					<xsd:element name="address2" type="xsd:string" minOccurs="0" />
+					<xsd:element name="country_code" type="xsd:string" minOccurs="0" />
+					<xsd:element name="fax" type="xsd:string" minOccurs="0" />
+					<xsd:element name="firstname" type="xsd:string" minOccurs="0" />
+					<xsd:element name="language_id" type="xsd:int" />
+					<xsd:element name="lastname" type="xsd:string" minOccurs="0" />
+					<xsd:element name="phone" type="xsd:string" minOccurs="0" />
+					<xsd:element name="status" type="xsd:string" minOccurs="0" />
+					<xsd:element name="timezone" type="xsd:string" minOccurs="0" />
+					<xsd:element name="title" type="xsd:string" minOccurs="0" />
+					<xsd:element name="user_id" type="xsd:int" />
+					<xsd:element name="user_name" type="xsd:string" minOccurs="0" />
+				</xsd:sequence>
+			</xsd:complexType>
+			<xsd:complexType name="getGroupsByName">
+				<xsd:sequence>
+					<xsd:element name="group_name" type="xsd:string" minOccurs="1" maxOccurs="unbounded" />
+				</xsd:sequence>
+			</xsd:complexType>
+			<xsd:complexType name="getGroupsByNameResponse">
+				<xsd:sequence>
+					<xsd:element name="group" type="tns:group" minOccurs="0" maxOccurs="unbounded" />
+				</xsd:sequence>
+			</xsd:complexType>
+			<xsd:complexType name="getUsersByName">
+				<xsd:sequence>
+					<xsd:element name="user_name" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
+				</xsd:sequence>
+			</xsd:complexType>
+			<xsd:complexType name="getUsersByNameResponse">
+				<xsd:sequence>
+					<xsd:element name="user" type="tns:user" minOccurs="0" maxOccurs="unbounded" />
+				</xsd:sequence>
+			</xsd:complexType>
+		</xsd:schema>
+	</types>
+	<message name="getVersion">
+		<part name="parameters" element="tns:getVersion" />
+	</message>
+	<message name="getVersionResponse">
+		<part name="parameters" element="tns:getVersionResponse" />
+	</message>
+	<message name="getGroups">
+		<part name="parameters" element="tns:getGroups" />
+	</message>
+	<message name="getGroupsResponse">
+		<part name="parameters" element="tns:getGroupsResponse" />
+	</message>
+	<message name="getUsers">
+		<part name="parameters" element="tns:getUsers" />
+	</message>
+	<message name="getUsersResponse">
+		<part name="parameters" element="tns:getUsersResponse" />
+	</message>
+	<message name="getGroupsByName">
+		<part name="parameters" element="tns:getGroupsByName" />
+	</message>
+	<message name="getGroupsByNameResponse">
+		<part name="parameters" element="tns:getGroupsByNameResponse" />
+	</message>
+	<message name="getPublicProjectNames">
+		<part name="parameters" element="tns:getPublicProjectNames" />
+	</message>
+	<message name="getPublicProjectNamesResponse">
+		<part name="parameters" element="tns:getPublicProjectNamesResponse" />
+	</message>
+	<message name="getUsersByName">
+		<part name="parameters" element="tns:getUsersByName" />
+	</message>
+	<message name="getUsersByNameResponse">
+		<part name="parameters" element="tns:getUsersByNameResponse" />
+	</message>
+	<message name="userGetGroups">
+		<part name="parameters" element="tns:userGetGroups" />
+	</message>
+	<message name="userGetGroupsResponse">
+		<part name="parameters" element="tns:userGetGroupsResponse" />
+	</message>
+	<message name="getSCMData">
+		<part name="parameters" element="tns:getSCMData" />
+	</message>
+	<message name="getSCMDataResponse">
+		<part name="parameters" element="tns:getSCMDataResponse" />
+	</message>
+	<portType name="CoreApi">
+		<operation name="getVersion">
+			<input message="tns:getVersion" />
+			<output message="tns:getVersionResponse" />
+		</operation>
+		<operation name="getGroups">
+			<input message="tns:getGroups" />
+			<output message="tns:getGroupsResponse" />
+		</operation>
+		<operation name="getUsers">
+			<input message="tns:getUsers" />
+			<output message="tns:getUsersResponse" />
+		</operation>
+		<operation name="getGroupsByName">
+			<input message="tns:getGroupsByName" />
+			<output message="tns:getGroupsByNameResponse" />
+		</operation>
+		<operation name="getPublicProjectNames">
+			<input message="tns:getPublicProjectNames" />
+			<output message="tns:getPublicProjectNamesResponse" />
+		</operation>
+		<operation name="getUsersByName">
+			<input message="tns:getUsersByName" />
+			<output message="tns:getUsersByNameResponse" />
+		</operation>
+		<operation name="userGetGroups">
+			<input message="tns:userGetGroups" />
+			<output message="tns:userGetGroupsResponse" />
+		</operation>
+		<operation name="getSCMData">
+			<input message="tns:getSCMData" />
+			<output message="tns:getSCMDataResponse" />
+		</operation>
+	</portType>
+	<binding name="CoreApiPortBinding" type="tns:CoreApi">
+		<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
+		<operation name="getVersion">
+			<soap:operation soapAction="" />
+			<input>
+				<soap:body use="literal" />
+			</input>
+			<output>
+				<soap:body use="literal" />
+			</output>
+		</operation>
+		<operation name="getGroups">
+			<soap:operation soapAction="" />
+			<input>
+				<soap:body use="literal" />
+			</input>
+			<output>
+				<soap:body use="literal" />
+			</output>
+		</operation>
+		<operation name="getUsers">
+			<soap:operation soapAction="" />
+			<input>
+				<soap:body use="literal" />
+			</input>
+			<output>
+				<soap:body use="literal" />
+			</output>
+		</operation>
+		<operation name="getGroupsByName">
+			<soap:operation soapAction="" />
+			<input>
+				<soap:body use="literal" />
+			</input>
+			<output>
+				<soap:body use="literal" />
+			</output>
+		</operation>
+		<operation name="getPublicProjectNames">
+			<soap:operation soapAction="" />
+			<input>
+				<soap:body use="literal" />
+			</input>
+			<output>
+				<soap:body use="literal" />
+			</output>
+		</operation>
+		<operation name="getUsersByName">
+			<soap:operation soapAction="" />
+			<input>
+				<soap:body use="literal" />
+			</input>
+			<output>
+				<soap:body use="literal" />
+			</output>
+		</operation>
+		<operation name="userGetGroups">
+			<soap:operation soapAction="" />
+			<input>
+				<soap:body use="literal" />
+			</input>
+			<output>
+				<soap:body use="literal" />
+			</output>
+		</operation>
+		<operation name="getSCMData">
+			<soap:operation soapAction="" />
+			<input>
+				<soap:body use="literal" />
+			</input>
+			<output>
+				<soap:body use="literal" />
+			</output>
+		</operation>
+	</binding>
+	<service name="CoreApiService">
+		<port name="CoreApiPort" binding="tns:CoreApiPortBinding">
+			<soap:address location="http://fusionforge.local/api/soap/coreapi.php" />
+		</port>
+	</service>
+</definitions>
\ No newline at end of file

Added: trunk/plugins/coclico/soapadmin/coreapi/coreapi.php
===================================================================
--- trunk/plugins/coclico/soapadmin/coreapi/coreapi.php	                        (rev 0)
+++ trunk/plugins/coclico/soapadmin/coreapi/coreapi.php	2010-05-17 20:57:48 UTC (rev 9749)
@@ -0,0 +1,45 @@
+<?php
+/*-
+ * SOAP Core Api for FusionForge
+ *
+ * Copyright © 2010
+ *      Laurent Huet <laurent.huet at gmail.com>
+ * All rights reserved.
+ *
+ * This file is part of FusionForge. FusionForge 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 Licence, or (at your option)
+ * any later version.
+ *
+ * FusionForge 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 FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *-
+ * FusionForge Core Api (full description in FusionforgeCoreApi.wsdl)
+ * Rewrite of the older Api based on NuSOAP
+ * 
+ * Main technical features :
+ * - Based on the PHP SOAP extension (PHP > 5.x)
+ * - SOAP Document/Litteral wrapped mode
+ * - WS-I Basic Profile Compliant
+ * 
+ */
+
+require_once './coreapiservice.php';
+
+# uncomment this for development purpose only
+# ini_set('soap.wsdl_cache_enabled', '0'); 
+
+use_soap_error_handler(false);
+
+$server = new CoreApiServer();
+$server->setClass("CoreApiService");
+$server->handle();
+
+?>
\ No newline at end of file

Added: trunk/plugins/coclico/soapadmin/coreapi/coreapiobjects.php
===================================================================
--- trunk/plugins/coclico/soapadmin/coreapi/coreapiobjects.php	                        (rev 0)
+++ trunk/plugins/coclico/soapadmin/coreapi/coreapiobjects.php	2010-05-17 20:57:48 UTC (rev 9749)
@@ -0,0 +1,335 @@
+<?php 
+/**
+ * getSCMData_soap
+ */
+class getSCMData_soap {
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $group_id;
+}
+
+/**
+ * getSCMDataResponse_soap
+ */
+class getSCMDataResponse_soap {
+	/**
+	 * @access public
+	 * @var scmData_soap
+	 */
+	public $scm_data;
+}
+
+/**
+ * scmData_soap
+ */
+class scmData_soap {
+	/**
+	 * @access public
+	 * @var integer
+	 */
+	public $allow_anonymous;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $box;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $connection_string;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $module;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $root;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $type;
+	/**
+	 * @access public
+	 * @var integer
+	 */
+	public $public;
+}
+
+/**
+ * getVersion_soap
+ */
+class getVersion_soap {
+}
+
+/**
+ * getVersionResponse_soap
+ */
+class getVersionResponse_soap {
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $version;
+}
+
+/**
+ * getGroups_soap
+ */
+class getGroups_soap {
+	/**
+	 * @access public
+	 * @var string[]
+	 */
+	public $group_id;
+}
+
+/**
+ * getGroupsResponse_soap
+ */
+class getGroupsResponse_soap {
+	/**
+	 * @access public
+	 * @var group_soap[]
+	 */
+	public $group;
+}
+
+/**
+ * group_soap
+ */
+class group_soap {
+	/**
+	 * @access public
+	 * @var integer
+	 */
+	public $group_id;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $group_name;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $homepage;
+	/**
+	 * @access public
+	 * @var boolean
+	 */
+	public $is_public;
+	/**
+	 * @access public
+	 * @var dateTime
+	 */
+	public $register_time;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $scm_box;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $short_description;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $status;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $unix_group_name;
+}
+
+/**
+ * getPublicProjectNames_soap
+ */
+class getPublicProjectNames_soap {
+}
+
+/**
+ * getPublicProjectNamesResponse_soap
+ */
+class getPublicProjectNamesResponse_soap {
+	/**
+	 * @access public
+	 * @var string[]
+	 */
+	public $project_name;
+}
+
+/**
+ * userGetGroups_soap
+ */
+class userGetGroups_soap {
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $user_id;
+}
+
+/**
+ * userGetGroupsResponse_soap
+ */
+class userGetGroupsResponse_soap {
+	/**
+	 * @access public
+	 * @var group_soap
+	 */
+	public $group;
+}
+
+/**
+ * getUsers_soap
+ */
+class getUsers_soap {
+	/**
+	 * @access public
+	 * @var string[]
+	 */
+	public $user_id;
+}
+
+/**
+ * getUsersResponse_soap
+ */
+class getUsersResponse_soap {
+	/**
+	 * @access public
+	 * @var user[]
+	 */
+	public $user;
+}
+
+/**
+ * user_soap
+ */
+class user_soap {
+	/**
+	 * @access public
+	 * @var dateTime
+	 */
+	public $add_date;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $address;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $address2;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $country_code;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $fax;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $firstname;
+	/**
+	 * @access public
+	 * @var integer
+	 */
+	public $language_id;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $lastname;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $phone;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $status;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $timezone;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $title;
+	/**
+	 * @access public
+	 * @var integer
+	 */
+	public $user_id;
+	/**
+	 * @access public
+	 * @var string
+	 */
+	public $user_name;
+}
+
+/**
+ * getGroupsByName_soap
+ */
+class getGroupsByName_soap {
+	/**
+	 * @access public
+	 * @var string[]
+	 */
+	public $group_name;
+}
+
+/**
+ * getGroupsByNameResponse_soap
+ */
+class getGroupsByNameResponse_soap {
+	/**
+	 * @access public
+	 * @var group_soap[]
+	 */
+	public $group;
+}
+
+/**
+ * getUsersByName_soap
+ */
+class getUsersByName_soap {
+	/**
+	 * @access public
+	 * @var string[]
+	 */
+	public $user_name;
+}
+
+/**
+ * getUsersByNameResponse_soap
+ */
+class getUsersByNameResponse_soap {
+	/**
+	 * @access public
+	 * @var user_soap[]
+	 */
+	public $user;
+}
+?>
\ No newline at end of file

Added: trunk/plugins/coclico/soapadmin/coreapi/coreapiservice.php
===================================================================
--- trunk/plugins/coclico/soapadmin/coreapi/coreapiservice.php	                        (rev 0)
+++ trunk/plugins/coclico/soapadmin/coreapi/coreapiservice.php	2010-05-17 20:57:48 UTC (rev 9749)
@@ -0,0 +1,530 @@
+<?php
+
+require_once '../../env.inc.php';
+require_once $gfwww.'include/squal_pre.php';
+require_once $gfcommon.'include/gettext.php';
+require_once $gfcommon.'include/FusionForge.class.php';
+require_once './coreapiobjects.php';
+
+// Log4php initialisation
+require_once dirname(__FILE__).'/../log4php/Logger.php';
+Logger::configure(dirname(__FILE__).'/../log4php.properties');
+
+
+/**
+ * CoreApiService (SOAP Server)
+ */
+Class CoreApiServer extends SoapServer {
+
+	private $logger; 
+	
+	/**
+	 * Default class map for wsdl=>php
+	 * @access private
+	 * @var array
+	 */
+	private static $classmap = array(
+		"getSCMData" => "getSCMData_soap",
+		"getSCMDataResponse" => "getSCMDataResponse_soap",
+		"scmData" => "scmData_soap",
+		"getVersion" => "getVersion_soap",
+		"getVersionResponse" => "getVersionResponse_soap",
+		"getGroups" => "getGroups_soap",
+		"getGroupsResponse" => "getGroupsResponse_soap",
+		"group" => "group_soap",
+		"getPublicProjectNames" => "getPublicProjectNames_soap",
+		"getPublicProjectNamesResponse" => "getPublicProjectNamesResponse_soap",
+		"userGetGroups" => "userGetGroups_soap",
+		"userGetGroupsResponse" => "userGetGroupsResponse_soap",
+		"getUsers" => "getUsers_soap",
+		"getUsersResponse" => "getUsersResponse_soap",
+		"user" => "user_soap",
+		"getGroupsByName" => "getGroupsByName_soap",
+		"getGroupsByNameResponse" => "getGroupsByNameResponse_soap",
+		"getUsersByName" => "getUsersByName_soap",
+		"getUsersByNameResponse" => "getUsersByNameResponse_soap",
+	);
+
+	/**
+	 * Constructor using wsdl location and options array
+	 * @param string $wsdl WSDL location for this service
+	 * @param array $options Options for the SoapClient
+	 */
+	public function __construct($wsdl="FusionforgeCoreApi.wsdl", $options=array()) {
+		
+		$this->logger = Logger::getLogger('api.soap.core.CoreApi');
+		$this->logger->debug("FusionForgeCoreApi Soap Server created ...");
+		foreach(self::$classmap as $wsdlClassName => $phpClassName) {
+		    if(!isset($options['classmap'][$wsdlClassName])) {
+		        $options['classmap'][$wsdlClassName] = $phpClassName;
+		    }
+		}
+		parent::__construct($wsdl, $options);
+	}
+}
+
+
+class CoreApiService {
+
+	private $logger; 
+	
+	public function __construct() {
+		// log4php logger initialization for the class
+		$this->logger = Logger::getLogger('fusionforge.api.soap.CoreApi');
+	}
+	
+		/**
+	 * Checks if an argument list matches against a valid argument type list
+	 * @param array $arguments The argument list to check
+	 * @param array $validParameters A list of valid argument types
+	 * @return boolean true if arguments match against validParameters
+	 * @throws Exception invalid function signature message
+	 */
+	public function _checkArguments($arguments, $validParameters) {
+		$variables = "";
+		foreach ($arguments as $arg) {
+		    $type = gettype($arg);
+		    if ($type == "object") {
+		        $type = get_class($arg);
+		    }
+		    $variables .= "(".$type.")";
+		}
+		if (!in_array($variables, $validParameters)) {
+		    throw new Exception("Invalid parameter types: ".str_replace(")(", ", ", $variables));
+		}
+		return true;
+	}
+	
+	/**
+	 * Service Call: getVersion
+	 * 
+	 * @param mixed getVersion_soap (Soap request object)
+	 * @return getVersionResponse_soap (Soap response object) or SoapFault if parameter are invalid
+	 */
+	public function getVersion($mixed = null) {
+		$this->logger->info("CoreApiService Soap call : getVersion");
+		$validParameters = array(
+			"(getVersion_soap)",
+		);
+
+		try {
+			$args = func_get_args();
+			$this->_checkArguments($args, $validParameters);
+		}
+		catch (Exception $e) {
+			// Invalid parameters => return a soap fault
+			return new SoapFault($e->getCode(),$e->getMessage());
+		}
+		
+		$fusionforge = new FusionForge();
+		$response = new getVersionResponse_soap();
+		$response->version = $fusionforge->software_version;
+		return $response;
+	}
+
+
+	/**
+	 * Service Call: getGroups
+	 * 
+	 * @param mixed  getGroups_soap (Soap request object)
+	 * @return getGroupsResponse_soap (Soap response object) or SoapFault if parameters are invalid
+	 */
+	public function getGroups($mixed = null) {
+		$group_ids = $mixed->group_id;
+		$this->logger->info("CoreApiService Soap call : getGroups for group_id ".var_export($group_ids, true));
+		$validParameters = array(
+			"(getGroups_soap)",
+		);
+		
+		try {
+			$args = func_get_args();
+			$this->_checkArguments($args, $validParameters);
+		}
+		catch (Exception $e) {
+			// Invalid parameters => return a soap fault
+			return new SoapFault($e->getCode(),$e->getMessage());
+		}
+		
+		$grps =& group_get_objects($group_ids);
+		if (!$grps) {
+			$this->logger->debug("Could Not Get Groups by Id");
+			return new soap_fault ('2001','group','Could Not Get Groups by Id'.$inputArgs,$feedback);
+		}
+
+		$response = new getGroupsResponse_soap();
+		$this->logger->debug((count($grps)+1)." Groups objects found");
+		
+		for ($i=0; $i<count($grps); $i++) {
+			$group = new group_soap();
+			$group->group_id = $grps[$i]->data_array['group_id'];
+			$group->group_name=$grps[$i]->data_array['group_name'];
+			$group->homepage=$grps[$i]->data_array['homepage'];
+			$group->is_public=$grps[$i]->data_array['is_public'];
+			$group->status=$grps[$i]->data_array['status'];
+			$group->unix_group_name=$grps[$i]->data_array['unix_group_name'];
+			$group->short_description=$grps[$i]->data_array['short_description'];
+			$group->scm_box=$grps[$i]->data_array['scm_box'];
+			$group->register_time=$grps[$i]->data_array['register_time'];
+			$response->group[$i]=$group;
+			$this->logger->debug("Adding Group objects : ".var_export($group, true));
+		}
+		
+		return $response;
+	}
+
+
+	/**
+	 * Service Call: getUsers
+	 * 
+	 * @param mixed  getUsers_soap (Soap request object)
+	 * @return getUsersResponse_soap (Soap response object) or SoapFault if parameters are invalid
+	 */
+	public function getUsers($mixed = null) {
+		$this->logger->debug("CoreApiService Soap call getUsers ".var_export($mixed, true));
+
+		// The $mixed->user_id is an array only if several user_id in the SOAP request
+		if (is_array($mixed->user_id)) {
+			$user_id = $mixed->user_id;
+		}
+		else {
+			$user_id = array(0=>$mixed->user_id);
+		}
+		
+		$validParameters = array(
+			"(getUsers_soap)",
+		);
+		
+		try {
+			$args = func_get_args();
+			$this->_checkArguments($args, $validParameters);
+		}
+		catch (Exception $e) {
+			// Invalid parameters => return a soap fault
+			return new SoapFault($e->getCode(),$e->getMessage());
+		}
+		
+		$users =& user_get_objects($user_id);
+		$this->logger->debug("users found : ".var_export($users, true));
+		if (!$users) {
+			return new SoapFault('3001','Could Not Get Users By Id');
+		}		
+		
+		$response = new getUsersResponse_soap();
+		for ($i=0; $i<count($users); $i++) {
+			if ($users[$i]->isError()){
+				//skip it if it had an error
+			} else {
+				//build each user_soap response
+				$user = new user_soap();
+				$user->user_id=$users[$i]->data_array['user_id'];
+				$user->user_name=$users[$i]->data_array['user_name'];
+				$user->title=$users[$i]->data_array['title'];
+				$user->firstname=$users[$i]->data_array['firstname'];
+				$user->lastname=$users[$i]->data_array['lastname'];
+				$user->address=$users[$i]->data_array['address'];
+				$user->address2=$users[$i]->data_array['address2'];
+				$user->phone=$users[$i]->data_array['phone'];
+				$user->fax=$users[$i]->data_array['fax'];
+				$user->status=$users[$i]->data_array['status'];
+				$user->timezone=$users[$i]->data_array['timezone'];
+				$user->country_code=$users[$i]->data_array['country_code'];
+				$user->add_date=$users[$i]->data_array['add_date'];
+				$user->language_id=$users[$i]->data_array['language_id'];
+				$response->user[$i]=$user;
+			}
+		}		
+		return $response;
+	}
+
+
+	/**
+	 * Service Call: getGroupsByName
+	 * 
+	 * @param mixed	getGroupsByName_soap (Soap request object)
+	 * @return getGroupsByNameResponse_soap (Soap response object) or SoapFault if parameters are invalid
+	 */
+	public function getGroupsByName($mixed = null) {
+		$this->logger->debug("Soap call getGroupsByName ".var_export($mixed, true));
+		// The $mixed->group_name is an array only if several group_name in the SOAP request
+		if (is_array($mixed->group_name)) {
+			$group_names = $mixed->group_name;
+		}
+		else {
+			$group_names = array(0=>$mixed->group_name);
+		}
+		
+		$validParameters = array(
+			"(getGroupsByName_soap)",
+		);
+		
+		try {
+			$args = func_get_args();
+			$this->_checkArguments($args, $validParameters);
+		}
+		catch (Exception $e) {
+			// Invalid parameters => return a soap fault
+			return new SoapFault($e->getCode(),$e->getMessage());
+		}	
+		$grps =& group_get_objects_by_name($group_names);
+		if (!$grps) {
+			return new SoapFault('2002','Could Not Get Groups by Name');
+		}
+		
+		$response = new getGroupsByNameResponse_soap();
+		// $grps contains an array of Group object
+		for ($i=0; $i<count($grps); $i++) {
+			if ($grps[$i]->isError()) {
+				//skip it if it had an error
+			} else {
+				//build each group_soap response
+				$group = new group_soap();
+				$group->group_id=$grps[$i]->data_array['group_id'];
+				$group->group_name=$grps[$i]->data_array['group_name'];
+				$group->homepage=$grps[$i]->data_array['homepage'];
+				$group->is_public=$grps[$i]->data_array['is_public'];
+				$group->status=$grps[$i]->data_array['status'];
+				$group->unix_group_name=$grps[$i]->data_array['unix_group_name'];
+				$group->short_description=$grps[$i]->data_array['short_description'];
+				$group->scm_box=$grps[$i]->data_array['scm_box'];
+				$group->register_time=$grps[$i]->data_array['register_time'];
+				$response->group[$i] = $group;
+			}
+		}
+
+		$this->logger->debug("getGroupsByNameResponse_soap : ".var_export($response, true));
+		return $response;
+	}
+
+
+	/**
+	 * Service Call: getPublicProjectNames
+	 * 
+	 * @param mixed	getPublicProjectNames_soap (Soap request object)
+	 * @return getPublicProjectNamesResponse_soap (Soap response object) or SoapFault if parameters are invalid
+	 */
+	public function getPublicProjectNames($mixed = null) {
+		$this->logger->debug("Soap call getPublicProjectNames");
+		$validParameters = array(
+			"(getPublicProjectNames_soap)",
+		);
+
+		try {
+			$args = func_get_args();
+			$this->_checkArguments($args, $validParameters);
+		}
+		catch (Exception $e) {
+			// Invalid parameters => return a soap fault
+			return new SoapFault($e->getCode(),$e->getMessage());
+		}		
+		// SOAP Response 
+		$response = new getPublicProjectNamesResponse_soap();
+		$forge = new FusionForge();
+		$response->project_name = $forge->getPublicProjectNames();
+
+		if ($forge->isError()) {
+			$errMsg = 'Could Not Get Public Group Names: '.$forge->getErrorMessage();
+			return new SoapFault('2003',$errMsg);
+		}
+		$this->logger->debug("Public Projects number found : ".var_export($response->project_name, true));
+		return $response;
+	}
+
+
+	/**
+	 * Service Call: getUsersByName
+	 * 
+	 * @param mixed	getUsersByName_soap (Soap request object)
+	 * @return getUsersByNameResponse_soap (Soap response object) or SoapFault if parameters are invalid
+	 */
+	public function getUsersByName($mixed = null) {
+		$this->logger->debug("CoreApiService Soap call getUsersByName ".var_export($mixed, true));
+		// The $mixed->group_name is an array only if several group_name in the SOAP request
+		if (is_array($mixed->user_name)) {
+			$user_names = $mixed->user_name;
+		}
+		else {
+			$user_names = array(0=>$mixed->user_name);
+		}
+		
+		$validParameters = array(
+			"(getUsersByName_soap)",
+		);
+		try {
+			$args = func_get_args();
+			$this->_checkArguments($args, $validParameters);
+		}
+		catch (Exception $e) {
+			// Invalid parameters => return a soap fault
+			return new SoapFault($e->getCode(),$e->getMessage());
+		}		
+				
+		$users =& user_get_objects_by_name($user_names);
+		if (!$users) {
+			return new SoapFault('3002','Could Not Get Users By Name');
+		}		
+		
+		$response = new getUsersByNameResponse_soap();
+		for ($i=0; $i<count($users); $i++) {
+			if ($users[$i]->isError()){
+				//skip it if it had an error
+			} else {
+				//build each user_soap response
+				$user = new user_soap();
+				$user->user_id=$users[$i]->data_array['user_id'];
+				$user->user_name=$users[$i]->data_array['user_name'];
+				$user->title=$users[$i]->data_array['title'];
+				$user->firstname=$users[$i]->data_array['firstname'];
+				$user->lastname=$users[$i]->data_array['lastname'];
+				$user->address=$users[$i]->data_array['address'];
+				$user->address2=$users[$i]->data_array['address2'];
+				$user->phone=$users[$i]->data_array['phone'];
+				$user->fax=$users[$i]->data_array['fax'];
+				$user->status=$users[$i]->data_array['status'];
+				$user->timezone=$users[$i]->data_array['timezone'];
+				$user->country_code=$users[$i]->data_array['country_code'];
+				$user->add_date=$users[$i]->data_array['add_date'];
+				$user->language_id=$users[$i]->data_array['language_id'];
+				$response->user[$i]=$user;
+			}
+		}		
+		return $response;
+	}
+
+
+	/**
+	 * Service Call: userGetGroups
+	 * 
+	 * @param mixed	userGetGroups_soap (Soap request object)
+	 * @return userGetGroupsResponse_soap (Soap response object) or SoapFault if parameters are invalid
+	 */
+	public function userGetGroups($mixed = null) {
+		
+		$this->logger->debug("CoreApiService Soap call : userGetGroups for user_id ".var_export($mixed, true));
+		$user_id = $mixed->user_id;
+		
+		$validParameters = array(
+			"(userGetGroups_soap)",
+		);
+		try {
+			$args = func_get_args();
+			$this->_checkArguments($args, $validParameters);
+		}
+		catch (Exception $e) {
+			// Invalid parameters => return a soap fault
+			return new SoapFault($e->getCode(),$e->getMessage());
+		}		
+				
+		$user =& user_get_object($user_id);
+		if (!$user) {
+			return new SoapFault('3003','Could Not Get Users Groups');
+		}
+
+		// $grps contains an array of Group object
+		$grps = $user->getGroups();
+		$this->logger->debug(count($grps). " groups found");
+		$response = new userGetGroupsResponse_soap();
+		
+		for ($i=0; $i<count($grps); $i++) {
+			if ($grps[$i]->isError()) {
+				//skip it if it had an error
+			} else {
+				//build each group_soap response
+				$group = new group_soap();
+				$group->group_id=$grps[$i]->data_array['group_id'];
+				$group->group_name=$grps[$i]->data_array['group_name'];
+				$group->homepage=$grps[$i]->data_array['homepage'];
+				$group->is_public=$grps[$i]->data_array['is_public'];
+				$group->status=$grps[$i]->data_array['status'];
+				$group->unix_group_name=$grps[$i]->data_array['unix_group_name'];
+				$group->short_description=$grps[$i]->data_array['short_description'];
+				$group->scm_box=$grps[$i]->data_array['scm_box'];
+				$group->register_time=$grps[$i]->data_array['register_time'];
+				$response->group[$i] = $group;
+				$this->logger->debug("adding group : ".var_export($group, true));
+			}
+		}
+				
+		$this->logger->debug("userGetGroupsResponse_soap : ".var_export($response, true));
+		
+		return $response;
+
+	}
+
+
+	/**
+	 * Service Call: getSCMData
+	 * 
+	 * @param mixed	getSCMData_soap (Soap request object)
+	 * @return getSCMDataResponse_soap (Soap response object) or SoapFault if parameters are invalid
+	 */
+	public function getSCMData($mixed = null) {
+		$group_id = $mixed->group_id;
+		$this->logger->debug("Soap call : getSCMData for group_id ".$group_id);
+		$validParameters = array(
+			"(getSCMData_soap)",
+		);
+		try {
+			$args = func_get_args();
+			$this->_checkArguments($args, $validParameters);
+		}
+		catch (Exception $e) {
+			// Invalid parameters => return a soap fault
+			return new SoapFault($e->getCode(),$e->getMessage());
+		}				
+		// Search the group object in the database
+		$grp =& group_get_object($group_id);
+		$this->logger->debug("group_get_object : ".var_export($grp, true));
+
+		// Error handle
+		if (!$grp || !is_object($grp)) {
+			$this->logger->error("Returning SOAP Fault - Could Not Get Group : ".$group_id);
+			// TODO : Error code to be determined
+			return new SoapFault('-1', 'Could Not Get Group');
+		} elseif ($grp->isError()) {
+			$this->logger->error($grp->getErrorMessage()." for group_id : ".$group_id);
+			// TODO : Error code to be determined
+			return new SoapFault ('-1',$grp->getErrorMessage());
+		}
+		if (!$grp->usesSCM()) {
+			$this->logger->error('SCM is not enabled in this project ; group_id : '.$group_id);
+			// TODO : Error code to be determined
+			return new SoapFault ('-1','SCM is not enabled in this project');
+		}		
+		
+		// Create the SOAP response
+		$response = new getSCMDataResponse_soap();
+		$scm_data = new scmData_soap();
+		
+		if ($grp->usesPlugin("scmcvs")) {
+			$scm_data->type = "CVS";
+			$scm_data->allow_anonymous = $grp->enableAnonSCM();
+			$scm_data->public = $grp->enablePserver();
+			$scm_data->box = $grp->getSCMBox();
+			$scm_data->module = $grp->getUnixName();
+			$scm_data->connection_string = "";	// this doesn't apply to CVS
+			// Note: This was taken from CVS plugin. Maybe we shouldn't hardcode this?
+			$scm_data->root = "/cvsroot/".$grp->getUnixName();
+		} else if ($grp->usesPlugin("scmsvn")) {
+			$scm_data->type = "SVN";
+			$scm_data->allow_anonymous = $grp->enableAnonSCM();
+			$scm_data->public = $grp->enablePserver();
+			$scm_data->box = $grp->getSCMBox();
+			$scm_data->root = $GLOBALS["svn_root"]."/".$grp->getUnixName();
+			$scm_data->module = "";		// doesn't apply to SVN
+			
+			// Note: This is an ugly hack. We can't access SVN plugin object for this project
+			// directly. Currently this is being rewritten, but for now we must make this.
+			
+			//TODO How to have access to $gfconfig variable ??
+			
+			include $gfconfig.'plugins/scmsvn/config.php';
+			$scm_data->connection_string = "http".(($use_ssl) ? "s" : "")."://".$grp->getSCMBox()."/".$svn_root."/".$grp->getUnixName();
+		}
+			
+		$response->scm_data= $scm_data;
+		return $response;
+	}
+	
+}
+
+?>
\ No newline at end of file




More information about the Fusionforge-commits mailing list