[Fusionforge-commits] r10655 - in trunk/plugins/coclico: . oslc oslc/bin oslc/common oslc/cronjobs oslc/db oslc/debian oslc/debian/dsf-in oslc/debian/po oslc/debian/source oslc/etc oslc/etc/httpd.d oslc/etc/plugins oslc/etc/plugins/oslc oslc/include oslc/include/oslc-zend oslc/include/oslc-zend/application oslc/include/oslc-zend/application/configs oslc/include/oslc-zend/application/controllers oslc/include/oslc-zend/application/exceptions oslc/include/oslc-zend/application/models oslc/include/oslc-zend/application/views oslc/include/oslc-zend/application/views/scripts oslc/include/oslc-zend/application/views/scripts/cm oslc/include/oslc-zend/application/views/scripts/error oslc/packaging oslc/packaging/control oslc/packaging/dirs oslc/packaging/docs oslc/packaging/install oslc/packaging/links oslc/translations oslc/utils oslc/www oslc/www/admin

Sabri LABBENE labbenes at libremir.placard.fr.eu.org
Thu Sep 23 17:38:51 CEST 2010


Author: labbenes
Date: 2010-09-23 17:38:51 +0200 (Thu, 23 Sep 2010)
New Revision: 10655

Added:
   trunk/plugins/coclico/oslc/
   trunk/plugins/coclico/oslc/bin/
   trunk/plugins/coclico/oslc/bin/db-delete.pl
   trunk/plugins/coclico/oslc/bin/db-upgrade.pl
   trunk/plugins/coclico/oslc/bin/sayhello
   trunk/plugins/coclico/oslc/common/
   trunk/plugins/coclico/oslc/common/oslc-init.php
   trunk/plugins/coclico/oslc/cronjobs/
   trunk/plugins/coclico/oslc/cronjobs/manage_oslc.php
   trunk/plugins/coclico/oslc/db/
   trunk/plugins/coclico/oslc/db/oslc-init.sql
   trunk/plugins/coclico/oslc/debian/
   trunk/plugins/coclico/oslc/debian/README.Debian
   trunk/plugins/coclico/oslc/debian/README.source
   trunk/plugins/coclico/oslc/debian/changelog
   trunk/plugins/coclico/oslc/debian/compat
   trunk/plugins/coclico/oslc/debian/control
   trunk/plugins/coclico/oslc/debian/copyright
   trunk/plugins/coclico/oslc/debian/docs
   trunk/plugins/coclico/oslc/debian/dsf-in/
   trunk/plugins/coclico/oslc/debian/dsf-in/plugin-oslc.postinst
   trunk/plugins/coclico/oslc/debian/dsf-in/plugin-oslc.prerm
   trunk/plugins/coclico/oslc/debian/po/
   trunk/plugins/coclico/oslc/debian/po/templates.pot
   trunk/plugins/coclico/oslc/debian/rules
   trunk/plugins/coclico/oslc/debian/source/
   trunk/plugins/coclico/oslc/debian/source/format
   trunk/plugins/coclico/oslc/etc/
   trunk/plugins/coclico/oslc/etc/httpd.d/
   trunk/plugins/coclico/oslc/etc/httpd.d/62plugin-oslc
   trunk/plugins/coclico/oslc/etc/plugins/
   trunk/plugins/coclico/oslc/etc/plugins/oslc/
   trunk/plugins/coclico/oslc/etc/plugins/oslc/config.php
   trunk/plugins/coclico/oslc/include/
   trunk/plugins/coclico/oslc/include/oslc-zend/
   trunk/plugins/coclico/oslc/include/oslc-zend/application/
   trunk/plugins/coclico/oslc/include/oslc-zend/application/Bootstrap.php
   trunk/plugins/coclico/oslc/include/oslc-zend/application/basic-pwd.txt
   trunk/plugins/coclico/oslc/include/oslc-zend/application/configs/
   trunk/plugins/coclico/oslc/include/oslc-zend/application/configs/application.ini
   trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/
   trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/CmController.php
   trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/ErrorController.php
   trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/FusionForgeCmController.php
   trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/FusionForgeOSLCConnector.php
   trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/MantisCmController.php
   trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/MantisOSLCConnector.php
   trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/OSLCConnector.php
   trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/cql-lime_parser.inc.php
   trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/cql.lime
   trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/cql.php
   trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/lime-parse_engine.php
   trunk/plugins/coclico/oslc/include/oslc-zend/application/exceptions/
   trunk/plugins/coclico/oslc/include/oslc-zend/application/exceptions/oslcException.php
   trunk/plugins/coclico/oslc/include/oslc-zend/application/models/
   trunk/plugins/coclico/oslc/include/oslc-zend/application/models/ChangeRequests.php
   trunk/plugins/coclico/oslc/include/oslc-zend/application/models/fusionforge.inc.php
   trunk/plugins/coclico/oslc/include/oslc-zend/application/models/mantis.inc.php
   trunk/plugins/coclico/oslc/include/oslc-zend/application/test.csv
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/_resource_xml.php
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/_service-catalog_xml.php
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/_service-document_xml.php
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/get.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/index.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/oslc-cm-service-document.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/oslc-cm-service-document.xml.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/oslc-service-catalog.json.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/oslc-service-catalog.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/oslc-service-catalog.xml.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/post.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/put.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/put.xml.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote-collection.json.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote-collection.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote-collection.xml.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote.json.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote.xml.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource-collection.json.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource-collection.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource-collection.xml.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource.json.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource.xml.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/show-selection-ui.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/_error_resource.php
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/default.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/error.json.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/error.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/error.xml.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/res-not-found.phtml
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/fusionforgecm
   trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/mantiscm
   trunk/plugins/coclico/oslc/include/oslcPlugin.class.php
   trunk/plugins/coclico/oslc/packaging/
   trunk/plugins/coclico/oslc/packaging/control/
   trunk/plugins/coclico/oslc/packaging/control/000source
   trunk/plugins/coclico/oslc/packaging/control/222plugin-oslc
   trunk/plugins/coclico/oslc/packaging/control/222plugin-oslc.shortdesc
   trunk/plugins/coclico/oslc/packaging/dirs/
   trunk/plugins/coclico/oslc/packaging/dirs/plugin-oslc
   trunk/plugins/coclico/oslc/packaging/docs/
   trunk/plugins/coclico/oslc/packaging/docs/plugin-oslc
   trunk/plugins/coclico/oslc/packaging/install/
   trunk/plugins/coclico/oslc/packaging/install/plugin-oslc
   trunk/plugins/coclico/oslc/packaging/links/
   trunk/plugins/coclico/oslc/packaging/links/plugin-oslc
   trunk/plugins/coclico/oslc/translations/
   trunk/plugins/coclico/oslc/translations/en.po
   trunk/plugins/coclico/oslc/translations/gforge.pot
   trunk/plugins/coclico/oslc/utils/
   trunk/plugins/coclico/oslc/utils/manage-translations.sh
   trunk/plugins/coclico/oslc/www/
   trunk/plugins/coclico/oslc/www/.htaccess
   trunk/plugins/coclico/oslc/www/admin/
   trunk/plugins/coclico/oslc/www/admin/index.php
   trunk/plugins/coclico/oslc/www/index.php
Log:
First bits of an OSLC REST server plugin for fusionforge.
It implements the Change Management domain os OSLC V2 and can be extended to other domains.

Added: trunk/plugins/coclico/oslc/bin/db-delete.pl
===================================================================
--- trunk/plugins/coclico/oslc/bin/db-delete.pl	                        (rev 0)
+++ trunk/plugins/coclico/oslc/bin/db-delete.pl	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,187 @@
+#!/usr/bin/perl -w
+#
+# Debian-specific script to delete plugin-specific tables
+# Roland Mas <lolando at debian.org>
+
+use strict ;
+use diagnostics ;
+
+use DBI ;
+use MIME::Base64 ;
+use HTML::Entities ;
+
+use vars qw/$dbh @reqlist $query/ ;
+use vars qw/$sys_default_domain $sys_cvs_host $sys_download_host
+    $sys_shell_host $sys_users_host $sys_docs_host $sys_lists_host
+    $sys_dns1_host $sys_dns2_host $FTPINCOMING_DIR $FTPFILES_DIR
+    $sys_urlroot $sf_cache_dir $sys_name $sys_themeroot
+    $sys_news_group $sys_dbhost $sys_dbname $sys_dbuser $sys_dbpasswd
+    $sys_ldap_base_dn $sys_ldap_host $admin_login $admin_password
+    $server_admin $domain_name $newsadmin_groupid $statsadmin_groupid
+    $skill_list/ ;
+use vars qw/$pluginname/ ;
+
+sub is_lesser ( $$ ) ;
+sub is_greater ( $$ ) ;
+sub debug ( $ ) ;
+sub parse_sql_file ( $ ) ;
+
+require ("/usr/share/gforge/lib/include.pl") ; # Include a few predefined functions 
+require ("/usr/share/gforge/lib/sqlparser.pm") ; # Our magic SQL parser
+
+debug "You'll see some debugging info during this installation." ;
+debug "Do not worry unless told otherwise." ;
+
+&db_connect ;
+
+# debug "Connected to the database OK." ;
+
+$pluginname = "oslc" ;
+
+$dbh->{AutoCommit} = 0;
+$dbh->{RaiseError} = 1;
+eval {
+    my ($sth, @array, $version, $action, $path, $target, $rname) ;
+
+    my $pattern = "plugin_" . $pluginname . '_%' ;
+
+    $query = "SELECT relname FROM pg_class WHERE relname LIKE '$pattern' AND relkind='v'" ;
+    $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    while (@array = $sth->fetchrow_array ()) {
+	$rname = $array [0] ;
+	&drop_view_if_exists ($rname) ;
+    }
+    $sth->finish () ;
+
+    $query = "SELECT relname FROM pg_class WHERE relname LIKE '$pattern' AND relkind='r'" ;
+    $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    while (@array = $sth->fetchrow_array ()) {
+	$rname = $array [0] ;
+	&drop_table_if_exists ($rname) ;
+    }
+    $sth->finish () ;
+
+    $query = "SELECT relname FROM pg_class WHERE relname LIKE '$pattern' AND relkind='i'" ;
+    $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    while (@array = $sth->fetchrow_array ()) {
+	$rname = $array [0] ;
+	&drop_index_if_exists ($rname) ;
+    }
+    $sth->finish () ;
+
+    $query = "SELECT relname FROM pg_class WHERE relname LIKE '$pattern' AND relkind='s'" ;
+    $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    while (@array = $sth->fetchrow_array ()) {
+	$rname = $array [0] ;
+	&drop_sequence_if_exists ($rname) ;
+    }
+    $sth->finish () ;
+
+    $dbh->commit ();
+
+
+    debug "It seems your database deletion went well and smoothly.  That's cool." ;
+    debug "Please enjoy using Debian FusionForge." ;
+
+    # There should be a commit at the end of every block above.
+    # If there is not, then it might be symptomatic of a problem.
+    # For safety, we roll back.
+    $dbh->rollback ();
+};
+
+if ($@) {
+    warn "Transaction aborted because $@" ;
+    debug "Transaction aborted because $@" ;
+    debug "Last SQL query was:\n$query\n(end of query)" ;
+    $dbh->rollback ;
+    debug "Please report this bug on the Debian bug-tracking system." ;
+    debug "Please include the previous messages as well to help debugging." ;
+    debug "You should not worry too much about this," ;
+    debug "your DB is still in a consistent state and should be usable." ;
+    exit 1 ;
+}
+
+$dbh->rollback ;
+$dbh->disconnect ;
+
+sub debug ( $ ) {
+    my $v = shift ;
+    chomp $v ;
+    print STDERR "$v\n" ;
+}
+
+sub drop_table_if_exists ( $ ) {
+    my $tname = shift or die  "Not enough arguments" ;
+    $query = "SELECT count(*) FROM pg_class WHERE relname='$tname' AND relkind='r'" ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    my @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    if ($array [0] != 0) {
+	# debug "Dropping table $tname" ;
+	$query = "DROP TABLE $tname" ;
+	# debug $query ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	$sth->finish () ;
+    }
+}
+
+sub drop_sequence_if_exists ( $ ) {
+    my $sname = shift or die  "Not enough arguments" ;
+    $query = "SELECT count(*) FROM pg_class WHERE relname='$sname' AND relkind='S'" ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    my @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    if ($array [0] != 0) {
+	# debug "Dropping sequence $sname" ;
+	$query = "DROP SEQUENCE $sname" ;
+	# debug $query ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	$sth->finish () ;
+    }
+}
+
+sub drop_index_if_exists ( $ ) {
+    my $iname = shift or die  "Not enough arguments" ;
+    $query = "SELECT count(*) FROM pg_class WHERE relname='$iname' AND relkind='i'" ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    my @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    if ($array [0] != 0) {
+	# debug "Dropping index $iname" ;
+	$query = "DROP INDEX $iname" ;
+	# debug $query ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	$sth->finish () ;
+    }
+}
+
+sub drop_view_if_exists ( $ ) {
+    my $iname = shift or die  "Not enough arguments" ;
+    $query = "SELECT count(*) FROM pg_class WHERE relname='$iname' AND relkind='v'" ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    my @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    if ($array [0] != 0) {
+	# debug "Dropping view $iname" ;
+	$query = "DROP VIEW $iname" ;
+	# debug $query ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	$sth->finish () ;
+    }
+}


Property changes on: trunk/plugins/coclico/oslc/bin/db-delete.pl
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/plugins/coclico/oslc/bin/db-upgrade.pl
===================================================================
--- trunk/plugins/coclico/oslc/bin/db-upgrade.pl	                        (rev 0)
+++ trunk/plugins/coclico/oslc/bin/db-upgrade.pl	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,301 @@
+#!/usr/bin/perl -w
+#
+# Debian-specific script to upgrade the database between releases
+# Roland Mas <lolando at debian.org>
+
+use strict ;
+use diagnostics ;
+
+use DBI ;
+use MIME::Base64 ;
+use HTML::Entities ;
+
+use vars qw/$dbh @reqlist $query/ ;
+use vars qw/$sys_default_domain $sys_cvs_host $sys_download_host
+    $sys_shell_host $sys_users_host $sys_docs_host $sys_lists_host
+    $sys_dns1_host $sys_dns2_host $FTPINCOMING_DIR $FTPFILES_DIR
+    $sys_urlroot $sf_cache_dir $sys_name $sys_themeroot
+    $sys_news_group $sys_dbhost $sys_dbname $sys_dbuser $sys_dbpasswd
+    $sys_ldap_base_dn $sys_ldap_host $admin_login $admin_password
+    $server_admin $domain_name $newsadmin_groupid $statsadmin_groupid
+    $skill_list/ ;
+use vars qw/$pluginname/ ;
+
+sub is_lesser ( $$ ) ;
+sub is_greater ( $$ ) ;
+sub debug ( $ ) ;
+sub parse_sql_file ( $ ) ;
+
+require ("/usr/share/gforge/lib/include.pl") ; # Include a few predefined functions 
+require ("/usr/share/gforge/lib/sqlparser.pm") ; # Our magic SQL parser
+
+debug "You'll see some debugging info during this installation." ;
+debug "Do not worry unless told otherwise." ;
+
+&db_connect ;
+
+# debug "Connected to the database OK." ;
+
+$pluginname = "oslc" ;
+
+$dbh->{AutoCommit} = 0;
+$dbh->{RaiseError} = 1;
+eval {
+    my ($sth, @array, $version, $path, $target) ;
+
+    &create_metadata_table ("0") ;
+    
+    $version = &get_db_version ;
+    $target = "0.1" ;
+    if (is_lesser $version, $target) {
+	my @filelist = ( "/usr/share/gforge/plugins/$pluginname/db/$pluginname-init.sql" ) ;
+	
+	foreach my $file (@filelist) {
+	    debug "Processing $file" ;
+	    @reqlist = @{ &parse_sql_file ($file) } ;
+	    
+	    foreach my $s (@reqlist) {
+		$query = $s ;
+		# debug $query ;
+		$sth = $dbh->prepare ($query) ;
+		$sth->execute () ;
+		$sth->finish () ;
+	    }
+	}
+	@reqlist = () ;
+	
+	&update_db_version ($target) ;
+	debug "Committing." ;
+	$dbh->commit () ;
+    }
+    
+#    $version = &get_db_version ;
+#    $target = "0.2" ;
+#    if (is_lesser $version, $target) {
+#	debug "Adding local data." ;
+#	
+#	do "/etc/gforge/local.pl" or die "Cannot read /etc/gforge/local.pl" ;
+#	
+#	my $ip_address = qx/host $domain_name | awk '{print \}'/ ;
+#	
+#	@reqlist = (
+#		    "INSERT INTO plugin_".$pluginname."_sample_data (domain, ip_address) VALUES ('$domain_name', '$ip_address')",
+#		    ) ;
+#	
+#	foreach my $s (@reqlist) {
+#	    $query = $s ;
+#	    # debug $query ;
+#	    $sth = $dbh->prepare ($query) ;
+#	    $sth->execute () ;
+#	    $sth->finish () ;
+#	}
+#	@reqlist = () ;
+#	
+#	&update_db_version ($target) ;
+#	debug "Committing." ;
+#	$dbh->commit () ;
+#    }
+
+    debug "It seems your database install/upgrade went well and smoothly.  That's cool." ;
+    debug "Please enjoy using Debian FusionForge." ;
+
+    # There should be a commit at the end of every block above.
+    # If there is not, then it might be symptomatic of a problem.
+    # For safety, we roll back.
+    $dbh->rollback ();
+};
+
+if ($@) {
+    warn "Transaction aborted because $@" ;
+    debug "Transaction aborted because $@" ;
+    debug "Last SQL query was:\n$query\n(end of query)" ;
+    $dbh->rollback ;
+    debug "Please report this bug on the Debian bug-tracking system." ;
+    debug "Please include the previous messages as well to help debugging." ;
+    debug "You should not worry too much about this," ;
+    debug "your DB is still in a consistent state and should be usable." ;
+    exit 1 ;
+}
+
+$dbh->rollback ;
+$dbh->disconnect ;
+
+sub is_lesser ( $$ ) {
+    my $v1 = shift || 0 ;
+    my $v2 = shift || 0 ;
+
+    my $rc = system "dpkg --compare-versions $v1 lt $v2" ;
+
+    return (! $rc) ;
+}
+
+sub is_greater ( $$ ) {
+    my $v1 = shift || 0 ;
+    my $v2 = shift || 0 ;
+
+    my $rc = system "dpkg --compare-versions $v1 gt $v2" ;
+
+    return (! $rc) ;
+}
+
+sub debug ( $ ) {
+    my $v = shift ;
+    chomp $v ;
+    print STDERR "$v\n" ;
+}
+
+sub create_metadata_table ( $ ) {
+    my $v = shift || "0" ;
+    my $tablename = "plugin_" .$pluginname . "_meta_data" ;
+    # Do we have the metadata table?
+
+    $query = "SELECT count(*) FROM pg_class WHERE relname = '$tablename' and relkind = 'r'";
+    # debug $query ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    my @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    # Let's create this table if we have it not
+
+    if ($array [0] == 0) {
+	debug "Creating $tablename table." ;
+	$query = "CREATE TABLE $tablename (key varchar primary key, value text not null)" ;
+	# debug $query ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	$sth->finish () ;
+    }
+
+    $query = "SELECT count(*) FROM $tablename WHERE key = 'db-version'";
+    # debug $query ;
+    $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    # Empty table?  We'll have to fill it up a bit
+
+    if ($array [0] == 0) {
+	debug "Inserting first data into $tablename table." ;
+	$query = "INSERT INTO $tablename (key, value) VALUES ('db-version', '$v')" ;
+	# debug $query ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	$sth->finish () ;
+    }
+}
+
+sub update_db_version ( $ ) {
+    my $v = shift or die "Not enough arguments" ;
+    my $tablename = "plugin_" .$pluginname . "_meta_data" ;
+
+    debug "Updating $tablename table." ;
+    $query = "UPDATE $tablename SET value = '$v' WHERE key = 'db-version'" ;
+    # debug $query ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    $sth->finish () ;
+}
+
+sub get_db_version () {
+    my $tablename = "plugin_" .$pluginname . "_meta_data" ;
+
+    $query = "SELECT value FROM $tablename WHERE key = 'db-version'" ;
+    # debug $query ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    my @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    my $version = $array [0] ;
+
+    return $version ;
+}
+
+sub drop_table_if_exists ( $ ) {
+    my $tname = shift or die  "Not enough arguments" ;
+    $query = "SELECT count(*) FROM pg_class WHERE relname='$tname' AND relkind='r'" ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    my @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    if ($array [0] != 0) {
+	# debug "Dropping table $tname" ;
+	$query = "DROP TABLE $tname" ;
+	# debug $query ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	$sth->finish () ;
+    }
+}
+
+sub drop_sequence_if_exists ( $ ) {
+    my $sname = shift or die  "Not enough arguments" ;
+    $query = "SELECT count(*) FROM pg_class WHERE relname='$sname' AND relkind='S'" ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    my @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    if ($array [0] != 0) {
+	# debug "Dropping sequence $sname" ;
+	$query = "DROP SEQUENCE $sname" ;
+	# debug $query ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	$sth->finish () ;
+    }
+}
+
+sub drop_index_if_exists ( $ ) {
+    my $iname = shift or die  "Not enough arguments" ;
+    $query = "SELECT count(*) FROM pg_class WHERE relname='$iname' AND relkind='i'" ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    my @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    if ($array [0] != 0) {
+	# debug "Dropping index $iname" ;
+	$query = "DROP INDEX $iname" ;
+	# debug $query ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	$sth->finish () ;
+    }
+}
+
+sub drop_view_if_exists ( $ ) {
+    my $iname = shift or die  "Not enough arguments" ;
+    $query = "SELECT count(*) FROM pg_class WHERE relname='$iname' AND relkind='v'" ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    my @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    if ($array [0] != 0) {
+	# debug "Dropping view $iname" ;
+	$query = "DROP VIEW $iname" ;
+	# debug $query ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	$sth->finish () ;
+    }
+}
+
+sub bump_sequence_to ( $$ ) {
+    my ($sth, @array, $seqname, $targetvalue) ;
+
+    $seqname = shift ;
+    $targetvalue = shift ;
+
+    do {
+	$query = "select nextval ('$seqname')" ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	@array = $sth->fetchrow_array () ;
+	$sth->finish () ;
+    } until $array[0] >= $targetvalue ;
+}


Property changes on: trunk/plugins/coclico/oslc/bin/db-upgrade.pl
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/plugins/coclico/oslc/bin/sayhello
===================================================================
--- trunk/plugins/coclico/oslc/bin/sayhello	                        (rev 0)
+++ trunk/plugins/coclico/oslc/bin/sayhello	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,9 @@
+#! /usr/bin/perl -w
+
+my $world ;
+
+do "/etc/gforge/plugins/oslc/world.conf"
+    or die "Cannot read /etc/gforge/plugins/oslc/world.conf" ;
+
+print STDOUT "Hello $world on STDOUT!\n" ;
+print STDERR "Hello $world on STDERR!\n" ;


Property changes on: trunk/plugins/coclico/oslc/bin/sayhello
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/plugins/coclico/oslc/common/oslc-init.php
===================================================================
--- trunk/plugins/coclico/oslc/common/oslc-init.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/common/oslc-init.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,34 @@
+<?php
+
+/**
+ *
+ * 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 License, 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+global $gfplugins;
+require_once $gfplugins.'oslc/include/oslcPlugin.class.php' ;
+
+$oslcPluginObject = new oslcPlugin ;
+
+register_plugin ($oslcPluginObject) ;
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>

Added: trunk/plugins/coclico/oslc/cronjobs/manage_oslc.php
===================================================================
--- trunk/plugins/coclico/oslc/cronjobs/manage_oslc.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/cronjobs/manage_oslc.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,70 @@
+#! /usr/bin/php -f
+<?php
+/**
+ * FusionForge source control management
+ *
+ * Copyright 2009, Roland Mas
+ *
+ * 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 License,
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+require 'env.inc.php';
+require_once $gfwww.'include/squal_pre.php';
+require_once $gfcommon.'include/cron_utils.php';
+
+// MailingList backend class
+/* This is only sample
+require_once $gfplugins.'oslc/include/BackendHelloworld.class.php' ;
+			 
+
+$res = db_query_params ('SELECT id,type, parameters FROM system_event WHERE status=$1 ORDER BY id DESC',
+			array ('1')); 
+if (!$res) {
+	printf('Unable to get list of events: '.db_error());
+	return false;
+}
+
+while ($data = db_fetch_array ($res)) {
+	if($data['type'] == 'HELLOWORLD_CREATE') {
+		$result = BackendHelloworld::instance()->createList($data['parameters']);
+	} elseif ($data['type'] == 'HELLOWORLD_DELETE') {
+		$result = BackendHelloworld::instance()->deleteList($data['parameters']);
+	}
+	$result ? $log="DONE":$test="ERROR";
+	$events[$data['id']]=$log;
+	echo "\n Event ".$data['id']." : ".$data['type']." ".$log." for list id=".$data['parameters'];
+}
+if(isset($events)) {
+	foreach($events as $event_id => $log) {
+		$sql = "UPDATE system_event SET end_date=$1, log=$2, status='3' WHERE id=$3;"; 
+		$result = db_query_params($sql,array(time(),$log,$event_id));
+		if (!$result) {
+			printf('Unable to update the list of events: '.db_error());
+			return false;
+		}
+	}
+
+}
+*/
+
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>

Added: trunk/plugins/coclico/oslc/db/oslc-init.sql
===================================================================
--- trunk/plugins/coclico/oslc/db/oslc-init.sql	                        (rev 0)
+++ trunk/plugins/coclico/oslc/db/oslc-init.sql	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,4 @@
+CREATE TABLE plugin_oslc_sample_data (
+	domain text,
+	ip_address text
+) ;

Added: trunk/plugins/coclico/oslc/debian/README.Debian
===================================================================
--- trunk/plugins/coclico/oslc/debian/README.Debian	                        (rev 0)
+++ trunk/plugins/coclico/oslc/debian/README.Debian	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,6 @@
+fusionforge-plugin-oslc for Debian
+---------------------
+
+See README.Debian in fusionforge-common package
+
+ -- Christian Bayle <bayle at debian.org>  Mon, 08 Mar 2010 16:37:51 +0100

Added: trunk/plugins/coclico/oslc/debian/README.source
===================================================================
--- trunk/plugins/coclico/oslc/debian/README.source	                        (rev 0)
+++ trunk/plugins/coclico/oslc/debian/README.source	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,9 @@
+oslc for Debian
+---------------------
+
+<this file describes information about the source package, see Debian policy
+manual section 4.14. You WILL either need to modify or delete this file>
+
+
+
+

Added: trunk/plugins/coclico/oslc/debian/changelog
===================================================================
--- trunk/plugins/coclico/oslc/debian/changelog	                        (rev 0)
+++ trunk/plugins/coclico/oslc/debian/changelog	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,5 @@
+fusionforge-plugin-oslc (1.0-1) unstable; urgency=low
+
+  * Initial release (Closes: #nnnn)  <nnnn is the bug number of your ITP>
+
+ -- Christian Bayle <bayle at debian.org>  Mon, 08 Mar 2010 16:37:51 +0100

Added: trunk/plugins/coclico/oslc/debian/compat
===================================================================
--- trunk/plugins/coclico/oslc/debian/compat	                        (rev 0)
+++ trunk/plugins/coclico/oslc/debian/compat	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1 @@
+7

Added: trunk/plugins/coclico/oslc/debian/control
===================================================================
--- trunk/plugins/coclico/oslc/debian/control	                        (rev 0)
+++ trunk/plugins/coclico/oslc/debian/control	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,20 @@
+Source: fusionforge-plugin-oslc
+Section: devel
+Priority: optional
+Maintainer: Christian Bayle <bayle at debian.org>
+Uploaders: Roland Mas <lolando at debian.org>
+Build-Depends-Indep: devscripts
+Build-Depends: debhelper (>= 7), perl, gettext
+Standards-Version: 3.8.4
+Homepage: http://fusionforge.org/
+Vcs-Bzr: http://scm.fusionforge.org/bzr/fusionforge/svn-trunk-ro/
+
+Package: fusionforge-plugin-oslc
+Architecture: all
+Depends: gforge-common, gforge-db-postgresql | gforge-db, gforge-web-apache2 | gforge-web, gforge-shell-postgresql | gforge-shell, php5-cli, ${misc:Depends}
+Description: collaborative development tool - oslc plugin
+ .
+ This plugin contains the oslc subsystem of FusionForge. It allows each
+ FusionForge project to have its own oslc, and gives some
+ control over it to the project's administrator.
+

Added: trunk/plugins/coclico/oslc/debian/copyright
===================================================================
--- trunk/plugins/coclico/oslc/debian/copyright	                        (rev 0)
+++ trunk/plugins/coclico/oslc/debian/copyright	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,63 @@
+The "sourceforge" package was first debianised on Wed, 22 Nov 2000
+22:06:35 +0100 by Roland Mas <lolando at debian.org>.  Work has been
+constant since then, and the package evolved a great deal.  It began
+to work, for a start, and then it evolved into GForge, what with the
+more recent versions of the Sourceforge software having been made
+proprietary.  And then in early 2009 it evolved into FusionForge, what
+with the more recent versions of GForge having been rewritten as
+proprietary software without a name change.
+
+FusionForge is Copyright © 2009-2010 by several people, including:
+Alain Peyrat            <aljeux at free.fr>
+Alexandre Neymann       <alexandre.neymann at dgfip.finances.gouv.fr>
+Christian Bayle         <bayle at debian.org>
+Roland Mas              <lolando at debian.org>
+Gonéri Le Bouder        <goneri.lebouder at atosorigin.com>
+Julien Heyman 		<julien.heyman at atosorigin.com>
+Olivier Meunier 	<olivier.meunier at centraliens.net>
+
+GForge itself is Copyright © 2000-2008 by a fair number of people,
+including:
+Tim Perdue              <tim at gforge.org>
+Roland Mas              <99.roland.mas at aist.enst.fr>
+Christian Bayle         <gforge at free.fr>
+Tom Copeland            <tom at infoether.com>
+Guillaume Smet          <guillaume-gforge at smet.org>
+Francisco Gimeno        <kikov at kikov.org>
+Sung Kim                <hunkims at gmail.com>
+Alain Peyrat            <aljeux at free.fr>
+
+Past Members of the development team include:
+Reinhard Spisser
+Ryan T. Sammartino
+Edward Ritter
+Michael Jennings
+
+Since FusionForge, and GForge before it, was initially a fork of
+Sourceforge, here's the copyright info for the Sourceforge software:
+,----
+| The original sources were downloaded from http://www.sourceforge.net/
+| 
+| Authors: The Sourceforge crew at VA Linux.  They are many, they
+| change as time goes by, and they are listed on the Sourceforge
+| website.  Let them be thanked for their work.
+| 
+| Copyright:
+| 
+| This software is Copyright © 1999-2000 by VA Linux.
+| 
+| You are free to distribute this software under the terms of the GNU
+| General Public License.
+`----
+
+The packaging and installing scripts (in the debian/ and deb-specific/
+directories amongst others) are Copyright © 2000-2010 by Christian
+Bayle <bayle at aist.enst.fr> and Roland Mas <lolando at debian.org>.  You
+are free to use and redistribute them under the terms of the GNU
+General Public License, version 2 or (at your option) any later
+version published by the Free Software Foundation.
+
+See Also Copyright file in fusionforge package
+
+On Debian systems, the complete text of the GNU General Public License
+can be found in the /usr/share/common-licenses directory.

Added: trunk/plugins/coclico/oslc/debian/dsf-in/plugin-oslc.postinst
===================================================================
--- trunk/plugins/coclico/oslc/debian/dsf-in/plugin-oslc.postinst	                        (rev 0)
+++ trunk/plugins/coclico/oslc/debian/dsf-in/plugin-oslc.postinst	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,52 @@
+#! /bin/sh
+# postinst script for @OLDPACKAGE at -plugin-oslc
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+#
+# quoting from the policy:
+#     Any necessary prompting should almost always be confined to the
+#     post-installation script, and should be protected with a conditional
+#     so that unnecessary prompting doesn't happen if a package's
+#     installation fails and the `postinst' is called with `abort-upgrade',
+#     `abort-remove' or `abort-deconfigure'.
+
+case "$1" in
+    configure)
+	@OLDPACKAGE at -config
+
+	# Prepare database
+	su -s /bin/sh @OLDPACKAGE@ -c '/usr/share/@OLDPACKAGE@/bin/register-plugin oslc "oslc"'
+	su -s /bin/sh @OLDPACKAGE@ -c '/usr/share/@OLDPACKAGE@/plugins/oslc/bin/db-upgrade.pl'
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+

Added: trunk/plugins/coclico/oslc/debian/dsf-in/plugin-oslc.prerm
===================================================================
--- trunk/plugins/coclico/oslc/debian/dsf-in/plugin-oslc.prerm	                        (rev 0)
+++ trunk/plugins/coclico/oslc/debian/dsf-in/plugin-oslc.prerm	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,45 @@
+#! /bin/sh
+# prerm script for @OLDPACKAGE at -plugin-oslc
+#
+# see: dh_installdeb(1)
+set -e
+
+#DEBHELPER#
+
+# summary of how this script can be called:
+#        * <prerm> `remove'
+#        * <old-prerm> `upgrade' <new-version>
+#        * <new-prerm> `failed-upgrade' <old-version>
+#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
+#        * <deconfigured's-prerm> `deconfigure' `in-favour'
+#          <package-being-installed> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    remove|deconfigure)
+	if [ -f /var/run/postgresql/.s.PGSQL.5432 ]
+	then
+		/usr/share/@OLDPACKAGE@/bin/unregister-plugin oslc
+	else
+		echo "WARNING: database not available to unregister oslc plugin"
+	fi
+        ;;
+    upgrade|failed-upgrade)
+        ;;
+    *)
+        echo "prerm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+
+
+exit 0
+
+

Added: trunk/plugins/coclico/oslc/debian/rules
===================================================================
--- trunk/plugins/coclico/oslc/debian/rules	                        (rev 0)
+++ trunk/plugins/coclico/oslc/debian/rules	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,85 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+SRCPACKAGE=$(shell head -1 $(CURDIR)/debian/changelog | sed 's/\(.[^ ]*\) .*/\1/')
+MAJOR=$(shell head -1 $(CURDIR)/debian/changelog | sed 's/.*(\(.*\)-[^-]*).*/\1/')
+ORIGFILE=$(SRCPACKAGE)_$(MAJOR).orig.tar.gz
+OLDPACKAGE=gforge
+PACKAGE=fusionforge
+FORGENAME=FusionForge
+
+SED_REPLACE=sed -e 's/@PACKAGE@/$(PACKAGE)/g' -e 's/@SRCPACKAGE@/$(SRCPACKAGE)/g' -e 's/@FORGENAME@/$(FORGENAME)/g' -e 's/@OLDPACKAGE@/$(OLDPACKAGE)/g'
+
+CRONDFILES=$(patsubst packaging/cron.d/%,debian/$(PACKAGE)-%.cron.d,$(wildcard packaging/cron.d/[a-z]*))
+DIRSFILES=$(patsubst packaging/dirs/%,debian/$(PACKAGE)-%.dirs,$(wildcard packaging/dirs/[a-z]*))
+LINKSFILES=$(patsubst packaging/links/%,debian/$(PACKAGE)-%.links,$(wildcard packaging/links/[a-z]*))
+INSTALLFILES=$(patsubst packaging/install/%,debian/$(PACKAGE)-%.install,$(wildcard packaging/install/[a-z]*))
+DOCSFILES=$(patsubst packaging/docs/%,debian/$(PACKAGE)-%.docs,$(wildcard packaging/docs/[a-z]*))
+POFILES=$(patsubst debian/dsf-po/%,debian/po/%,$(wildcard debian/dsf-po/*) debian/po/POTFILES.in)
+DSFINFILES=$(patsubst debian/dsf-in/%,debian/$(PACKAGE)-%,$(wildcard debian/dsf-in/[a-z]*))
+
+.PHONY: conffiles
+conffiles: $(CRONDFILES) $(DIRSFILES) $(LINKSFILES) $(INSTALLFILES) $(DOCSFILES) $(DSFINFILES) debian/control
+
+debian/$(PACKAGE)-%.cron.d:
+	(cat $(CURDIR)/packaging/cron.d/00phpcron ; sed -e 's/\$$FFUSER/$(PACKAGE)/g' $(CURDIR)/packaging/cron.d/$*) > $@
+
+debian/$(PACKAGE)-%.dirs:
+	cp $(CURDIR)/packaging/dirs/$* $@ 
+
+debian/$(PACKAGE)-%.links:
+	cp $(CURDIR)/packaging/links/$* $@ 
+
+debian/$(PACKAGE)-%.install:
+	cp $(CURDIR)/packaging/install/$* $@ 
+
+debian/$(PACKAGE)-%.docs:
+	cp $(CURDIR)/packaging/docs/$* $@
+
+debian/control: $(wildcard packaging/control/*)
+	ls $(CURDIR)/packaging/control/[0-9][0-9][0-9]* | grep -v shortdesc | grep -v scmcpold | while read file ; do cat $${file}; if [ -f $${file}.shortdesc ] ; then cat $(CURDIR)/packaging/control/AAAdesc; echo ' .'; cat $${file}.shortdesc; fi; echo '';  done | $(SED_REPLACE) > $@
+
+debian/po/templates.pot: $(wildcard debian/dsf-in/*.templates.dsfh-in) $(wildcard debian/dsf-helper/*.templates)
+        @debconf-updatepo --podir=debian/dsf-po
+
+debian/po/%:
+	cat $(patsubst debian/po/%,debian/dsf-po/%,$@) | $(SED_REPLACE) > $@
+
+# postinst and prerm files
+debian/$(PACKAGE)-%:
+	cat $(patsubst debian/$(PACKAGE)-%,debian/dsf-in/%,$@) | $(SED_REPLACE) > $@
+
+build: debian/po/templates.pot conffiles
+	dh $@
+	# Build gettext *.mo files
+	utils/manage-translations.sh build
+
+clean:
+	dh $@
+	rm -f $(CURDIR)/debian/*.cron.d
+	rm -f $(CURDIR)/debian/*.dirs
+	rm -f $(CURDIR)/debian/*.links
+	rm -f $(CURDIR)/debian/*.install
+	rm -f $(CURDIR)/debian/*.docs
+	rm -f $(CURDIR)/debian/*.postinst
+	rm -f $(CURDIR)/debian/*.prerm
+	rm -rf locales
+	rm -f $(POFILES)
+
+makeorig: 
+	find $(PKGDIR) -type f -or -type l | grep -v '/CVS/' | \
+	grep -v '/.svn/' | grep -v '/.testbox/' | \
+	grep -v rpm-specific | grep -v docs/phpdoc/docs | \
+	grep -v ^./debian/ | grep -v \\.jar$$ | \
+	grep -v \\.pdf$$ | grep -v plugins/fckeditor/www/_samples | \
+	cpio -o -H ustar | gzip > ../$(ORIGFILE)
+
+%:
+	dh  $@

Added: trunk/plugins/coclico/oslc/debian/source/format
===================================================================
--- trunk/plugins/coclico/oslc/debian/source/format	                        (rev 0)
+++ trunk/plugins/coclico/oslc/debian/source/format	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1 @@
+1.0

Added: trunk/plugins/coclico/oslc/etc/httpd.d/62plugin-oslc
===================================================================
--- trunk/plugins/coclico/oslc/etc/httpd.d/62plugin-oslc	                        (rev 0)
+++ trunk/plugins/coclico/oslc/etc/httpd.d/62plugin-oslc	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,12 @@
+# 62plugin-oslc begin
+#	AddHandler cgi-script .cgi
+
+#	ScriptAlias /cgi-bin/oslc/ /var/lib/oslc/cgi-bin/
+#	ScriptAlias /oslc/ /var/lib/oslc/cgi-bin/
+
+#	Alias /images/oslc /usr/share/images/oslc
+#	<Location /images/oslc>
+#		order allow,deny
+#		allow from all
+#	</Location>
+# 62plugin-oslc end

Added: trunk/plugins/coclico/oslc/etc/plugins/oslc/config.php
===================================================================
--- trunk/plugins/coclico/oslc/etc/plugins/oslc/config.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/etc/plugins/oslc/config.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,79 @@
+<?php 
+
+// here you can put all your configuration variables
+
+$world = 'Earth';
+
+// Define the backend tracker type : by defaut : fusionforge
+defined('TRACKER_TYPE')
+    || define('TRACKER_TYPE', (getenv('TRACKER_TYPE') ? getenv('TRACKER_TYPE') : 'fusionforge'));
+    
+// Define application environment
+defined('APPLICATION_ENV')
+    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));
+
+// Define path separator
+defined('PATH_SEPARATOR')
+    || define('PATH_SEPARATOR', ((strpos(PHP_OS,'Win') !== false) ? ';' : ':'));
+
+switch (TRACKER_TYPE) {
+	case 'mantis':
+		// Initialize the Mantis environment necessary to plug to its internal API
+
+		// this is supposed to be placed into mantis_top_level_dir/www/oslc-zend/
+		defined('MANTIS_DIR')
+    		|| define('MANTIS_DIR', (getenv('MANTIS_DIR') ? getenv('MANTIS_DIR') : dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR));
+		
+		$t_mantis_dir = MANTIS_DIR;
+
+		// TODO : explain the following line :
+		$g_bypass_headers = true;
+		require($t_mantis_dir.DIRECTORY_SEPARATOR.'core'.DIRECTORY_SEPARATOR.'constant_inc.php' );
+		require_once( $t_mantis_dir . 'core.php' );
+		require_once( $t_mantis_dir . 'core/summary_api.php' );
+
+		break;
+	case 'demo':
+		break;
+	case 'fusionforge':
+		define('APPLICATION_PATH', '/usr/share/gforge/plugins/oslc/include/oslc-zend/application');
+		/*require(APPLICATION_PATH.'/../../../../www/env.inc.php');
+	    require_once $gfwww.'include/pre.php';*/
+		break;
+	default:
+		throw new Exception('Unsupported TRACKER_TYPE : '. TRACKER_TYPE .' !');
+		break;
+}
+
+// Define the backend tracker type : by defaut : mantis
+defined('AUTH_TYPE')
+    || define('AUTH_TYPE', (getenv('AUTH_TYPE') ? getenv('AUTH_TYPE') : 'basic'));
+
+switch (AUTH_TYPE) {
+	case 'basic':
+		break;
+	case 'oauth':
+		switch (TRACKER_TYPE) {
+			case 'mantis':
+				// Initialize the Mantis environment necessary to plug to its internal API
+
+				// this is supposed to be placed into mantis_top_level_dir/www/oslc-zend/
+				// TODO : render this customizable in .htaccess much like TRACKER_TYPE above
+				$t_mantis_dir = dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR;
+
+				// TODO : explain the following line :
+				$g_bypass_headers = true;
+				require_once( $t_mantis_dir . 'plugins/OauthAuthz/oauth/DbOAuthDataStore.inc.php' );
+
+				break;
+			default:
+				throw new Exception('Unsupported oauth AUTH_TYPE for TRACKER_TYPE: '. TRACKER_TYPE .' !');
+				break;
+		}
+		break;
+	default:
+		throw new Exception('Unsupported AUTH_TYPE : '. AUTH_TYPE .' !');
+		break;
+}
+
+?>

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/Bootstrap.php
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/Bootstrap.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/Bootstrap.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,78 @@
+<?php
+
+/**
+ * This file is (c) Copyright 2009 by Madhumita DHAR, 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.
+ *
+ */
+
+  /* $Id$ */
+
+// This is a bit of black zend magic... don't ask : 
+// we don't know and borrowed it from somewhere ;-)
+
+// The next stop will be in controllers/CmController.php
+
+// TODO : document what was necessary here vs regular zend_rest app
+
+class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
+{
+	/* Not necessary it seems
+	protected function _initAutoload(){
+        $autoloader = new Zend_Application_Module_Autoloader(array(
+            'namespace' => 'Default_',
+            'basePath'  => dirname(__FILE__),
+        ));
+	
+        return $autoloader;
+	} 
+	*/
+	
+	protected function _initRestRoute() {
+	  // This may be necessary if needing to override the _initRequest()
+	  //	  	$this->bootstrap('Request');
+	  	$this->bootstrap('FrontController');
+		
+	  	$front = Zend_Controller_Front::getInstance();
+		
+		/* This seems only needed if REST only for specific modules 
+		$cmRoute = new Zend_Rest_Route($front, array(), array('default' => array('cm')));
+		$front->getRouter()->addRoute('rest', $cmRoute);
+		*/
+		$restRoute = new Zend_Rest_Route($front);
+		$front->getRouter()->addRoute('default', $restRoute);
+	} 
+	
+	/* Seems not necessary to override it from the defaults at the moment
+	protected function _initRequest(){
+        $this->bootstrap('FrontController');
+        $front = $this->getResource('FrontController');
+	$request = $front->getRequest();
+    	if (null === $front->getRequest()) {
+            $request = new Zend_Controller_Request_Http();
+            $front->setRequest($request);
+        }
+    	return $request;        
+	}*/
+
+
+}
+
+?>


Property changes on: trunk/plugins/coclico/oslc/include/oslc-zend/application/Bootstrap.php
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/basic-pwd.txt
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/basic-pwd.txt	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/basic-pwd.txt	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,2 @@
+theuser:Oslc-Demo:testpass
+

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/configs/application.ini
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/configs/application.ini	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/configs/application.ini	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,30 @@
+[production]
+
+; Customize this according to the location of the index.php file 
+; and make sure rewrite rules are activated
+;resources.frontController.baseUrl = "/tracker/oslc-zend/"
+
+phpSettings.display_startup_errors = 0
+phpSettings.display_errors = 0
+
+bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
+bootstrap.class = "Bootstrap"
+
+;resources.frontController.moduleDirectory = APPLICATION_PATH "/models"
+;resources.frontController.defaultModuleName = "ChangeRequest"
+resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
+resources.frontController.defaultControllerName = "cm"
+
+resources.frontController.throwerrors = false
+
+[staging : production]
+
+[testing : production]
+phpSettings.display_startup_errors = 1
+phpSettings.display_errors = 1
+
+[development : production]
+phpSettings.display_startup_errors = 1
+phpSettings.display_errors = 1
+resources.frontController.throwerrors = true
+

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/CmController.php
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/CmController.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/CmController.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,263 @@
+<?php
+
+/**
+ * This file is (c) Copyright 2009 by Madhumita DHAR, 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.
+ *
+ * This program has been developed in the frame of the HELIOS
+ * project with financial support of its funders.
+ *
+ */
+
+require_once('HTTP.php');
+
+$exceptions_dir = dirname( dirname( __FILE__ )) . DIRECTORY_SEPARATOR. 'exceptions'. DIRECTORY_SEPARATOR;
+require_once($exceptions_dir . 'oslcException.php');
+
+/**
+ * Zend controller managing REST invocations
+ * 
+ * This is the main entry point. It dispatches REST invocations to other applications-specific REST controllers.
+ * 
+ * @package ZendControler
+ */
+class CmController extends Zend_Rest_Controller {
+	
+
+	/**
+	 * Defines by default accepted mime-types for queries on actions, and corresponding 
+	 * format of output. Applications can define more actions and their respective accepted
+	 * mime-types.
+	 * 
+	 * ATTENTION : order is important for the XML variants : the first one is the default returned when only basic XML is required
+	 * 
+	 * @var array
+	 */
+	private static $supportedAcceptMimeTypes = array(
+							
+							'get' => array(
+								'application/x-oslc-cm-change-request+xml' => 'xml',
+								'application/xml' => 'xml',
+								'text/xml' => 'xml',
+								'application/atom+xml' => 'xml',
+								'application/x-oslc-disc-service-provider-catalog+xml' => 'xml',
+							 	'application/json' => 'json',
+							 	'application/x-oslc-cm-change-request+json' => 'json'
+							 	//'text/html' => '?',
+							 	//'application/xhtml+xml' => '?'
+							 	),
+							 	
+							 'post' => array(
+								'application/x-oslc-cm-change-request+xml' => 'xml',
+								'application/xml' => 'xml',
+								'text/xml' => 'xml',
+							 	'application/x-oslc-cm-change-request+json' => 'json',
+							 	'application/json' => 'json'
+							 	//'text/html' => '?',
+							 	//'application/xhtml+xml' => '?'
+							 	),
+							 	
+							 'put' => array(
+								'application/x-oslc-cm-change-request+xml' => 'xml',
+								'application/xml' => 'xml',
+								'text/xml' => 'xml',
+							 	'application/json' => 'json',
+							 	'application/x-oslc-cm-change-request+json' => 'json'
+							 	//'text/html' => '?',
+							 	//'application/xhtml+xml' => '?'
+								),
+
+							'readResource'=> array(
+								'application/x-oslc-cm-change-request+xml' => 'xml',
+								'application/xml' => 'xml',
+								'text/xml' => 'xml',
+				 				'application/json' => 'json',
+				 				'application/x-oslc-cm-change-request+json' => 'json'
+								),
+
+							'readResourceCollection' => array(
+								'application/atom+xml' => 'xml',
+								'application/json' => 'json'
+								),
+
+							/* Service Provider Catalog : http://open-services.net/bin/view/Main/OslcServiceProviderCatalogV1*/
+							'oslcServiceCatalog' => array(
+								'application/x-oslc-disc-service-provider-catalog+xml' => 'xml',
+							 	'application/xml' => 'xml',
+								'application/json' => 'json'
+								),
+
+							'oslcCmServiceDocument' => array(
+								'application/xml' => 'xml'
+								)
+	);
+							 	
+	private $rest_controller;
+	
+	/**
+	 * Initilizes the Zend REST controler
+	 */
+	public function init() {
+		//print_r("ACTION : ". $this->getRequest()->getActionName());
+		// load some initializations needed once we're in the controller, really running the application
+		$controller_dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
+		require_once($controller_dir . 'OSLCConnector.php');
+		
+		switch (TRACKER_TYPE) {
+			case 'mantis':
+				// load Mantis specific classes
+				require_once($controller_dir . 'MantisCmController.php');
+				$modelDir = $this->getFrontController()->getModuleDirectory(). DIRECTORY_SEPARATOR . 'models';
+				require_once($modelDir . '/mantis.inc.php');
+				break;
+		
+			case 'fusionforge':
+				require_once($controller_dir . 'FusionForgeCmController.php');
+				break;
+				
+			case 'demo':
+				break;
+				
+			default:
+				throw new BadRequestException('Unsupported TRACKER_TYPE : '. TRACKER_TYPE .' !');
+				break;
+		}
+	}
+
+	public function getSupportedAcceptMimeTypes(){
+		return self::$supportedAcceptMimeTypes;
+	}
+	
+	/**
+	 * Checks if the request's Accept mime-type is correct for that action
+	 * 
+	 * Upon success, returns the prefered content-type for the same format.
+	 * @param array $mime_types supported accepted mime types for application action
+	 * @param string $action request action
+	 * 
+	 * @return string
+	 */
+	public function checkSupportedActionMimeType($mime_types, $action) {
+		
+		$req = $this->getRequest();
+		$action = $req->getActionName();
+		//print_r("Action : ".$action);
+
+		// check Accept header's mime type 
+		$accept = $req->getHeader('Accept');
+		//print_r("\nAccept : ".$accept);
+		
+		// prepare an array of accepted types
+		$accepted_types = array();
+		if(isset($mime_types[$action])) {
+			$accepted_types = array_keys($mime_types[$action]);
+		}
+		// make sure text/html is always an option (in last option)
+		$accepted_types[]='text/html';
+		//print_r($accepted_types);
+		// use PEAR's HTTP::negotiateMimeType to identify the preferred content-type
+		//$accept = HTTP::negotiateMimeType($accepted_types,'');
+		$http=new HTTP();
+		$accept = $http->negotiateMimeType($accepted_types,'');
+		
+		//print_r("Accept2 : ".$accept);
+		// text/html is always supported
+		// otherwise, has to be declared in $supportedAcceptMimeTypes[$action]
+		if (!isset($mime_types[$action][$accept]) && $accept != 'text/html') {
+		  	// unsupported accept type
+		  	throw new NotAcceptableException("Accept header ".$req->getHeader('Accept')." not supported!");
+		}
+
+		// we have selected the requested type and check the corresponding output format
+		$content_type = $accept;
+		
+		// if found, then check for default type for equivalent formats (the first one with same format)
+		// should make application/xml more specific for instance
+		if(isset($mime_types[$action][$accept])) {
+			$format = $mime_types[$action][$accept];
+			foreach ($mime_types[$action] as $key => $value) {
+				if ($value == $format) {
+					$content_type = $key;
+					break;
+				}
+			}
+		}
+		return $content_type; 
+	}
+	
+	/**
+	 * Utility to load the PHP classes for the model
+	 * 
+	 * @param string $class
+	 * @param string $module
+	 * @return class
+	 */
+	public function loadModelClasses($class, $module = null)
+	{
+		$modelDir = $this->getFrontController()->getModuleDirectory($module). DIRECTORY_SEPARATOR . 'models';
+		Zend_Loader::loadClass($class, $modelDir);
+		return $class;
+	}
+	
+	public function getAction(){
+		switch (TRACKER_TYPE) {
+				case 'mantis':
+					$this->_forward('get','mantiscm');
+					break;
+				case 'fusionforge':
+					$this->_forward('get', 'fusionforgecm');
+					break;
+				default:
+					break;
+			}
+	}
+	
+	public function postAction(){
+		switch (TRACKER_TYPE) {
+				case 'mantis':
+					$this->_forward('post','mantiscm');
+					break;	
+				case 'fusionforge':
+					$this->_forward('post','fusionforgecm');
+					break;
+				default:
+					break;	
+			}
+	}
+
+	public function indexAction(){
+
+	}
+
+	public function putAction(){
+		switch (TRACKER_TYPE) {
+				case 'mantis':
+					$this->_forward('put','mantiscm');
+					break;	
+				case 'fusionforge':
+					$this->_forward('put','fusionforgecm');
+					break;
+				default:
+					break;				
+			}
+	}
+
+	public function deleteAction(){
+		throw new BadRequestException('Method delete not yet supported !');
+	}
+}
+?>

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/ErrorController.php
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/ErrorController.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/ErrorController.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,111 @@
+<?php
+
+/**
+ * This file is (c) Copyright 2009 by Madhumita DHAR, 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.
+ *
+ */
+
+  /* $Id$ */
+
+// TODO: support the XML format for error messages (see http://open-services.net/bin/view/Main/CmRestApiV1)
+
+class ErrorController extends Zend_Controller_Action
+{
+
+    public function errorAction()
+    {
+        $errors = $this->_getParam('error_handler');
+        $contextSwitch = $this->_helper->getHelper('contextSwitch');
+        $contextSwitch->addActionContext($this->getRequest()->getActionName(), 'xml')->initContext();
+        $contextSwitch->addActionContext($this->getRequest()->getActionName(), 'json')->initContext();
+        
+        switch ($errors->type) { 
+            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
+            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
+        
+                // 404 error -- controller or action not found
+                $this->getResponse()->setHttpResponseCode(404);
+                $this->view->message = 'Page not found';
+                break;
+            default:
+                // application error 
+                //$this->getResponse()->setHttpResponseCode(500);
+                $this->view->message = 'Application error';
+                //print_r(get_class($errors->exception));
+                switch(get_class($errors->exception))
+                {
+                	case 'ForbiddenException':
+                	case 'NotAcceptableForCRCollectionException':
+                	case 'BadRequestException':
+                	case 'NotFoundException':
+                	case 'ConflictException':
+                	case 'UnsupportedMediaTypeException':
+                	case 'NotAcceptableForSingleCRException':
+                	case 'GoneException':
+                	case 'PreconditionFailedException':
+                		//$this->_forward('res-not-found');
+                		$this->getResponse()->setHttpResponseCode($errors->exception->getCode());
+                		break;
+                		
+                	default:
+                		$this->getResponse()->setHttpResponseCode(500);
+                		break;
+                }
+              
+                break;
+        }
+        
+        if($errors->exception->getCode()==0)
+        {
+        	$return_code = 500;
+        }
+        else
+        {
+        	$return_code = $errors->exception->getCode();
+        }
+        
+        $this->view->code = $return_code;
+        $this->view->exception = $errors->exception;
+        $this->view->request   = $errors->request;
+        
+        $this->getResponse()->setHeader('Content-Type', 'text/html');
+    }
+
+    public function resnotfoundAction()
+    {
+    	$this->getResponse()->setHttpResponseCode(404);
+	    $this->_forward('Default');
+    }
+
+    public function unknownaccepttypeAction()
+    {
+    	$this->view->error_message = 'Unknown "Accept:" content-type';
+      $this->getResponse()->setHttpResponseCode(415);
+      $this->_forward('Default');
+    }
+
+    public function defaultAction()
+    {
+	    $this->getResponse()->setHeader('Content-Type', 'text/html');
+    }
+
+}
+


Property changes on: trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/ErrorController.php
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/FusionForgeCmController.php
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/FusionForgeCmController.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/FusionForgeCmController.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,603 @@
+<?php 
+/**
+ * This file is (c) Copyright 2010 by Sabri LABBENE, Madhumita DHAR, 
+ * Olivier BERGER, 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.
+ */
+
+$controller_dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
+require_once($controller_dir . 'CmController.php');
+require_once($controller_dir . 'FusionForgeOSLCConnector.php');
+
+class FusionForgeCmController extends CmController {
+
+		/**
+	 * @var oslc
+	 * 
+	 * This will be the OSLC-CM controller managing the business logic of the application
+	 */
+	private $oslc;
+	
+		/**
+	 * Defines accepted mime-types for queries on actions, and corresponding 
+	 * format of output
+	 * 
+	 * ATTENTION : order is important for the XML variants : the first one is the default returned when only basic XML is required
+	 * 
+	 * @var array
+	 */
+	private static $supportedAcceptMimeTypes = array();
+
+	/**
+	 * Init FusionForge REST controller.
+	 */
+	public function init(){
+		self::$supportedAcceptMimeTypes = parent::getSupportedAcceptMimeTypes();
+		
+		// TODO : render this path configurable
+		//		$writer = new Zend_Log_Writer_Stream('/tmp/zend-log.txt');
+		//		$this->logger = new Zend_Log($writer);
+
+		parent::loadModelClasses('ChangeRequests');
+
+		// now do things that relate to the REST framework
+		$req = $this->getRequest();
+		//print_r($req);
+
+		if(($req->getActionName()=='post')||($req->getActionName()=='put'))
+		{
+			$accept = $req->getHeader('Content-Type');
+		}
+		elseif($req->getActionName()=='get')
+		{
+			$accept = $req->getHeader('Accept');
+		}
+		
+		$action = $req->getActionName();
+		
+		$mime = parent::checkSupportedActionMimeType(self::$supportedAcceptMimeTypes, $action);
+		if($mime) {
+			$accept = $mime;
+		}
+
+		// determine output format
+		if (isset(self::$supportedAcceptMimeTypes[$action])) {
+			if (isset(self::$supportedAcceptMimeTypes[$action][$accept])) {
+				$format = self::$supportedAcceptMimeTypes[$action][$accept];
+				//print_r('format :'.$format);
+				$req->setParam('format', $format);
+			}
+		}
+		
+		$contextSwitch = $this->_helper->getHelper('contextSwitch');
+
+		// we'll handle JSON ourselves
+		$contextSwitch->setAutoJsonSerialization(false);
+		$types = array();
+		foreach (self::$supportedAcceptMimeTypes as $action => $typesarr) {
+			//print_r(array_unique(array_values($typesarr)));
+			$types = array_unique(array_values($typesarr));
+			//print_r("Typesarr : ".$typesarr);
+			$contextSwitch->addActionContext($action, $types)->initContext();
+		}
+		
+		// Create an OSLC Controller for FusionForge.
+		$this->oslc = new FusionForgeOSLCConnector();
+	}
+	
+	public function getAction(){
+		$params = $this->getRequest()->getParams();
+
+		// check authentication although it's not yet really useful
+		/*$login = null;
+		$authenticated = $this->retrieveAuthentication($login);
+		if(isset($login)) {
+			// Basic auth requested
+			if (!$authenticated) {
+				// not succesfully authd as $login
+				// can't go on;
+				throw new Exception('Invalid authentication provided !');
+			}
+		}*/
+
+		// handle OSLC services catalog access (http://open-services.net/bin/view/Main/OslcServiceProviderCatalogV1)
+		if ( isset($params['id']) && ($params['id'] == "oslc-services")) {
+			$this->_forward('oslcServiceCatalog');
+			return;
+		}
+		
+		// handle OSLC-CM service document access
+		elseif (isset($params['oslc-cm-service'])) {
+			$this->_forward('oslcCmServiceDocument');
+			return;
+		}
+		
+		// Now, do the OSLC-CM resources access work
+		// if no bug was mentioned, then return a resource collection
+		if (!array_key_exists('bug', $params)) {
+			// forward to an independant action so that it has its own views
+			// (see readresourcecollectionAction())
+			$this->_forward('readResourceCollection');
+		}
+		elseif(array_key_exists('bug', $params)) {
+			// now we're indeed getting one single resource
+			$this->_forward('readResource');
+		} else {
+			throw new NotFoundException("Resource ".$this->getRequest()->getRequestUri()." was not found on the server!");
+		}
+
+		// This is not explicitely required in OSLC-CM V1
+		// In the case of RDF+XML requested, mention it explicitely : LOD friendly
+		$req = $this->getRequest();
+		$accept = $req->getHeader('Accept');
+		switch (true) {
+			case (strstr($accept, 'application/rdf+xml')):
+				$resp = $this->getResponse()->setHeader('Content-Type', 'application/rdf+xml');
+				break;
+		}
+	}
+	
+	/**
+	 * Handles PUT action as routed by Zend_Rest_Route
+	 * 
+	 * Update of an existing changerequest
+	 * Will be invoked if PUT or if POST on a path relating to resources (due to Zend REST route behaviour)
+	 * So in case of POST, will pass the handling to postAction()
+	 * 
+	 * @return unknown_type
+	 */
+	public function putAction(){
+		$req = $this->getRequest();
+
+		// in case invoked like POST on .../cm/project/whatever we arrive to putAction
+		// so we check such case and then redirect to postAction() if needed
+		if ($req->isPost()) {
+            $this->postAction();
+		}
+		else {
+		
+			// otherwise it is indeed a PUT and we are trying to modify a change request
+			
+			// do authentication.
+			$login = null;
+			$authenticated = $this->retrieveAuthentication($login);
+			if(isset($login)) {
+				// Basic auth requested
+				if (!$authenticated) {
+					// not succesfully authd as $login
+					// can't go on;
+					throw new Exception('Invalid authentication provided !');
+				}
+			}
+
+			$contenttype = $req->getHeader('Content-Type');
+			$contenttype = $contenttype ? $contenttype : 'none';
+
+			switch($contenttype) {
+				case 'application/x-oslc-cm-change-request+xml':
+				case 'application/x-oslc-cm-change-request+json':
+				case 'application/xml':
+					break;
+				default:
+					throw new Exception('Unknown Content-Type for method put : '. $contenttype .' !');
+					break;
+			}
+
+			$identifier = null;
+
+			$params = $req->getParams();
+
+			if (array_key_exists('id', $params)) {
+				$identifier = $req->getParam('id');
+			}
+			else {
+				$identifier = $req->getParam('bug');
+
+				if (! isset($identifier)) {
+					throw new Exception('No change request id provided !');
+				}
+			}
+
+			// checking if modification
+
+			$modifiedproperties = null;
+
+			$oslc_cm_properties = $req->getParam('oslc_cm_properties');
+			if (isset($oslc_cm_properties)) {
+				$modifiedproperties = explode(',', $oslc_cm_properties);
+				if (array_key_exists('identifier', $modifiedproperties)) {
+					throw new Exception('Identifier cannot be modified !');
+				}
+			}
+
+			$body = file_get_contents('php://input');
+
+			// TODO: This should be done by $this->oslc
+			switch($contenttype) {
+				case 'application/x-oslc-cm-change-request+xml':
+				case 'application/xml':
+					// extract values from XML
+					$newchangerequest = FusionForgeChangeRequest::CreateFusionForgeArrayFromXml($body);
+					break;
+				case 'application/x-oslc-cm-change-request+json':
+					// extract values from JSON.
+					$newchangerequest = FusionForgeChangeRequest::CreateFusionForgeArrayFromJson($body);
+					break;
+			}
+
+			if(!$this->oslc->checkChangeRequestExists($identifier))	{
+				throw new Exception("Change Request to be updated doesn't exist!");
+			}
+			else {
+				// Proceed to change request update
+				$this->oslc->updateChangeRequest($identifier, $newchangerequest, $modifiedproperties);
+				
+				//logout the user
+				session_logout();
+			}
+		}
+	}
+	
+	public function postAction(){
+		$req = $this->getRequest();
+		
+		// check that we're indeed invoked by a POST request
+		if(! $req->isPost()) {
+			throw new Exception('postAction invoked without POST !');
+		}
+		
+		$params = $req->getParams();
+		
+		// do authentication.
+		$login = null;
+		$authenticated = $this->retrieveAuthentication($login);
+		if(isset($login)) {
+			// Basic auth requested
+			if (!$authenticated) {
+				// not succesfully authd as $login
+				// can't go on;
+				throw new Exception('Invalid authentication provided !');
+			}
+		}
+		
+		$contenttype = $req->getHeader('Content-Type');
+		$contenttype = $contenttype ? $contenttype : 'none';
+		
+		switch($contenttype) {
+			case 'application/x-oslc-cm-change-request+xml':
+			case 'application/x-oslc-cm-change-request+xml; charset=UTF-8':
+			case 'application/x-oslc-cm-change-request+json':
+			case 'application/json':
+			case 'application/xml':
+				break;
+			default:
+				throw new UnsupportedMediaTypeException('Unknown Content-Type for method post : '. $contenttype .' !');
+				break;
+		}
+		
+		// used for PhpUnit tests.
+		if(APPLICATION_ENV=='testing') {
+			$body = $_POST['xml'];
+		} else {
+			$body = file_get_contents('php://input');
+		}
+		//print $body;
+
+		if(array_key_exists('project',$params)) {
+			if (array_key_exists('tracker', $params)) {
+				// create a change request
+				switch($contenttype) {
+					case 'application/x-oslc-cm-change-request+xml':
+					case 'application/xml':
+					case 'application/x-oslc-cm-change-request+xml; charset=UTF-8':
+						$newchangerequest = FusionForgeChangeRequest::CreateFusionForgeArrayFromXml($body);
+						break;
+					case 'application/x-oslc-cm-change-request+json':
+						$newchangerequest = FusionForgeChangeRequest::CreateFusionForgeArrayFromJson($body);
+						break;
+				}
+				//print_r($newchangerequest);
+	
+				$creationparams = array('project' => $params['project'],
+										'tracker' => $params['tracker'],
+										'new' => $newchangerequest);
+
+				// pass the creation work to the OSLC connector
+				$identifier = $this->oslc->createChangeRequest($creationparams);
+				
+			}else{
+				throw new ConflictException('Need a valid tracker to create a change request');
+			}
+		}else{
+			throw new ConflictException('Need a valid project and tracker to create change request !');	
+		}
+		
+		// prepare redirection
+		$httpScheme = $this->getRequest()->getScheme();
+		$httpHost = $this->getRequest()->getHttpHost();
+		$requestUri = $this->getRequest()->getRequestUri();
+		$baseURL = $this->getFrontController()->getBaseUrl();
+		$controllerName = $this->getFrontController()->getDefaultControllerName();
+
+		if(APPLICATION_ENV=='testing')
+		{
+			$newlocation = '/'.$controllerName.'/project/'.$params['project'].'/tracker/'.$params['tracker'].'/bug/'.$identifier;
+		}
+		else
+		{
+			$newlocation = $httpScheme.'://'.$httpHost.$baseURL.'/'.$controllerName.'/project/'.$params['project'].'/tracker/'.$params['tracker'].'/bug/'.$identifier;
+		}
+		
+		//logout the user
+		session_logout();
+				
+		//redirect to new change request
+		$this->getResponse()->setRedirect($newlocation,201);
+	}
+	public function indexAction(){
+		
+	}
+	public function deleteAction(){
+		
+	}
+	
+	/**
+	 * Retrieve an individual resource and populates the view of an OSLC CM ChangeRequest
+	 * 
+	 * @param string $identifier
+	 * @param string $uri
+	 */
+	public function readresourceAction() {
+		
+		$params = $this->getRequest()->getParams();
+		$content_type = parent::checkSupportedActionMimeType(self::$supportedAcceptMimeTypes, $this->getRequest()->getActionName());
+		if (! $content_type) {
+			$this->_forward('UnknownAcceptType','error');
+			return;
+		}
+		
+		$identifier = $params['bug'];
+		
+		// prepare resource URI
+		$httpScheme = $this->getRequest()->getScheme();
+		$httpHost = $this->getRequest()->getHttpHost();
+		$requestUri = $this->getRequest()->getRequestUri();
+		$changerequestURI = $httpScheme.'://'.$httpHost.$requestUri;
+
+		// Check if some specific fields have been requested for the ChangeRequest.
+		if (isset($params['oslc_properties'])){
+			$preparedChangeRequest = $this->oslc->fetchChangeRequest($identifier, $changerequestURI, $params['oslc_properties']);
+		} else {
+			$preparedChangeRequest = $this->oslc->fetchChangeRequest($identifier, $changerequestURI);
+		}
+		
+		if(isset($preparedChangeRequest)) {
+
+			// populate the view with the model
+			foreach($preparedChangeRequest as $field => $value) {
+				$this->view->{$field} = $value;
+			}
+			
+			$this->getResponse()->setHeader('Content-Type', $content_type);
+		}
+		else{
+			$this->view->missing_resource = $identifier;
+			$this->_forward('ResNotFound','error');
+		}
+	}
+	
+	public function readresourcecollectionAction()	{
+
+		$content_type = parent::checkSupportedActionMimeType(self::$supportedAcceptMimeTypes, $this->getRequest()->getActionName());
+		if (! $content_type) {
+		  //			print_r("error");
+		  throw new NotAcceptableException("Accept header ".$this->getRequest()->getHeader('Accept')." not supported!");
+		  return;
+		}
+		//exit;
+		$req = $this->getRequest();
+		$params = $req->getParams();
+		
+		// load the model. Will fetch requested change requests from the db.
+		$params = $this->oslc->init($params);
+
+		// construct ATOM feed-like header
+		$httpScheme = $this->getRequest()->getScheme();
+		$httpHost = $this->getRequest()->getHttpHost();
+		$requestUri = $this->getRequest()->getRequestUri();
+		$requestUri = str_replace('bugs','bug', $requestUri);
+		$requestUri = preg_replace("/project.*/", 'bug/', $requestUri);
+		$requestUri = $requestUri.(($requestUri[strlen($requestUri)-1]=='/')?'':'/');
+		$prefix = $httpScheme.'://'.$httpHost.$requestUri;
+
+		// get all resources
+		$collection = $this->oslc->getResourceCollection($prefix);
+
+		// construct an intermediate array that will be used to populate the view
+		$preparedCollection = array ('id'         => $httpScheme.'://'.$httpHost.$requestUri,
+									'collection'     => $collection
+							);
+		// Add request params so they ca reach views.
+		foreach($params as $key => $value){
+			$preparedCollection[$key] = $value;
+		}
+
+		// populate the view with the loaded values
+		foreach($preparedCollection as $key => $value) {
+			$this->view->$key = $value;
+		}
+
+		//print_r($this->view);
+		$this->getResponse()->setHeader('Content-Type', $content_type);
+		
+	}
+	
+	/**
+	 * Handle OSLC services catalog access (http://open-services.net/bin/view/Main/OslcServiceProviderCatalogV1)
+	 */
+	public function oslcservicecatalogAction() {
+		
+		$content_type = parent::checkSupportedActionMimeType(self::$supportedAcceptMimeTypes, $this->getRequest()->getActionName());
+		if (! $content_type) {
+		  //			print_r("error");
+		  $this->_forward('UnknownAcceptType','error');
+		  return;
+		}
+		
+		// each project will generate its own service description
+		$proj_arr = $this->oslc->getProjectsList();
+		
+		$this->view->projects = $proj_arr;
+		
+		$this->getResponse()->setHeader('Content-Type', $content_type);
+	}
+
+	/**
+	 * 
+	 * Handles OSLC service document (service document) access.
+	 * TODO: Implement service document details.
+	 */
+	public function oslccmservicedocumentAction() {
+		$content_type = parent::checkSupportedActionMimeType(self::$supportedAcceptMimeTypes, $this->getRequest()->getActionName());
+		if (! $content_type) {
+		  //			print_r("error");
+		  $this->_forward('UnknownAcceptType','error');
+		  return;
+		}
+		
+		$req = $this->getRequest();
+		$params = $req->getParams();
+		$project = $params['oslc-cm-service'];
+		$this->view->project = $project;
+
+		$this->getResponse()->setHeader('Content-Type', $content_type);
+
+	}
+
+	
+		/**
+	 * Performs authentication according to the configured AUTH_TYPE configured
+	 *
+	 * @param string $login
+	 * @return True if auth is valid, in which case $login is modified.
+	 * 		   If there was actually no auth requested, then return False, but $login will be set to null.
+	 */
+
+	private function retrieveAuthentication(&$login) {
+		switch (AUTH_TYPE) {
+			case 'basic':
+				return $this->retrieveRequestAuthHttpBasic($login);
+				break;
+			case 'oauth':
+				return $this->checkOauthAuthorization($login);
+				break;
+			default:
+				throw new BadRequestException('Unsupported AUTH_TYPE : '. AUTH_TYPE .' !');
+				break;
+		}
+	}
+	
+/**
+	 * Helper function that performs HTTP Basic authentication from request parameters/headers
+	 *
+	 * @param string $login
+	 * @return True if auth is valid, in which case $login is modified.
+	 * 		   If there was actually no auth requested, then return False, but $login will be set to null.
+	 */
+
+	private function retrieveRequestAuthHttpBasic(&$login) {
+		// extract login and password from Basic auth
+		$login = null;
+		$password = null;
+
+		$returned = False;
+
+		$request = $this->getRequest();
+		$auth = $request->getHeader('Authorization');
+		//		print_r('Auth :'.$auth);
+		//		print_r('Auth :'.$auth.'!');
+		if (strlen($auth) != 0) {
+			$auth = explode(' ',$auth);
+			if ($auth[0] == 'Basic') {
+				//print_r($auth);
+				$basic = base64_decode($auth[1]);
+				//print_r($basic);
+				$basic = explode(':',$basic);
+
+				$login = $basic[0];
+				$password = $basic[1];
+				//print_r('request username'.$login);
+				//print_r('request password'.$password);
+			}
+			else {
+				throw new BadRequestException('Unsupported auth method : '. $auth[0] .' !');
+			}
+		}
+		if (isset($password)) {
+				
+			$config = array(
+		    	'accept_schemes' => 'basic',
+    			'realm'          => 'Oslc-Demo',
+    			'digest_domains' => '/cm',
+    			'nonce_timeout'  => 3600,
+			);
+				
+			// Http authentication adapter
+			$adapter = new Zend_Auth_Adapter_Http($config);
+
+			// setup the OslcControler's Auth HTTP Basic resolver
+			$basicResolver = $this->oslc->getHttpAuthBasicResolver($login, $password);
+
+			// The authentication check will be performed by Mantis
+			$adapter->setBasicResolver($basicResolver);
+
+			$request = $this->getRequest();
+			$adapter->setRequest($request);
+			$response = $this->getResponse();
+			$adapter->setResponse($response);
+
+			// perform authentication check
+			//$result = $this->auth->authenticate($adapter);
+			$result = $adapter->authenticate();
+			if (!$result->isValid()) {
+				print_r('Access denied for : '. $login .' !');
+			}
+			//print_r($result->getCode());
+			switch ($result->getCode()) {
+				case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:
+					/** do stuff for nonexistent identity **/
+					print_r('Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND');
+					break;
+				case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
+					/** do stuff for invalid credential **/
+					print_r('Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID');
+					break;
+				case Zend_Auth_Result::SUCCESS:
+					/** do stuff for successful authentication **/
+					//					print_r('Zend_Auth_Result::SUCCESS');
+					$returned = True;
+					break;
+				default:
+					/** do stuff for other failure **/
+					print_r('other problem');
+					break;
+			}
+		}
+
+		return $returned;
+	}
+}
+?>

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/FusionForgeOSLCConnector.php
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/FusionForgeOSLCConnector.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/FusionForgeOSLCConnector.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,610 @@
+<?php
+
+/**
+ * This file is (c) Copyright 2010 by Olivier BERGER, 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.
+ *
+ */
+
+/**
+ * This is the FusionForge OSLC-CM controller, which specializes the generic 
+ * OSLC-CM controller (in oslc.inc.php) 
+ */
+
+/* $Id:$ */
+
+$controller_dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
+require_once($controller_dir . 'OSLCConnector.php');
+
+$model_dir = APPLICATION_PATH.'/models/';
+require_once($model_dir . 'fusionforge.inc.php');
+
+require(APPLICATION_PATH.'/../../../../../www/env.inc.php');
+require_once $gfwww.'include/pre.php';
+
+require_once $gfwww.'tracker/include/ArtifactTypeHtml.class.php';
+require_once $gfcommon.'tracker/ArtifactFactory.class.php';
+require_once $gfcommon.'include/Group.class.php';
+require_once $gfcommon.'include/FusionForge.class.php';
+
+
+//print_r($sys_dbname);//, $sys_dbuser, $sys_dbpasswd, $sys_dbhost, $sys_dbport));
+
+/**
+ * FusionForge OSLC server controller
+ *
+ * @author olivier
+ *
+ */
+class FusionForgeOSLCConnector extends OslcConnector {
+
+
+	private static $status_arr = array('open'=>1, 'closed'=>2, 'deleted' => 3);
+	
+	/**
+	 * Filter parameters provided in the REST GET request to check whether mandatory ones are set.
+	 * 
+	 * @param array $params
+	 * @return array 
+	 */
+	public function filterRequestParams($params) {
+
+		// the args that need to be passed to initialize the model
+		$modelparams = array();
+		
+		// Process the args provided by Zend REST
+		if (is_array($params)) {
+			if(!isset($params['project'])){
+				throw new Exception('Missing project id !');
+			}
+			elseif(!isset($params['tracker'])) {
+				throw new Exception('Missing tracker id resource for project '.$params['project'].' !');
+			} else {
+				//$modelparams['project'] = $params['project'];
+				//$modelparams['tracker'] = $params['tracker'];
+			}
+			
+			/*if(isset($params['bug'])) {
+				$modelparams['bug'] = $params['bug'];
+			}*/
+		}
+
+		//return $modelparams;
+		return $params; 		
+	}
+	
+	/**
+	 * Checks whether a change request exists inside FusionForge trackers. 
+	 * @param int $id change request id.
+	 * @return bool
+	 */
+	public function checkChangeRequestExists($id) {
+		$returned = false;
+		$art_obj = artifact_get_object($id);
+		if (!$art_obj || !is_object($art_obj)) {
+			return false;
+		}else{
+			return true;
+		}
+	}
+	
+	/**
+	 * 
+	 *  Constructs the model from fusionforge db by fetching the change requests requested
+	 *  through an oslc query.
+	 *  @param array $filter array of the query settings.
+	 *  @param array $fields array of the requested fields
+	 *  @TODO: Implement oslc_searchTerms
+	 *  @TODO: Implement oslc_select
+	 */
+	protected function changeRequestsQuery($params) {
+		$query = array();
+		$filter = $params['filter'];
+		
+		if(array_key_exists('limit', $filter))	{
+			$query['max_rows'] = $filter['limit'];		
+		}else 	{
+			$query['max_rows'] = 0;
+		}
+		
+		if(array_key_exists('offset', $filter))	{
+			$query['offset'] = $filter['offset'];		
+		}else 	{
+			$query['offset'] = 0;		
+		}
+
+		if(array_key_exists('where', $filter))	{
+			foreach($filter['where']['terms'] as $term)	{
+				if($term[0]=='=')	{	
+					$term[2] = str_replace("\"", "", $term[2]);
+					switch($term[1])	{
+						case 'helios_bt:status':
+							if (array_key_exists($term[2],self::$status_arr))	{
+								$query['status'] = self::$status_arr[$term[2]];
+							}else	{
+								throw new BadRequestException('Invalid heliosbt:status value specified!');
+							}
+							break;
+						case 'helios_bt:assigned_to':
+							if ($assignee = user_get_object_by_name($term[2])) {
+								$query['assigned_to'] = $assignee->getID();
+							}else {
+								throw new BadRequestException("Invalid helios_bt:assigned_to: " . $term[2]); 
+							}
+							break;
+						default:  throw new BadRequestException("Invalid attribute ".$term[1]." specified in oslc_where! only heliosbt:status|assignedto are accepted.");
+						break;
+					}
+				}
+			}		
+		}
+		
+		if (!array_key_exists('status', $query)) {
+			$query['status'] = '';
+		}
+		if (!array_key_exists('assigned_to', $query)) {
+			$query['assigned_to'] = '';
+		}
+		
+		if (array_key_exists('orderBy', $filter)) {
+			if (count(array_keys($filter['orderBy'])) > 1) {
+				throw new ConflictException("Sorting over more than one attribute is not supported by FusionForge API!");
+			} else {
+				switch ($filter['orderBy'][0][1]) {
+					case 'dc:identifier': 
+						$query['order_col'] = 'artifact_id';
+						break;
+					case 'dc:title':
+						$query['order_col'] = 'summary';
+						break;
+					case 'dc:created': 
+						$query['order_col'] = 'open_date';
+						break;
+					case 'dc:closed':
+						$query['order_col'] = 'close_date';
+						break;
+					case 'helios_bt:assigned_to': 
+						$query['order_col'] = 'assigned_to';
+						break;
+					case 'dc:creator': 
+						$query['order_col'] = 'submitted_by';
+						break;
+					case 'helios_bt:priority': 
+						$query['order_col'] = 'priority';
+						break;
+					default: 
+						throw new ConflictException("Sorting over attribute ".$filter['orderBy'][0][1]." is not supported in FusionForge API !");
+						break;
+				}
+			}
+			$query['sort'] = $filter['orderBy'][0][0];
+		} else {
+			$query['order_col'] = '';
+			$query['sort'] = '';
+		}
+		if (array_key_exists('searchTerms', $filter)) {
+			$terms = "";
+			foreach ($filter['searchTerms'] as $term) {
+				$terms = $terms.$term." " ;
+			}
+			$query['search'] = substr($terms, 0, -1);
+		} else {
+			$query['search'] = "";
+		}
+		$query['set'] = false;
+		
+		$group_id = $params['project'];
+		$atid = $params['tracker'];
+		
+		$group = group_get_object($group_id);
+		if (!$group || !is_object($group)) {
+			exit_no_group();
+		}
+		if ($group->isError()) {
+			if($group->isPermissionDeniedError()) {
+				throw new Exception('Error : permission denied');
+			} else {
+				throw new Exception('Error '. $group->getErrorMessage());
+			}
+		}
+		
+		$ath = new ArtifactTypeHtml($group,$atid);
+		if (!$ath || !is_object($ath)) {
+			throw new Exception('Error '. 'ArtifactType could not be created');
+		}
+		if ($ath->isError()) {
+			//print_r($ath->isError());
+			if($ath->isPermissionDeniedError()) {
+				//print_r($ath->isPermissionDeniedError());
+				throw new Exception('Error : permission denied');
+			} else {
+				throw new Exception('Error '. $ath->getErrorMessage());
+			}
+		}
+		
+		$af = new ArtifactFactory($ath);
+		if (!$af || !is_object($af)) {
+			throw new Exception('Error Could Not Get ArtifactFactory');
+		} elseif ($af->isError()) {
+			throw new Exception('Error '. $af->getErrorMessage());
+		}
+		
+		// parametrize the tracker query.
+		$af->setup($query['offset'],
+			$query['order_col'],
+			$query['sort'],
+			$query['max_rows'],
+			$query['set'],
+			$query['assigned_to'],
+			$query['status'],
+			array()
+		);
+		
+		// Force these properties of ArtifactQuery object to take the values we want.
+		$af->status = $query['status'];
+		$af->assigned_to = $query['assigned_to'];
+		$af->offset = $query['offset'];
+		$af->max_rows = $query['max_rows'];
+		$af->sort = $query['sort'];
+		$af->order_col = $query['order_col'];
+		
+		// Can add here values for 'details' and 'summary'. Values comes from oslc_searchTerms
+		//$af->summary = $query['search'];
+		//$af->details =	$query['search'];
+		
+		// query the DB for requested artifacts 
+		$art_arr =& $af->getArtifacts();
+		
+		if ($art_arr === false) {
+			throw new Exception('Error '. $af->getErrorMessage());
+		}
+		// instanciate the model from the returned artifacts
+		if(isset($params['fields'])){
+			$this->changerequests = new ChangeRequestsFusionForgeDb($art_arr, $params['fields']);
+		} else {
+			$this->changerequests = new ChangeRequestsFusionForgeDb($art_arr);
+		}
+	}
+	
+	/*
+	 * Constructs the model from the FusionForge DB by fetching the requested changeRequests.
+	 *
+	 * TODO : remove provided project if not found in DB
+	 * 
+	 * @param array $params contains 'project' + 'tracker' if filtered on particular project's tracker
+	 */
+	public function fetchChangeRequests($params) {
+		$art_arr	= array();
+
+		// what the DB will be queried on
+		$group_id = null;
+		$atid = null;
+
+		if (is_array($params)) {
+			
+			if (isset($params['project'])) {
+				$group_id = $params['project'];
+			}
+			if (isset($params['tracker'])) {
+				$atid = $params['tracker'];
+			}
+			if (isset($params['bug'])) {
+				$art_id = $params['bug'];
+				$art_obj = artifact_get_object($art_id);
+				$art = $art_obj->fetchData($art_id);
+				$this->changerequests = new ChangeRequestsFusionForgeDb($art);
+			}
+
+			$group = group_get_object($group_id);
+			if (!$group || !is_object($group)) {
+				exit_no_group();
+			}
+			if ($group->isError()) {
+				if($group->isPermissionDeniedError()) {
+					throw new Exception('Error : permission denied');
+				} else {
+					throw new Exception('Error '. $group->getErrorMessage());
+				}
+			}
+
+			$ath = new ArtifactTypeHtml($group,$atid);
+			if (!$ath || !is_object($ath)) {
+				throw new Exception('Error '. 'ArtifactType could not be created');
+			}
+			if ($ath->isError()) {
+				//print_r($ath->isError());
+				if($ath->isPermissionDeniedError()) {
+					//print_r($ath->isPermissionDeniedError());
+					throw new Exception('Error : permission denied');
+				} else {
+					throw new Exception('Error '. $ath->getErrorMessage());
+				}
+			}
+
+
+			$af = new ArtifactFactory($ath);
+
+			if (!$af || !is_object($af)) {
+				throw new Exception('Error Could Not Get ArtifactFactory');
+			} elseif ($af->isError()) {
+				throw new Exception('Error '. $af->getErrorMessage());
+			}
+
+			$_assigned_to = '';
+			$_status = '';
+			$set=false;
+
+			// parameters of the query
+			$af->setup(0,'','',0,$set,$_assigned_to,$_status);
+
+			// query the DB for requested artifacts 
+			$art_arr =& $af->getArtifacts();
+
+			if ($art_arr === false) {
+				throw new Exception('Error '. $af->getErrorMessage());
+			}
+			// instanciate the model from the returned artifacts
+			if(isset($params['fields'])){
+				$this->changerequests = new ChangeRequestsFusionForgeDb($art_arr, $params['fields']);
+			} else {
+				$this->changerequests = new ChangeRequestsFusionForgeDb($art_arr);
+			}
+		}
+	}
+	
+	public function fetchChangeRequest($identifier, $uri, $requested_fields=array()) {
+		$art_obj =& artifact_get_object($identifier);
+		if(!$art_obj){
+			throw new NotFoundException('Change Request not found');
+		}
+		$art = array($art_obj);
+		
+		$changerequest = new ChangeRequestsFusionForgeDb($art, $requested_fields);
+
+		return $this->prepareChangeRequest($changerequest[$identifier], $uri);
+	}
+	
+	/**
+	 * Updates an existant FusionForge ChangeRequest in the tracker DataBase.
+	 * @param int $identifier id of the ChangeRequest within FusionForge tracker
+	 * @param ChangeRequest the change request given as input for the PUT request.
+	 * @param array $props array of the properties that PUT request is going to change 
+	 * @return boolean true if success, false otherwise.
+	 */
+	public function updateChangeRequest($identifier, $changerequest, $props) {
+		// Get the artifact data using its ID. 
+		$art_obj =& artifact_get_object($identifier);
+		$art = $art_obj->data_array;
+
+		$cm_request = $changerequest->container;
+
+		$terms = array('dc:','helios_bt:');
+		foreach($props as &$prop) {
+			$prop = str_replace($terms,"",$prop);
+			//echo $prop;
+		}
+		
+		// Check all the mandatory fields for an artifact update request.
+		
+		// dc:title ===> summary 
+		if(in_array('title',$props))
+		{
+			if(isset($cm_request['title']))
+			{
+				$art['summary'] = $cm_request['title'];			// mandatory
+			}
+			else
+			{
+				throw new BadRequestException("dc:title mentioned in the request query not found in request body!");
+			}
+		}
+		
+		// dc:description ===> details 
+		if(in_array('description',$props))
+		{
+			if(isset($cm_request['description']))
+			{
+				$art['details'] = $cm_request['description'];			// mandatory
+			}
+			else
+			{
+				throw new BadRequestException("dc:decription mentioned in the request query not found in request body!");
+			}
+		}
+		
+		// helios_bt:priority ===> priority 
+		if(in_array('priority',$props))
+		{
+			if(isset($cm_request['priority']))
+			{
+				$art['priority'] = $cm_request['priority'];			// mandatory
+			}
+			else
+			{
+				throw new BadRequestException("helios_bt:priority mentioned in the request query not found in request body!");
+			}
+		}
+		
+		// helios_bt:status ===> status 
+		if(in_array('status',$props))
+		{
+			if(isset($cm_request['status']))
+			{
+				$art['status_id'] = self::$status_arr[$cm_request['status']];			// mandatory
+			}
+			else
+			{
+				throw new BadRequestException("helios_bt:status mentioned in the request query not found in request body!");
+			}
+		}
+		
+		//helios_bt:assigned_to ====> assigned_to
+		if(in_array('assigned_to', $props))
+		{
+			if(isset($cm_request['assigned_to']))
+			{
+				$art['assigned_to'] = $cm_request['assigned_to'];
+			}
+			else 
+			{
+				throw new BadRequestException("helios_bt:assigned_to mentionned in the request query not found in request body!");
+			}
+		}
+		
+		
+		$canned_response=100;
+		
+		// We assume that we don't change the artifact type (bug, task, etc)
+		// in PUT request. 
+		$new_artifact_type_id = $art_obj->ArtifactType->getID();
+		
+		//TODO: figure out if a follow up is in OSLC specs and if it is the case include it.
+		$follow_up_msg = '';
+		
+		if(!$art_obj->update($art['priority'],$art['status_id'],$art['assigned_to'],$art['summary'],$canned_response,$follow_up_msg,$new_artifact_type_id,array(),$art['details']))
+		{
+			throw new Exception($art_obj->getErrorMessage());
+		}
+	}
+	
+	/**
+	 * Creates a new change request in FusionForge tracker 
+	 * 
+	 * @param array $creation_params array that contain:change request data, tracker id and project id. 
+	 * @return int $identifier Id in FusionForge tracker of the newly created change request.
+	 */
+	public function createChangeRequest($creation_params){
+		$cm_request = $creation_params['new']->container;
+
+		$grp = group_get_object($creation_params['project']);
+
+		if(!$grp || !is_object($grp)){
+			throw new Exception('Error: Could not get project. Please give a Valid project identifier.');
+		}
+		
+		$at = new ArtifactType($grp, $creation_params['tracker']);
+		if (!$at || !is_object($at)) {
+			throw new Exception('Error: Could Not Get ArtifactType. Please give a valid tracker identifier.', $code);
+		}
+		
+		$a = new Artifact($at);
+		if (!$a || !is_object($a)) {
+			throw new Exception('Error: Could Not Get Artifact');
+		}
+		
+		// Check that Mandatory fields are given.
+		if (!isset($cm_request['title'])) {
+			throw new BadRequestException('Mandatory field "Title" missing!!');
+		}
+		if (!isset($cm_request['description'])) {
+			throw new BadRequestException('Mandatory field "Description" missing!!');
+		}
+		// Proceed to Change request creation in FusionForge Tracker.
+		if (!$a->create($cm_request['title'], $cm_request['description'])){
+			throw new Exception($a->getErrorMessage());
+		}else {
+			return $a->getID();
+		}
+
+	}
+
+	/**
+	 * Gets the projects list. Needed for a service catalog creation
+	 */
+	public function getProjectsList()
+	{
+		return $this->getProjects();
+	}
+
+	/**
+	 * gets the list of public projects Names
+	 */
+	private function getProjects()
+	{
+		$fusionforge = new FusionForge();
+		$projects_names = $fusionforge->getPublicProjectNames();
+		// manage errors on $projects_names here ...
+		$projects = group_get_objects_by_name($projects_names);
+		// manage errors on $projects here ...
+		return $this->createProjectsArray($projects);
+	}  
+	
+	/**
+	 *  Converts projects objects into a single projects array.
+	 */
+	private function createProjectsArray($projects)
+	{
+		$return = array();
+		foreach($projects as $prj_idx => $project){
+			$data = $project->data_array;
+			$return[$prj_idx] = array(
+				'id'                => $data['group_id'], 
+				'name'              => $data['group_name'],
+				'homepage'          => $data['homepage'],
+				'is_public'         => $data['is_public'],
+				'status'            => $data['status'],
+				'unix_group_name'   => $data['unix_group_name'],
+				'short_description' => $data['short_description'],
+				'scm_box'           => $data['scm_box'],
+				'register_time'     => $data['register_time']
+			);
+		}
+		return $return;
+	
+	}
+	
+	public function getHttpAuthBasicResolver($login, $password) {
+		$basicResolver = new FusionForge_Http_Auth_Resolver($login, $password);
+		return $basicResolver;
+	}
+}
+
+// HTTP auth adapater's resolver using FusionForge APIs for user + password verification
+class FusionForge_Http_Auth_Resolver implements Zend_Auth_Adapter_Http_Resolver_Interface
+{
+	// the query's elements
+	protected $username = null;
+	protected $password = null;
+
+	public function __construct($username, $password)
+	{
+		$this->username = $username;
+		$this->password = $password;
+	}
+
+	
+	/**
+	 * Check if the password matches with FusionForge database
+	 */
+	public function resolve($username, $realm) {
+		// Include FusionForge Sessions Management API 
+		//require_once $gfcommon.'include/session.php';
+		
+		// Try and login the user into fusionforge.
+		$success=session_login_valid(strtolower($this->username), $this->password);
+        if ($success) {
+			return $this->password; 
+        } else {
+        	return false;
+        } 
+	}
+
+}
+?>

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/MantisCmController.php
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/MantisCmController.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/MantisCmController.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,871 @@
+<?php 
+/**
+ * This file is (c) Copyright 2010 by Sabri LABBENE, Madhumita DHAR, 
+ * Olivier BERGER, 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.
+ */
+
+$controller_dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
+require_once($controller_dir . 'CmController.php');
+require_once($controller_dir . 'MantisOSLCConnector.php');
+
+class MantisCmController extends CmController{
+	
+	/**
+	 * @var oslc
+	 * 
+	 * This will be the OSLC-CM controller managing the business logic of the application
+	 */
+	private $oslc;
+	private static $mantisSupportedAcceptMimeTypes = array(
+				'readBugnote'=> array(
+					'application/x-oslc-cm-change-request+xml' => 'xml',
+					'application/xml' => 'xml',
+					'text/xml' => 'xml',
+				 	'application/json' => 'json',
+				 	'application/x-oslc-cm-change-request+json' => 'json'
+				),			 	
+
+				'readBugnoteCollection' => array(
+					'application/atom+xml' => 'xml',
+					'application/json' => 'json'
+				)
+	);
+	
+	private static $supportedAcceptMimeTypes = array();
+	
+	public function getSupportedAcceptMimeTypes(){
+		return self::$supportedAcceptMimeTypes;
+	}
+	
+	/*public function __construct(){
+		// just merge Mantis specifc action mime types with the default set
+		// of supported actions mime types in OSLC-CM
+		$this->getSupportedAcceptMimeTypes = array_merge(CmController::getSupportedAcceptMimeTypes(), $this->mantisSupportedAcceptMimeTypes);
+	}*/
+	
+	/**
+	 * Init Mantis REST controller.
+	 */
+	public function init(){
+		// TODO : render this path configurable
+		//		$writer = new Zend_Log_Writer_Stream('/tmp/zend-log.txt');
+		//		$this->logger = new Zend_Log($writer);
+		self::$supportedAcceptMimeTypes = array_merge(parent::getSupportedAcceptMimeTypes(), self::$mantisSupportedAcceptMimeTypes);
+		parent::loadModelClasses('ChangeRequests');
+
+		// now do things that relate to the REST framework
+		$req = $this->getRequest();
+		//print_r($req);
+		//print_r("in init\n");
+		if(($req->getActionName()=='post')||($req->getActionName()=='put'))
+		{
+			$accept = $req->getHeader('Content-Type');
+		}
+		elseif($req->getActionName()=='get')
+		{
+			$accept = $req->getHeader('Accept');
+		}
+		
+		$action = $req->getActionName();
+		//print_r("Action : ".$action);
+		
+		$mime = $this->checkSupportedActionMimeType($this->getSupportedAcceptMimeTypes(), $action);
+		
+		if($mime) {
+			$accept = $mime;
+		}
+		// determine output format
+		if (isset(self::$supportedAcceptMimeTypes[$action])) {
+			if (isset(self::$supportedAcceptMimeTypes[$action][$accept])) {
+				$format = self::$supportedAcceptMimeTypes[$action][$accept];
+				//print_r('format :'.$format);
+				$req->setParam('format', $format);
+			}
+		}
+		
+		$contextSwitch = $this->_helper->getHelper('contextSwitch');
+
+		// we'll handle JSON ourselves
+		$contextSwitch->setAutoJsonSerialization(false);
+		
+		foreach (self::$supportedAcceptMimeTypes as $action => $typesarr) {
+			if(($action!="post")&&($action!="put")){
+				$types = array_unique(array_values($typesarr));
+				$contextSwitch->addActionContext($action, $types)->initContext();
+				//print_r($action);
+				//print_r($types);
+			}
+		}
+		
+		// Create an OSLC Connector for Mantis.
+		$this->oslc = new MantisOSLCConnector();
+		
+	}
+	
+
+	
+		/**
+	 * Performs authentication according to the configured AUTH_TYPE configured
+	 *
+	 * @param string $login
+	 * @return True if auth is valid, in which case $login is modified.
+	 * 		   If there was actually no auth requested, then return False, but $login will be set to null.
+	 */
+
+	private function retrieveAuthentication(&$login) {
+		switch (AUTH_TYPE) {
+			case 'basic':
+				return $this->retrieveRequestAuthHttpBasic($login);
+				break;
+			case 'oauth':
+				return $this->checkOauthAuthorization($login);
+				break;
+			default:
+				throw new BadRequestException('Unsupported AUTH_TYPE : '. AUTH_TYPE .' !');
+				break;
+		}
+	}
+	
+	/**
+	 * Helper function that performs HTTP Basic authentication from request parameters/headers
+	 *
+	 * @param string $login
+	 * @return True if auth is valid, in which case $login is modified.
+	 * 		   If there was actually no auth requested, then return False, but $login will be set to null.
+	 */
+
+	private function retrieveRequestAuthHttpBasic(&$login) {
+		// extract login and password from Basic auth
+		$login = null;
+		$password = null;
+
+		$returned = False;
+
+		$request = $this->getRequest();
+		$auth = $request->getHeader('Authorization');
+		//		print_r('Auth :'.$auth);
+		//		print_r('Auth :'.$auth.'!');
+		if (strlen($auth) != 0) {
+			$auth = explode(' ',$auth);
+			if ($auth[0] == 'Basic') {
+				//print_r($auth);
+				$basic = base64_decode($auth[1]);
+				//print_r($basic);
+				$basic = explode(':',$basic);
+
+				$login = $basic[0];
+				$password = $basic[1];
+				//print_r('request username'.$login);
+				//print_r('request password'.$password);
+			}
+			else {
+				throw new BadRequestException('Unsupported auth method : '. $auth[0] .' !');
+			}
+		}
+		if (isset($password)) {
+				
+			$config = array(
+		    	'accept_schemes' => 'basic',
+    			'realm'          => 'Oslc-Demo',
+    			'digest_domains' => '/cm',
+    			'nonce_timeout'  => 3600,
+			);
+				
+			// Http authentication adapter
+			$adapter = new Zend_Auth_Adapter_Http($config);
+
+			// setup the OslcControler's Auth HTTP Basic resolver
+			$basicResolver = $this->oslc->getHttpAuthBasicResolver($login, $password);
+
+			// The authentication check will be performed by Mantis
+			$adapter->setBasicResolver($basicResolver);
+
+			$request = $this->getRequest();
+			$adapter->setRequest($request);
+			$response = $this->getResponse();
+			$adapter->setResponse($response);
+
+			// perform authentication check
+			//$result = $this->auth->authenticate($adapter);
+			$result = $adapter->authenticate();
+			if (!$result->isValid()) {
+				print_r('Access denied for : '. $login .' !');
+			}
+			//print_r($result->getCode());
+			switch ($result->getCode()) {
+				case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:
+					/** do stuff for nonexistent identity **/
+					print_r('Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND');
+					break;
+				case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
+					/** do stuff for invalid credential **/
+					print_r('Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID');
+					break;
+				case Zend_Auth_Result::SUCCESS:
+					/** do stuff for successful authentication **/
+					//					print_r('Zend_Auth_Result::SUCCESS');
+					$returned = True;
+					break;
+				default:
+					/** do stuff for other failure **/
+					print_r('other problem');
+					break;
+			}
+		}
+
+		return $returned;
+	}
+
+	/**
+	 * Checks that OAuth authorization is correct, or fallbacks to Basic Auth
+	 * 
+	 * Will log-in the user corresponding to the OAuth authorization delegation
+	 * 
+	 * @param string $login (write)
+	 */
+	private function checkOauthAuthorization(&$login) {
+		$request = $this->getRequest();
+		$auth = $request->getHeader('Authorization');
+		if ($auth) {
+			$auth_type = explode(' ',$auth);
+			$auth_type = $auth_type[0];
+			if ($auth_type == 'OAuth') {
+				$returned = $this->oslc->checkOauthAuthorization($auth);
+				return $returned;
+			}
+			else {
+				return $this->retrieveRequestAuthHttpBasic($login);
+			}
+		}
+		else {
+			return False;
+		}
+	}
+
+	// Actions for the different REST methods
+
+	/**
+	 * Displays an HTML page for humans when invoked without additional path
+	 */
+	public function indexAction(){
+
+	}
+
+	public function listAction(){
+		throw new BadRequestException('Method list not yet supported !');
+	}
+	
+	/**
+	 * GET REST Action handler : Get one or all changerequests
+	 * 
+	 * Allow /cm/bug/ or /cm/bugs/ to list all changerequests
+	 *  or /cm/bug/bug_id to retrieve one specific changerequest
+	 * 
+	 */
+	public function getAction() {
+		//print_r('getAction');
+
+		// Analyse the arguments of the GET request contained in path
+
+		$params = $this->getRequest()->getParams();
+		//print_r($params);
+		//exit(0);
+
+		// check authentication although it's not yet really useful
+		$login = null;
+		$authenticated = $this->retrieveAuthentication($login);
+		if(isset($login)) {
+			// Basic auth requested
+			if (!$authenticated) {
+				// not succesfully authd as $login
+				// can't go on;
+				throw new Exception('Invalid authentication provided !');
+			}
+		}
+
+		// handle OSLC services catalog access (http://open-services.net/bin/view/Main/OslcServiceProviderCatalogV1)
+		if ( isset($params['id']) && ($params['id'] == "oslc-services")) {
+			$this->_forward('oslcServiceCatalog');
+			//return;
+		}		
+		// handle OSLC-CM service document access
+		elseif (isset($params['oslc-cm-service'])) {
+			$this->_forward('oslcCmServiceDocument');
+			//return;
+		}
+		elseif(($params['ui']=="selection")&&isset($params['project']))
+		{
+			$this->_forward('showSelectionUi');
+			//echo "here";exit;
+		}		
+		elseif(preg_match("/^\/cm\/bug\/[1-9]+[0-9]*\/notes[\/]?$/", $this->getRequest()->getPathInfo()))
+		{
+			$this->_forward('readBugnoteCollection');
+		}
+		
+		elseif(preg_match("/^\/cm\/notes\/[1-9]+[0-9]*[\/]?$/", $this->getRequest()->getPathInfo()))
+		{
+			$this->_forward('readBugnote');
+		}		
+		elseif(preg_match("/^\/cm\/([A-Za-z]?\/)|(0\/)|([1-9]+[0-9]*\/)|(\/)stats_activity[\/]?$/", $this->getRequest()->getPathInfo()))
+		{
+			$proj = $this->getRequest()->getPathInfo();
+			$proj = preg_replace("/^\/cm\//","",$proj);
+			$proj = preg_replace("/\/stats_activity[\/]?$/","",$proj);
+			//print_r($proj);
+			$this->oslc->retrieveStatsByActivity($proj);
+		}
+		
+		elseif(preg_match("/^\/cm\/([A-Za-z]?\/)|(0\/)|([1-9]+[0-9]*\/)|(\/)stats_age[\/]?$/", $this->getRequest()->getPathInfo()))
+		{
+			//print_r("get stats \n");
+			$proj = $this->getRequest()->getPathInfo();
+			$proj = preg_replace("/^\/cm\//","",$proj);
+			$proj = preg_replace("/\/stats_age[\/]?$/","",$proj);
+			$this->oslc->retrieveStatsByAge($proj);
+		}
+		
+		elseif(preg_match("/^\/cm\/([A-Za-z]?\/)|(0\/)|([1-9]+[0-9]*\/)|(\/)stats_date[\/]?$/", $this->getRequest()->getPathInfo()))
+		{
+			//print_r("get stats \n");
+			$proj = $this->getRequest()->getPathInfo();
+			$proj = preg_replace("/^\/cm\//","",$proj);
+			$proj = preg_replace("/\/stats_date[\/]?$/","",$proj);
+			$this->oslc->retrieveStatsByDate($proj);
+		}		
+		else {
+			// Now, do the OSLC-CM resources access work
+			
+			// if no bug was mentioned, then return a resource collection
+			if ((array_key_exists('project', $params))||($params['id']=='bug')||($params['id']=='bugs')) {
+				// forward to an independant action so that it has its own views
+				//print_r("going to readresourcecollectionAction()");
+				$this->_forward('readResourceCollection');
+			}
+			elseif((array_key_exists('bug', $params))||(array_key_exists('bugs', $params)))
+			{
+				// now we're indeed getting one single resource
+				// read the individual resource and pass to the view
+				$this->_forward('readResource');
+
+			
+			}else
+			{
+				throw new NotFoundException("Resource ".$this->getRequest()->getRequestUri()." was not found on the server!");
+			}
+
+			// This is not explicitely required in OSLC-CM V1
+			// In the case of RDF+XML requested, mention it explicitely : LOD friendly
+			$req = $this->getRequest();
+			$accept = $req->getHeader('Accept');
+			switch (true) {
+				case (strstr($accept, 'application/rdf+xml')):
+					$resp = $this->getResponse()->setHeader('Content-Type', 'application/rdf+xml');
+					break;
+			}
+		}
+	}
+	
+	/**
+	 * Handles PUT action as routed by Zend_Rest_Route
+	 * 
+	 * Update of an existing changerequest
+	 * Will be invoked if PUT or if POST on a path relating to resources (due to Zend REST route behaviour)
+	 * So in case of POST, will pass the handling to postAction()
+	 * 
+	 * @return unknown_type
+	 */
+	public function putAction(){
+		//print_r('putAction');
+
+		$req = $this->getRequest();
+		//print_r($req);
+
+		// in case invoked like POST on .../cm/project/whatever we arrive to putAction
+		// so we check such case and then redirect to postAction() if needed
+		if ($req->isPost()) {
+        	//print_r('redirect to post');
+            $this->_forward('post');            
+		}
+		else {
+		
+			// otherwise it is indeed a PUT and we are trying to modify a change request
+			
+			$login = null;
+			$authenticated = $this->retrieveAuthentication($login);
+			if(isset($login)) {
+				// Basic auth requested
+				if (!$authenticated) {
+					// not succesfully authd as $login
+					// can't go on;
+					throw new Exception('Invalid authentication provided !');
+				}
+			}
+
+			$contenttype = $req->getHeader('Content-Type');
+			
+			$contenttype = $contenttype ? $contenttype : 'none';
+
+			switch($contenttype) {
+				case 'application/x-oslc-cm-change-request+xml':
+				case 'application/x-oslc-cm-change-request+json':
+				case 'application/xml':
+				case 'application/json':
+					break;
+				default:
+					//print_r('exception');
+					throw new UnsupportedMediaTypeException('Unknown Content-Type for method put : '. $contenttype .' !');
+					break;
+			}
+
+			$identifier = null;
+
+			$params = $req->getParams();
+			//print_r($params);
+
+			if (array_key_exists('id', $params)) {
+				$identifier = $req->getParam('id');
+			}
+			else {
+				$identifier = $req->getParam('bug');
+
+				if (! isset($identifier)) {
+					throw new ConflictException('No change request id provided !');
+				}
+			}
+
+			// checking if modification
+
+			$modifiedproperties = null;
+
+			$oslc_cm_properties = $req->getParam('oslc_cm_properties');
+			if (isset($oslc_cm_properties)) {
+				$modifiedproperties = explode(',', $oslc_cm_properties);
+				if (array_key_exists('identifier', $modifiedproperties)) {
+					throw new ConflictException('Identifier cannot be modified !');
+				}
+			}
+			/*
+			 print_r($req->isXmlHttpRequest());
+			 print_r($req->getParams());
+			 */
+			if(APPLICATION_ENV=='testing')
+			{
+				$body = $_POST['xml'];
+				//print_r("in testing");
+				//print_r($_POST);
+			}
+			else
+			{
+				$body = file_get_contents('php://input');
+			}
+			//print_r("Body: ".$body."******End of body*******");
+			/*
+			$newresource = $req->getRawBody();
+			print_r($req);
+			print_r($newresource);
+			*/
+			// TODO: This should be done by $this->oslc
+			switch($contenttype) {
+				case 'application/x-oslc-cm-change-request+xml':
+				case 'application/xml':
+					$newchangerequest = MantisChangeRequest::CreateMantisArrayFromXml($body);
+					break;
+				case 'application/x-oslc-cm-change-request+json':
+				case 'application/json':
+					$newchangerequest = MantisChangeRequest::CreateMantisArrayFromJson($body);
+					break;
+			}
+
+			if(!$this->oslc->checkChangeRequestExists($identifier))
+			{
+				throw new ConflictException("Change Request to be updated doesn't exist!");
+			}
+			else
+			{
+				$this->oslc->updateChangeRequest($identifier, $newchangerequest, $modifiedproperties);
+			}
+						
+		}
+	}
+	
+	/**
+	 * Handles POST action as routed by Zend_Rest_Route
+	 * 
+	 * Creation of a new changerequest
+	 * 
+	 * May be invoked from putAction() because of Zend pecularities
+	 * 
+	 * @return unknown_type
+	 */
+	public function postAction(){
+
+		$req = $this->getRequest();
+		
+		// check that we're indeed invoked by a POST request
+		if(! $req->isPost()) {
+			throw new Exception('postAction invoked without POST !');
+		}
+		
+		$params = $req->getParams();
+		//print_r($params);
+
+		// check authentication although it's not yet really useful
+		$login = null;
+		$authenticated = $this->retrieveAuthentication($login);
+		if(isset($login)) {
+			// Basic auth requested
+			if (!$authenticated) {
+				// not succesfully authd as $login
+				// can't go on;
+				throw new Exception('Invalid authentication provided !');
+			}
+		}
+		
+		
+		$req = $this->getRequest();
+		//print_r("Request: ".$req);
+
+		$contenttype = $req->getHeader('Content-Type');
+		
+		$contenttype = $contenttype ? $contenttype : 'none';
+
+		switch($contenttype) {
+			case 'application/x-oslc-cm-change-request+xml':
+			case 'application/x-oslc-cm-change-request+xml; charset=UTF-8':
+			case 'application/x-oslc-cm-change-request+json':
+			case 'application/json':
+			case 'application/xml':
+				break;
+			default:
+				//print_r('exception');
+				throw new UnsupportedMediaTypeException('Unknown Content-Type for method post : '. $contenttype .' !');
+				break;
+		}
+
+		//print_r(APPLICATION_ENV);
+		// used for PhpUnit tests.
+		if(APPLICATION_ENV=='testing')
+		{
+			$body = $_POST['xml'];
+			//print_r("in testing");
+			//print_r($_POST);
+		}
+		else
+		{
+			$body = file_get_contents('php://input');
+		}
+		
+		if(array_key_exists('project',$params)) {
+			// create a change request
+			switch($contenttype) {
+				case 'application/x-oslc-cm-change-request+xml':
+				case 'application/xml':
+				case 'application/x-oslc-cm-change-request+xml; charset=UTF-8':
+					$newchangerequest = MantisChangeRequest::CreateMantisArrayFromXml($body);
+					break;
+				case 'application/x-oslc-cm-change-request+json':
+				case 'application/json':
+					$newchangerequest = MantisChangeRequest::CreateMantisArrayFromJson($body);
+					break;
+			}
+
+			$creationparams = array('project' => $params['project'],
+									'new' => $newchangerequest);
+
+			// pass the creation work to the OSLC connector
+			$identifier = $this->oslc->createChangeRequest($creationparams);
+		}
+		elseif(array_key_exists('bug',$params))
+		{
+			switch($contenttype) {
+				case 'application/x-oslc-cm-change-request+xml':
+				case 'application/xml':
+				case 'application/x-oslc-cm-change-request+xml; charset=UTF-8':
+					$notes_arr = MantisChangeRequest::CreateMantisNotesArrayFromXml($body);
+					break;
+				case 'application/x-oslc-cm-change-request+json':
+				case 'application/json':
+					$notes_arr = MantisChangeRequest::CreateMantisNotesArrayFromJson($body);
+					break;
+			}
+			//print_r($req->getPathInfo());
+			$path = $req->getPathInfo();
+			if (preg_match("/^\/cm\/bug\/[1-9]+[0-9]*\/notes[\/]?$/", $path)) 
+			{
+				$this->oslc->addBugnotes($params['bug'],$notes_arr);
+				$identifier = $params['bug']."/notes";
+				//print_r($notes_arr);
+			}
+			else
+			{
+				throw new BadRequestException('Incorrect syntax for bugnote URL');
+			}
+			
+		}
+		else
+		{
+			throw new ConflictException('Need a valid project to create change request !');
+		}
+	
+		
+		// prepare redirection
+		$httpScheme = $this->getRequest()->getScheme();
+		$httpHost = $this->getRequest()->getHttpHost();
+		$requestUri = $this->getRequest()->getRequestUri();
+		$baseURL = $this->getFrontController()->getBaseUrl();
+		$controllerName = $this->getFrontController()->getDefaultControllerName();
+
+		if(APPLICATION_ENV=='testing')
+		{
+			$newlocation = '/'.$controllerName.'/bug/'.$identifier;
+		}
+		else
+		{
+			$newlocation = $httpScheme.'://'.$httpHost.$baseURL.'/'.$controllerName.'/bug/'.$identifier;
+		}
+		print_r($newlocation);
+		
+		$this->getResponse()->setRedirect($newlocation,201);
+		
+	}
+
+	public function deleteAction(){
+		print_r('deleteAction');
+		//$this->_forward('get');
+		throw new BadRequestException('Method delete not yet supported !');
+	}
+	
+	/* returns a collection of OSLC CM ChangeRequests */
+
+	/**
+	 * GET REST Action handler : Get all changerequests
+	 * 
+	 * Allow /cm/bug/ or /cm/bugs/ to list all changerequests
+	 * 
+	 * Invoked as rerouted from getAction()
+	 * 
+	 */
+	public function readresourcecollectionAction()	{
+		
+		$content_type = $this->checkSupportedActionMimeType($this->getSupportedAcceptMimeTypes(), $this->getRequest()->getActionName());
+		if (! $content_type) {
+		  //			print_r("error");
+		  throw new NotAcceptableException("Accept header ".$this->getRequest()->getHeader('Accept')." not supported!");
+		}
+		
+		$req = $this->getRequest();
+		$params = $req->getParams();
+		
+		// load the model
+		$params = $this->oslc->init($params);
+		//print_r($params);
+
+		// construct ATOM feed-like header
+		$httpScheme = $this->getRequest()->getScheme();
+		$httpHost = $this->getRequest()->getHttpHost();
+		$requestUri = $this->getRequest()->getRequestUri();
+		$pos = strpos($requestUri, "?");
+		if($pos)	{
+			//removing the query string from the uri if it exists
+			$requestUri = substr($requestUri, 0, $pos);
+		}
+		
+		$requestUri = str_replace('bugs','bug', $requestUri);
+		$requestUri = preg_replace("/project.*/", 'bug/', $requestUri);
+		$requestUri = $requestUri.(($requestUri[strlen($requestUri)-1]=='/')?'':'/');
+		$prefix = $httpScheme.'://'.$httpHost.$requestUri;
+
+		// get all resources
+		$collection = $this->oslc->getResourceCollection($prefix);
+		
+		// construct an intermediate array that will be used to populate the view
+		$preparedCollection = array ('id'         => $httpScheme.'://'.$httpHost.$requestUri,
+									'collection'     => $collection
+							);
+		// Add request params so they ca reach views.
+		foreach($params as $key => $value){
+			$preparedCollection[$key] = $value;
+		}
+
+		// populate the view with the loaded values
+		foreach($preparedCollection as $key => $value) {
+			$this->view->$key = $value;
+		}
+
+		//print_r($this->view);
+		$this->getResponse()->setHeader('Content-Type', $content_type);
+		
+	}
+	
+	/**
+	 * Retrieve an individual resource and populates the view of an OSLC CM ChangeRequest
+	 * 
+	 */
+	public function readresourceAction()
+	{
+		if (! $this->checkSupportedActionMimeType($this->getSupportedAcceptMimeTypes(), $this->getRequest()->getActionName())) {
+			return;
+		}
+				
+		//(preg_match("/^\/cm\/bug\/[1-9]+[0-9]*[\/]?$/", $this->getRequest()->getPathInfo()))
+		$params = $this->getRequest()->getParams();
+		$identifier = $params['bug'];
+		// prepare resource URI
+		$httpScheme = $this->getRequest()->getScheme();
+		$httpHost = $this->getRequest()->getHttpHost();
+		$requestUri = $this->getRequest()->getRequestUri();
+
+		$uri = $httpScheme.'://'.$httpHost.$requestUri;
+		$content_type = $this->checkSupportedActionMimeType($this->getSupportedAcceptMimeTypes(), $this->getRequest()->getActionName());
+		
+		if (! $content_type) {
+		  //			print_r("error");
+		  $this->_forward('UnknownAcceptType','error');
+		  return;
+		}
+		
+		$preparedChangeRequest = $this->oslc->getChangeRequest($identifier, $uri);
+		//print_r($preparedChangeRequest);
+
+		if (isset($preparedChangeRequest)) {
+
+			// populate the view with the model
+			foreach($preparedChangeRequest as $field => $value) {
+				$this->view->{$field} = $value;
+			}
+			
+			$this->getResponse()->setHeader('Content-Type', $content_type);
+		}
+
+		else
+		{
+			$this->view->missing_resource = $identifier;
+			$this->_forward('ResNotFound','error');
+
+		}
+		//print($content_type);
+	}
+	
+	public function readbugnotecollectionAction() {
+		if (! $this->checkSupportedActionMimeType($this->getSupportedAcceptMimeTypes(), $this->getRequest()->getActionName())) {
+			return;
+		}
+		
+		$req = $this->getRequest();
+		$params = $req->getParams();
+		
+		$httpScheme = $this->getRequest()->getScheme();
+		$httpHost = $this->getRequest()->getHttpHost();
+		$requestUri = $this->getRequest()->getRequestUri();
+		$requestUri = $requestUri.(($requestUri[strlen($requestUri)-1]=='/')?'':'/');
+		$bugnoteUri = preg_replace("/bug\/[1-9]+[0-9]*\//", '', $requestUri);
+		$prefix = $httpScheme.'://'.$httpHost.$bugnoteUri;		
+
+		//print_r("get bugnotes \n");
+		$collection = $this->oslc->getBugnoteCollection($params['bug'], $prefix);
+		
+		// construct an intermediate array that will be used to populate the view
+		$preparedCollection = array ('id'         => $httpScheme.'://'.$httpHost.$requestUri,
+							  'collection'     => $collection);
+
+		// populate the view with the loaded values
+		foreach($preparedCollection as $key => $value) {
+			$this->view->$key = $value;
+		}
+		//print_r($this->view);
+	}
+	
+	public function readbugnoteAction()
+	{
+		$req = $this->getRequest();
+		$params = $req->getParams();
+		
+		$httpScheme = $this->getRequest()->getScheme();
+		$httpHost = $this->getRequest()->getHttpHost();
+		$requestUri = $this->getRequest()->getRequestUri();
+		$prefix = $httpScheme.'://'.$httpHost.$requestUri;		
+
+		//print_r("get a single bugnote \n");
+		$note = $this->oslc->getBugnote($params['notes'], $prefix);
+		
+		if (isset($note)) {
+
+			// populate the view with the model
+			foreach($note as $field => $value) {
+				$this->view->{$field} = $value;
+			}
+		}
+
+		else
+		{
+			$this->view->missing_resource = $params['notes'];
+			$this->_forward('ResNotFound','error');
+
+		}
+		
+	}
+	
+	/**
+	 * Handle OSLC services catalog access (http://open-services.net/bin/view/Main/OslcServiceProviderCatalogV1)
+	 */
+	public function oslcservicecatalogAction() {
+		
+		$content_type = $this->checkSupportedActionMimeType($this->getSupportedAcceptMimeTypes(), $this->getRequest()->getActionName());
+		if (! $content_type) {
+		  //			print_r("error");
+		  $this->_forward('UnknownAcceptType','error');
+		  return;
+		}
+		
+		// each project will generate its own service description
+		$proj_arr = $this->oslc->getProjectList();
+
+		$this->view->projects = $proj_arr;
+		
+		$this->getResponse()->setHeader('Content-Type', $content_type);
+	}
+	
+	public function oslccmservicedocumentAction() {
+		$content_type = $this->checkSupportedActionMimeType($this->getSupportedAcceptMimeTypes(), $this->getRequest()->getActionName());
+		if (! $content_type) {
+		  //			print_r("error");
+		  $this->_forward('UnknownAcceptType','error');
+		  return;
+		}
+		
+		$req = $this->getRequest();
+		$params = $req->getParams();
+		$project = $params['oslc-cm-service'];
+		$this->view->project = $project;
+
+		$this->getResponse()->setHeader('Content-Type', $content_type);
+
+	}
+	
+	public function showselectionuiAction()
+	{
+		$req = $this->getRequest();
+		$params = $req->getParams();
+		$project = $params['project'];
+		$data = $this->oslc->getDataForSelectionUi($project);
+		$this->view->data = $data;
+	}
+	
+}
+
+?>

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/MantisOSLCConnector.php
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/MantisOSLCConnector.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/MantisOSLCConnector.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,1602 @@
+<?php
+
+/**
+ * This file is (c) Copyright 2009 by Olivier BERGER, Madhumita DHAR, 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.
+ *
+ */
+
+/**
+ * This is the Mantis OSLC-CM connector, which specializes the generic 
+ * OSLC-CM controller (in oslc.inc.php) 
+ */
+
+/* $Id:$*/
+
+// load base class OslcConnector
+$controller_dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
+
+// load Mantis specific classes
+require_once($controller_dir . 'OSLCConnector.php');
+
+// load Mantis specific model classes
+$model_dir = APPLICATION_PATH.'/models/';
+require_once($model_dir . 'mantis.inc.php');
+
+// load MantisBt internal APIs
+// MANTIS_DIR is set in config.inc.php
+$t_mantis_dir = MANTIS_DIR;
+
+// TODO : explain the following line :
+$g_bypass_headers = true;
+require_once( $t_mantis_dir . 'core.php' );
+
+// we then need to make sure all globals are properly initialized (important when in phpunit)
+// see tests/mantis-config_inc.php(.example) for the setting of 'MANTIS_GLOBALS_SETAGAIN'
+defined('MANTIS_GLOBALS_SETAGAIN') ||
+		define('MANTIS_GLOBALS_SETAGAIN', '0');
+// by default nothing like this is done, so loading core.php is enough to have all globals set as needs be
+// only when in phpunit is this set and this hack is done
+if(MANTIS_GLOBALS_SETAGAIN == 1) {
+	foreach(get_defined_vars() as $key=>$value)
+	{
+	       if((substr($key,0,2)=="g_")&&(!array_key_exists($key, $GLOBALS)))
+	       {
+	       		if(!isset($GLOBALS[$key])) {
+	       			//print('set : $GLOBALS['.$key.']='.$value);
+	               $GLOBALS[$key] = $value;
+	       		}
+	       }
+	}
+}
+
+require_once( $t_mantis_dir . 'core/summary_api.php' );
+
+
+foreach(get_defined_vars() as $key=>$value)
+{
+       if((substr($key,0,2)=="g_")&&(!array_key_exists($key, $GLOBALS)))
+       {
+       		if(!isset($GLOBALS[$key])) {
+       			//print('set : $GLOBALS['.$key.']='.$value);
+               $GLOBALS[$key] = $value;
+       		}
+       }
+}
+// Mantis specific classes used by the controller
+
+// HTTP auth adapater's resolver using Mantis APIs for user + password verification
+class Mantis_Http_Auth_Resolver implements Zend_Auth_Adapter_Http_Resolver_Interface
+{
+	// the query's elements
+	protected $username = null;
+	protected $password = null;
+	
+	public function __construct($username, $password)
+	{
+		$this->username = $username;
+		$this->password = $password;
+	}
+
+	/**
+	 * Check if the password matches with Mantis database
+	 */
+	public function resolve($username, $realm)
+	{
+
+		//print_r('username :'. $username);
+		//print_r('realm :'. $realm);
+		$returned = false;
+
+		//		print_r('login :'.$this->username);
+		//		print_r('password :'.$this->password);
+		//		exit(0);
+
+		// get user id
+		$t_user_id = user_get_id_by_name( $username );
+		// retrieve the user's encoded pasword
+		$password = user_get_field( $t_user_id, 'password' );
+
+		// check if the encoding of the provided password matches the one retrieved from DB
+		$encoded_pass = auth_process_plain_password($this->password , null, MD5 );
+
+		$user_id = null;
+		// if passwords match, we can return the clear text password to the HTTP adapter
+		if ( $encoded_pass == $password ) {
+
+			$return_val = auth_attempt_script_login( $username, $this->password );
+			//print_r('login'.$return_val.'!');
+			//	echo $return_val;
+
+			if ($return_val) {
+				$user_id = auth_get_current_user_id();
+				//print_r('user :');
+				//print_r($user_id);
+			}
+		}
+		if (!isset($user_id)) {
+			throw new ForbiddenException('Mantis user/password provided were incorrect!');
+		}
+		else {
+			$returned = $this->password;
+		}
+
+		return $returned;
+	}
+}
+
+/**
+ * Mantis OSLC server connector
+ *
+ * @author olivier
+ *
+ */
+class MantisOSLCConnector extends OSLCConnector {
+
+
+	private static $status_arr = array('new'=>10, 'feedback'=>20, 'acknowledged'=>30, 'confirmed'=>40, 'assigned'=>50, 'resolved'=>80, 'closed'=>90);
+	
+	private static $priority_arr = array('none'=>10, 'low'=>20, 'normal'=>30, 'high'=>40, 'urgent'=>50, 'immediate'=>60);
+	
+	private static $severity_arr = array('feature'=>10, 'trivial'=>20, 'text'=>30, 'tweak'=>40, 'minor'=>50, 'major'=>60, 'crash'=>70, 'block'=>80);
+	
+	private static $where_params = array(
+		'dc:creator',
+		'dc:type',
+		'mantisbt:severity',
+		'mantisbt:status',
+		'mantisbt:priority',
+		'mantisbt:target_version',
+		'mantisbt:version_number',
+		'mantisbt:project'
+	);
+	
+	private static $orderBy_params = array(
+		'mantisbt:priority',
+		'dc:identifier',
+		'dc:type',
+		'mantisbt:severity',
+		'mantisbt:status',
+		'dc:modified',
+		'dc:title'
+	);
+	
+	private static $properties_params = array( 	//TODO synchronize with models/mantis.inc.php 
+												//where the properties are implemented
+		'dc:identifier',
+		'dc:title',
+		'dc:description',
+		'dc:creator',
+		'mantisbt:project',
+		'mantisbt:status',
+		'mantisbt:priority',
+		'mantisbt:severity',
+		'mantisbt:version',
+		'mantisbt:target_version',
+		'dc:modified',
+		'dc:created',
+		'mantisbt:version_number' 
+	);
+	
+	/**
+	 * Filter only meaningful parameters provided in the REST GET request
+	 * 
+ 	 * Initially $params may contain 'id' => 'bug' or 'id' => 'bugs' for 
+	 * all resources to be loaded or 'bug' => identifier for one 
+	 * resource, so a filtering and normalization is needed
+	 *
+	 * @param array $params
+	 * @return array
+	 */
+	protected function filterRequestParams($params) {
+	
+		// if only one bug requested
+		$identifier = null;
+
+		// if a project  is filtered on
+		$project = null; //by default for all projects
+
+		//print_r($params);
+		// Process the args provided by Zend REST
+		// potential args that matter :
+		//  'id' => 'bug[s]' : all bugs to be returned
+		//  'bug' => bugid : only one bug
+		//  'project' => projid : only one project's bugs
+		//  none of these : all bugs
+
+		// if ../cm/anything_but_slash
+		if (is_array($params)) {
+			if (array_key_exists('id', $params)) {
+				// anything but ../cm/bug or ../cm/bugs
+				if ( ($params['id'] != "bug") && ($params['id'] != "bugs")) {
+					throw new NotFoundException('Unknown resource '.$params['id'].' !');
+				}
+			}
+			else {
+				// case of ../cm/project/projid
+				if (array_key_exists('project', $params)) {
+					$project = $params['project'];
+				}
+				// case of ../cm/bug/bugid
+				if (array_key_exists('bug', $params)) {
+					$identifier = $params['bug'];
+				}
+				// forbid ../cm/bugs/whatever
+				if (array_key_exists('bugs', $params)) {
+					throw new BadRequestException('Incorrect resource bugs['.$params['bugs'].'] !');
+				}
+			}
+		}
+		
+		// the args that need to be passed to initialize the model
+		$modelparams = array();
+		
+		if(isset($project)) {
+			$modelparams['project'] = $project;
+		}
+		if ($identifier) {
+			$modelparams['bug'] = $identifier;
+		}
+		
+		return $modelparams;		
+	}
+	
+	protected function createQueryFromFilter($filter)
+	{
+		//print_r($filter);
+		$query = array();
+		$query['type'] = 1;
+		$query['view_type'] = "advanced";
+		$query['user_monitor'][]= 0;
+		$query['handler_id'][] = 0;
+		$query['show_resol$orderBy_paramsution'][] = 0;
+		$query['show_profile'][] = 0;
+		$query['view_state'] = 0;
+		$query['sticky_issues'] = "on";
+		$query['highlight_changed'] = 6;
+		$query['relationship_type'] = -1;
+		$query['relationship_bug'] = 0;
+		$query['platform'][] = 0;
+		$query['os'][] = 0;
+		$query['os_build'][] = 0;
+		$query['tag_string'] = "";
+		$query['note_user_id'][] = 0;
+		
+		if(array_key_exists('limit', $filter))	{
+			$query['per_page'] = $filter['limit'];		
+		}else 	{
+			$query['per_page'] = 0;
+		}
+		
+		if(array_key_exists('offset', $filter))	{
+			$query['page_number'] = $filter['offset'];		
+		}else 	{
+			$query['page_number'] = 1;		
+		}
+		
+		if(array_key_exists('where', $filter))	{
+			foreach($filter['where']['terms'] as $term)	{
+				if($term[0]=='=')	{	
+					$term[2] = str_replace("\"", "", $term[2]);
+					//print_r($term[2]);		
+					switch($term[1])	{
+						case self::$where_params[0]:
+							if($creator_id = user_get_id_by_name($term[2]))	{
+								$query['reporter_id'][] = $creator_id;
+							}else	{
+								throw new BadRequestException("Invalid dc:creator: ".$term[2]);
+							}
+							break;
+						case self::$where_params[1]:
+							$category_array = category_get_all_rows(0);
+							$flag_type = 0;
+							foreach( $category_array as $category_row )
+							{
+								if(strcasecmp($category_row['name'],$term[2])==0 ) {
+									$query['show_category'][] = $category_row['name'];
+									$flag_type = 1;
+									break;
+								}
+							}
+							if($flag_type==0) {
+								throw new BadRequestException("Invalid dc:type: ".$term[2]);
+							}
+							break;
+						case self::$where_params[2]:
+							if (array_key_exists($term[2],self::$severity_arr))	{
+								$query['show_severity'][] = self::$severity_arr[$term[2]];
+							}else	{
+								throw new BadRequestException('Invalid mantisbt:severity value specified!');
+							}
+							break;
+						case self::$where_params[3]:
+							if (array_key_exists($term[2],self::$status_arr))	{
+								$query['show_status'][] = self::$status_arr[$term[2]];
+							}else	{
+								throw new BadRequestException('Invalid mantisbt:status value specified!');
+							}
+							break;
+						case self::$where_params[4]:
+							if (array_key_exists($term[2],self::$priority_arr))	{
+								$query['show_priority'][] = self::$priority_arr[$term[2]];
+							}else	{
+								throw new BadRequestException('Invalid mantisbt:priority value specified!');
+							}
+							break;
+						case self::$where_params[5]:
+							if(version_get_id($term[2], 0))	{
+								$query['target_version'][] = $term[2];
+							}else	{
+								throw new NotFoundException('Version '.$term[2].' does not exist!');
+							}
+							break;
+						case self::$where_params[6]:
+							$v_num_id = custom_field_get_id_from_name("version_number");
+							if(custom_field_validate( $v_num_id, $term[2] ))	{
+								$query['custom_field_'.$v_num_id][] = $term[2];
+							}else {
+								throw new BadRequestException("Invalid value ".$term[2]." specified for mantisbt:version_number!");
+							}
+							break;
+						case self::$where_params[7]:
+							if(project_exists(project_get_id_by_name($term[2])))	{
+								$query['project_id'][] = $term[2];
+							}else {
+								throw new BadRequestException("Invalid value ".$term[2]." specified for mantisbt:project!");
+							}
+							break;
+						default:  throw new BadRequestException("Invalid attribute ".$term[1]." specified in oslc_where!");
+						break;
+					}
+				}
+			}		
+		}
+		
+		if(!array_key_exists('reporter_id', $query))	{
+			$query['reporter_id'][] = 0;
+		}
+		
+		if(!array_key_exists('show_category', $query))	{
+			$query['show_category'][] = 0;
+		}
+		
+		if(!array_key_exists('show_severity', $query))	{
+			$query['show_severity'][] = 0;
+		}
+		
+		if(!array_key_exists('show_status', $query))	{
+			$query['show_status'][] = 0;
+		}
+		
+		if(!array_key_exists('show_priority', $query))	{
+			$query['show_priority'][] = 0;
+		}
+		
+		if(!array_key_exists('target_version', $query))	{
+			$query['target_version'][] = 0;
+		}
+		
+		$custom_field_ids = custom_field_get_linked_ids();
+		foreach($custom_field_ids as $id)	{
+			if(!array_key_exists('custom_field_'.$id, $query))	{
+				$query['custom_field_'.$id][] = 0;
+			}
+		}
+		
+		if(!array_key_exists('project_id', $query))	{
+			$query['project_id'][] = 0;
+		}
+
+		if(array_key_exists('orderBy', $filter))	{
+			if(count($filter['orderBy'])>2)	{
+				throw new ConflictException("Sorting over more than two attributes is not supported for mantis!");
+			}else {
+				for($i=0;$i<2;$i++)	{
+					if(array_key_exists($i, $filter['orderBy']))	{
+						$query['dir_'.$i] = $filter['orderBy'][$i][0];
+						switch($filter['orderBy'][$i][1])	{
+							case self::$orderBy_params[0]: $query['sort_'.$i] = "priority";
+								break;
+							case self::$orderBy_params[1]: $query['sort_'.$i] = "id";
+								break;
+							case self::$orderBy_params[2]: $query['sort_'.$i] = "category_id";
+								break;
+							case self::$orderBy_params[3]: $query['sort_'.$i] = "severity";
+								break;
+							case self::$orderBy_params[4]: $query['sort_'.$i] = "status";
+								break;
+							case self::$orderBy_params[5]: $query['sort_'.$i] = "last_updated";
+								break;
+							case self::$orderBy_params[6]: $query['sort_'.$i] = "summary";
+								break;
+							default: throw new ConflictException("Sorting over attribute ".$filter['orderBy'][$i][1]." is not supported for mantis!");
+								break; 
+						}
+						
+					}else	{
+						$query['dir_'.$i] = "";
+						$query['sort_'.$i] = "";
+					}
+				}
+			}
+			
+		}else	{
+			$query['dir_0'] = "";
+			$query['dir_1'] = "";
+			$query['sort_0'] = "";
+			$query['sort_1'] = "";
+		}
+
+		if (array_key_exists('searchTerms', $filter))	{
+			$terms = "";
+			foreach ($filter['searchTerms'] as $term) {
+				$terms = $terms.$term." " ;
+			}
+			//print_r($terms);
+			$query['search'] = substr($terms, 0, -1);
+		}else 	{
+			$query['search'] = "";
+		}		
+		
+		return $query;
+	}
+	
+	/*
+	 * Retrieves the data to be displayed in the selection ui
+	 */
+	public function getDataForSelectionUi($project)
+	{
+		$data = array();
+		
+		//check project validity
+		if(!is_numeric($project)) {
+			$project = project_get_id_by_name($project);
+		}
+		if(project_exists($project))	{
+			$data['project'] = project_get_name($project);
+		}else {
+			throw new BadRequestException("Invalid project specified!");
+		}
+		
+		
+		//construct array for oslc.where with all possible values for each attribute
+		foreach (self::$where_params as $param) {
+			if($param=='dc:creator')
+			{
+				foreach(project_get_all_user_rows($project) as $user)	{
+					$data['where'][$param][] = $user['username'];
+				}
+			}
+			if($param=='dc:type')
+			{
+				foreach(category_get_all_rows($project) as $row){
+					$data['where'][$param][] = $row['name'];
+				}
+			}
+			if($param=='mantisbt:severity')
+			{
+				foreach (self::$severity_arr as $key => $value) {
+					$data['where'][$param][] = $key;
+				}
+			}
+			if($param=='mantisbt:status')
+			{
+				foreach (self::$status_arr as $key => $value) {
+					$data['where'][$param][] = $key;
+				}
+			}
+			if($param=='mantisbt:priority')
+			{
+				foreach (self::$priority_arr as $key => $value) {
+					$data['where'][$param][] = $key;
+				}
+			}
+			if($param=='mantisbt:target_version')
+			{
+				foreach (version_get_all_rows($project) as $version) {
+					$data['where'][$param][] = $version['version'];
+				}
+			}
+			if($param=='mantisbt:version_number')
+			{
+				$def = custom_field_get_definition(custom_field_get_id_from_name("version_number"));
+				foreach (custom_field_distinct_values($def, $project) as $v_num) {
+					$data['where'][$param][] = $v_num;
+				}
+				
+			}
+						
+		}
+		
+		//construct array for oslc.properties
+		$data['properties'] = self::$properties_params;
+		
+		//construct array for oslc.orderBy
+		$data['orderBy'] = self::$orderBy_params;
+		
+		return $data;
+		
+	}
+	
+	protected function postQuery($filter, $fields)
+	{
+		/*$post = array();
+		$data = "type=1&page_number=1&view_type=advanced&reporter_id%5B%5D=2&user_monitor%5B%5D=0&handler_id%5B%5D=0&show_category%5B%5D=General&show_severity%5B%5D=10&show_resolution%5B%5D=0&show_profile%5B%5D=0&show_status%5B%5D=10&show_priority%5B%5D=20&target_version%5B%5D=Branch+2.1&per_page=0&view_state=10&sticky_issues=on&highlight_changed=6&relationship_type=-1&relationship_bug=0&platform%5B%5D=0&os%5B%5D=0&os_build%5B%5D=0&tag_string=&custom_field_1%5B%5D=1.1&note_user_id%5B%5D=2&sort_0=last_updated&dir_0=DESC&sort_1=status&dir_1=DESC&project_id%5B%5D=0&search=random+post";
+		$data = "type=1&page_number=1&view_type=advanced&reporter_id%5B%5D=0&user_monitor%5B%5D=0&handler_id%5B%5D=0&show_category%5B%5D=General&show_severity%5B%5D=0&show_resolution%5B%5D=0&show_profile%5B%5D=0&show_status%5B%5D=10&show_priority%5B%5D=0&target_version%5B%5D=0&per_page=100&view_state=0&sticky_issues=on&highlight_changed=6&relationship_type=-1&relationship_bug=0&platform%5B%5D=0&os%5B%5D=0&os_build%5B%5D=0&tag_string=&custom_field_1%5B%5D=0&note_user_id%5B%5D=0&sort_0=summary&dir_0=ASC&sort_1=last_updated&dir_1=DESC&project_id%5B%5D=0&search=random+post";
+		parse_str($data, $post);
+		print_r($post);*/
+		
+		$post = array();
+		$post = $this->createQueryFromFilter($filter);
+		
+		//print_r($post);
+		foreach($post as $key => $value) //to mimic POST action on view_all_set.php
+		{
+			$_POST[$key] = $value;
+		}
+		$_POST['temporary']=true;
+		
+		//another option, to copy all the code from view_all_set.php to a local file mantisquery.php
+		//include APPLICATION_PATH.'/models/'.'mantisquery.php';
+		
+		//to disable the redirection code in view_all_set.php
+		$temp_stop_on_errors = config_get_global( 'stop_on_errors');
+		config_set_global( 'stop_on_errors' , ON);
+		global $g_error_handled;
+		$temp_g_error_handled = $g_error_handled;
+		$g_error_handled = true;
+		
+		include MANTIS_DIR.'view_all_set.php';
+		$_POST['filter']=$t_token_id;
+		//print_r("BACK TO POST QUERY");
+		
+		//putting everything back to previous state
+		config_set_global( 'stop_on_errors' , $temp_stop_on_errors);
+		$g_error_handled = $temp_g_error_handled;
+		
+		$f_page_number		= $post['page_number'];
+
+		$t_per_page = null;
+		$t_bug_count = null;
+		$t_page_count = null;
+	
+		$rows = filter_get_bug_rows( $f_page_number, $t_per_page, $t_page_count, $t_bug_count, null, null, null, true );
+		
+		/*foreach($rows as $bug)
+		{
+			print_r($bug->id."-");
+		}
+		*/
+		
+		$this->changerequests = new ChangeRequestsMantisDb($rows, $fields);
+		//print_r($this->changerequests);
+		
+	}
+			
+	/*
+	 * Constructs the model from the Mantis DB
+	 *
+	 * TODO : remove provided project if not found in DB
+	 * 
+	 * @param array $params contains 'project' if filtered on particular project
+	 */
+	protected function fetchChangeRequests($params=null)
+	{
+		$rows	= null;
+
+		// This has only been tested really with GET/retrieval
+		if (is_array($params)) {
+			$project = null;	
+		
+			if (isset($params['project'])) {
+				$project = $params['project'];
+			}
+
+			//global $g_log_level;
+			//$g_log_level = LOG_FILTERING;
+
+			$t_offline_file = dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'mantis_offline.php';
+			//	print_r($t_offline_file);
+			//	if ($t_offline_file)
+			//	   print_r('problem');
+
+			$user_id = null;
+			//		$return_val = auth_attempt_script_login( 'administrator' );
+			
+			if (auth_is_user_authenticated())
+			{
+				// this normally redirects to login page
+				$user_id = auth_get_current_user_id();
+			}
+
+			if (! isset($user_id)) {
+				throw new Exception('Could not authenticate user '.$login.' !');
+			}
+			//auth_ensure_user_authenticated();
+			//print_r('do query');
+			$f_page_number = 1;
+			$t_per_page = -1 ; // all bugs at once
+			$t_page_count = null;
+			$t_bug_count = null;
+			$t_custom_filter = null;
+			if(is_int($project))
+			{
+				$t_project_id = $project;
+			}
+			else
+			{
+				$t_project_id = project_get_id_by_name($project);
+			}
+			
+			//print_r($t_project_id);
+			$t_user_id = null;
+			$t_show_sticky = null;
+
+			$rows = filter_get_bug_rows( $f_page_number, $t_per_page, $t_page_count, $t_bug_count, $t_custom_filter, $t_project_id, $t_user_id, $t_show_sticky);
+			//print_r($t_bug_count);
+			//print_r('Rows :');
+			//print_r($rows);
+			//exit(0);
+			if ( $rows === false ) {
+				throw new NotFoundException('No bugs found !');
+			}
+		}
+
+		$this->changerequests = new ChangeRequestsMantisDb($rows, $params['fields']);
+		//print_r($this->changerequests);
+
+	}
+	
+	public function getChangeRequest($id, $uri)
+	{
+		$row[0] = bug_get($id, true);
+		$changerequest = new ChangeRequestsMantisDb($row);
+		//print_r($this->prepareChangeRequest($changerequest[$id], $uri));
+		return $this->prepareChangeRequest($changerequest[$id], $uri);
+	}
+	
+	public function getBugnoteCollection($bugid, $url)
+	{
+		$tmp_arr = bugnote_get_all_visible_bugnotes($bugid, 'DESC', -1);
+		//print_r($tmp_arr);
+		$notes_arr = array();
+		foreach($tmp_arr as $note)
+		{
+			$notes['resource']['dc:title'] = "Bugnote-".$note->id;
+			$notes['resource']['dc:identifier'] = $url.$note->id;
+			$notes['resource']['dc:creator'] = user_get_name($note->reporter_id);
+			$notes['resource']['dc:description'] = $note->note;
+			$notes['resource']['dc:created'] = date(DATE_ATOM, $note->date_submitted);
+			$notes['resource']['dc:modified'] = date(DATE_ATOM, $note->last_modified);
+			$notes['id'] = $notes['resource']['dc:identifier'];
+			$notes['title'] = $notes['resource']['dc:title'];
+			//print_r($note->id);
+			$notes_arr[] = $notes;
+			
+		}
+		return $notes_arr;
+	}
+	
+	public function getBugnote($bugnote_id, $url)
+	{
+		if(!bugnote_exists($bugnote_id))
+		{
+			throw new Exception("Bugnote ".$bugnote_id." does not exist!");
+		}
+		
+		$note['id'] = $url;
+		
+		$note['resource']['dc:title'] = "Bugnote-".$bugnote_id;
+		$note['resource']['dc:identifier'] = $url;
+		$note['resource']['dc:description'] = bugnote_get_text($bugnote_id);
+		
+		$creator = bugnote_get_field($bugnote_id, 'reporter_id');
+		$note['resource']['dc:creator'] = user_get_name($creator);
+				
+		$created = bugnote_get_field($bugnote_id, 'date_submitted');
+		$note['resource']['dc:created'] = date(DATE_ATOM, $created);
+		
+		$modified = bugnote_get_field($bugnote_id, 'last_modified');
+		$note['resource']['dc:modified'] = date(DATE_ATOM, $modified);
+
+		return $note;
+	}
+	
+	public function getProjectList()
+	{
+		return project_get_all_rows();
+	}
+	
+	public function setProject($proj_id)
+	{
+		if(!is_numeric($proj_id))
+		{
+			$proj_id = project_get_id_by_name($proj_id);
+		}
+		if(($proj_id!=0)&&!(project_exists($proj_id)))
+		{
+			$proj_id = 0;
+		}
+		return $proj_id;
+	}
+	
+	public function retrieveStatsByDate($id)
+	{
+		$pid = $this->setProject($id);
+		$this->statsByDate( config_get( 'date_partitions' ), $pid);
+	}
+	
+	public function retrieveStatsByActivity($id)
+	{
+		$pid = $this->setProject($id);
+		$this->statsByActivity($pid);
+	}
+	
+	public function retrieveStatsByAge($id)
+	{
+		$pid = $this->setProject($id);
+		$this->statsByAge($pid);
+	}
+	
+	# Print list of bugs opened from the longest time
+	# taken from function summary_print_by_age()
+	function statsByAge($pid)
+	{
+		$t_mantis_bug_table = db_get_table( 'mantis_bug_table' );
+	
+		$t_project_id = $pid;
+		$t_user_id = auth_get_current_user_id();
+		$t_resolved = config_get( 'bug_resolved_status_threshold' );
+	
+		$specific_where = helper_project_specific_where( $t_project_id );
+		if( ' 1<>1' == $specific_where ) {
+			return;
+		}
+		$query = "SELECT * FROM $t_mantis_bug_table
+					WHERE status < $t_resolved
+					AND $specific_where
+					ORDER BY date_submitted ASC, priority DESC";
+		$result = db_query( $query );
+	
+		$t_count = 0;
+		$t_private_bug_threshold = config_get( 'private_bug_threshold' );
+		while( $row = db_fetch_array( $result ) ) {
+	
+			// as we select all from bug_table, inject into the cache.
+			bug_cache_database_result( $row );
+	
+			// Skip private bugs unless user has proper permissions
+			if(( VS_PRIVATE == bug_get_field( $row['id'], 'view_state' ) ) && ( false == access_has_bug_level( $t_private_bug_threshold, $row['id'] ) ) ) {
+				continue;
+			}
+	
+			if( $t_count++ == 10 ) {
+				break;
+			}
+	
+			$t_bugid = $row['id'];
+			$t_summary = $row['summary'];
+			$t_days_open = intval(( time() - $row['date_submitted'] ) / SECONDS_PER_DAY );
+	
+			print $t_bugid.",".$t_summary.",".$t_days_open."\n";
+			
+		}
+	}
+	
+	# Print list of open bugs with the highest activity score
+	# the score is calculated assigning one "point" for each history event
+	# associated with the bug
+	# taken from function summary_print_by_activity()
+	function statsByActivity($pid)
+	{
+		$t_mantis_bug_table = db_get_table( 'mantis_bug_table' );
+		$t_mantis_history_table = db_get_table( 'mantis_bug_history_table' );
+	
+		$t_project_id = $pid;
+		$t_user_id = auth_get_current_user_id();
+		$t_resolved = config_get( 'bug_resolved_status_threshold' );
+	
+		$specific_where = helper_project_specific_where( $t_project_id );
+		if( ' 1<>1' == $specific_where ) {
+			return;
+		}
+		$query = "SELECT COUNT(h.id) as count, b.id, b.summary, b.view_state
+					FROM $t_mantis_bug_table AS b, $t_mantis_history_table AS h
+					WHERE h.bug_id = b.id
+					AND b.status < " . db_param() . "
+					AND $specific_where
+					GROUP BY h.bug_id, b.id, b.summary, b.last_updated, b.view_state
+					ORDER BY count DESC, b.last_updated DESC";
+		$result = db_query_bound( $query, Array( $t_resolved ) );
+	
+		$t_count = 0;
+		$t_private_bug_threshold = config_get( 'private_bug_threshold' );
+		$t_summarydata = Array();
+		$t_summarybugs = Array();
+		while( $row = db_fetch_array( $result ) ) {
+	
+			// Skip private bugs unless user has proper permissions
+			if(( VS_PRIVATE == $row['view_state'] ) && ( false == access_has_bug_level( $t_private_bug_threshold, $row['id'] ) ) ) {
+				continue;
+			}
+	
+			if( $t_count++ == 10 ) {
+				break;
+			}
+	
+			$t_summarydata[] = array(
+				'id' => $row['id'],
+				'summary' => $row['summary'],
+				'count' => $row['count'],
+			);
+			$t_summarybugs[] = $row['id'];
+		}
+	
+		bug_cache_array_rows( $t_summarybugs );
+	
+		foreach( $t_summarydata as $row ) {
+			//$t_bugid = string_get_bug_view_link( $row['id'] );
+			$t_bugid = $row['id'];
+			$t_summary = string_html_specialchars( $row['summary'] );
+			$t_notescount = $row['count'];
+	
+			print $t_bugid.",".$t_summary.",".$t_notescount."\n";
+			
+		}
+	}
+	
+	# This function shows the number of bugs submitted in the last X days
+	# An array of integers representing days is passed in
+	# taken from summary_print_by_date( $p_date_array )
+	function statsByDate( $p_date_array, $pid) {
+		helper_set_current_project($pid);
+		$arr_count = count( $p_date_array );
+		$x = 0;
+		$stats[$x][] = 'By date (days)';
+		$stats[$x][] = 'Opened';
+		$stats[$x][] = 'Resolved';
+		$stats[$x][] = 'Balance';
+		print implode(",",$stats[$x]);
+		print "\n";
+		
+		foreach( $p_date_array as $t_days ) {
+			$x++;
+			$t_new_count = $this->summaryNewBugCountByDate( $t_days, $pid);
+			$t_resolved_count = $this->summaryResolvedBugCountByDate( $t_days, $pid);
+	
+			$t_start_date = mktime( 0, 0, 0, date( 'm' ), ( date( 'd' ) - $t_days ), date( 'Y' ) );
+			$t_new_bugs_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&amp;' . FILTER_PROPERTY_FILTER_BY_DATE . '=on&amp;' . FILTER_PROPERTY_START_YEAR . '=' . date( 'Y', $t_start_date ) . '&amp;' . FILTER_PROPERTY_START_MONTH . '=' . date( 'm', $t_start_date ) . '&amp;' . FILTER_PROPERTY_START_DAY . '=' . date( 'd', $t_start_date ) . '&amp;' . FILTER_PROPERTY_HIDE_STATUS_ID . '=">';
+	
+			$stats[$x][] = $t_days;
+			$stats[$x][] = $t_new_count;
+			$stats[$x][] = $t_resolved_count;
+			
+				
+			$t_balance = $t_new_count - $t_resolved_count;
+			if( $t_balance > 0 ) {
+	
+				# we are talking about bugs: a balance > 0 is "negative" for the project...
+				$t_style = " negative";
+				$t_balance = sprintf( '%+d', $t_balance );
+	
+				# "+" modifier added in PHP >= 4.3.0
+			}
+			else if( $t_balance < 0 ) {
+				$t_style = ' positive';
+				$t_balance = sprintf( '%+d', $t_balance );
+			}
+	
+			$stats[$x][] = $t_balance;
+			print implode(",",$stats[$x]);
+			print "\n";
+						
+		}
+	
+		# end foreach
+		//print_r($stats);
+		//return $stats;
+		
+	}
+	
+	# prints the bugs submitted in the last X days (default is 1 day) for the
+	# current project
+	function summaryNewBugCountByDate( $p_time_length = 1, $id) {
+		$t_mantis_bug_table = db_get_table( 'mantis_bug_table' );
+	
+		$c_time_length = (int) $p_time_length * SECONDS_PER_DAY;
+	
+		$t_project_id = $id;
+		$t_user_id = auth_get_current_user_id();
+	
+		$specific_where = helper_project_specific_where( $t_project_id );
+		if( ' 1<>1' == $specific_where ) {
+			return;
+		}
+	
+		$query = "SELECT COUNT(*)
+					FROM $t_mantis_bug_table
+					WHERE " . db_helper_compare_days( "" . db_now() . "", "date_submitted", "<= $c_time_length" ) . " AND $specific_where";
+		$result = db_query_bound( $query );
+		return db_result( $result, 0 );
+	}
+	
+	# returns the number of bugs resolved in the last X days (default is 1 day) for the
+	# current project
+	function summaryResolvedBugCountByDate( $p_time_length = 1, $id) {
+		$t_bug_table = db_get_table( 'mantis_bug_table' );
+		$t_bug_history_table = db_get_table( 'mantis_bug_history_table' );
+		$t_resolved = config_get( 'bug_resolved_status_threshold' );
+	
+		$c_time_length = (int) $p_time_length * SECONDS_PER_DAY;
+	
+		$t_project_id = $id;
+		$t_user_id = auth_get_current_user_id();
+	
+		$specific_where = helper_project_specific_where( $t_project_id );
+		if( ' 1<>1' == $specific_where ) {
+			return;
+		}
+	
+		$query = "SELECT COUNT(DISTINCT(b.id))
+					FROM $t_bug_table b
+					LEFT JOIN $t_bug_history_table h
+					ON b.id = h.bug_id
+					AND h.type = " . NORMAL_TYPE . "
+					AND h.field_name = 'status'
+					WHERE b.status >= " . db_param() . "
+					AND h.old_value < " . db_param() . "
+					AND h.new_value >= " . db_param() . "
+					AND " . db_helper_compare_days( "" . db_now() . "", "date_modified", "<= $c_time_length" ) . "
+					AND $specific_where";
+		$result = db_query_bound( $query, Array( $t_resolved, $t_resolved, $t_resolved ) );
+		return db_result( $result, 0 );
+	}
+	
+	public function addBugnotes($bugid, $bugnotes)
+	{
+		if(!bug_exists($bugid))
+		{
+			throw new NotFoundException( "Bug ".$bugid." does not exist!" );
+		}
+	
+		foreach($bugnotes as $note)
+		{
+			if((!isset($note))||(is_blank($note)))
+			{
+				throw new BadRequestException( "Bug note must not be blank!" );
+			}
+		}
+				
+		$project_id = bug_get_field( $bugid, 'project_id' );
+		$user_id = auth_get_current_user_id();
+				
+		if(!access_has_bug_level(config_get('add_bugnote_threshold'), $bugid, $user_id))
+		{
+			throw new Exception( "You do not have access rights to add notes to this bug!" );
+		}
+	
+		if(bug_is_readonly($bugid))
+		{
+			throw new Exception("Bug ".$bugid." is readonly!" );
+		}
+	
+		foreach($bugnotes as $note)
+		{
+			bugnote_add($bugid, $note);
+		}
+			
+	}
+	
+	private function checkCreator($reporter, &$cm_data)
+	{
+		$user = auth_get_current_user_id();
+		if($reporter_id = user_get_id_by_name($reporter))
+		{
+			if($reporter_id==$user)
+			{
+				if(!(user_get_access_level( $user, $cm_data->project_id )>=REPORTER))
+				{
+					throw new Exception("Access denied!!");
+				}
+				else
+				{
+					$cm_data->reporter_id = $user;
+				}
+			}
+			else
+			{
+				if( !access_has_project_level(DEVELOPER, $cm_data->project_id, $user ) ) {
+					throw new Exception( "User does not have access level required to specify a different bug reporter!" );
+				}
+				else
+				{
+					$cm_data->reporter_id = $reporter_id;
+				}
+			}
+		}
+		else
+		{
+			throw new BadRequestException("Invalid creator: ".$reporter);
+		}
+		
+	}
+	
+	private function checkType($category, &$cm_data)
+	{
+		$category_id = null;
+		$category_array = category_get_all_rows( $cm_data->project_id );
+		foreach( $category_array as $category_row )
+		{
+			if( $category_row['name'] == $category ) {
+				$category_id = $category_row['id'];
+				break;
+			}
+		}
+		if ( !isset($category_id) && !config_get( 'allow_no_category' ) )
+		{
+			throw new BadRequestException("Invalid subject/category field specified");
+		}
+		else
+		{
+			$cm_data->category_id = $category_id;
+		}
+	}
+	
+	private function checkStatus($status, &$cm_data)
+	{
+		if (array_key_exists($status,self::$status_arr))
+		{
+			$cm_data->status = self::$status_arr[$status];
+			//print_r($cm_data->status);
+		}
+		else
+		{
+			throw new BadRequestException('Unknown mantisbt:status value specified!');
+		}
+	}
+	
+	private function checkPriority($priority, &$cm_data)
+	{
+		if (array_key_exists($priority,self::$priority_arr))
+		{
+			$cm_data->priority = self::$priority_arr[$priority];
+			//print_r($cm_data->priority);
+		}
+		else
+		{
+			throw new BadRequestException('Unknown mantisbt:priority value specified!');
+		}
+	}
+	
+	private function checkSeverity($severity, &$cm_data)
+	{
+		if (array_key_exists($severity,self::$severity_arr))
+		{
+			$cm_data->severity = self::$severity_arr[$severity];
+		}
+		else
+		{
+			throw new BadRequestException('Unknown mantisbt:severity value specified!');
+		}
+	}
+	
+	private function checkVersion($version, &$cm_data)
+	{
+		if(version_get_id($version, $cm_data->project_id ))
+		{
+			$cm_data->version = $version;
+		}
+		else
+		{
+			$proj_name = project_get_name( $cm_data->project_id );
+			throw new NotFoundException('Version '.$version.' does not exist in Project '.$proj_name.' !!!');
+		}
+	}
+	
+	private function checkTargetVersion($target_version, &$cm_data)
+	{
+		if(version_get_id($target_version, $cm_data->project_id ))
+		{
+			$cm_data->target_version = $target_version;
+		}
+		else
+		{
+			$proj_name = project_get_name( $cm_data->project_id );
+			throw new NotFoundException('Version '.$target_version.' does not exist in Project '.$proj_name.' !!!');
+		}
+	}
+	
+	private function checkVersionNumber($version_number, &$cm_data, $id)
+	{
+		//version_number => custom_field
+		$v_num_id = custom_field_get_id_from_name("version_number");
+		//$v_def = custom_field_get_definition($v_num_id);
+		//$v_values = custom_field_distinct_values($v_def);
+		//print_r($v_values);
+		if( !$v_num_id) {
+				throw new NotFoundException('mantisbt:version_number not found (it has possibly not been created in the custom fields)' );
+		}
+		else if(!custom_field_is_linked($v_num_id,$cm_data->project_id))
+		{
+			$proj_name = project_get_name( $cm_data->project_id );
+			throw new Exception('Custom_field mantisbt:version_number has not been linked to Project '.$proj_name.' yet!!!');
+		}
+		else if(!custom_field_has_write_access($v_num_id, $id, $cm_data->reporter_id))
+		{
+			throw new Exception('User '.$cm_data->reporter_id.' does not have access to set attribute mantisbt:version_number');
+		}
+		else if( !custom_field_validate( $v_num_id, $version_number ))
+		{
+			throw new BadRequestException( 'Invalid custom_field value for attribute mantisbt:version_number!!!');
+		}
+		else if( !custom_field_set_value( $v_num_id, $id, $version_number ))
+		{
+			throw new Exception( 'Unable to set custom_field value for attribute mantisbt:version_number to ChangeRequest:'.$cm_id.' !!!');
+		}
+	}
+
+	public function createChangeRequest($params)
+	{
+		$cm_request = $params['new']->container;
+		//print_r($cm_request);
+		  
+		$cm_data = new BugData;
+		
+		//dc:title ===> mantis:summary
+		if(isset($cm_request['title'])) {
+			$cm_data->summary = $cm_request['title'];			//mandatory
+		}else{
+			throw new BadRequestException('Mandatory field "Title" missing!!');
+		}
+
+		//dc:description ===> mantis:description
+		if(isset($cm_request['description'])) {
+			$cm_data->description = $cm_request['description'];			//mandatory
+		}else{
+			throw new BadRequestException('Mandatory field "Description" missing!!');
+		}
+
+		///project/xxxxx ===> mantis:project
+		//print_r($params['project']);
+		$project = $params['project'];
+		if(!preg_match ("/[^0-9]/", $project))
+		{
+			$cm_data->project_id = $project;
+		}
+		else
+		{
+			$cm_data->project_id = project_get_id_by_name($project);
+			//print_r($cm_data->project_id);
+		}
+		
+		if(( $cm_data->project_id == 0 ) || !project_exists( $cm_data->project_id ) ) {
+			throw new NotFoundException("Project does not exist!!!");
+		}
+		
+		$user = auth_get_current_user_id();
+
+		if(isset($cm_request['creator']))
+		{
+			$reporter = $cm_request['creator'];
+			$this->checkCreator($reporter, $cm_data);			
+		}
+		else
+		{
+			if(!(user_get_access_level( $user, $cm_data->project_id )>=REPORTER))
+			{
+				throw new Exception("Access denied!!");
+			}
+			else
+			{
+				$cm_data->reporter_id = $user;
+			}
+		}
+			
+		//dc:type ===> mantis:category
+		if(isset($cm_request['type']))
+		{
+			$category= $cm_request['type'];                 //mandatory
+			$this->checkType($category, $cm_data);			
+		}
+		else
+		{
+			throw new BadRequestException('Mandatory field "Category" missing!!');
+		}
+		
+		//mantisbt:priority
+		//print_r($cm_request['priority']);
+		$cm_request['priority'] = strtolower($cm_request['priority']);
+		if(isset($cm_request['priority']))
+		{
+			$this->checkPriority($cm_request['priority'], $cm_data);			
+		}
+		else
+		{
+			$cm_data->priority = config_get( 'default_bug_priority' );
+		}
+		
+		//mantisbt:severity
+		$cm_request['severity'] = strtolower($cm_request['severity']);
+		if(isset($cm_request['severity']))
+		{
+			$this->checkSeverity($cm_request['severity'], $cm_data);
+		}
+		else
+		{
+			$cm_data->severity = config_get( 'default_bug_severity' );
+		}
+		
+		if ( isset( $cm_request['version'] ) && !is_blank( $cm_request['version'] ) )
+		{
+			//$v_id = version_get_id( $cm_request['version'], $cm_data->project_id );
+			$this->checkVersion($cm_request['version'], $cm_data);						
+		}
+		
+		if ( isset( $cm_request['target_version'] ) && !is_blank( $cm_request['target_version'] ) )
+		{
+			//$v_id = version_get_id( $cm_request['version'], $cm_data->project_id );
+			$this->checkTargetVersion($cm_request['target_version'], $cm_data);						
+		}
+		
+		
+		
+		$cm_data->handler_id = 0;
+		$cm_data->profile_id = 0;
+
+		$cm_data->view_state = config_get( 'default_bug_view_status' );
+		$cm_data->reproducibility = config_get( 'default_bug_reproducibility' );
+		$cm_data->status = config_get( 'bug_submit_status' );		
+		$cm_data->projection = config_get( 'default_bug_projection' );
+		$cm_data->eta = config_get( 'default_bug_eta' );
+		$cm_data->resolution = config_get( 'default_bug_resolution' );
+		
+		$cm_data->steps_to_reproduce = config_get( 'default_bug_steps_to_reproduce' );
+		$cm_data->additional_information = config_get( 'default_bug_additional_info' );
+		$cm_data->due_date = date_get_null();
+		$cm_data->summary			= trim( $cm_data->summary );
+
+		# still have to add code to Validate the custom fields (for a particular project) before adding the bug
+		
+		# Create the bug
+		$cm_id = $cm_data->create();
+		// bugnotes still to be added
+		email_new_bug( $cm_id );
+		//print_r("after creation");
+
+		if ( isset( $cm_request['version_number'] ) && !is_blank( $cm_request['version_number'] ) )
+		{
+			$this->checkVersionNumber($cm_request['version_number'], $cm_data, $cm_id);
+		}
+				
+		if(isset( $cm_request['notes']))
+		{
+			$notes = array();
+			$x = 0;
+			foreach($cm_request['notes'] as $request)
+			{
+				if (!is_blank( $request))
+				{
+					$notes[$x++] = (string)$request;
+					//echo "note " . $x;
+				}
+			}
+			$this->addBugnotes($cm_id, $notes);
+		}
+			
+		return $cm_id;
+	}
+	
+	public function checkChangeRequestExists($id)
+	{
+		return bug_exists($id);
+	}
+	
+	public function updateChangeRequest($id, $changerequest, $props)
+	{
+		$cm_data = bug_get($id, true);
+		$cm_request = $changerequest->container;
+		//print_r($cm_data);
+		$terms = array('dc:','mantisbt:');
+		foreach($props as &$prop)
+		{
+			$prop = str_replace($terms,"",$prop);
+			//echo $prop;
+		}
+		//print_r($props);
+		
+		$user = auth_get_current_user_id();
+		if(!(user_get_access_level($user, $cm_data->project_id )>=REPORTER))
+		{
+			throw new Exception("User doesnt have access to update bug!!");
+		}
+				
+		if(in_array('creator',$props))
+		{
+			if(isset($cm_request['creator']))
+			{
+				$reporter = $cm_request['creator'];
+				$this->checkCreator($reporter, $cm_data);			
+			}
+			else
+			{
+				throw new BadRequestException("dc:creator mentioned in the request query not found in request body!");
+			}
+		}
+		
+		//dc:title ===> mantis:summary
+		if(in_array('title',$props))
+		{
+			if(isset($cm_request['title']))
+			{
+				$cm_data->summary = $cm_request['title'];			//mandatory
+			}
+			else
+			{
+				throw new BadRequestException("dc:title mentioned in the request query not found in request body!");
+			}
+		}
+
+		//dc:description ===> mantis:description
+		if(in_array('description',$props))
+		{
+			if(isset($cm_request['description']))
+			{
+				$cm_data->description = $cm_request['description'];			//mandatory
+				//print_r($cm_data);
+			}
+			else
+			{
+				throw new BadRequestException("dc:description mentioned in the request query not found in request body!");
+			}
+		}		
+						
+		//dc:type ===> mantis:category
+		if(in_array('type',$props))
+		{
+			if(isset($cm_request['type']))
+			{
+				$category= $cm_request['type'];                 //mandatory
+				$this->checkType($category, $cm_data);			
+			}
+			else
+			{
+				throw new BadRequestException("dc:type mentioned in the request query not found in request body!");
+			}
+		}
+		
+		//mantisbt:status
+		if(in_array("status",$props))
+		{
+			if(isset($cm_request['status']))
+			{
+				$cm_request['status'] = strtolower($cm_request['status']);
+				$this->checkStatus($cm_request['status'], $cm_data);		
+			}
+			else
+			{
+				throw new BadRequestException("mantisbt:status mentioned in the request query not found in request body!");
+			}
+		}
+		
+		//mantisbt:priority
+		if(in_array("priority",$props))
+		{
+			if(isset($cm_request['priority']))
+			{
+				$cm_request['priority'] = strtolower($cm_request['priority']);
+				$this->checkPriority($cm_request['priority'], $cm_data);			
+			}
+			else
+			{
+				throw new BadRequestException("mantisbt:priority mentioned in the request query not found in request body!");
+			}
+		}
+		
+		//mantisbt:severity
+		if(in_array('severity',$props))
+		{
+			$cm_request['severity'] = strtolower($cm_request['severity']);
+			if(isset($cm_request['severity']))
+			{
+				$this->checkSeverity($cm_request['severity'], $cm_data);
+			}
+			else
+			{
+				throw new BadRequestException("mantisbt:severity mentioned in the request query not found in request body!");
+			}
+		}
+		
+		if(in_array('version',$props))
+		{
+			if ( isset( $cm_request['version'] ) && !is_blank( $cm_request['version'] ) )
+			{
+				//$v_id = version_get_id( $cm_request['version'], $cm_data->project_id );
+				$this->checkVersion($cm_request['version'], $cm_data);						
+			}
+			else
+			{
+				throw new BadRequestException("mantisbt:version mentioned in the request query not found in request body!");
+			}
+		}
+		
+		if(in_array('target_version',$props))
+		{
+			if ( isset( $cm_request['target_version'] ) && !is_blank( $cm_request['target_version'] ) )
+			{
+				//$v_id = version_get_id( $cm_request['version'], $cm_data->project_id );
+				$this->checkTargetVersion($cm_request['target_version'], $cm_data);						
+			}
+			else
+			{
+				throw new BadRequestException("mantisbt:target_version mentioned in the request query not found in request body!");
+			}
+		}
+		
+		
+		$cm_data->summary = trim( $cm_data->summary );
+
+		# still have to add code to Validate the custom fields (for a particular project) before adding the bug
+		
+		# Update the bug
+		if(!$cm_data->update(TRUE, TRUE))
+		{
+			throw new Exception("Change Request ".$id." was not able to be updated for some reason!");
+		}
+		// bugnotes still to be added
+		//print_r("after creation");
+
+		if(in_array('version_number',$props))
+		{
+			if ( isset( $cm_request['version_number'] ) && !is_blank( $cm_request['version_number'] ) )
+			{
+				$this->checkVersionNumber($cm_request['version_number'], $cm_data, $id);
+			}
+			else
+			{
+				throw new BadRequestException("mantisbt:version_number mentioned in the request query not found in request body!");
+			}
+		}
+				
+		if(in_array('notes',$props))
+		{
+			if(isset( $cm_request['notes']))
+			{
+				$notes = array();
+				$x = 0;
+				foreach($cm_request['notes'] as $request)
+				{
+					if (!is_blank( $request))
+					{
+						$notes[$x++] = (string)$request;
+						//echo "note " . $x;
+					}
+				}
+				$this->addBugnotes($id, $notes);
+			}
+			else
+			{
+				throw new BadRequestException("mantisbt:notes mentioned in the request query not found in request body!");
+			}
+		}
+		
+	}
+
+	public function getHttpAuthBasicResolver($login, $password) {
+
+		$basicResolver = new Mantis_Http_Auth_Resolver($login, $password);
+
+		return $basicResolver;
+
+	}
+	
+	/**
+	 * Reproduced from OAuth PHP lib : splits oauth headers
+	 * 
+	 * @param string $header
+	 */
+	private static function splitHeader($header) {
+		// remove 'OAuth ' at the start of a header
+		$header = substr($header, 6);
+
+		// error cases: commas in parameter values?
+		$parts = explode(",", $header);
+		$out = array();
+		foreach ($parts as $param) {
+			$param = ltrim($param);
+			// skip the "realm" param, nobody ever uses it anyway
+			if (substr($param, 0, 5) != "oauth") continue;
+
+			$param_parts = explode("=", $param);
+
+			// rawurldecode() used because urldecode() will turn a "+" in the
+			// value into a space
+			$out[$param_parts[0]] = rawurldecode(substr($param_parts[1], 1, -1));
+		}
+		return $out;
+	}
+
+	/**
+	 * Uses OAuth PHP lib's and OauthAuthz plugin's data store to check OAuth headers
+	 * validating an access token, and logging-in the corresponding user
+	 * 
+	 * @param string $auth_header
+	 * @return boolean
+	 */
+	public function checkOauthAuthorization($auth_header) {
+		//try {
+			$oauth_server = new OAuthServer(MantisBtDbOAuthDataStore::singleton());
+
+			$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
+			$oauth_server->add_signature_method($hmac_method);
+			
+			// HACK : zend framework relies on PHP parse_str() which replaces dots by underscores in the parameters
+			// so we need to restore the original "oslc_cm.xxx" query parameters before checking the signature
+			$parameters=$_GET;
+			$new_params=array();
+			foreach($parameters as $key => $value) {
+				$prefix = substr($key, 0,8);
+				if($prefix == 'oslc_cm_') {
+					$suffix=substr($key, 8);
+					$new_params['oslc_cm.'.$suffix] = $value;
+				}
+				else {
+					$new_params[$key] = $value;
+				}
+			}
+			$header_parameters = $this->splitHeader($auth_header);
+			$parameters = array_merge($header_parameters, $new_params);
+			$req = OAuthRequest::from_request(null,null,$parameters);
+			list($consumer, $token) = $oauth_server->verify_request( $req);
+
+			// Now, the request is valid.
+
+			// We know which consumer is connected
+			/*
+			echo "Authenticated as consumer : \n";
+			//print_r($consumer);
+			echo "  name: ". $consumer->getName() ."\n";
+			echo "  key: $consumer->key\n";
+			echo "\n";
+
+			// And on behalf of which user it connects
+			echo "Authenticated with access token whose key is :  $token->key \n";
+			echo "\n";*/
+			$t_token = OauthAuthzAccessToken::load_by_key($token->key);
+			$user = user_get_name($t_token->getUserId());
+			/*
+			echo "Acting on behalf of user : $user\n";
+			echo "\n"; */
+
+			// if user is succesfully retrieved, then simulate its login
+			if( isset($user) && auth_attempt_script_login($user) ) { 
+				return True;
+			}
+			else {
+				return False;
+			} 
+		/*	
+		} catch (OAuthException $e) {
+			//print($e->getMessage() . "\n<hr />\n");
+			//print_r($req);
+			return false;
+		}
+		*/
+	}
+}

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/OSLCConnector.php
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/OSLCConnector.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/OSLCConnector.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,367 @@
+<?php
+
+/**
+ * This file is (c) Copyright 2009 by Olivier BERGER, 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.
+ *
+ */
+
+/* $Id:$ */
+
+require_once("cql.php");
+
+/**
+ * OSLC-CM connector module
+ * 
+ * This implements the application's controller. It is distinct from the Zend controller
+ * to try and become more independant from Zend (think reuse).
+ * 
+ * @author Olivier Berger <olivier.berger at it-sudparis.eu
+ * @package controler
+ *
+ */
+
+/**
+ * OSLC-CM controler base class
+ *
+ * @abstract
+ */
+class OSLCConnector {
+
+	/**
+	 * Holds a database of OSLC-CM ChangeRequest elements (the model) 
+	 * 
+	 * @var ChangeRequests
+	 */
+	protected $changerequests;
+
+	/**
+	 * @param array $params unused in base class
+	 */
+	public function __construct($params=null) {
+		$this->changerequests = null;
+	}
+	
+	public function getChangeRequests() {
+		return $this->changerequests;
+	}
+	
+	/**
+	 * Initialize the model with appropriate parameters (project, etc.)
+	 * 
+	 * Performs the checks on the parameters provided by Zend and invokes the model as needed.
+	 * 
+	 * @param array $params parameters as passed by Zend 
+	 * @return unknown_type
+	 */
+	public function init($params=null) {
+		
+		$modelparams = $this->filterRequestParams($params);
+
+		// take into account the filtering on certain constraints
+		//the oslc_cm query parameters need to be url encoded for the params to be correct
+		//print_r($params);
+		$modelparams['filter'] = array();
+		if(array_key_exists('oslc_where', $params)) {
+			//print_r($params['oslc_cm_query']);
+			$filter=parse_cql(urldecode($params['oslc_where']));
+			if($filter) {
+				$modelparams['filter']['where']=$filter;
+			}
+		}
+		
+		if(array_key_exists('oslc_orderBy', $params))
+		{
+			$tok = strtok($params['oslc_orderBy'], ",");
+			while ($tok !== false) {
+    			//echo "Word=$tok ";
+    			if(preg_match("/^[+-][a-zA_Z:_]+$/", $tok))	{
+    				if(substr($tok, 0, 1)=="+")	{
+    					$dir = "ASC";
+    				}elseif(substr($tok, 0, 1)=="-") {
+    					$dir = "DESC";
+    				} 
+    				$attr = substr($tok, 1);
+    				$modelparams['filter']['orderBy'][] = array($dir, $attr);
+    			}
+    			else	{
+    				throw new BadRequestException("Error in oslc_orderBy syntax");
+    			}
+    			$tok = strtok(",");
+			}
+		}
+		
+		$temp_limit = 0;
+		
+		if(array_key_exists('oslc_limit', $params))
+		{
+			//converting to type int or float depending on the value of the value of the param
+			$temp_limit = $params['oslc_limit']+0;
+			//checking for a positive integer
+			if((is_int($temp_limit))&&($temp_limit>0))	{
+				$modelparams['filter']['limit']=$params['oslc_limit'];
+			}else	{
+				throw new BadRequestException("The value for oslc_limit is not a positive integer!");
+			}
+		}
+		
+		if(array_key_exists('oslc_offset', $params))
+		{
+			//converting to type int or float depending on the value of the value of the param
+			$temp_offset = $params['oslc_offset']+0;
+			//checking for a positive integer 
+			if((is_int($temp_offset))&&($temp_offset>0))	{
+				//checking that oslc_limit has also been correctly defined
+				if(array_key_exists('limit', $modelparams['filter']))	{					
+					//offset should be a multiple of limit
+					if($temp_offset%$temp_limit==0)	{
+						$modelparams['filter']['offset']= ($temp_offset/$temp_limit)+1;
+					}else 	{
+						throw new ConflictException("oslc_offset should be a multiple of oslc_limit");
+					}
+				}else 	{
+					throw new ConflictException("oslc_offset cannot work without oslc_limit being defined");
+				}
+			}else	{
+				throw new BadRequestException("The value for oslc_limit is not a positive integer!");
+			}
+		}
+		
+		// take into account the restriction on values to be returned
+		if(array_key_exists('oslc_properties', $params)) {
+				$modelparams['fields'] = $params['oslc_properties']; 
+		}
+		
+		if(array_key_exists('oslc_searchTerms', $params)) {
+			$tok = strtok($params['oslc_searchTerms'], ",");
+			do 	{
+    			$tok = str_replace("\"", "", $tok);
+    			$modelparams['filter']['searchTerms'][] = $tok;
+    			$tok = strtok(",");
+			}while ($tok !== false);
+		}
+
+		if(array_key_exists('filter', $modelparams) || array_key_exists('fields', $modelparams))
+		{
+			$this->changeRequestsQuery($modelparams);
+		}
+		else
+		{
+			$this->fetchChangeRequests($modelparams);
+		}
+		//print_r($this->changerequests);
+		return $modelparams;
+	}
+
+	/**
+	 * Instantiate a Zend Auth adapter for HTTP Basic auth
+	 * 
+	 * It will be responsible of the validation of username and passwords provided
+	 * 
+	 * By default, use a file containing usernames, realms and passwords
+	 * (see docs of Zend_Auth_Adapter_Http_Resolver_File)
+	 * 
+	 * $login and $password are only there to allow subclassing
+	 * 
+	 * @param string $login transmitted in request
+	 * @param string $password transmitted in request (clear text)
+	 * @return Zend_Auth_Adapter_Http_Resolver_Interface
+	 */
+	public function getHttpAuthBasicResolver($login, $password) {
+		// authenticate to .htpasswd-like file
+		$basicResolver = new Zend_Auth_Adapter_Http_Resolver_File();
+		$basicResolver->setFile(APPLICATION_PATH.'/basic-pwd.txt');
+			
+		return $basicResolver;
+
+	}
+
+	/**
+	 * Retrieves ChangeRequest resources to be sent to the view
+	 * 
+	 * The format returned is array( 'id' => identifier,
+	 * 								 'resource' => array (
+	 * 											'fieldname' => value,
+	 * 											...))
+	 * This format should suit all needs of every views
+	 * 
+	 * @param string $identifier of the ChangeRequest to be retrieved
+	 * @param string $uri to be defined as its id
+	 * @return array
+	 */
+	public function getResource($identifier, $uri=null) {
+		$returned = null;
+
+		$changerequest = $this->changerequests[$identifier];
+
+		if (isset($changerequest)) {
+			$returned = $this->prepareChangeRequest($changerequest, $uri);
+		}
+
+		return $returned;
+	}
+
+	/**
+	 * Retrieves a list of ChangeRequest resources to be sent to the view
+	 * 
+	 * @param string $uri
+	 * @return array
+	 * @TODO: change function name to something like 'formatRessourceCollection'
+	 */
+	public function getResourceCollection($uri=null)
+	{
+		
+		$returned = array();
+		// construct a list of all entries of the feed
+		foreach ($this->changerequests as $identifier => $changerequest) {
+
+			$feedentry = $this->prepareChangeRequest($changerequest);
+
+			$feedentry['title'] = 'changerequest '.$identifier.' : '.$feedentry['resource']['dc:title'];
+			$feedentry['id']= $uri.$identifier;
+
+			$returned[] = $feedentry;
+		}
+		return $returned;
+	}
+
+	/**
+	 * Prepare a ChangeRequest to the format expected by the views
+	 * 
+	 * It will do any necessary conversions, such as adding proper 
+	 * ontology prefixes.
+	 * 
+	 * The format returned is array( 'id' => identifier,
+	 * 								 'resource' => array (
+	 * 											'fieldname' => value,
+	 * 											...))
+	 * This format should suit all needs of every views
+	 * 
+	 * @param unknown_type $changerequest
+	 * @param unknown_type $uri
+	 * @return string
+	 */
+	protected function prepareChangeRequest($changerequest, $uri=null) {
+		$preparedChangeRequest = array('resource' => array());
+		$dc_attr = array("title", "identifier", "type", "description","subject","creator","modified","name","created");
+
+		foreach ($changerequest as $fieldname => $value) {
+
+			// here, may do some conversions betw model and view
+			switch ($fieldname) {
+				/*
+					case 'creator':
+					$feedentry['author'] = $value;
+					break;
+					*/
+				default :
+					// construct values with ontology prefix for the OSLC-CM DC fields
+					// TODO : use real RDF triples ?
+					$tokens = explode(':', $fieldname);
+					if( (count($tokens) == 1) && (in_array($fieldname,$dc_attr))) {
+						$fieldname = 'dc:'.$fieldname;
+					}
+					$preparedChangeRequest['resource'][$fieldname] = $value;
+					break;
+			}
+		}
+
+		if (!isset($uri)) {
+			$uri = '#';
+		}
+		$preparedChangeRequest['id'] = $uri;
+
+		return $preparedChangeRequest;
+
+	}
+	
+	/**
+	 * Create a new bug in the model
+	 * @param ChangeRequest $cm_request
+	 * @return unknown_type
+	 */
+	/*public function createChangeRequest($cm_request)
+	{
+		$identifier = -1;
+		$cm_request['identifier'] = $identifier;
+		
+		$this->changerequests[$identifier] = $cm_request;
+		
+		return $identifier;
+	}*/
+	
+	public function modifyChangeRequest()
+	{
+		
+	}
+}
+
+/**
+ * For demo DB using a CSV file
+ *  
+ * @package CsvControler 
+ */
+
+/**
+ * Concrete Demo OslcControler controler for CSV file support 
+ *
+ */
+class OslcCsvDemoConnector extends OslcConnector {
+
+	protected $csvFilename;
+	
+	/**
+	 * @param array $params optional 'csvfilename' path to CSV file
+	 */
+	public function __construct($params = null) {
+		parent::__construct($params);
+		
+		if(is_array($params) && array_key_exists('csvfilename',$params)) {
+			$csvFilename = $params['csvfilename'];
+			if($csvFilename) {
+				$this->csvFilename = $csvFilename;
+			}
+		}
+	}
+	/**
+	 * Initialize a ChangeRequestsCsv DB
+	 * 
+	 * It is passed in $params the 'id' => identifier if only one resource requested
+	 * 
+	 * @param array $params
+	 */
+	protected function fetchChangeRequests($params=null) {
+
+		// TODO : allow a configurable location for the test file outside of the code ?
+
+		$filename = $this->csvFilename;
+		
+		if(!$filename) {
+			$filename = APPLICATION_PATH."/test.csv";
+		}
+
+		$this->changerequests = new ChangeRequestsCsv($filename);
+
+		if(array_key_exists('project', $params)) {
+			$this->changerequests->setFilter(array('project' => $params['project']));
+		}
+	}
+	
+}

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/cql-lime_parser.inc.php
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/cql-lime_parser.inc.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/cql-lime_parser.inc.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,603 @@
+<?php
+
+
+/*
+
+DON'T EDIT THIS FILE!
+
+This file was automatically generated by the Lime parser generator.
+The real source code you should be looking at is in one or more
+grammar files in the Lime format.
+
+THE ONLY REASON TO LOOK AT THIS FILE is to see where in the grammar
+file that your error happened, because there are enough comments to
+help you debug your grammar.
+
+If you ignore this warning, you're shooting yourself in the brain,
+not the foot.
+
+*/
+
+class cql_lime_parser extends lime_parser {
+var $qi = 0;
+var $i = array (
+  0 => 
+  array (
+    'query_in' => 's 1',
+    'term' => 's 27',
+    'identifier' => 's 5',
+    'value' => 's 17',
+    'word' => 's 18',
+    'integer' => 's 8',
+    'string' => 's 9',
+    'query' => 's 28',
+    '\'start\'' => 'a \'start\'',
+  ),
+  1 => 
+  array (
+    'modifiers' => 's 2',
+    'boolean_op' => 's 3',
+    'and_kw' => 's 21',
+    'sort' => 's 22',
+    '\'/\'' => 's 23',
+    '#' => 'r 0',
+  ),
+  2 => 
+  array (
+    '#' => 'r 1',
+  ),
+  3 => 
+  array (
+    'term' => 's 4',
+    'identifier' => 's 5',
+    'value' => 's 17',
+    'word' => 's 18',
+    'integer' => 's 8',
+    'string' => 's 9',
+  ),
+  4 => 
+  array (
+    '\'/\'' => 'r 3',
+    'and_kw' => 'r 3',
+    '#' => 'r 3',
+  ),
+  5 => 
+  array (
+    'operator' => 's 6',
+    'equal_kw' => 's 10',
+    'not_kw' => 's 11',
+    'lt_kw' => 's 13',
+    'gt_kw' => 's 15',
+  ),
+  6 => 
+  array (
+    'value' => 's 7',
+    'integer' => 's 8',
+    'string' => 's 9',
+  ),
+  7 => 
+  array (
+    'and_kw' => 'r 4',
+    '\'/\'' => 'r 4',
+    '#' => 'r 4',
+  ),
+  8 => 
+  array (
+    'and_kw' => 'r 21',
+    '\'/\'' => 'r 21',
+    '#' => 'r 21',
+  ),
+  9 => 
+  array (
+    'and_kw' => 'r 22',
+    '\'/\'' => 'r 22',
+    '#' => 'r 22',
+  ),
+  10 => 
+  array (
+    'integer' => 'r 6',
+    'string' => 'r 6',
+  ),
+  11 => 
+  array (
+    'equal_kw' => 's 12',
+  ),
+  12 => 
+  array (
+    'integer' => 'r 7',
+    'string' => 'r 7',
+  ),
+  13 => 
+  array (
+    'equal_kw' => 's 14',
+    'integer' => 'r 8',
+    'string' => 'r 8',
+  ),
+  14 => 
+  array (
+    'integer' => 'r 10',
+    'string' => 'r 10',
+  ),
+  15 => 
+  array (
+    'equal_kw' => 's 16',
+    'integer' => 'r 9',
+    'string' => 'r 9',
+  ),
+  16 => 
+  array (
+    'integer' => 'r 11',
+    'string' => 'r 11',
+  ),
+  17 => 
+  array (
+    'and_kw' => 'r 5',
+    '\'/\'' => 'r 5',
+    '#' => 'r 5',
+  ),
+  18 => 
+  array (
+    '\':\'' => 's 19',
+    'equal_kw' => 'r 15',
+    'not_kw' => 'r 15',
+    'lt_kw' => 'r 15',
+    'gt_kw' => 'r 15',
+    '#' => 'r 15',
+  ),
+  19 => 
+  array (
+    'word' => 's 20',
+  ),
+  20 => 
+  array (
+    'equal_kw' => 'r 16',
+    'not_kw' => 'r 16',
+    'lt_kw' => 'r 16',
+    'gt_kw' => 'r 16',
+    '#' => 'r 16',
+  ),
+  21 => 
+  array (
+    'word' => 'r 12',
+    'integer' => 'r 12',
+    'string' => 'r 12',
+  ),
+  22 => 
+  array (
+    '#' => 'r 13',
+  ),
+  23 => 
+  array (
+    'sort_kw' => 's 24',
+  ),
+  24 => 
+  array (
+    '\'=\'' => 's 25',
+  ),
+  25 => 
+  array (
+    'identifier' => 's 26',
+    'word' => 's 18',
+  ),
+  26 => 
+  array (
+    '#' => 'r 14',
+  ),
+  27 => 
+  array (
+    'and_kw' => 'r 2',
+    '\'/\'' => 'r 2',
+    '#' => 'r 2',
+  ),
+  28 => 
+  array (
+    '#' => 'r 23',
+  ),
+);
+function reduce_0_query_1($tokens, &$result) {
+#
+# (0) query :=  query_in
+#
+$result = reset($tokens);
+
+	global $parsed_results;
+	$parsed_results = $result;
+	
+}
+
+function reduce_1_query_2($tokens, &$result) {
+#
+# (1) query :=  query_in  modifiers
+#
+$result = reset($tokens);
+
+	global $parsed_results;
+	$parsed_results = $result;
+	
+}
+
+function reduce_2_query_in_1($tokens, &$result) {
+#
+# (2) query_in :=  term
+#
+$result = reset($tokens);
+ 
+
+	$result = array( 'terms' => array($tokens[0]) );
+
+	debug_found('query_in', 'single term :'. print_r($result,true) ); 
+	
+}
+
+function reduce_3_query_in_2($tokens, &$result) {
+#
+# (3) query_in :=  query_in  boolean_op  term
+#
+$result = reset($tokens);
+
+ 
+	$first_subquery = $tokens[0];
+	$terms = $first_subquery['terms'];
+	$terms[] = $tokens[2];
+	$result = array( 'terms' => $terms );
+	
+	debug_found('query_in', 'found multiplesubqueries with boolean query_in : '. print_r($result,true) );
+	
+}
+
+function reduce_4_term_1($tokens, &$result) {
+#
+# (4) term :=  identifier  operator  value
+#
+$result = reset($tokens);
+$i =& $tokens[0];
+$o =& $tokens[1];
+$v =& $tokens[2];
+
+
+	$result = array($o, $i, $v);
+
+	debug_found('term', 'found identifier operator value term: '. print_r($result,true) ); 
+	
+}
+
+function reduce_5_term_2($tokens, &$result) {
+#
+# (5) term :=  value
+#
+$result = reset($tokens);
+ 
+	debug_found('term', 'found single value term: '. print_r($result,true) );
+	
+}
+
+function reduce_6_operator_1($tokens, &$result) {
+#
+# (6) operator :=  equal_kw
+#
+$result = reset($tokens);
+
+}
+
+function reduce_7_operator_2($tokens, &$result) {
+#
+# (7) operator :=  not_kw  equal_kw
+#
+$result = reset($tokens);
+ $result = $tokens[0].$tokens[1]; 
+}
+
+function reduce_8_operator_3($tokens, &$result) {
+#
+# (8) operator :=  lt_kw
+#
+$result = reset($tokens);
+
+}
+
+function reduce_9_operator_4($tokens, &$result) {
+#
+# (9) operator :=  gt_kw
+#
+$result = reset($tokens);
+
+}
+
+function reduce_10_operator_5($tokens, &$result) {
+#
+# (10) operator :=  lt_kw  equal_kw
+#
+$result = reset($tokens);
+ $result = $tokens[0].$tokens[1]; 
+}
+
+function reduce_11_operator_6($tokens, &$result) {
+#
+# (11) operator :=  gt_kw  equal_kw
+#
+$result = reset($tokens);
+ $result = $tokens[0].$tokens[1]; 
+}
+
+function reduce_12_boolean_op_1($tokens, &$result) {
+#
+# (12) boolean_op :=  and_kw
+#
+$result = reset($tokens);
+
+}
+
+function reduce_13_modifiers_1($tokens, &$result) {
+#
+# (13) modifiers :=  sort
+#
+$result = reset($tokens);
+
+}
+
+function reduce_14_sort_1($tokens, &$result) {
+#
+# (14) sort :=  '/'  sort_kw  '='  identifier
+#
+$result = reset($tokens);
+
+}
+
+function reduce_15_identifier_1($tokens, &$result) {
+#
+# (15) identifier :=  word
+#
+$result = reset($tokens);
+ 
+	debug_found('identifier', 'found simple identifier: '. print_r($result,true) );
+	
+}
+
+function reduce_16_identifier_2($tokens, &$result) {
+#
+# (16) identifier :=  word  ':'  word
+#
+$result = reset($tokens);
+
+
+	$result = $tokens[0].':'.$tokens[2];
+	 
+	debug_found('identifier', 'found prefixed identifier: '. print_r($result,true) );
+	
+}
+
+function reduce_17_in_val_1($tokens, &$result) {
+#
+# (17) in_val :=
+#
+$result = reset($tokens);
+
+	$result=array(); /* problem */
+}
+
+function reduce_18_in_val_2($tokens, &$result) {
+#
+# (18) in_val :=  '['  in_val_in  ']'
+#
+$result = reset($tokens);
+$in =& $tokens[1];
+ $result[] = $in; 
+}
+
+function reduce_19_in_val_in_1($tokens, &$result) {
+#
+# (19) in_val_in :=  value
+#
+$result = reset($tokens);
+/* problem */
+}
+
+function reduce_20_in_val_in_2($tokens, &$result) {
+#
+# (20) in_val_in :=  ','  in_val_in
+#
+$result = reset($tokens);
+
+}
+
+function reduce_21_value_1($tokens, &$result) {
+#
+# (21) value :=  integer
+#
+$result = reset($tokens);
+ 
+	debug_found('value', 'found integer: '. print_r($result,true) ); 
+	
+}
+
+function reduce_22_value_2($tokens, &$result) {
+#
+# (22) value :=  string
+#
+$result = reset($tokens);
+ 
+	debug_found('value', 'found string: '. print_r($result,true) ); 
+	
+}
+
+function reduce_23_start_1($tokens, &$result) {
+#
+# (23) 'start' :=  query
+#
+$result = reset($tokens);
+
+}
+
+var $method = array (
+  0 => 'reduce_0_query_1',
+  1 => 'reduce_1_query_2',
+  2 => 'reduce_2_query_in_1',
+  3 => 'reduce_3_query_in_2',
+  4 => 'reduce_4_term_1',
+  5 => 'reduce_5_term_2',
+  6 => 'reduce_6_operator_1',
+  7 => 'reduce_7_operator_2',
+  8 => 'reduce_8_operator_3',
+  9 => 'reduce_9_operator_4',
+  10 => 'reduce_10_operator_5',
+  11 => 'reduce_11_operator_6',
+  12 => 'reduce_12_boolean_op_1',
+  13 => 'reduce_13_modifiers_1',
+  14 => 'reduce_14_sort_1',
+  15 => 'reduce_15_identifier_1',
+  16 => 'reduce_16_identifier_2',
+  17 => 'reduce_17_in_val_1',
+  18 => 'reduce_18_in_val_2',
+  19 => 'reduce_19_in_val_in_1',
+  20 => 'reduce_20_in_val_in_2',
+  21 => 'reduce_21_value_1',
+  22 => 'reduce_22_value_2',
+  23 => 'reduce_23_start_1',
+);
+var $a = array (
+  0 => 
+  array (
+    'symbol' => 'query',
+    'len' => 1,
+    'replace' => true,
+  ),
+  1 => 
+  array (
+    'symbol' => 'query',
+    'len' => 2,
+    'replace' => true,
+  ),
+  2 => 
+  array (
+    'symbol' => 'query_in',
+    'len' => 1,
+    'replace' => true,
+  ),
+  3 => 
+  array (
+    'symbol' => 'query_in',
+    'len' => 3,
+    'replace' => true,
+  ),
+  4 => 
+  array (
+    'symbol' => 'term',
+    'len' => 3,
+    'replace' => true,
+  ),
+  5 => 
+  array (
+    'symbol' => 'term',
+    'len' => 1,
+    'replace' => true,
+  ),
+  6 => 
+  array (
+    'symbol' => 'operator',
+    'len' => 1,
+    'replace' => true,
+  ),
+  7 => 
+  array (
+    'symbol' => 'operator',
+    'len' => 2,
+    'replace' => true,
+  ),
+  8 => 
+  array (
+    'symbol' => 'operator',
+    'len' => 1,
+    'replace' => true,
+  ),
+  9 => 
+  array (
+    'symbol' => 'operator',
+    'len' => 1,
+    'replace' => true,
+  ),
+  10 => 
+  array (
+    'symbol' => 'operator',
+    'len' => 2,
+    'replace' => true,
+  ),
+  11 => 
+  array (
+    'symbol' => 'operator',
+    'len' => 2,
+    'replace' => true,
+  ),
+  12 => 
+  array (
+    'symbol' => 'boolean_op',
+    'len' => 1,
+    'replace' => true,
+  ),
+  13 => 
+  array (
+    'symbol' => 'modifiers',
+    'len' => 1,
+    'replace' => true,
+  ),
+  14 => 
+  array (
+    'symbol' => 'sort',
+    'len' => 4,
+    'replace' => true,
+  ),
+  15 => 
+  array (
+    'symbol' => 'identifier',
+    'len' => 1,
+    'replace' => true,
+  ),
+  16 => 
+  array (
+    'symbol' => 'identifier',
+    'len' => 3,
+    'replace' => true,
+  ),
+  17 => 
+  array (
+    'symbol' => 'in_val',
+    'len' => 0,
+    'replace' => true,
+  ),
+  18 => 
+  array (
+    'symbol' => 'in_val',
+    'len' => 3,
+    'replace' => true,
+  ),
+  19 => 
+  array (
+    'symbol' => 'in_val_in',
+    'len' => 1,
+    'replace' => true,
+  ),
+  20 => 
+  array (
+    'symbol' => 'in_val_in',
+    'len' => 2,
+    'replace' => true,
+  ),
+  21 => 
+  array (
+    'symbol' => 'value',
+    'len' => 1,
+    'replace' => true,
+  ),
+  22 => 
+  array (
+    'symbol' => 'value',
+    'len' => 1,
+    'replace' => true,
+  ),
+  23 => 
+  array (
+    'symbol' => '\'start\'',
+    'len' => 1,
+    'replace' => true,
+  ),
+);
+}

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/cql.lime
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/cql.lime	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/cql.lime	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,155 @@
+#
+# This file is (c) Copyright 2010 by Olivier BERGER, 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.
+#
+
+#
+# This file contains the grammar definition for the "Library of Congress Contextual 
+# Query Language" (CQL) -like OSLC-CM V1's Change Management Query Syntax 
+# ( http://open-services.net/bin/view/Main/CmQuerySyntaxV1).
+#
+# Its is meant to be parsed by the "LIME Parser generator for PHP" 
+# (http://lime-php.sourceforge.net/) to generate the "cql-lime_parser.inc.php" parser
+#
+
+# Here's the BNF for the grammar
+# query      ::= (term (boolean_op term)*)+ modifiers
+# term       ::= (identifier operator)? value+ | (identifier "in")? in_val | fulltext
+# operator   ::= "=" | "!=" | "<" | ">" | "<=" | ">="
+# boolean_op ::= "and"
+# modifiers  ::= sort?
+# sort       ::= "/sort" "=" identifier
+# fulltext   ::= "oslc_cm:searchTerms" "=" '"' value+ '"'
+# identifier ::= word (":" word)?
+# in_val     ::= "[" value ("," value)* "]"
+# value      ::= (integer | string)
+# word       ::= /any sequence of letters and numbers, starting with a letter/
+# string     ::= '"' + /any sequence of characters/ + '"'
+# integer    ::= /any sequence of integers/
+
+# $Id: CmController.php 69 2009-12-17 21:35:25Z berger_o $
+
+# name of the class to be generated for the parser
+%class cql_lime_parser
+
+# The following tokens are provided by the tokenizer :
+#  integer  : an integer
+#  string   : a string quoted with double quotes (")
+#  word     : an unquoted string
+#  and_kw   : 'and'
+#  sort_kw  : 'sort'
+#  equal_kw : '='
+#  not_kw   : '!'
+#  lt_kw    : '<' 
+#  gt_kw    : '>'
+
+
+%start query
+
+# start to try and map :
+#  query ::= (term (boolean_op term)*)+ modifiers
+# decomposed in 2 rules using 'query_in'
+
+query = query_in {
+	global $parsed_results;
+	$parsed_results = $$;
+	}
+| query_in modifiers {
+	global $parsed_results;
+	$parsed_results = $$;
+	}
+.
+
+query_in = term { 
+
+	$$ = array( 'terms' => array($1) );
+
+	debug_found('query_in', 'single term :'. print_r($$,true) ); 
+	}
+| query_in boolean_op term {
+ 
+	$first_subquery = $1;
+	$terms = $first_subquery['terms'];
+	$terms[] = $3;
+	$$ = array( 'terms' => $terms );
+	
+	debug_found('query_in', 'found multiplesubqueries with boolean query_in : '. print_r($$,true) );
+	}
+.
+
+
+# term       ::= (identifier operator)? value+ | (identifier "in")? in_val | fulltext
+
+term = identifier/i operator/o value/v {
+
+	$$ = array($o, $i, $v);
+
+	debug_found('term', 'found identifier operator value term: '. print_r($$,true) ); 
+	}
+| value { 
+	debug_found('term', 'found single value term: '. print_r($$,true) );
+	}
+.
+
+operator = equal_kw
+| not_kw equal_kw { $$ = $1.$2; }
+| lt_kw 
+| gt_kw 
+| lt_kw equal_kw { $$ = $1.$2; } 
+| gt_kw equal_kw { $$ = $1.$2; } 
+.
+
+boolean_op = and_kw
+.
+
+modifiers = sort
+.
+
+sort = '/' sort_kw '=' identifier
+.
+
+identifier = word { 
+	debug_found('identifier', 'found simple identifier: '. print_r($$,true) );
+	}
+| word ':' word {
+
+	$$ = $1.':'.$3;
+	 
+	debug_found('identifier', 'found prefixed identifier: '. print_r($$,true) );
+	}
+.
+
+in_val = {
+	$$=array(); /* problem */}
+| '[' in_val_in/in ']' { $$[] = $in; }
+.
+
+in_val_in = value {/* problem */}
+| ',' in_val_in
+.
+
+value = integer { 
+	debug_found('value', 'found integer: '. print_r($$,true) ); 
+	}
+| string { 
+	debug_found('value', 'found string: '. print_r($$,true) ); 
+	}
+.
+

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/cql.php
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/cql.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/cql.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,155 @@
+<?php
+
+/**
+ * This file is (c) Copyright 2010 by Olivier BERGER, 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.
+ *
+ */
+
+include_once "lime-parse_engine.php";
+include_once "cql-lime_parser.inc.php";
+
+// change to true to get debug
+$debug_founds=false;
+//$debug_founds=true;
+
+function debug_found($term, $message) {
+	global $debug_founds;
+	if($debug_founds) echo "found $term: ".$message."\n";
+}
+
+function tokenize($line) {
+	// Numbers are tokens, as are all other non-whitespace characters.
+	// Note: This isn't a particularly efficent tokenizer, but it gets the
+	// job done.
+	$out = array();
+	//echo "tokenize '$line'\n";
+	while (strlen($line)) {
+		//echo "handle rest of the line : '$line'\n";
+		$line = trim($line);
+		if (preg_match('/^[0-9]+(\.[0-9]*)?/', $line, $regs)) {
+			# It's a number
+			$out[] = $regs[0];
+			$line = substr($line, strlen($regs[0]));
+		} else if (preg_match('/^[A-Za-z][A-Za-z0-9_]+/', $line, $regs)) {
+			# It's a word
+			$out[] = $regs[0];
+			$line = substr($line, strlen($regs[0]));
+		} else if (preg_match('/^"[^"]*"/', $line, $regs)) {
+			# It's a string
+			# we need to take care of embedded escaped quotes'\"'
+			$outstr='';
+			while(preg_match('/^"[^"]*"/', $line, $regs)) {
+				$string = $regs[0];
+				//print_r($string);
+				if ( (strlen($string) > 2) && ($string[strlen($string)-2] == "\\") ) {
+					//print_r('- outstr :');
+					$outstr .= substr($string, 0, strlen($string)-1);
+					//print_r($outstr);
+					//print_r('- newline :');
+					$line = substr($line, strlen($string)-1);
+					//print_r($line);
+				}
+				else {
+					$outstr .= $string;
+					$line = substr($line, strlen($string));
+					//print_r($line);
+				}
+			}
+			$out[] = $outstr;
+		} else {
+			# It's some other character
+			$out[] = $line[0];
+			$line = substr($line, 1);
+		}
+	}
+	return $out;
+}
+
+//$symbol_table = array();
+
+function parse_cql($line) {
+	//echo "calculate : ";
+	global $parser;
+	$parser = new parse_engine(new cql_lime_parser());
+	global $parsed_results;
+	$parsed_results = False;
+	
+	if (!strlen($line)) return $parsed_results;
+	try {
+		$parser->reset();
+		// split the line into tokens and process them
+		$tokens = tokenize($line);
+		//echo "tokenized :";
+		//print_r($tokens);
+		foreach($tokens as $t) {
+			if (is_numeric($t)) {
+				$parser->eat('integer', doubleval($t));
+			}
+			else if ($t[0] == '"') {
+				$parser->eat('string', $t);
+			}
+			else if (ctype_alpha($t)) {
+				// a word
+				if ($t == 'and') {
+					$parser->eat('and_kw', $t);
+				}
+				elseif ($t == 'sort') {
+					$parser->eat('sort_kw', $t);
+				}
+				else {
+					$parser->eat('word', $t);
+				}
+			}
+			elseif (preg_match('/^[A-Za-z][A-Za-z0-9_]+/', $t)){
+				$parser->eat('word' ,$t);
+			}
+			else {
+				switch($t) {
+			  case '=' :
+			  	$parser->eat('equal_kw', $t);
+			  	break;
+			  case '!' :
+			  	$parser->eat('not_kw', $t);
+			  	break;
+			  case '<' :
+			  	$parser->eat('lt_kw', $t);
+			  	break;
+			  case '>' :
+			  	$parser->eat('gt_kw', $t);
+			  	break;
+			  default :
+			  	$parser->eat("'$t'", null);
+			  	break;
+				}
+			}
+		}
+		$parser->eat_eof();
+		
+	} catch (parse_error $e) {
+		echo $e->getMessage(), "\n";
+	}
+	return $parsed_results;
+}
+
+if($debug_founds) {
+	$parser = new parse_engine(new cql_lime_parser());
+	while ($line = fgets(STDIN)) parse_cql(trim($line));
+}

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/lime-parse_engine.php
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/lime-parse_engine.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/controllers/lime-parse_engine.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,252 @@
+<?php
+/*
+ *  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 Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+
+define('LIME_CALL_PROTOCOL', '$tokens, &$result');
+
+abstract class lime_parser {
+}
+
+class parse_error extends Exception {}	# If this happens, the input doesn't match the grammar.
+class parse_bug extends Exception {}	# If this happens, I made a mistake.
+
+class parse_unexpected_token extends parse_error {
+	function __construct($type, $state) {
+		parent::__construct("Unexpected token of type ($type)");
+		$this->type = $type;
+		$this->state = $state;
+	}
+}
+class parse_premature_eof extends parse_error {
+	function __construct() {
+		parent::__construct("Premature EOF");
+	}
+}
+
+
+class parse_stack {
+	function __construct($qi) {
+		$this->q = $qi;
+		$this->qs = array();
+		$this->ss = array();
+	}
+	function shift($q, $semantic) {
+		$this->ss[] = $semantic;
+		$this->qs[] = $this->q;
+		$this->q = $q;
+		# echo "Shift $q -- $semantic<br/>\n";
+	}
+	function top_n($n) {
+		if (!$n) return array();
+		return array_slice($this->ss, 0-$n);
+	}
+	function pop_n($n) {
+		if (!$n) return array();
+		$qq = array_splice($this->qs, 0-$n);
+		$this->q = $qq[0];
+		return array_splice($this->ss, 0-$n);
+	}
+	function occupied() { return !empty($this->ss); }
+	function index($n) {
+		if ($n) $this->q = $this->qs[count($this->qs)-$n];
+	}
+	function text() {
+		return $this->q." : ".implode(' . ', array_reverse($this->qs));
+	}
+}
+class parse_engine {
+	function __construct($parser) {
+		$this->parser = $parser;
+		$this->qi = $parser->qi;
+		$this->rule = $parser->a;
+		$this->step = $parser->i;
+		#$this->prepare_callables();
+		$this->reset();
+		#$this->debug = false;
+	}
+	function reset() {
+		$this->accept = false;
+		$this->stack = new parse_stack($this->qi);
+	}
+	private function enter_error_tolerant_state() {
+		while ($this->stack->occupied()) {
+			if ($this->has_step_for('error')) return true;
+			$this->drop();
+		};
+		return false;
+	}
+	private function drop() { $this->stack->pop_n(1); }
+	function eat_eof() {
+		{/*
+		
+		So that I don't get any brilliant misguided ideas:
+		
+		The "accept" step happens when we try to eat a start symbol.
+		That happens because the reductions up the stack at the end
+		finally (and symetrically) tell the parser to eat a symbol
+		representing what they've just shifted off the end of the stack
+		and reduced. However, that doesn't put the parser into any
+		special different state. Therefore, it's back at the start
+		state.
+		
+		That being said, the parser is ready to reduce an EOF to the
+		empty program, if given a grammar that allows them.
+		
+		So anyway, if you literally tell the parser to eat an EOF
+		symbol, then after it's done reducing and accepting the prior
+		program, it's going to think it has another symbol to deal with.
+		That is the EOF symbol, which means to reduce the empty program,
+		accept it, and then continue trying to eat the terminal EOF.
+		
+		This infinte loop quickly runs out of memory.
+		
+		That's why the real EOF algorithm doesn't try to pretend that
+		EOF is a terminal. Like the invented start symbol, it's special.
+		
+		Instead, we pretend to want to eat EOF, but never actually
+		try to get it into the parse stack. (It won't fit.) In short,
+		we look up what reduction is indicated at each step in the
+		process of rolling up the parse stack.
+		
+		The repetition is because one reduction is not guaranteed to
+		cascade into another and clean up the entire parse stack.
+		Rather, it will instead shift each partial production as it
+		is forced to completion by the EOF lookahead.
+		*/}
+		
+		# We must reduce as if having read the EOF symbol
+		do {
+			# and we have to try at least once, because if nothing
+			# has ever been shifted, then the stack will be empty
+			# at the start.
+			list($opcode, $operand) = $this->step_for('#');
+			switch ($opcode) {
+				case 'r': $this->reduce($operand); break;
+				case 'e': $this->premature_eof(); break;
+				default: throw new parse_bug(); break;
+			}
+		} while ($this->stack->occupied());
+		{/*
+		If the sentence is well-formed according to the grammar, then
+		this will eventually result in eating a start symbol, which
+		causes the "accept" instruction to fire. Otherwise, the
+		step('#') method will indicate an error in the syntax, which
+		here means a premature EOF.
+		
+		Incedentally, some tremendous amount of voodoo with the parse
+		stack might help find the beginning of some unfinished
+		production that the sentence was cut off during, but as a
+		general rule that would require deeper knowledge.
+		*/}
+		if (!$this->accept) throw new parse_bug();
+		return $this->semantic;
+	}
+	private function premature_eof() {
+		$seen = array();
+		while ($this->enter_error_tolerant_state()) {
+			if (isset($seen[$this->state()])) {
+				// This means that it's pointless to try here.
+				// We're guaranteed that the stack is occupied.
+				$this->drop();
+				continue;
+			}
+			$seen[$this->state()] = true;
+			
+			$this->eat('error', NULL);
+			if ($this->has_step_for('#')) {
+				// Good. We can continue as normal.
+				return;
+			} else {
+				// That attempt to resolve the error condition
+				// did not work. There's no point trying to
+				// figure out how much to slice off the stack.
+				// The rest of the algorithm will make it happen.
+			}
+		}
+		throw new parse_premature_eof();
+	}
+	private function current_row() { return $this->step[$this->state()]; }
+	private function step_for($type) {
+		$row = $this->current_row();
+		if (!isset($row[$type])) return array('e', $this->stack->q);
+		return explode(' ', $row[$type]);
+	}
+	private function has_step_for($type) {
+		$row = $this->current_row();
+		return isset($row[$type]);
+	}
+	private function state() { return $this->stack->q; }
+	function eat($type, $semantic) {
+		# assert('$type == trim($type)');
+		# if ($this->debug) echo "Trying to eat a ($type)\n";
+		list($opcode, $operand) = $this->step_for($type);
+		switch ($opcode) {
+			case 's':
+			# if ($this->debug) echo "shift $type to state $operand\n";
+			$this->stack->shift($operand, $semantic);
+			# echo $this->stack->text()." shift $type<br/>\n";
+			break;
+			
+			case 'r':
+			$this->reduce($operand);
+			$this->eat($type, $semantic);
+			# Yes, this is tail-recursive. It's also the simplest way.
+			break;
+			
+			case 'a':
+			if ($this->stack->occupied()) throw new parse_bug('Accept should happen with empty stack.');
+			$this->accept = true;
+			#if ($this->debug) echo ("Accept\n\n");
+			$this->semantic = $semantic;
+			break;
+			
+			case 'e':
+			# This is thought to be the uncommon, exceptional path, so
+			# it's OK that this algorithm will cause the stack to
+			# flutter while the parse engine waits for an edible token.
+			# if ($this->debug) echo "($type) causes a problem.\n";
+			if ($this->enter_error_tolerant_state()) {
+				$this->eat('error', NULL);
+				if ($this->has_step_for($type)) $this->eat($type, $semantic);
+			} else {
+				# If that didn't work, give up:
+				throw new parse_error("Parse Error: ($type)($semantic) not expected");
+			}
+			break;
+			
+			default:
+			throw new parse_bug("Bad parse table instruction ".htmlspecialchars($opcode));
+		}
+	}
+	private function reduce($rule_id) {
+		$rule = $this->rule[$rule_id];
+		$len = $rule['len'];
+		$semantic = $this->perform_action($rule_id, $this->stack->top_n($len));
+		#echo $semantic.br();
+		if ($rule['replace']) $this->stack->pop_n($len);
+		else $this->stack->index($len);
+		$this->eat($rule['symbol'], $semantic);
+	}
+	private function perform_action($rule_id, $slice) {
+		# we have this weird calling convention....
+		$result = null;
+		$method = $this->parser->method[$rule_id];
+		#if ($this->debug) echo "rule $id: $method\n";
+		$this->parser->$method($slice, $result);
+		return $result;
+	}
+}

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/exceptions/oslcException.php
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/exceptions/oslcException.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/exceptions/oslcException.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,74 @@
+<?php
+
+class oslcException extends Exception
+{
+	protected $code = 0;
+	protected $exception_details = "OSLC Custom Exception";
+	
+	public function __construct($message, Exception $previous = null)
+	{
+		parent::__construct($message, $this->code, $previous);
+		
+	}
+	
+	public function getExceptionDetails()
+	{
+		return $this->exception_details;
+	}
+}
+
+class ForbiddenException extends oslcException
+{
+	protected $code = 403;
+	protected $exception_details = "Server has rejected request, as response content size many not be optimal";
+}
+
+class NotAcceptableForCRCollectionException extends oslcException
+{
+	protected $code = 406;
+	protected $exception_details = "Server can not fulfill the request due to it's Accept headers";
+}
+
+class BadRequestException extends oslcException
+{
+	protected $code = 400;
+	protected $exception_details = "Some of the parameters may not be properly structured. For e.g. malformed query parameters, malformed content (malformed XML)";
+}
+
+class NotFoundException extends oslcException
+{
+	protected $code = 404;
+	protected $exception_details = "The request URL does not represent a URL on the server";
+}
+
+class ConflictException extends oslcException
+{
+	protected $code = 409;
+	protected $exception_details = "Request content specifies a property that the resource doesn't support or has an invalid value";
+}
+
+class UnsupportedMediaTypeException extends oslcException
+{
+	protected $code = 415;
+	protected $exception_details = "The Content-type of the body of the request is not known to the service provider";
+}
+
+class NotAcceptableException extends oslcException
+{
+	protected $code = 405;
+	protected $exception_details = "Server can not fulfill the request due to it's Accept headers";
+}
+
+class GoneException extends oslcException
+{
+	protected $code = 410;
+	protected $exception_details = "The resource no longer exists in the system ";
+}
+
+class PreconditionFailedException extends oslcException
+{
+	protected $code = 412;
+	protected $exception_details = "The ETag supplied in the If-Match request header value did not match that of the resource being modified";
+}
+
+?>
\ No newline at end of file

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/models/ChangeRequests.php
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/models/ChangeRequests.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/models/ChangeRequests.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,612 @@
+<?php
+
+/**
+ * This file is (c) Copyright 2009 by Madhumita DHAR, Olivier BERGER,
+ * 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.
+ *
+ */
+
+/* $Id$ */
+
+/**
+ * OSLC-CM V1 ChangeRequest model
+ * 
+ * @package model
+ * @subpackage OslcCmChangeRequest
+ */
+
+// Define the backend tracker type : by defaut : mantis
+defined('TRACKER_TYPE')
+    || define('TRACKER_TYPE', (getenv('TRACKER_TYPE') ? getenv('TRACKER_TYPE') : 'mantis'));
+
+switch (TRACKER_TYPE) {
+	case 'mantis':
+		break;
+	case 'fusionforge':
+		break;
+	case 'demo':
+		// Use the PEAR File_CSV module which handles various kinds of CSV encodings
+		require_once 'File/CSV.php';
+		break;
+	default:
+		throw new Exception('Unsupported TRACKER_TYPE : '. TRACKER_TYPE .' !');
+		break;
+}
+
+/**
+ * Models OSLC-CM ChangeRequest (see http://open-services.net/bin/view/Main/CmResourceDefinitionsV1)
+ *
+ * Implements ArrayAccess and Iterator so that it can be accessed as
+ * an array of its attributes.
+ *
+ * @author Olivier Berger <olivier.berger at it-sudparis.eu>
+ *
+ */
+
+class ChangeRequest implements ArrayAccess, Iterator
+{
+
+	/**
+	 * Mandatory attributes for a changerequest
+	 * @var array
+	 */
+	protected $_mandatory = array('title','identifier');
+
+	/**
+	 * So far, unused, but may need a check
+	 * @var array
+	 */
+	protected $_optional = array('type','description','subject','creator','modified');
+
+	/**
+	 * Holds the container for the real attributes array
+	 * 
+	 * The dublin core OSLC-CM V1 attributes ($_mandatory and $_optional) are handled without any prefix.
+	 * Additional attributes from other ontologies can be stored but with their prefixes
+	 * 
+	 * @var array
+	 */
+	private $container = array();
+
+	/**
+	 * @param string $identifier unique ChangeRequest id
+	 * @param string $title
+	 * @param string $type Type of request that is represented, such as: defect, enhancement, etc.
+	 * @param string $description
+	 * @param string $subject a collection of keywords and tags
+	 * @param string $creator
+	 * @param string $modified modified date time which must conform to RFC3339 format
+	 */
+	function __construct($identifier = null, $title = null, $type = null, $description = null, $subject = null, $creator = null, $modified = null)
+	{
+		// $identifier may be provided as null first, for practical reasons although ultimately non null
+		$this->container = array(
+			'identifier' => $identifier,
+			'title' => $title);
+
+		if(isset($type))
+		$this->container['type'] = $type;
+		if(isset($description))
+		$this->container['description'] = $description;
+		if(isset($subject))
+		$this->container['subject'] = $subject;
+		if(isset($creator))
+		$this->container['creator'] = $creator;
+		if(isset($modified))
+		$this->container['modified'] = $modified;
+	}
+
+	/**
+	 * Factory for the creation of instances of ChangeRequest subclasses
+	 *
+	 * @param string $bugtrackertype
+	 * @return ChangeRequest
+	 */
+	public static function Create($bugtrackertype = 'default')
+	{
+		// use a utility function outside the class since otherwise we would 
+		//have cycle in dependencies between ChangeRequest and MantisChangeRequest
+		return __createChangeRequest($bugtrackertype);
+	}
+
+	/**
+	 * Create from XML (RDF) OSLC-CM document
+	 *
+	 * @param string $xmlstr
+	 * @return ChangeRequest
+	 */
+	public static function CreateFromXml($xmlstr)
+	{
+		// will contain an array of fields read in the oslc:ChangeRequest
+		$resource = null;
+
+		// we use simplexml PHP library which supports namespaces
+		
+		/*******Sample CR*****************************************
+		 * 
+		 * <?xml version="1.0"?>
+		 * <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+		 *   <oslc_cm:ChangeRequest xmlns:oslc_cm="http://open-services.net/xmlns/cm/1.0/">
+		 *       <dc:title xmlns:dc="http://purl.org/dc/terms/">Provide import</dc:title>
+		 *       <dc:identifier xmlns:dc="http://purl.org/dc/terms/">1234</dc:identifier>
+		 *       <dc:type xmlns:dc="http://purl.org/dc/terms/">http://myserver/mycmapp/types/Enhancement</dc:type>
+		 *       <dc:description xmlns:dc="http://purl.org/dc/terms/">Implement the system's import capabilities.</dc:description>
+		 *       <dc:subject xmlns:dc="http://purl.org/dc/terms/">import</dc:subject>
+		 *       <dc:creator xmlns:dc="http://purl.org/dc/terms/">mailto:aadams at someemail.com</dc:creator>
+		 *       <dc:modified xmlns:dc="http://purl.org/dc/terms/">2008-09-16T08:42:11.265Z</dc:modified>
+		 *   </oslc_cm:ChangeRequest>
+		 * </rdf:RDF>
+		 *           
+		 */
+
+		$xml = simplexml_load_string($xmlstr);
+		$namespace = $xml->getNamespaces();
+		if ( ($namespace['rdf'] == 'http://www.w3.org/1999/02/22-rdf-syntax-ns#') &&
+			 ($xml->getName() == 'RDF')) 
+		{		
+			foreach ($xml->children('http://open-services.net/xmlns/cm/1.0/') as $changerequest) {
+				if ($changerequest->getName() == 'ChangeRequest') {
+					$resource = array();
+					foreach ($changerequest->children('http://purl.org/dc/terms/') as $child) {
+						$field = $child->getName();
+						$value = (string)$child;
+						$resource[$field] = $value;
+					}
+				}
+			}
+		}
+
+		$changerequest = new ChangeRequest();
+
+		// initialize the ChangeRequest attributes
+		foreach ($resource as $field => $value) {
+			$changerequest->container[$field] = $value;
+		}
+
+		return $changerequest;
+	}
+
+	/**
+	 * Create a ChangeRequest from a JSON OSLC-CM representation
+	 * 
+	 * @param string $jsonstr
+	 * @return ChangeRequest
+	 */
+	
+	public static function CreateFromJson($jsonstr) {
+
+		$resource = Zend_Json::decode($jsonstr);
+
+		$changerequest = new ChangeRequest();
+
+		// the dublin core elements prefix is removed
+		
+		foreach ($resource as $field => $value) {
+			$field = str_replace('dc:', '', $field);
+			$field = str_replace('mantisbt:', '', $field);
+			$changerequest->container[$field] = $value;
+		}
+
+		return $changerequest;
+
+	}
+
+	// ArrayAccess methods
+
+	public function offsetSet($offset, $value) {
+		$this->container[$offset] = $value;
+	}
+
+	public function offsetExists($offset) {
+		return isset($this->container[$offset]);
+	}
+
+	public function offsetUnset($offset) {
+		unset($this->container[$offset]);
+	}
+
+	public function offsetGet($offset) {
+		return isset($this->container[$offset]) ? $this->container[$offset] : null;
+	}
+
+	// Iterator methods
+	
+	public function rewind() {
+		reset($this->container);
+	}
+
+	public function current() {
+		return current($this->container);
+	}
+
+	public function key() {
+		return key($this->container);
+	}
+
+	public function next() {
+		return next($this->container);
+	}
+
+	public function valid() {
+		return $this->current() !== false;
+	}
+
+	/**
+	 * Check that all mandatory ChangeRequest fields are defined
+	 * 
+	 * Throws an exception otherwise
+	 */
+	public function checkMandatoryFields() {
+		// check that all mandatory fields are there
+		foreach ($this->_mandatory as $mandatoryfield) {
+			if (! isset($this[$mandatoryfield])) {
+				throw new Exception('Mandatory field "'.$mandatoryfield.'" not present !');
+			}
+		}
+	}
+
+}
+
+
+/**
+ * Abstract class implementing a ChangeRequest DB
+ * 
+ * Holds all ChangeRequest in memory.
+ * They will be loaded all at once when first access is made 
+ * unless this behaviour is redefined un subclasses by 
+ * overloading loadChangeRequest()
+ * 
+ * @abstract
+ */
+class ChangeRequests implements ArrayAccess, Iterator, Countable
+{
+	/**
+	 * Attributes known for the ChangeRequest instances
+	 * 
+	 * @var array
+	 */
+	protected $_fields;
+	
+	/**
+	 * An array containing the ChangeRequest instances accessible by their identifiers
+	 * 
+	 * @var array
+	 */
+	protected $_data;
+
+	function __construct() {
+		$this->_fields = null;
+		$this->_data = null;
+
+	}
+
+	/**
+	 * Loads all ChangeRequest at once
+	 * 
+	 * Method to be implemented / overloaded in subclasses
+	 * 
+	 * @abstract
+	 */
+	protected function loadAllChangeRequests()
+	{
+		//print_r('abstract ChangeRequests::loadAllChangeRequests()');
+	}
+
+	/**
+	 * Load a single ChangeRequest provided its indentifier
+	 * 
+	 * May be overloaded if need to do individual queries in a DB 
+	 * instead of loading everything at once
+	 * 
+	 * @param string $identifier
+	 */
+	protected function loadChangeRequest($identifier) {
+
+		// by default, try and load all changerequests on the first query
+		$this->loadAllChangeRequests();
+	}
+	
+	public function setFilter($params) {
+		
+	}
+	
+	// Countable methods
+	public function count() {
+		return count($this->_data);
+	}
+
+	// ArrayAccess methods
+
+	public function offsetSet($offset, $value) {
+		$newid = $value['identifier'];
+		if ($offset != $newid) {
+			throw new Exception('Sorry, ChangeRequest identifier cannot be modified !');
+		}
+		$this->loadChangeRequest($offset);
+		$this->_data[$offset] = $value;
+		//print_r('offsetSet');
+		//throw new Exception('Sorry, writing to read-only ChangeRequests object !');
+	}
+
+	public function offsetExists($offset) {
+		//print_r('offsetExists');
+		$this->loadChangeRequest($offset);
+		return isset($this->_data[$offset]);
+	}
+
+	public function offsetUnset($offset) {
+		//print_r('offsetUnset');
+		throw new Exception('Sorry, writing to read-only ChangeRequests object !');
+	}
+
+	public function offsetGet($offset) {
+		//print_r('offsetGet');
+		$this->loadChangeRequest($offset);
+		return isset($this->_data[$offset]) ? $this->_data[$offset] : null;
+	}
+
+	// Iterator methods
+
+	public function rewind() {
+		//print_r('rewind');
+		$this->loadAllChangeRequests();
+		if(isset($this->_data)) {
+			reset($this->_data);
+		}
+	}
+
+	public function current() {
+		//print_r('current');
+		if(isset($this->_data))	{
+			return current($this->_data);
+		}
+		else {
+		     return false;
+		}
+	}
+
+	public function key() {
+		//print_r('key');
+		return key($this->_data);
+	}
+
+	public function next() {
+		//print_r('next');
+		return next($this->_data);
+	}
+
+	public function valid() {
+		//print_r('valid');
+		return $this->current() !== false;
+	}
+
+}
+
+
+/**
+ * Utility function for ChangeRequest::Create
+ */
+$model_dir = APPLICATION_PATH.'/models/';
+require_once($model_dir . 'mantis.inc.php');
+require_once($model_dir . 'fusionforge.inc.php');
+
+function __createChangeRequest($bugtrackertype)
+{
+	$changerequest = null;
+	switch ($bugtrackertype) {
+		case 'default' :
+			$changerequest = new ChangeRequest();
+			break;
+		case 'fusionforge' :
+			$changerequest = new FusionForgeChangeRequest();
+			break;
+		case 'mantis' :
+			$changerequest = new MantisChangeRequest();
+			break;
+		default :
+			throw new Exception('Unknown bugtracker type '.$bugtrackertype.' !');
+			break;
+	}
+	return $changerequest;
+}
+
+
+/**
+ * For demo DB using a CSV file
+ *  
+ * @package CsvModel 
+ */
+
+/**
+ * Subclass implementing a ChangeRequests DB loaded from a CSV file
+ *
+ * Can be used to implement standalone read-only ChangeRequests DB
+ */
+
+class ChangeRequestsCsv extends ChangeRequests
+{
+	/**
+	 * @var filename
+	 */
+	private $_csvfilename;
+
+	private $_filter = null;
+	
+	/**
+	 * @param string $filename
+	 */
+	function __construct($filename) {
+		parent::__construct();
+
+		$this->_csvfilename = $filename;
+
+	}
+
+	public function setFilter($params) {
+		//print_r('set filter :');
+		//print_r($params);
+		if(array_key_exists('project',$params)) {
+			$this->_filter = array('mantisbt:project' => $params['project']);
+		}	
+	}
+	
+	/**
+	 * Load all ChangeRequest from the CSV file
+	 * 
+	 */
+	protected function loadAllChangeRequests()
+	{
+		//print_r('ChangeRequestsCsv::loadAllChangeRequests()');
+		
+		// only load once (if not already loaded before)
+		if (isset($this->_data))
+		return;
+		
+		$this->_data = array();
+
+		$filename = $this->_csvfilename;
+		
+		// load the formet of the CSV file
+		//print_r('load from : '.$filename);
+		$conf = File_CSV::discoverFormat($filename);
+		//print_r($conf);
+		// columns number of the identifier
+		$idcolnum = null;
+		$bugtrackertype = 'default';
+
+		// process all lines
+		while ($res = File_CSV::read($filename, $conf)) {
+			//print_r($res);
+			// first line defines columns names
+			if (! $this->_fields) {
+
+				$this->_fields = array();
+
+				// search for identifier's column number
+				for ($i=0; $i < $conf['fields']; $i++ ) {
+						
+					if ( trim($res[$i]) == 'identifier') {
+						$idcolnum = $i;
+					}
+						
+					// handle special case of the additional definitions at the end of the columns headers
+					$definitions = explode('=', $res[$i]);
+					if ( (count($definitions) > 1) && ($definitions[0] == 'bugtracker')) {
+						switch ($definitions[1]) {
+							case 'default' :
+							case 'fusionforge' :
+							case 'mantis' :
+								$bugtrackertype = $definitions[1];
+								break;
+							default :
+								throw new Exception('Unknown bugtracker type '.$definitions[1].' in CSV file headers !');
+								break;
+						}
+					}
+					else {
+
+						$this->_fields[] = $res[$i];
+					}
+				}
+
+			}
+			// other data lines processing
+			else {
+				// identifier
+				$id = $res[$idcolnum];
+
+				// maybe check if not duplicate identifier ?
+
+				// add an entry for the identifier
+
+				$cr = ChangeRequest::Create($bugtrackertype);
+				
+				for ($i=0; $i < count($this->_fields); $i++ ) {
+					$fieldname = $this->_fields[$i];
+					if (isset($res[$i])) {
+						$cr[$fieldname] = $res[$i];
+					}
+					else {
+						throw new Exception('No value for bug '.$id.' in column '.$fieldname.' !');
+					}					
+				}
+				
+				$cr->checkMandatoryFields();
+				
+				//print_r($cr);
+				//print_r('filter:');
+				//print_r($this->_filter);
+				
+				// filter only for specific fields/values
+				if (isset($this->_filter) && is_array($this->_filter)) {
+					// for each filter field
+					foreach ($this->_filter as $field => $value) {
+						//print_r('filter on :'.$field.' == '.$value);
+						if(isset($cr[$field])) {
+							//print_r('found field '.$field);
+							//print_r($cr[$field]);
+							if ($cr[$field] != $value) {
+								$cr = null;
+								break;
+							}
+						}
+						else {
+							$cr = null;
+							break;
+						}
+					}
+				}
+				if($cr) {
+					//print_r('OK : kept');
+					$this->_data[$id] = $cr;
+				}/*
+				else {
+					print_r('NOK : dismissed');	
+				} 	*/	
+			}
+		}
+		
+		// reset the CSV file reading to be able to call it twice on same file
+		$file = File_CSV::getPointer($filename,$conf);
+		if($file) {
+			//print_r('file :');
+			//print_r($file);
+			$reset = File_CSV::resetPointer($filename, $conf, FILE_MODE_READ);
+			if(!$reset) {
+				throw new Exception('Could not File_CSV::resetPointer("'.$filename.'") !');
+			}
+		}
+		//print_r($this);
+	}
+
+	// load only a specific changerequest from its id
+	/*
+	protected function loadChangeRequest($identifier) {
+
+		// $this->_data[$identifier] = getArtifact($identifier); -> select * from artifact where id = $identifier
+
+		// We can only parse the whole CSV file at once until further optimization
+		$this->loadAllChangeRequests();
+	}
+	*/
+}
+
+
+

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/models/fusionforge.inc.php
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/models/fusionforge.inc.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/models/fusionforge.inc.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,287 @@
+<?php
+
+/**
+ * This file is (c) Copyright 2009 by Madhumita DHAR, Olivier BERGER,
+ * 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.
+ *
+ */
+
+/* $Id$ */
+
+$model_dir = APPLICATION_PATH.'/models/';
+require_once($model_dir . 'ChangeRequests.php');
+
+
+/**
+ * For FusionForge
+ *  
+ * @package FusionForgeModel 
+ */
+
+/**
+ * Example of a FusionForge ChangeRequest that extends its model
+ * 
+ *  Adds a status with the helios_bt ontology (fictional)
+ */
+class FusionForgeChangeRequest extends ChangeRequest
+{
+	/**
+	 * Adds helios_bt:status as mandatory
+	 * 
+	 * @var array
+	 */
+	protected $_mandatory = array('title','identifier','helios_bt:status');
+
+	protected $_optional = array('description','creator','modified',);	
+
+	// may then add a status ?
+	//private $_status;
+
+
+	/**
+	 * Create from XML (RDF) OSLC-CM document
+	 *
+	 * @param string $xmlstr
+	 * @return ChangeRequest
+	 * 
+	 * TODO: Replace with other semantic rdf parser, ex: PHP-ARC2
+	 */
+	public static function CreateFusionForgeArrayFromXml($xmlstr)
+	{
+		// will contain an array of fields read in the oslc:ChangeRequest
+		$resource = null;
+
+		// we use simplexml PHP library which supports namespaces
+		
+		/*******Sample CR*****************************************
+		 * 
+		 * <?xml version="1.0"?>
+		 * <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+		 *   <oslc_cm:ChangeRequest xmlns:oslc_cm="http://open-services.net/xmlns/cm/1.0/">
+		 *       <dc:title xmlns:dc="http://purl.org/dc/terms/">Provide import</dc:title>
+		 *       <dc:identifier xmlns:dc="http://purl.org/dc/terms/">1234</dc:identifier>
+		 *       <dc:type xmlns:dc="http://purl.org/dc/terms/">http://myserver/mycmapp/types/Enhancement</dc:type>
+		 *       <dc:description xmlns:dc="http://purl.org/dc/terms/">Implement the system's import capabilities.</dc:description>
+		 *       <dc:subject xmlns:dc="http://purl.org/dc/terms/">import</dc:subject>
+		 *       <dc:creator xmlns:dc="http://purl.org/dc/terms/">mailto:aadams at someemail.com</dc:creator>
+		 *       <dc:modified xmlns:dc="http://purl.org/dc/terms/">2008-09-16T08:42:11.265Z</dc:modified>
+		 *   </oslc_cm:ChangeRequest>
+		 * </rdf:RDF>
+		 *           
+		 */
+		
+		$dc_attr = array("title", "identifier", "description","creator","modified","created");
+		$fusionforgebt_attr = array("status","priority", "assigned_to");
+
+		$xml = simplexml_load_string($xmlstr);
+
+		$namespace = $xml->getNamespaces(true);
+		/*$namespace = array(
+			'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
+			'oslc_cm' => 'http://open-services.net/xmlns/cm/1.0/',
+		    'mantisbt' => 'http://www.mantisbt.org/xmlns/mantisbt/',
+		    'dc' => 'http://purl.org/dc/terms/'
+		);*/
+		if ( ($namespace['rdf'] == 'http://www.w3.org/1999/02/22-rdf-syntax-ns#') &&
+			 ($xml->getName() == 'RDF')) 
+		{		
+			foreach ($xml->children('http://open-services.net/xmlns/cm/1.0/') as $changerequest) {
+				if ($changerequest->getName() == 'ChangeRequest') {
+					$resource = array();
+					foreach ($changerequest->children('http://purl.org/dc/terms/') as $child) {
+						$field = $child->getName();
+						if (in_array($field,$dc_attr))
+						{
+							$value = (string)$child;
+							$resource[$field] = $value;
+						}
+					}
+					foreach ($changerequest->children('http://heliosplatform.sourceforge.net/ontologies/2010/05/helios_bt.owl') as $child) {
+						$field = $child->getName();
+						if(!$field){
+							print('No ontology attribute !!!');
+						}
+						if (in_array($field,$fusionforgebt_attr))
+						{
+							$value = (string)$child;
+							$resource[$field] = $value;
+						}
+					}
+				}
+			}
+		}
+
+		$changerequest = new FusionForgeChangeRequest();
+
+		// initialize the ChangeRequest attributes
+		foreach ($resource as $field => $value) {
+			$changerequest->container[$field] = $value;
+		}
+		//print_r($xml);
+		//print_r($resource);
+		//print_r($changerequest);
+
+		return $changerequest;
+	}
+	
+	public static function CreateFusionForgeArrayFromJson($jsonstr) {
+		$resource = Zend_Json::decode($jsonstr);
+
+		$changerequest = new FusionForgeChangeRequest();
+
+		// the dublin core elements prefix is removed
+		
+		foreach ($resource as $field => $value) {
+			$field = str_replace('dc:', '', $field);
+			$field = str_replace('helios_bt:', '', $field);
+			
+			$changerequest->container[$field] = $value;
+		}
+
+		return $changerequest;
+	}
+	
+}
+
+
+// Represents a base of changerequests loaded from FusionForge DB
+class ChangeRequestsFusionForgeDb extends ChangeRequests
+{
+	// created out of fusionforge query results ArtifactFactory::getArtifacts()
+	function __construct($art_arr, $fields='')
+	{
+		parent::__construct();
+		$changerequestsdata = $this->convert_artifacts_array($art_arr, $fields);
+		foreach ($changerequestsdata as $identifier => $data) {
+			$this->_data[$identifier] = ChangeRequest::Create('fusionforge');
+			$this->_data[$identifier] = $data;
+		}
+	}
+
+	/* duplicated from code in the SOAP API
+	 * 
+	 * TODO Add code that maps fusionforge tracker fields to ontologies (dc, helios_bt, etc) 
+	 * 
+	 */
+	protected static function convert_artifacts_array($at_arr, $fields_string) {
+		$FusionForgeCR_attr = array('artifact_id','group_artifact_id','status_id','priority','submitted_by','assigned_to','open_date','close_date',
+			'summary','details','assigned_unixname','assigned_realname','assigned_email','submitted_unixname','submitted_realname','submitted_email',
+			'status_name','last_modified_date');
+		
+		$return = array();
+		
+		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();
+
+					//********
+					//** 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);
+						}
+					}
+					
+					$identifier = $at_arr[$i]->data_array['artifact_id'];
+					
+					// If specific fields were requested using a query
+					// we only return the requested fields data in the change request.
+					if (strlen($fields_string) > 0) {
+						$fields = explode(",", $fields_string);
+					}
+					
+					if(isset($fields) && is_array($fields) && count($fields) > 0){
+						foreach ($fields as $field) {
+							switch ($field) {
+								case 'dc:identifier': 
+									$return[$identifier]['identifier'] = $identifier;
+									break;
+								case 'dc:title': 
+									$return[$identifier]['title'] = $at_arr[$i]->data_array['summary'];
+									break;
+								case 'dc:description': 
+									$return[$identifier]['description'] = $at_arr[$i]->data_array['details'];
+									break;
+								case 'dc:creator': 
+									$return[$identifier]['creator'] = $at_arr[$i]->data_array['submitted_realname'];
+									break;
+								case 'helios_bt:status': 
+									$return[$identifier]['helios_bt:status'] = $at_arr[$i]->data_array['status_name'];
+									break;
+								case 'helios_bt:priority': 
+									$return[$identifier]['helios_bt:priority'] = $at_arr[$i]->data_array['priority'];
+									break;
+								case 'helios_bt:assigned_to': 
+									$return[$identifier]['helios_bt:assigned_to'] = $at_arr[$i]->data_array['assigned_realname'];
+									break;
+								case 'dc:modified': 
+									$return[$identifier]['modified'] = $at_arr[$i]->data_array['last_modified_date'];
+									break;
+								case 'dc:created': 
+									$return[$identifier]['created'] = $at_arr[$i]->data_array['open_date'];
+									break;
+								default: 
+									throw new ConflictException("The attribute specified ".$field." cannot be found!");
+							}
+						}
+					} else {
+						//return the by default set of Change request fields.
+						$return[$identifier]=array(
+							'identifier'=>$identifier,
+							'title'=>$at_arr[$i]->data_array['summary'],
+							'description'=>$at_arr[$i]->data_array['details'],
+							'helios_bt:status'=>$at_arr[$i]->data_array['status_name'],
+							'helios_bt:priority'=>$at_arr[$i]->data_array['priority'],
+							'creator' => $at_arr[$i]->data_array['submitted_realname'],
+							'helios_bt:assigned_to' => $at_arr[$i]->data_array['assigned_realname'],
+							'modified' => $at_arr[$i]->data_array['last_modified_date'],
+							'created' => $at_arr[$i]->data_array['open_date']
+						);
+					}
+				}
+			}
+		}
+		return $return;
+	}
+
+}
\ No newline at end of file

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/models/mantis.inc.php
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/models/mantis.inc.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/models/mantis.inc.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,336 @@
+<?php
+
+/**
+ * This file is (c) Copyright 2009 by Madhumita DHAR, Olivier BERGER,
+ * 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.
+ *
+ */
+
+/* $Id$ */
+
+$model_dir = APPLICATION_PATH.'/models/';
+require_once($model_dir . 'ChangeRequests.php');
+
+/**
+ * Example of a FusionForge ChangeRequest that extends its model
+ * 
+ *  Adds a status with the helios_bt ontology (fictional)
+ */
+class MantisChangeRequest extends ChangeRequest
+{
+	/**
+	 * Adds helios_bt:status as mandatory
+	 * 
+	 * @var array
+	 */
+	protected $_mandatory = array('title','identifier','helios_bt:status');
+
+	protected $_optional = array('type','description','subject','creator','modified','mantisbt:project');
+	
+	// may then add a status ?
+	//private $_status;
+	
+	/**
+	 * Create from XML (RDF) OSLC-CM document
+	 *
+	 * @param string $xmlstr
+	 * @return ChangeRequest
+	 */
+	public static function CreateMantisArrayFromXml($xmlstr)
+	{
+		// will contain an array of fields read in the oslc:ChangeRequest
+		$resource = null;
+
+		// we use simplexml PHP library which supports namespaces
+		
+		/*******Sample CR*****************************************
+		 * 
+		 * <?xml version="1.0"?>
+		 * <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+		 *   <oslc_cm:ChangeRequest xmlns:oslc_cm="http://open-services.net/xmlns/cm/1.0/">
+		 *       <dc:title xmlns:dc="http://purl.org/dc/terms/">Provide import</dc:title>
+		 *       <dc:identifier xmlns:dc="http://purl.org/dc/terms/">1234</dc:identifier>
+		 *       <dc:type xmlns:dc="http://purl.org/dc/terms/">http://myserver/mycmapp/types/Enhancement</dc:type>
+		 *       <dc:description xmlns:dc="http://purl.org/dc/terms/">Implement the system's import capabilities.</dc:description>
+		 *       <dc:subject xmlns:dc="http://purl.org/dc/terms/">import</dc:subject>
+		 *       <dc:creator xmlns:dc="http://purl.org/dc/terms/">mailto:aadams at someemail.com</dc:creator>
+		 *       <dc:modified xmlns:dc="http://purl.org/dc/terms/">2008-09-16T08:42:11.265Z</dc:modified>
+		 *   </oslc_cm:ChangeRequest>
+		 * </rdf:RDF>
+		 *           
+		 */
+		
+		$dc_attr = array("title", "identifier", "type", "description","subject","creator","modified","name","created");
+		$mantisbt_attr = array("severity","status","priority","branch","version", "target_version","version_number","notes");
+
+		$xml = simplexml_load_string($xmlstr);
+		//print_r($xml);
+		$namespace = $xml->getNamespaces(true);
+		/*$namespace = array(
+			'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
+			'oslc_cm' => 'http://open-services.net/xmlns/cm/1.0/',
+		    'mantisbt' => 'http://www.mantisbt.org/xmlns/mantisbt/',
+		    'dc' => 'http://purl.org/dc/terms/'
+		);*/
+		if ( ($namespace['rdf'] == 'http://www.w3.org/1999/02/22-rdf-syntax-ns#') &&
+			 ($xml->getName() == 'RDF')) 
+		{		
+			foreach ($xml->children('http://open-services.net/xmlns/cm/1.0/') as $changerequest) {
+				if ($changerequest->getName() == 'ChangeRequest') {
+					$resource = array();
+					foreach ($changerequest->children('http://purl.org/dc/terms/') as $child) {
+						$field = $child->getName();
+						if (in_array($field,$dc_attr))
+						{
+							$value = (string)$child;
+							$resource[$field] = $value;
+						}
+					}
+					$x = 0;
+					foreach ($changerequest->children($namespace['mantisbt']) as $child) {
+						$field = $child->getName();
+						if (in_array($field,$mantisbt_attr))
+						{
+							$value = (string)$child;
+							if(strcasecmp($field,"notes")==0) //creating array for storing mantisbt notes
+							{
+								if($x==0)
+								{
+									$resource[$field] = array();
+								}
+								$resource[$field][$x++] = $value;
+							}
+							else
+							{
+								$resource[$field] = $value;	
+							}
+						}
+					}
+				}
+			}
+		}
+
+		$changerequest = new MantisChangeRequest();
+
+		// initialize the ChangeRequest attributes
+		foreach ($resource as $field => $value) {
+			$changerequest->container[$field] = $value;
+		}
+		//print_r($xml);
+		//print_r($resource);
+		//print_r($changerequest);
+
+		return $changerequest;
+	}
+	
+	public static function CreateMantisArrayFromJson($jsonstr)
+	{
+		$resource = Zend_Json::decode($jsonstr);
+
+		$changerequest = new MantisChangeRequest();
+
+		// the dublin core elements prefix is removed
+		
+		foreach ($resource as $field => $value) {
+			if($field=="mantisbt:notes")
+			{
+				$value = self::CreateMantisNotesArrayFromJson($jsonstr);
+			}
+			$field = str_replace('dc:', '', $field);
+			$field = str_replace('mantisbt:', '', $field);
+			
+			$changerequest->container[$field] = $value;
+		}
+
+		return $changerequest;
+	}
+	
+	public static function CreateMantisNotesArrayFromJson($jsonstr)
+	{
+		Zend_Json::decode($jsonstr); //to check for well-formed json
+		preg_match_all("/\"mantisbt:notes\":\"[^\"]+/", $jsonstr, $matches);
+		$notes = array();
+		foreach ($matches[0] as $note)
+		{
+			$notes[] = preg_replace("/\"mantisbt:notes\":\"/", "", $note);
+		}
+		return $notes;
+	}
+	
+	/**
+	 * Create an array of bugnotes from XML (RDF)
+	 *
+	 * @param string $xmlstr
+	 * @return array containing bug note values
+	 */
+	public static function CreateMantisNotesArrayFromXml($xmlstr)
+	{
+		// will contain an array of mantisbt:notes
+		$resource = null;
+
+		$xml = simplexml_load_string($xmlstr);
+		$namespace = $xml->getNamespaces(true);
+		
+		if ( ($namespace['rdf'] == 'http://www.w3.org/1999/02/22-rdf-syntax-ns#') &&
+			 ($xml->getName() == 'RDF')) 
+		{		
+			foreach ($xml->children('http://open-services.net/xmlns/cm/1.0/') as $changerequest) {
+				if ($changerequest->getName() == 'ChangeRequest') {
+					$resource = array();
+					
+					$x = 0;
+					foreach ($changerequest->children($namespace['mantisbt']) as $child) {
+						$field = $child->getName();
+						//print($field);
+						
+						if (strcasecmp($field,"notes")==0)
+						{
+							$value = (string)$child;
+							$resource[$x] = $value;
+							$x++;
+							
+						}
+					}
+				}
+			}
+		}
+
+		return $resource;
+	}
+	
+}
+
+// Represents a base of changerequests loaded from FusionForge DB
+class ChangeRequestsMantisDb extends ChangeRequests
+{
+
+	private static $status_arr = array(10=>'new', 20=>'feedback', 30=>'acknowledged', 40=>'confirmed', 50=>'assigned', 80=>'resolved', 90=>'closed');
+	
+	private static $priority_arr = array(10=>'none', 20=>'low', 30=>'normal', 40=>'high', 50=>'urgent', 60=>'immediate');
+	
+	private static $severity_arr = array(10=>'feature', 20=>'trivial', 30=>'text', 40=>'tweak', 50=>'minor', 60=>'major', 70=>'crash', 80=>'block');
+	
+	/**
+	 * @param array $rows_arr as returned by filter_get_bug_rows() in Mantis internal API
+	 */
+	function __construct($rows_arr, $fields = "")
+	{
+		parent::__construct();
+
+		$changerequestsdata = $this->convert_rows_array($rows_arr, $fields);
+		foreach ($changerequestsdata as $identifier => $data) {
+			$this->_data[$identifier] = ChangeRequest::Create('mantis');
+			$this->_data[$identifier] = $data;
+		}
+
+	}
+
+	/**
+	 * converts data as returned by filter_get_bug_rows() in Mantis internal API to array
+	 * @param array $rows_arr
+	 * @return array of arrays
+	 * version_full_name($row->version,$row->project_id,$row->project_id),
+	 */
+	protected static function convert_rows_array($rows_arr, $fieldstring) {
+
+		$return = array();
+
+		if (is_array($rows_arr) && count($rows_arr) > 0) {
+			for ($i=0; $i<count($rows_arr); $i++) {
+
+				$row = $rows_arr[$i];
+				
+				if(count($row) < 1) { continue; }
+
+				//print_r($rows_arr[$i]);
+
+				$identifier = $row->id;
+				
+				$v_num_id = custom_field_get_id_from_name("version_number");
+				$return[$identifier]=array();
+				$fields = explode(",", $fieldstring);
+				//print_r($fieldstring);
+				
+				if(empty($fieldstring))	{
+					$return[$identifier]=array(
+						'identifier'=>$identifier,
+						'title'=>$row->summary,
+						'description'=>$row->description,
+						'creator'=>user_get_name($row->reporter_id),
+						'mantisbt:project'=>project_get_name($row->project_id),
+						'mantisbt:status'=>self::$status_arr[$row->status],
+						'mantisbt:priority'=>self::$priority_arr[$row->priority],
+						'mantisbt:severity'=>self::$severity_arr[$row->severity],
+						'mantisbt:version'=>$row->version,
+						'mantisbt:target_version'=>$row->target_version,
+						'modified'=>date(DATE_ATOM,$row->last_updated),
+						'created'=>date(DATE_ATOM,$row->date_submitted)
+						);
+					if ($v_num_id) {
+						$v_num = custom_field_get_value( $v_num_id, $identifier );
+						$return[$identifier]['mantisbt:version_number'] = $v_num;
+					}
+					 
+				}else {
+					foreach ($fields as $field)	{
+						switch($field)	{
+							case 'dc:identifier': $return[$identifier]['identifier'] = $identifier;
+								break;
+							case 'dc:title': $return[$identifier]['title'] = $row->summary;
+								break;
+							case 'dc:description': $return[$identifier]['description'] = $row->description;
+								break;
+							case 'dc:creator': $return[$identifier]['creator'] = user_get_name($row->reporter_id);
+								break;
+							case 'mantisbt:project': $return[$identifier]['mantisbt:project'] = project_get_name($row->project_id);
+								break;
+							case 'mantisbt:status': $return[$identifier]['mantisbt:status'] = self::$status_arr[$row->status];
+								break;
+							case 'mantisbt:priority': $return[$identifier]['mantisbt:priority'] = self::$priority_arr[$row->priority];
+								break;
+							case 'mantisbt:severity': $return[$identifier]['mantisbt:severity'] = self::$severity_arr[$row->severity];
+								break;
+							case 'mantisbt:version': $return[$identifier]['mantisbt:version'] = $row->version;
+								break;
+							case 'mantisbt:target_version': $return[$identifier]['mantisbt:target_version'] = $row->target_version;
+								break;
+							case 'dc:modified': $return[$identifier]['modified'] = date(DATE_ATOM,$row->last_updated);
+								break;
+							case 'dc:created': $return[$identifier]['created'] = date(DATE_ATOM,$row->date_submitted);
+								break;
+							case 'mantisbt:version_number': 	if ($v_num_id) {
+					  				$v_num = custom_field_get_value( $v_num_id, $identifier );
+					  				$return[$identifier]['mantisbt:version_number'] = $v_num;
+								}else	{
+									throw new ConflictException("Version number attribute doesnt exist!");
+								}
+								break;
+							default: throw new ConflictException("The attribute specified ".$field." cannot be found!");
+						}
+					}
+								
+				}
+				
+			}
+		}
+		return $return;
+	}
+
+}

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/test.csv
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/test.csv	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/test.csv	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,4 @@
+title,identifier,type,description,subject,creator,modified,helios_bt:status,mantisbt:project,bugtracker=fusionforge
+Provide import,1234,http://myserver/mycmapp/types/Enhancement,Implement the system's import capabilities.,import,mailto:aadams at someemail.com,2008-09-16T08:42:11.265Z,open,1
+Fix soap api,12345,http://myserver/mycmapp/types/Fixes,Correct the soap api default attributes,soap,mailto:jsmith at someemail.com,2008-09-21T08:41:10.265Z,closed,2
+Fix againsoap api,123456,http://myserver/mycmapp/types/Fixes,Correct the soap api default attributes,soap,mailto:jsmith at someemail.com,2008-09-21T08:41:10.265Z,open,1

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/_resource_xml.php
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/_resource_xml.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/_resource_xml.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,136 @@
+<?php
+
+/*
+ * This file is (c) Copyright 2009 by Olivier BERGER, 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.
+ *
+ */
+
+/* $Id$ */
+ 
+function encodeResource($doc, $container, $resource) {
+	// oslc_cm attributes
+	foreach ($resource as $field => $value) {
+		$tokens = explode(':', $field);
+		if (count($tokens) != 2)
+			throw new Exception('Bad internal resource filed type '.$field.' : missing prefix !');
+		$prefix = $tokens[0];
+		switch ($prefix) {
+			case 'dc' :
+				$prefix = 'http://purl.org/dc/terms/';
+				break;
+			case 'helios_bt' :
+				$prefix = 'http://heliosplatform.sourceforge.net/ontologies/2010/05/helios_bt.owl';
+				break;
+			case 'mantisbt' :
+				$prefix = 'http://helios-platform.org/ontologies/mantisbt/';
+				break;
+			default :
+				throw new Exception('Unknown ontology prefix '.$prefix.' !');
+				break;
+		}
+		$element = $doc->createElementNS($prefix, $field, $resource[$field]);
+		$child = $container->appendChild($element);
+	}
+	
+	$mandatorytags = array('dc:title', 'dc:identifier');
+	
+}
+
+function createRessourceCollectionView($view){
+	$feedcharset = 'UTF-8';
+	$feedauthor = 'OSLC-CM-V1 Demo server ( '.TRACKER_TYPE.' version)';
+	if(isset($view->tracker)){
+		$feedtitle = TRACKER_TYPE.' OSLC-CM Change requests';
+	}else{
+		$feedtitle = 'All '.TRACKER_TYPE.' OSLC-CM Change requests';
+	}
+
+	$doc = new DOMDocument('1.0',$feedcharset);
+	$doc->formatOutput = true;
+
+	// process the ATOM feed header
+	$root = $doc->createElementNS("http://www.w3.org/2005/Atom", "feed");
+	$feed = $doc->appendChild($root);
+
+	$title = $doc->createElement('title', $feedtitle);
+	$child = $feed->appendChild($title);
+
+	$id = $doc->createElement('id', $view->id);
+	$child = $feed->appendChild($id);
+
+	$author = $doc->createElement('author');
+	$child = $feed->appendChild($author);
+	$name = $doc->createElement('name', $feedauthor);
+	$child = $child->appendChild($name);
+
+	// process all entries
+	foreach ($view->collection as $entry) {
+		$entryel = $doc->createElement('entry');
+		$entryel = $feed->appendChild($entryel);
+
+		$title = $doc->createElement('title', $entry['title']);
+		$child = $entryel->appendChild($title);
+
+		$id = $doc->createElement('id', $entry['id']);
+		$child = $entryel->appendChild($id);
+		$link = $doc->createElement('link');
+		$child = $entryel->appendChild($link);
+		$href = $doc->createAttribute('href');
+		$child = $child->appendChild($href);
+		$href = $doc->createTextNode($entry['id']);
+		$child = $child->appendChild($href);
+
+
+		if( count($entry['resource']) ) {
+			$content = $doc->createElement('content');
+			$content = $entryel->appendChild($content);
+			$type = $doc->createAttribute('type');
+			$child = $content->appendChild($type);
+			$type = $doc->createTextNode('application/xml');
+			$child = $child->appendChild($type);
+
+			encodeResource($doc, $content, $entry['resource']);
+		}
+	}
+	$doc->normalizeDocument();
+	return $doc->saveXML();
+}
+
+function createResourceView($view)
+{
+	$doc = new DOMDocument();
+	$doc->formatOutput = true;
+	
+	$root = $doc->createElementNS("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf:RDF");
+	$root = $doc->appendChild($root);
+	
+	$child = $doc->createElementNS("http://open-services.net/xmlns/cm/1.0/","oslc_cm:ChangeRequest");
+	$changerequest = $root->appendChild($child);
+	
+	$child = $doc->createAttributeNS("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf:about");
+	$about = $changerequest->appendChild($child);
+	$child = $doc->createTextNode($view->id);
+	$child = $about->appendChild($child);
+	
+	encodeResource($doc, $changerequest, $view->resource);
+	
+	return $doc->saveXML();
+}

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/_service-catalog_xml.php
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/_service-catalog_xml.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/_service-catalog_xml.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,78 @@
+<?php
+
+/*
+ * This file is (c) Copyright 2009 by Olivier BERGER, 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.
+ *
+ */
+
+/* $Id$ */
+
+// Generate a OSLC-CM V1 Service Catalog document (http://open-services.net/bin/view/Main/OslcServiceProviderCatalogV1)
+
+function projects_to_service_catalog($base_url, $projects) {
+
+	$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);
+	
+	// TODO ? : MAY have an oslc_disc:details child element. 
+	
+	$child = $doc->createTextNode(TRACKER_TYPE. " Change management service provider catalog");
+	$child = $title->appendChild($child);
+
+	foreach ($projects as $proj) {
+
+		if(count($proj)>0)
+		{
+			// 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:title");
+			$title = $sp->appendChild($child);
+			$child = $doc->createTextNode($proj['name']);
+			$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/'.$proj['id']);
+			$child = $resource->appendChild($child);
+
+
+		}
+	}
+	return $doc->saveXML();
+}

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/_service-document_xml.php
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/_service-document_xml.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/_service-document_xml.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,133 @@
+<?php
+
+/*
+ * This file is (c) Copyright 2009 by Olivier BERGER, 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.
+ *
+ */
+
+/* $Id$ */
+
+// 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) {
+
+	$doc = new DOMDocument();
+	$doc->formatOutput = true;
+
+	$root = $doc->createElementNS("http://open-services.net/xmlns/cm/1.0/", "oslc_cm:ServiceDescriptor");
+	$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 GET-based Bug 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);
+	
+	//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);
+
+	return $doc->saveXML();
+}
\ No newline at end of file

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/index.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/index.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/index.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,31 @@
+<?php
+
+$tracker = 'unknown';
+
+switch (TRACKER_TYPE) {
+	case 'mantis':
+		$tracker = 'Mantis';
+		break;
+	case 'fusionforge':
+		$tracker = 'FusionForge';
+		break;
+	case 'demo':
+		$tracker = 'Demo Server';
+		break;
+	default:
+		$tracker = 'Unknown';
+		break;
+}
+?>
+<body>
+<h1><?php echo 'Thanks for using this '.$tracker.' OSLC-CM V1 compatible REST server' ?></h1>
+
+<p>To test, please access one of the following links, using the proper "Accept:" content type header :</p>
+<ul>
+	<li>
+	<p><tt>curl -H "Accept: application/x-oslc-disc-service-provider-catalog+xml" -X GET <a 
+		href="<?php echo $this->baseUrl().'/cm/oslc-services/' ?>">
+		.../cm/oslc-services/</a></tt> : to retrieve an RDF/XML OSLC Service Provider Catalog document.</p>
+	</li>
+</ul>
+</body>

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/oslc-cm-service-document.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/oslc-cm-service-document.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/oslc-cm-service-document.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,54 @@
+<?php
+
+/**
+ * This file is (c) Copyright 2010 by Olivier Berger, 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.
+ *
+ */
+
+  /* $Id$ */
+
+require('_service-document_xml.php');
+
+
+/*$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:title");
+$title = $sp->appendChild($child);
+$child = $doc->createTextNode("Demo OSLC CM service provider");
+$child = $title->appendChild($child);
+
+$child = $doc->createElementNS("http://open-services.net/xmlns/discovery/1.0/", "oslc_disc:services");
+$serv = $sp->appendChild($child);
+$child = $doc->createAttributeNS("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf:resource");
+$service = $serv->appendChild($child);
+$child = $doc->createTextNode($this->baseUrl().'/cm/oslc-cm-service');
+$child = $service->appendChild($child);*/
+?>
+<body>
+<h1>OSLC-CM V1 Service Description document</h1>
+<pre>
+<?php
+	$xml = project_to_service_description($this->baseUrl(), $this->project);
+	print str_replace('>', '&gt;', str_replace('<', '&lt;', $xml)); ?>
+</pre>
+</body>
+

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/oslc-cm-service-document.xml.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/oslc-cm-service-document.xml.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/oslc-cm-service-document.xml.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * This file is (c) Copyright 2010 by Olivier Berger, 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.
+ *
+ */
+
+  /* $Id$ */
+
+require('_service-document_xml.php');
+
+print project_to_service_description($this->baseUrl(), $this->project);
\ No newline at end of file

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/oslc-service-catalog.json.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/oslc-service-catalog.json.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/oslc-service-catalog.json.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,14 @@
+<?php
+
+$json["dc:title"] = TRACKER_TYPE. " Change management service provider catalog";
+foreach ($this->projects as $proj)
+{
+	$service["oslc_disc:entry"]["oslc_disc:ServiceProvider"]["dc:title"] = $proj["name"];
+	$service["oslc_disc:entry"]["oslc_disc:ServiceProvider"]["oslc_disc:services"] = $this->baseUrl().'/cm/oslc-cm-service/'.$proj['id'];
+	$catalog[] = $service;
+}
+
+$json["oslc_disc:ServiceProviderCatalog"] = $catalog;
+
+
+print Zend_Json::prettyPrint(Zend_Json::encode($json));
\ No newline at end of file

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/oslc-service-catalog.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/oslc-service-catalog.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/oslc-service-catalog.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,54 @@
+<?php
+
+/**
+ * This file is (c) Copyright 2010 by Olivier Berger, 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.
+ *
+ */
+
+  /* $Id$ */
+
+require('_service-catalog_xml.php');
+
+
+/*$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:title");
+$title = $sp->appendChild($child);
+$child = $doc->createTextNode("Demo OSLC CM service provider");
+$child = $title->appendChild($child);
+
+$child = $doc->createElementNS("http://open-services.net/xmlns/discovery/1.0/", "oslc_disc:services");
+$serv = $sp->appendChild($child);
+$child = $doc->createAttributeNS("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf:resource");
+$service = $serv->appendChild($child);
+$child = $doc->createTextNode($this->baseUrl().'/cm/oslc-cm-service');
+$child = $service->appendChild($child);*/
+?>
+<body>
+<h1>OSLC-CM V1 Service Catalog document</h1>
+<pre>
+<?php
+	$xml = projects_to_service_catalog($this->baseUrl(), $this->projects);
+	print str_replace('>', '&gt;', str_replace('<', '&lt;', $xml)); ?>
+</pre>
+</body>
+

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/oslc-service-catalog.xml.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/oslc-service-catalog.xml.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/oslc-service-catalog.xml.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * This file is (c) Copyright 2010 by Olivier Berger, 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.
+ *
+ */
+
+  /* $Id$ */
+
+require('_service-catalog_xml.php');
+
+print projects_to_service_catalog($this->baseUrl(), $this->projects);

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/post.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/post.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/post.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1 @@
+<?php

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/put.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/put.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/put.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1 @@
+<?php

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/put.xml.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/put.xml.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/put.xml.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,2 @@
+<?php
+

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote-collection.json.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote-collection.json.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote-collection.json.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,40 @@
+<?php
+
+  /* 
+   * This file is (c) Copyright 2009 by Olivier BERGER, Institut
+   * TELECOM
+   *
+   * Use, modification, redistribution of this software are subject to
+   * the terms of the NEW BSD License, whose text can be found in the
+   * 'COPYING' file that is distributed along with the software archive.
+   *
+   * Thus you may use it at your own risk, of course !
+   *
+   * This program has been developed in the frame of the HELIOS
+   * project with financial support of its funders.
+   *
+   */
+
+  /* $Id$ */
+
+$entriescount = count($this->collection);
+
+$json = array('oslc_cm:totalCount' => $entriescount);
+
+$resources = array();
+
+foreach ($this->collection as $resource) {
+	$newresource = array();
+	$newresource['rdf:about'] = $resource['id'];
+	foreach ($resource['resource'] as $key => $value) {
+		$newresource[$key] = $value;
+	}
+	$resources[] = $newresource;
+}
+
+$json['oslc_cm:results'] = $resources;
+
+//print_r($json);
+
+
+print Zend_Json::prettyPrint(Zend_Json::encode($json));
\ No newline at end of file

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote-collection.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote-collection.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote-collection.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,47 @@
+<html>
+<body>
+<?php
+
+/*
+ * This file is (c) Copyright 2009 by Olivier BERGER, Institut
+ * TELECOM
+ *
+ * Use, modification, redistribution of this software are subject to
+ * the terms of the NEW BSD License, whose text can be found in the
+ * 'COPYING' file that is distributed along with the software archive.
+ *
+ * Thus you may use it at your own risk, of course !
+ *
+ * This program has been developed in the frame of the HELIOS
+ * project with financial support of its funders.
+ *
+ */
+
+/* $Id$ */
+
+require_once('_resource_xml.php');
+
+$tracker = 'unknown';
+
+switch (TRACKER_TYPE) {
+	case 'mantis':
+		$tracker = 'Mantis';
+		break;
+	case 'fusionforge':
+		$tracker = 'FusionForge';
+		break;
+	case 'demo':
+		$tracker = 'Demo Server';
+		break;
+	default:
+		$tracker = 'Unknown';
+		break;
+}
+
+print '<h1>'.$tracker.' Change Requests Comments:</h1>';
+$xml = createRessourceCollectionView($this);
+print '<pre>'.(str_replace('>', '&gt;', str_replace('<', '&lt;', $xml))).'<pre>';
+?>
+
+</body>
+</html>
\ No newline at end of file

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote-collection.xml.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote-collection.xml.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote-collection.xml.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,20 @@
+<?php
+
+/*
+ * This file is (c) Copyright 2009 by Madhumita DHAR, Institut
+ * TELECOM
+ *
+ * Use, modification, redistribution of this software are subject to
+ * the terms of the NEW BSD License, whose text can be found in the
+ * 'COPYING' file that is distributed along with the software archive.
+ *
+ * Thus you may use it at your own risk, of course !
+ *
+ * This program has been developed in the frame of the HELIOS
+ * project with financial support of its funders.
+ *
+ */
+
+require_once('_resource_xml.php');
+
+print createRessourceCollectionView($this);
\ No newline at end of file

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote.json.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote.json.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote.json.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,29 @@
+<?php
+
+
+  /* 
+   * This file is (c) Copyright 2009 by Madhumita DHAR, Institut
+   * TELECOM
+   *
+   * Use, modification, redistribution of this software are subject to
+   * the terms of the NEW BSD License, whose text can be found in the
+   * 'COPYING' file that is distributed along with the software archive.
+   *
+   * Thus you may use it at your own risk, of course !
+   *
+   * This program has been developed in the frame of the HELIOS
+   * project with financial support of its funders.
+   *
+   */
+
+  /* $Id$ */
+
+$json = array('rdf:about' => $this->id);
+foreach ($this->resource as $field => $value) {
+	$json[$field] = $value;
+}
+print Zend_Json::prettyPrint(Zend_Json::encode($json));
+
+//require('_get_response.php');
+//print $doc->saveXML();
+//print Zend_Json::fromXML();
\ No newline at end of file


Property changes on: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote.json.phtml
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,31 @@
+<html>
+<body>
+<?php
+
+require_once('_resource_xml.php');
+
+$tracker = 'unknown';
+
+switch (TRACKER_TYPE) {
+	case 'mantis':
+		$tracker = 'Mantis';
+		break;
+	case 'fusionforge':
+		$tracker = 'FusionForge';
+		break;
+	case 'demo':
+		$tracker = 'Demo Server';
+		break;
+	default:
+		$tracker = 'Unknown';
+		break;
+}
+
+print '<h1>'.$tracker.' Change Request:</h1>';
+$xml = createResourceView($this);
+$xml = str_replace('>', '&gt;', str_replace('<', '&lt;', $xml));
+print '<pre>'.$xml.'</pre>';
+?>
+
+</body>
+</html>

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote.xml.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote.xml.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote.xml.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,22 @@
+<?php
+
+  /* 
+   * This file is (c) Copyright 2009 by Madhumita DHAR, Institut
+   * TELECOM
+   *
+   * Use, modification, redistribution of this software are subject to
+   * the terms of the NEW BSD License, whose text can be found in the
+   * 'COPYING' file that is distributed along with the software archive.
+   *
+   * Thus you may use it at your own risk, of course !
+   *
+   * This program has been developed in the frame of the HELIOS
+   * project with financial support of its funders.
+   *
+   */
+
+  /* $Id$ */
+
+require_once('_resource_xml.php');
+
+print createResourceView($this);
\ No newline at end of file


Property changes on: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-bugnote.xml.phtml
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource-collection.json.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource-collection.json.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource-collection.json.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,40 @@
+<?php
+
+  /* 
+   * This file is (c) Copyright 2009 by Olivier BERGER, Institut
+   * TELECOM
+   *
+   * Use, modification, redistribution of this software are subject to
+   * the terms of the NEW BSD License, whose text can be found in the
+   * 'COPYING' file that is distributed along with the software archive.
+   *
+   * Thus you may use it at your own risk, of course !
+   *
+   * This program has been developed in the frame of the HELIOS
+   * project with financial support of its funders.
+   *
+   */
+
+  /* $Id$ */
+
+$entriescount = count($this->collection);
+
+$json = array('oslc_cm:totalCount' => $entriescount);
+
+$resources = array();
+
+foreach ($this->collection as $resource) {
+	$newresource = array();
+	$newresource['rdf:about'] = $resource['id'];
+	foreach ($resource['resource'] as $key => $value) {
+		$newresource[$key] = $value;
+	}
+	$resources[] = $newresource;
+}
+
+$json['oslc_cm:results'] = $resources;
+
+//print_r($json);
+
+
+print Zend_Json::prettyPrint(Zend_Json::encode($json));
\ No newline at end of file

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource-collection.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource-collection.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource-collection.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,47 @@
+<html>
+<body>
+<?php
+
+/*
+ * This file is (c) Copyright 2009 by Olivier BERGER, Institut
+ * TELECOM
+ *
+ * Use, modification, redistribution of this software are subject to
+ * the terms of the NEW BSD License, whose text can be found in the
+ * 'COPYING' file that is distributed along with the software archive.
+ *
+ * Thus you may use it at your own risk, of course !
+ *
+ * This program has been developed in the frame of the HELIOS
+ * project with financial support of its funders.
+ *
+ */
+
+/* $Id$ */
+
+require_once('_resource_xml.php');
+
+$tracker = 'unknown';
+
+switch (TRACKER_TYPE) {
+	case 'mantis':
+		$tracker = 'Mantis';
+		break;
+	case 'fusionforge':
+		$tracker = 'FusionForge';
+		break;
+	case 'demo':
+		$tracker = 'Demo Server';
+		break;
+	default:
+		$tracker = 'Unknown';
+		break;
+}
+
+print '<h1>'.$tracker.' Change Requests:</h1>';
+$xml = createRessourceCollectionView($this);
+print '<pre>'.(str_replace('>', '&gt;', str_replace('<', '&lt;', $xml))).'<pre>';
+?>
+
+</body>
+</html>

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource-collection.xml.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource-collection.xml.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource-collection.xml.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,22 @@
+<?php
+
+/*
+ * This file is (c) Copyright 2009 by Olivier BERGER, Institut
+ * TELECOM
+ *
+ * Use, modification, redistribution of this software are subject to
+ * the terms of the NEW BSD License, whose text can be found in the
+ * 'COPYING' file that is distributed along with the software archive.
+ *
+ * Thus you may use it at your own risk, of course !
+ *
+ * This program has been developed in the frame of the HELIOS
+ * project with financial support of its funders.
+ *
+ */
+
+/* $Id$ */
+
+require_once('_resource_xml.php');
+
+print createRessourceCollectionView($this);
\ No newline at end of file

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource.json.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource.json.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource.json.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,29 @@
+<?php
+
+
+  /* 
+   * This file is (c) Copyright 2009 by Madhumita DHAR, Institut
+   * TELECOM
+   *
+   * Use, modification, redistribution of this software are subject to
+   * the terms of the NEW BSD License, whose text can be found in the
+   * 'COPYING' file that is distributed along with the software archive.
+   *
+   * Thus you may use it at your own risk, of course !
+   *
+   * This program has been developed in the frame of the HELIOS
+   * project with financial support of its funders.
+   *
+   */
+
+  /* $Id$ */
+
+$json = array('rdf:about' => $this->id);
+foreach ($this->resource as $field => $value) {
+	$json[$field] = $value;
+}
+print Zend_Json::prettyPrint(Zend_Json::encode($json));
+
+//require('_get_response.php');
+//print $doc->saveXML();
+//print Zend_Json::fromXML();
\ No newline at end of file


Property changes on: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource.json.phtml
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,31 @@
+<html>
+<body>
+<?php
+
+require_once('_resource_xml.php');
+
+$tracker = 'unknown';
+
+switch (TRACKER_TYPE) {
+	case 'mantis':
+		$tracker = 'Mantis';
+		break;
+	case 'fusionforge':
+		$tracker = 'FusionForge';
+		break;
+	case 'demo':
+		$tracker = 'Demo Server';
+		break;
+	default:
+		$tracker = 'Unknown';
+		break;
+}
+
+print '<h1>'.$tracker.' Change Request:</h1>';
+$xml = createResourceView($this);
+$xml = str_replace('>', '&gt;', str_replace('<', '&lt;', $xml));
+print '<pre>'.$xml.'</pre>';
+?>
+
+</body>
+</html>

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource.xml.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource.xml.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource.xml.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,22 @@
+<?php
+
+  /* 
+   * This file is (c) Copyright 2009 by Madhumita DHAR, Institut
+   * TELECOM
+   *
+   * Use, modification, redistribution of this software are subject to
+   * the terms of the NEW BSD License, whose text can be found in the
+   * 'COPYING' file that is distributed along with the software archive.
+   *
+   * Thus you may use it at your own risk, of course !
+   *
+   * This program has been developed in the frame of the HELIOS
+   * project with financial support of its funders.
+   *
+   */
+
+  /* $Id$ */
+
+require_once('_resource_xml.php');
+
+print createResourceView($this);
\ No newline at end of file


Property changes on: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/read-resource.xml.phtml
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/show-selection-ui.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/show-selection-ui.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/cm/show-selection-ui.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,649 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+<?php 
+	$project = $this->data['project'];
+	foreach ($this->data['where'] as $key => $value) {
+		$where[] = $key;
+	}
+	//print_r($this->data['where']);
+?>
+<html xmlns="http://www.w3.org/1999/xhtml">
+    <head>
+        <title>OSLC Query UI</title>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+		<style type="text/css">
+		@import "http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojox/grid/resources/Grid.css";
+		@import url("http://ajax.googleapis.com/ajax/libs/dojo/1.5/dijit/themes/soria/soria.css");
+		
+		body { 	font: 13px Myriad,Arial,Helvetica,clean,sans-serif; 	
+				*font-size: small;	
+				*font: x-small;}
+				
+		h1 {	font-size: 1.5em; 	
+				font-weight: normal;	
+				line-height: 1em; 	
+				margin-top: 1em;	
+				margin-bottom:0;}
+				
+		h2 { 	font-size: 1.1667em;
+				font-weight: bold; 	
+				line-height: 1.286em; 	
+				margin-top: 1.929em; 	
+				margin-bottom:0.643em;}
+		
+		h3, h4, h5, h6 {	font-size: 1em; 	
+							font-weight: bold; 	
+							line-height: 1.5em; 	
+							margin-top: 1.5em; 	
+							margin-bottom: 0;}
+							
+		p { 	font-size: 1em;
+				margin-top: 1.5em;
+				margin-bottom: 1.5em;
+				line-height: 1.5em;}
+		
+		body {
+			margin: 2em;
+		}
+		
+		table td {
+			padding: 2px;
+		}
+		
+		</style>
+        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.4.0/dojo/dojo.xd.js"
+			djconfig="parseOnLoad:true">
+		</script>
+        <script type="text/javascript">
+        dojo.require("dojox.grid.DataGrid");
+        dojo.require("dijit.Menu");
+        dojo.require("dijit.MenuItem");
+        dojo.require("dojox.data.CsvStore");
+        dojo.require("dojo.data.ItemFileReadStore");
+        dojo.require("dojox.encoding.base64");
+
+		var props; 	//array of all properties, dc:title has not been included in the list
+					//and is always shown in the results
+		var where; //array of all where options
+		var whereoptions; //2d array of options of where options
+		var queryconnect;
+		var selectedrowindex; //row selected to sent to client
+		var tempresult;
+		var convertToByteArray = function(data){
+            var bin=[] ;
+            for (var i=0; i<data.length; i++){
+            	bin.push(data.charCodeAt(i));
+            }
+            return bin;
+        }
+        
+        var doQuery = function(event) {
+
+            var user = dojo.trim(dojo.byId("usertext").value);
+            var pass = dojo.trim(dojo.byId("passtext").value);
+
+            if((user=="")&&(pass!=""))	{
+                alert("User field is empty!");
+                return;
+            }else if((user!="")&&(pass==""))	{
+                alert("Password field is empty!");
+                return;
+            }else if((!user.match(/^[a-zA-Z0-9\s-\.+_]+$/))&&(user!=""))	{
+                alert("Invalid user name!");
+                return;
+            }
+
+            //processing oslc.limit
+            var limit = dojo.trim(dojo.byId("limittext").value);
+            if(/^[1-9][0-9]*$/.test(limit))	{
+                if(limit>30)	{
+                    alert("oslc.limit should be less than 30!");
+                    return;
+                }
+            }else if(limit=="")	{
+                alert("Default oslc.limit value taken to be 10");
+                limit = "10";
+                dojo.byId("limittext").value = limit;
+            }else	{
+                alert("oslc.limit should be an integer less than 30!");
+                return;
+            }
+
+            //processing oslc.offset
+            var offset = dojo.trim(dojo.byId("offsettext").value);
+            if(/^[1-9][0-9]*$/.test(offset))	{
+                if((offset%limit!=0)&&(offset!="0"))	{
+                    alert("oslc.offset should be a multiple of oslc.limit!");
+                    return;
+                }
+            }else if(offset!="")	{
+                alert("oslc.offset should be an integer which is a multiple of oslc.limit!");
+                return;
+            }
+
+            //processing oslc.searchTerms
+            var searchterms = dojo.trim(dojo.byId("searchtermstext").value.replace(/\"/g,""));
+            if(searchterms!="")	{
+	            var searchtermsArray = searchterms.split(" ");
+	            for(var i=0;i<searchtermsArray.length;i++)
+	            {
+	                if(i==0)	{
+	                	searchterms = "\"" + searchtermsArray[i] + "\"";
+	                }else	{
+	                	searchterms = searchterms + ",\"" + searchtermsArray[i] + "\"";
+	                }
+	            }
+            }
+
+            //processing oslc.properties
+        	var selectedprops = ["dc:title"];
+            dojo.query(".proprowclass").forEach(
+                    function(item, index, array)	{
+						var propselect = item.cells[0].childNodes[0];
+						if(propselect.value!="none")	{
+							selectedprops.push(propselect.value);
+						}
+                    });
+            var layoutjson = [{
+                field: "rdf:about",
+                name: "URL",
+                width: "auto"
+            }];
+            var propstring; //comma separated properties list to be used in the ajax call
+            if(selectedprops.length==1)	{
+                alert("As no properties are selected, only dc:title and URL will be displayed!");
+            }
+            for(var i=0;i<selectedprops.length;i++)
+            {
+                if(i==0)	{
+                    propstring = selectedprops[i];
+                }else	{
+                    propstring = propstring + "," + selectedprops[i];
+                }
+                layoutjson.push(
+                		{
+                            field: selectedprops[i],
+                            name: selectedprops[i],
+                            width: "auto"
+                        });
+            }            
+
+            //processing oslc.where
+            var selectedwhere = ["mantisbt:project=\"<?php echo $project ?>\""];
+            dojo.query(".whererowclass").forEach(
+                    function(item, index, array)	{
+						var where1 = item.cells[0].childNodes[0];
+						var where2 = item.cells[2].childNodes[0];
+						if((where1.value!="none")&&(where2.value!="none"))	{
+							var tempString = where1.value + "=\"" + where2.value + "\"";
+							console.log(tempString);
+							selectedwhere.push(tempString);
+						}
+                    });
+            var wherestring; //'and' separated where options list to be used in the ajax call
+            for(var i=0;i<selectedwhere.length;i++)
+            {
+                if(i==0)	{
+                	wherestring = selectedwhere[i];
+                }else	{
+                	wherestring = wherestring + " and " + selectedwhere[i];
+                }
+            }
+
+            //processing oslc.orderBy
+            var selectedorder = [];
+            dojo.query(".orderrowclass").forEach(
+                    function(item, index, array)	{
+						var attr = item.cells[0].childNodes[0];
+						var dir = item.cells[1].childNodes[0];
+						if((attr.value!="none")&&(dir.value!="none"))	{
+							var tempString = dir.value + attr.value;
+							console.log(tempString);
+							selectedorder.push(tempString);
+						}
+                    });
+            var orderstring; //comma separated where options list to be used in the ajax call
+            for(var i=0;i<selectedorder.length;i++)
+            {
+                if(i==0)	{
+                	orderstring = selectedorder[i];
+                }else	{
+                	orderstring = orderstring + "," + selectedorder[i];
+                }
+            }
+
+            //creating content object for xhrargs
+            var contentobj = {};
+            contentobj['oslc_limit'] = limit;
+            contentobj['oslc_where'] = wherestring;
+            if(offset!="")	{
+                contentobj['oslc_offset'] = offset;
+            }
+            if(searchterms!="")	{
+            	contentobj['oslc_searchTerms'] = searchterms;
+            }
+            if(selectedprops.length>1)	{
+                contentobj['oslc_properties'] = propstring;
+            }
+            if(selectedorder.length>0)	{
+                contentobj['oslc_orderBy'] = orderstring;
+            }
+            //alert(contentobj.toSource());
+            
+
+            var xhrArgs = {
+                    url: "/~mdhar/mantisbt/oslc-zend/cm/bugs",
+                    headers: {Accept: "application/json"},
+                    preventCache: true,
+                    handleAs: "json",
+                    content: contentobj,
+                    load: function(dataa, ioArgs) {
+                  	  	//alert(dataa.toSource());
+                  	  	var jsonObj = {};
+                  	  	for (var key in dataa) {
+						   var obj = dataa[key];						   
+						   if(key=="oslc_cm:totalCount")	{
+							   jsonObj.identifier = "rdf:about";
+						   }
+						   else if(key=="oslc_cm:results")   {
+							   var tempArr = [];							      
+							   for (var num in obj) {
+								  var result = obj[num];
+							      var temp = {};
+							      for(var prop in result)	{
+								      temp[prop] = result[prop];
+							      }
+							      tempArr.push(temp);
+							   }
+							   jsonObj.items = tempArr;
+						   }
+						}
+						//alert(jsonObj.toSource());
+                        //alert(ioArgs.xhr.responseText);
+                        var jsonStore = new dojo.data.ItemFileReadStore({data:jsonObj});
+                        window["grid"] = dijit.byId("grid");
+                        window["menu"] = dijit.byId("gridMenu");
+                        grid.setStructure(layoutjson);
+                        grid.setStore(jsonStore, {});
+                        grid.onRowDblClick = function(e)	{
+                            console.log("row double clicked");
+                        }
+                        menu.bindDomNode(grid.domNode);
+                     	// prevent grid methods from killing the context menu event by implementing our own handler
+            			grid.onCellContextMenu = function(e) {
+            				selectedrowindex = e.rowIndex;            				          				
+            			};
+                        
+                     
+                    },
+                    error: function(err) {
+                  	  err = err.message||err;
+                  	  alert('error: '+err);
+                    }
+                }
+
+            if((user!="")&&(pass!=""))	{
+                //tried but didnt work
+                //xhrArgs['user'] = user;
+                //xhrArgs['password'] = pass;
+                
+                var userpass = user + ":" + pass;                
+                xhrArgs['headers']['Authorization'] = "Basic " + dojox.encoding.base64.encode(convertToByteArray(userpass));
+            }            
+            //alert(xhrArgs.toSource());
+
+            //Call the asynchronous xhrGet
+		    var deferred = dojo.xhrGet(xhrArgs);
+		    dojo.query(".plusclass").forEach(
+				    function(item, index, array)	{
+					    item.disabled = true;
+				    });
+		    dojo.query(".minusclass").forEach(
+				    function(item, index, array)	{
+					    item.disabled = true;
+				    });
+			dojo.disconnect(queryconnect);
+          
+            
+        };
+
+        function respondWithPostMessage(/*string*/ response) {
+            window.parent.postMessage("oslc-response:" + response, "*");
+            //TODO if window is not parented window.postMessage to be used
+            //which shud be ignored
+         }
+
+        var addtoclient = function()	{
+            //alert("addedtoclient");
+            tempresult = {};
+            var grid = dijit.byId("grid");
+            var items = grid.selection.getSelected();
+            if (items.length) {
+            	var tempArray = [];
+                dojo.forEach(items, function(selectedItem) {
+                    var temp = {};
+                    if (selectedItem !== null) {
+                        dojo.forEach(grid.store.getAttributes(selectedItem), function(attribute) {
+                            var value = grid.store.getValues(selectedItem, attribute);
+                            if(attribute=="rdf:about")	{
+                                temp['rdf:resource'] = value;
+                            }else if(attribute=="dc:title")	{
+                                temp[attribute] = value;
+                                temp['oslc_cm:label'] = value;
+                            }
+                        });
+                        tempArray.push(temp);
+                    }
+                });
+                tempresult['oslc_cm:results'] = tempArray;
+            }
+            var resultstring = tempresult.toSource();
+            console.log(resultstring);
+            respondWithPostMessage(resultstring);
+        }
+
+        var refresh = function()
+        {
+        	queryconnect = dojo.connect(dojo.byId("querybutton"), "onclick", doQuery);
+        	dojo.query(".plusclass").forEach(
+				    function(item, index, array)	{
+					    item.disabled = false;
+				    });
+		    dojo.query(".minusclass").forEach(
+				    function(item, index, array)	{
+					    item.disabled = false;
+				    });
+		    dijit.byId("grid").setStructure(null);
+		    dijit.byId("grid").setStore(null);
+		    
+        }
+        
+          //var plusconnects; not needed anymore
+          
+          var NUMBER = {    PROPERTIES: 2,
+                  			ORDERBY: 3,
+					        WHERE: 4	};
+	        
+          var add = function(event)
+          {
+              var rowclass;
+        	  if(event.target.id=="propplus")	{
+            	  numcells = NUMBER.PROPERTIES;
+            	  rowclass = ".proprowclass";
+        	  }else if(event.target.id=="whereplus")	{
+            	  numcells = NUMBER.WHERE;
+            	  rowclass = ".whererowclass";
+        	  }else if(event.target.id=="orderplus")	{
+            	  numcells = NUMBER.ORDERBY;
+            	  rowclass = ".orderrowclass";
+        	  }
+              //alert(event.target.parentNode.parentNode);
+              if(dojo.query(rowclass).length<5)
+              {  
+	              var newrow = dojo.clone(event.target.parentNode.parentNode);
+	              var numcells;
+	              
+	              if(newrow.cells.length<=numcells)
+	              {
+	                  var tdm = document.createElement("td");
+	                  tdm.innerHTML = "<button id=\"minus\" class=\"minusclass\">-</button>";
+	                  newrow.appendChild(tdm);
+	              }
+	              if(event.target.id=="whereplus")	{
+		              showOptions(newrow.cells[0].childNodes[0]);
+	              }
+	              
+	              dojo.place(newrow, event.target.parentNode.parentNode.parentNode);
+	              var newplus = newrow.cells[numcells-1].childNodes[0];
+	              if(event.target.id=="orderplus")	{
+		              dojo.destroy(newplus.parentNode);
+		              dojo.destroy(event.target.parentNode);
+		              var newminus = newrow.cells[numcells-1].childNodes[0];
+	              }else	{
+		              dojo.connect(newplus, "onclick", add);
+		              var newminus = newrow.cells[numcells].childNodes[0];
+	              }
+	              dojo.connect(newminus, "onclick", remove);
+              }
+          }
+
+          var remove = function(event)
+          {
+              if(event.target.parentNode.parentNode.id=="orderrow")
+              {
+                  var row = document.getElementById('orderrow').parentNode.rows[0];
+            	  var tdm = document.createElement("td");
+                  tdm.innerHTML = "<button id=\"orderplus\" class=\"plusclass\">+</button>";
+                  row.appendChild(tdm);
+                  dojo.connect(row.cells[NUMBER.ORDERBY-1].childNodes[0], "onclick", add);
+              }
+              dojo.destroy(event.target.parentNode.parentNode);
+          }
+
+          var showOptions = function(list)
+          {
+              //alert(whereoptions[list.selectedIndex-1]);
+                            
+              var optionlist = list.parentNode.parentNode.cells[NUMBER.WHERE-2].childNodes[0];
+              var len = list.parentNode.parentNode.cells[NUMBER.WHERE-2].childNodes[0].length;
+              //alert(len);
+              for(var i=len-1;i>=0;i--)	{
+            	  //alert((i+1)+"/"+len+" "+optionlist.options[i].text);
+                  optionlist.remove(i);
+                  
+              }
+              
+	          if(list.selectedIndex>0)	{	              
+	              len = whereoptions[list.selectedIndex-1].length;
+	              for(var i=0;i<len;i++)	{
+	                  var val = whereoptions[list.selectedIndex-1][i];
+	                  try	{
+						optionlist.add(new Option(val, val), null) //add new option to end
+	            		
+	            	  }
+	            	  catch(e)	{ //for IE
+						optionlist.add(new Option(val, val)) //add new option to end
+	            	  }
+	              }
+              }else if(list.selectedIndex==0)	{
+            	  try	{
+					optionlist.add(new Option("Select", "none"), null) //add new option to end
+            		
+            	  }
+            	  catch(e)	{ //for IE
+					optionlist.add(new Option("Select", "none")) //add new option to end
+            	  }
+              }
+              
+          }
+
+          var init = function()
+          {
+        	  dojo.query(".plusclass").forEach(
+        	          function(item, index, array){
+        	               dojo.connect(item, "onclick", add);
+        	          });
+	          queryconnect = dojo.connect(dojo.byId("querybutton"), "onclick", doQuery);
+
+	          var properties = dojo.byId("proplist").options;
+	          props = [];
+	          for(var i=1;i<properties.length;i++) //starts from 1 to not incluse "select"
+	          {
+		          if(properties[i].text!="dc:title")	{
+			          props[i-1] = properties[i].text;
+			          //alert(props[i-1]);
+		          }
+	          }
+	          where = [];
+	          var i = 0;
+	          <?php 
+	          print "whereoptions = [];";
+	          foreach ($this->data['where'] as $key => $value) {
+	          	print "where.push(\"$key\" );";
+	          	$i = 0;
+	          	print "whereoptions[i] = [];";
+	          	foreach ($value as $option) {
+	          		print "whereoptions[i][$i] = \"$option\";";
+	          		$i++;
+	          	}
+	          	print "i++;";
+	          }
+	          ?>
+          }
+
+          dojo.addOnLoad(init);
+          
+        </script>
+    </head>
+    <body>
+        <h1><?php echo strtoupper($project); ?>: Query UI for OSLC</h1><hr/>
+        <!-- <p>some details of the query and blah blah to be added here</p> -->
+        
+        <br>
+        <!-- <p><b>Project: <?php echo $project ?></b></p> -->
+        <table>
+        	     		
+        </table>
+        <table border=1>        
+        <tr><td width=50%>
+	        <table CELLSPACING=2 CELLPADDING=2 id="main">
+	        	<tr><td>
+	        	<table><tr><td><fieldset>
+        		<legend><em>User</em></legend>
+        		<input id="usertext" type=text>
+        		</fieldset>
+        		</td>
+        		<td><fieldset>
+        		<legend><em>Password</em></legend>
+        		<input id="passtext" type=password>
+        		</fieldset>
+        		</td>
+        		</tr></table>
+        		</td>
+        		</tr>   
+	        	<tr><td>
+	        	<fieldset>
+        		<legend><em>oslc.properties</em></legend>
+		        <table id="propstable">
+					<tr class="proprowclass" id="proprow">
+						<!--  td width="100">oslc.properties</td>-->
+						<td><select id="proplist">
+							<option value="none" selected="selected">Select</option>
+							<?php 
+							foreach ($this->data['properties'] as $value) {
+								if(strcmp($value,"dc:title")!=0)	{
+									echo '<option value="'.$value.'">'.$value.'</option>';
+								}
+							}
+							?>			  			
+							</select>
+						</td>
+						<td><button id="propplus" class="plusclass">+</button>
+						</td>
+					</tr>
+				</table>
+				</fieldset>
+				</td></tr>
+				<tr><td>
+				<fieldset>
+        		<legend><em>oslc.where</em></legend>
+		        <table id="wheretable">
+					<tr class="whererowclass" id="whererow">
+						<!-- <td width="100">oslc.where</td> -->
+						<td><select id="wherelist" onchange="showOptions(this)">
+							<option value="none" selected="selected">Select</option>
+							<?php 
+							foreach ($where as $value) {
+								echo '<option value="'.$value.'">'.$value.'</option>';
+							}
+							?>
+							</select>
+						</td>
+						<td><label>=</label></td>
+						<td><select id="whereoptionslist">
+							<option value="none" selected="selected">Select</option>
+							</select>
+						</td>
+						<td><button id="whereplus" class="plusclass">+</button>
+						</td>
+					</tr>
+				</table>
+				</fieldset>
+				</td></tr>
+				<tr><td>
+		        <fieldset>
+        		<legend><em>oslc.orderBy</em></legend>
+		        <table id="ordertable">
+					<tr class="orderrowclass" id="orderrow">
+						<!--  <td width="100">oslc.orderBy</td> -->
+						<td><select id="orderlist">
+							<option value="none" selected="selected">Select</option>
+							<?php 
+							foreach ($this->data['orderBy'] as $value) {
+								echo '<option value="'.$value.'">'.$value.'</option>';
+							}
+							?>			  			
+							</select>
+						</td>
+						<td><select id="orderdirlist">
+							<option value="none" selected="selected">Select</option>
+							<option value="+" >Ascending</option>
+							<option value="-" >Descending</option>
+							</select>
+						</td>
+						<td><button id="orderplus" class="plusclass">+</button>
+						</td>
+					</tr>
+				</table>
+				</fieldset>
+				</td></tr>
+				<tr><td>
+		        <fieldset>
+        		<legend><em>oslc.limit</em></legend>
+		        <table id="limittable">
+					<tr class="limitrowclass" id="limitrow">
+						<!-- <td width="100">oslc.limit</td> -->
+						<td><input id="limittext" type=text></td>
+					</tr>
+				</table>
+				</fieldset>
+				</td></tr>
+				<tr><td>
+		        <fieldset>
+        		<legend><em>oslc.offset</em></legend>
+		        <table id="offsettable">
+					<tr class="offsetrowclass" id="offsetrow">
+						<!-- <td width="100">oslc.offset</td> -->
+						<td><input id="offsettext" type=text></td>
+					</tr>
+				</table>
+				</fieldset>
+				</td></tr>
+				<tr><td>
+		        <fieldset>
+        		<legend><em>oslc.searchTerms</em></legend>
+		        <table id="searchtable">
+					<tr class="searchrowclass" id="searchrow">
+						<!-- <td width="100">oslc.searchTerms</td> -->
+						<td><input id="searchtermstext" type=text></td>
+					</tr>
+				</table>
+				</fieldset>
+				</td></tr>
+				<tr><td align="center">
+					<button id="querybutton">QUERY</button>
+					
+					<button id="refreshbutton" onclick="refresh()">REFRESH</button>
+				</td></tr>
+			</table>
+		</td>
+		<td>
+			<div id="grid" dojoType="dojox.grid.DataGrid">
+			</div>
+			<div dojoType="dijit.Menu" id="gridMenu"  style="display: none;">
+				<div dojoType="dijit.MenuItem" onClick="addtoclient()">Add to client</div>
+				</div>
+		</td></tr>
+		</table>
+    </body>
+</html>

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/_error_resource.php
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/_error_resource.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/_error_resource.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,52 @@
+<?php
+
+/*
+ * This file is (c) Copyright 2009 by Madhumita DHAR, 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.
+ *
+ */
+
+/* $Id$ */
+
+function createErrorResourceView($view)
+{
+	$doc = new DOMDocument();
+	$doc->formatOutput = true;
+	
+	$root = $doc->createElementNS("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf:RDF");
+	$root = $doc->appendChild($root);
+	
+	$errornode = $doc->createElementNS("http://open-services.net/xmlns/cm/1.0/","oslc_cm:Error");
+	$errornode = $doc->appendChild($errornode);
+	
+	$code = $doc->createElementNS("http://open-services.net/xmlns/cm/1.0/","oslc_cm:statusCode", $view->code);
+	$errornode->appendChild($code);
+	
+	$message = $doc->createElementNS("http://open-services.net/xmlns/cm/1.0/","oslc_cm:message", $view->exception->getMessage());
+	$errornode->appendChild($message);
+	
+	$message = $doc->createElementNS("http://open-services.net/xmlns/cm/1.0/","oslc_cm:trace", $view->exception->getTraceAsString());
+	$errornode->appendChild($message);
+	
+	$errornode = $root->appendChild($errornode);	
+	
+	$doc->normalizeDocument();
+	return $doc->saveXML();
+}
\ No newline at end of file

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/default.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/default.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/default.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,8 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
+<html><head>
+<title>Error</title>
+</head><body>
+<h1>Application error</h1>
+<p><?php echo $this->error_message ?>.</p>
+<hr>
+</body></html>

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/error.json.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/error.json.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/error.json.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,22 @@
+<?php
+
+
+  /* 
+   * This file is (c) Copyright 2009 by Madhumita DHAR, Institut
+   * TELECOM
+   *
+   * Use, modification, redistribution of this software are subject to
+   * the terms of the NEW BSD License, whose text can be found in the
+   * 'COPYING' file that is distributed along with the software archive.
+   *
+   * Thus you may use it at your own risk, of course !
+   *
+   * This program has been developed in the frame of the HELIOS
+   * project with financial support of its funders.
+   *
+   */
+
+$json = array("oslc_cm:Error" => array(	"oslc_cm:statusCode"	=> (string)$this->code,
+										"oslc_cm:message"		=> (string)$this->exception->getMessage()));
+
+print Zend_Json::encode($json);
\ No newline at end of file

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/error.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/error.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/error.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,30 @@
+<html>
+<body>
+<?php
+
+/*
+ * This file is (c) Copyright 2009 by Madhumita DHAR, Institut
+ * TELECOM
+ *
+ * Use, modification, redistribution of this software are subject to
+ * the terms of the NEW BSD License, whose text can be found in the
+ * 'COPYING' file that is distributed along with the software archive.
+ *
+ * Thus you may use it at your own risk, of course !
+ *
+ * This program has been developed in the frame of the HELIOS
+ * project with financial support of its funders.
+ *
+ */
+
+/* $Id$ */
+
+require_once('_error_resource.php');
+
+print '<h1> Error:</h1>';
+$xml = createErrorResourceView($this);
+print '<pre>'.(str_replace('>', '&gt;', str_replace('<', '&lt;', $xml))).'<pre>';
+?>
+
+</body>
+</html>
\ No newline at end of file

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/error.xml.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/error.xml.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/error.xml.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,20 @@
+<?php
+
+  /* 
+   * This file is (c) Copyright 2009 by Madhumita DHAR, Institut
+   * TELECOM
+   *
+   * Use, modification, redistribution of this software are subject to
+   * the terms of the NEW BSD License, whose text can be found in the
+   * 'COPYING' file that is distributed along with the software archive.
+   *
+   * Thus you may use it at your own risk, of course !
+   *
+   * This program has been developed in the frame of the HELIOS
+   * project with financial support of its funders.
+   *
+   */
+
+	require_once '_error_resource.php';
+	
+	print createErrorResourceView($this);
\ No newline at end of file

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/res-not-found.phtml
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/res-not-found.phtml	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/error/res-not-found.phtml	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,8 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
+<html><head>
+<title>404 Not Found</title>
+</head><body>
+<h1>Not Found</h1>
+<p>The requested resource <?php echo $this->missing_resource ?> was not found on this server.</p>
+<hr>
+</body></html>

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/fusionforgecm
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/fusionforgecm	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/fusionforgecm	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1 @@
+link cm
\ No newline at end of file


Property changes on: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/fusionforgecm
___________________________________________________________________
Added: svn:special
   + *

Added: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/mantiscm
===================================================================
--- trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/mantiscm	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/mantiscm	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1 @@
+link cm/
\ No newline at end of file


Property changes on: trunk/plugins/coclico/oslc/include/oslc-zend/application/views/scripts/mantiscm
___________________________________________________________________
Added: svn:special
   + *

Added: trunk/plugins/coclico/oslc/include/oslcPlugin.class.php
===================================================================
--- trunk/plugins/coclico/oslc/include/oslcPlugin.class.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/include/oslcPlugin.class.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,162 @@
+<?php
+
+/**
+ * oslcPlugin Class
+ *
+ *
+ * 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 License, 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+class oslcPlugin extends Plugin {
+	public function __construct($id=0) {
+		$this->Plugin($id) ;
+		$this->name = "oslc";
+		$this->text = "oslc!"; // To show in the tabs, use...
+		$this->_addHook("user_personal_links");//to make a link to the user's personal part of the plugin
+		$this->_addHook("usermenu");
+		$this->_addHook("groupmenu");	// To put into the project tabs
+		$this->_addHook("groupisactivecheckbox"); // The "use ..." checkbox in editgroupinfo
+		$this->_addHook("groupisactivecheckboxpost"); //
+		$this->_addHook("userisactivecheckbox"); // The "use ..." checkbox in user account
+		$this->_addHook("userisactivecheckboxpost"); //
+		$this->_addHook("project_admin_plugins"); // to show up in the admin page fro group
+	}
+
+	function CallHook ($hookname, $params) {
+		global $use_oslcplugin,$G_SESSION,$HTML;
+		if ($hookname == "usermenu") {
+			$text = $this->text; // this is what shows in the tab
+			if ($G_SESSION->usesPlugin("oslc")) {
+				$param = '?type=user&id=' . $G_SESSION->getId() . "&pluginname=" . $this->name; // we indicate the part we're calling is the user one
+				echo ' | ' . $HTML->PrintSubMenu (array ($text),
+						  array ('/plugins/oslc/index.php' . $param ));				
+			}
+		} elseif ($hookname == "groupmenu") {
+			$group_id=$params['group'];
+			$project = &group_get_object($group_id);
+			if (!$project || !is_object($project)) {
+				return;
+			}
+			if ($project->isError()) {
+				return;
+			}
+			if (!$project->isProject()) {
+				return;
+			}
+			if ( $project->usesPlugin ( $this->name ) ) {
+				$params['TITLES'][]=$this->text;
+				$params['DIRS'][]=util_make_url ('/plugins/oslc/index.php?type=group&id=' . $group_id . "&pluginname=" . $this->name) ; // we indicate the part we're calling is the project one
+			} else {
+				$params['TITLES'][]=$this->text." is [Off]";
+				$params['DIRS'][]='';
+			}	
+			(($params['toptab'] == $this->name) ? $params['selected']=(count($params['TITLES'])-1) : '' );
+		} elseif ($hookname == "groupisactivecheckbox") {
+			//Check if the group is active
+			// this code creates the checkbox in the project edit public info page to activate/deactivate the plugin
+			$group_id=$params['group'];
+			$group = &group_get_object($group_id);
+			echo "<tr>";
+			echo "<td>";
+			echo ' <input type="checkbox" name="use_oslcplugin" value="1" ';
+			// checked or unchecked?
+			if ( $group->usesPlugin ( $this->name ) ) {
+				echo "checked";
+			}
+			echo " /><br/>";
+			echo "</td>";
+			echo "<td>";
+			echo "<strong>Use ".$this->text." Plugin</strong>";
+			echo "</td>";
+			echo "</tr>";
+		} elseif ($hookname == "groupisactivecheckboxpost") {
+			// this code actually activates/deactivates the plugin after the form was submitted in the project edit public info page
+			$group_id=$params['group'];
+			$group = &group_get_object($group_id);
+			$use_oslcplugin = getStringFromRequest('use_oslcplugin');
+			if ( $use_oslcplugin == 1 ) {
+				$group->setPluginUse ( $this->name );
+			} else {
+				$group->setPluginUse ( $this->name, false );
+			}
+		} elseif ($hookname == "userisactivecheckbox") {
+			//check if user is active
+			// this code creates the checkbox in the user account manteinance page to activate/deactivate the plugin
+			$user = $params['user'];
+			echo "<tr>";
+			echo "<td>";
+			echo ' <input type="checkbox" name="use_oslcplugin" value="1" ';
+			// checked or unchecked?
+			if ( $user->usesPlugin ( $this->name ) ) {
+				echo "checked";
+ 			}
+			echo " />    Use ".$this->text." Plugin";
+			echo "</td>";
+			echo "</tr>";
+		} elseif ($hookname == "userisactivecheckboxpost") {
+			// this code actually activates/deactivates the plugin after the form was submitted in the user account manteinance page
+			$user = $params['user'];
+			$use_oslcplugin = getStringFromRequest('use_oslcplugin');
+			if ( $use_oslcplugin == 1 ) {
+				$user->setPluginUse ( $this->name );
+			} else {
+				$user->setPluginUse ( $this->name, false );
+			}
+			echo "<tr>";
+			echo "<td>";
+			echo ' <input type="checkbox" name="use_oslcplugin" value="1" ';
+			// checked or unchecked?
+			if ( $user->usesPlugin ( $this->name ) ) {
+				echo "checked";
+			}
+			echo " />    Use ".$this->text." Plugin";
+			echo "</td>";
+			echo "</tr>";
+		} elseif ($hookname == "user_personal_links") {
+			// this displays the link in the user's profile page to it's personal oslc (if you want other sto access it, youll have to change the permissions in the index.php
+			$userid = $params['user_id'];
+			$user = user_get_object($userid);
+			$text = $params['text'];
+			//check if the user has the plugin activated
+			if ($user->usesPlugin($this->name)) {
+				echo '	<p>' ;
+				echo util_make_link ("/plugins/oslc/index.php?id=$userid&type=user&pluginname=".$this->name,
+						     _('View Personal oslc')
+					);
+				echo '</p>';
+			}
+		} elseif ($hookname == "project_admin_plugins") {
+			// this displays the link in the project admin options page to it's  oslc administration
+			$group_id = $params['group_id'];
+			$group = &group_get_object($group_id);
+			if ( $group->usesPlugin ( $this->name ) ) {
+				echo '<p>'.util_make_link ("/plugins/oslc/admin/index.php?id=".$group->getID().'&type=admin&pluginname='.$this->name,
+						     _('oslc Admin')).'</p>' ;
+			}
+		}												    
+		elseif ($hookname == "blahblahblah") {
+			// ...
+		} 
+	}
+}
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>

Added: trunk/plugins/coclico/oslc/packaging/control/000source
===================================================================
--- trunk/plugins/coclico/oslc/packaging/control/000source	                        (rev 0)
+++ trunk/plugins/coclico/oslc/packaging/control/000source	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,10 @@
+Source: @SRCPACKAGE@
+Section: devel
+Priority: optional
+Maintainer: Christian Bayle <bayle at debian.org>
+Uploaders: Roland Mas <lolando at debian.org>
+Build-Depends-Indep: devscripts
+Build-Depends: debhelper (>= 7), perl, gettext
+Standards-Version: 3.8.4
+Homepage: http://fusionforge.org/
+Vcs-Bzr: http://scm.fusionforge.org/bzr/fusionforge/svn-trunk-ro/

Added: trunk/plugins/coclico/oslc/packaging/control/222plugin-oslc
===================================================================
--- trunk/plugins/coclico/oslc/packaging/control/222plugin-oslc	                        (rev 0)
+++ trunk/plugins/coclico/oslc/packaging/control/222plugin-oslc	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,4 @@
+Package: @SRCPACKAGE@
+Architecture: all
+Depends: @OLDPACKAGE at -common, @OLDPACKAGE at -db-postgresql | @OLDPACKAGE at -db, @OLDPACKAGE at -web-apache2 | @OLDPACKAGE at -web, @OLDPACKAGE at -shell-postgresql | @OLDPACKAGE at -shell, php5-cli, ${misc:Depends}
+Description: collaborative development tool - oslc plugin

Added: trunk/plugins/coclico/oslc/packaging/control/222plugin-oslc.shortdesc
===================================================================
--- trunk/plugins/coclico/oslc/packaging/control/222plugin-oslc.shortdesc	                        (rev 0)
+++ trunk/plugins/coclico/oslc/packaging/control/222plugin-oslc.shortdesc	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,3 @@
+ This plugin contains the oslc subsystem of FusionForge. It allows each
+ FusionForge project to have its own oslc, and gives some
+ control over it to the project's administrator.

Added: trunk/plugins/coclico/oslc/packaging/dirs/plugin-oslc
===================================================================
--- trunk/plugins/coclico/oslc/packaging/dirs/plugin-oslc	                        (rev 0)
+++ trunk/plugins/coclico/oslc/packaging/dirs/plugin-oslc	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,5 @@
+etc/gforge/httpd.d
+etc/gforge/plugins/oslc
+usr/share/gforge/plugins/oslc/cgi-bin
+usr/share/gforge/plugins/oslc/common
+usr/share/gforge/plugins/oslc/www

Added: trunk/plugins/coclico/oslc/packaging/docs/plugin-oslc
===================================================================
--- trunk/plugins/coclico/oslc/packaging/docs/plugin-oslc	                        (rev 0)
+++ trunk/plugins/coclico/oslc/packaging/docs/plugin-oslc	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1 @@
+debian/README.Debian

Added: trunk/plugins/coclico/oslc/packaging/install/plugin-oslc
===================================================================
--- trunk/plugins/coclico/oslc/packaging/install/plugin-oslc	                        (rev 0)
+++ trunk/plugins/coclico/oslc/packaging/install/plugin-oslc	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,8 @@
+common/*                  usr/share/gforge/plugins/oslc/common/
+include/*                 usr/share/gforge/plugins/oslc/include/
+db/*                      usr/share/gforge/plugins/oslc/db/
+bin/*                     usr/share/gforge/plugins/oslc/bin/
+www/*                     usr/share/gforge/plugins/oslc/www/
+cronjobs/*                usr/share/gforge/cronjobs
+etc/plugins/oslc/*     etc/gforge/plugins/oslc/
+etc/httpd.d/*             usr/share/gforge/etc/httpd.d/

Added: trunk/plugins/coclico/oslc/packaging/links/plugin-oslc
===================================================================
--- trunk/plugins/coclico/oslc/packaging/links/plugin-oslc	                        (rev 0)
+++ trunk/plugins/coclico/oslc/packaging/links/plugin-oslc	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1 @@
+/usr/share/gforge/plugins/oslc/www /usr/share/gforge/www/plugins/oslc

Added: trunk/plugins/coclico/oslc/utils/manage-translations.sh
===================================================================
--- trunk/plugins/coclico/oslc/utils/manage-translations.sh	                        (rev 0)
+++ trunk/plugins/coclico/oslc/utils/manage-translations.sh	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,56 @@
+#! /bin/sh -e
+
+if [ -e gforge/translations/gforge.pot ] ; then        # We're in the parent dir
+    cd gforge
+elif [ -e translations/gforge.pot ] ; then             # probably in gforge/ (or a renamed gforge/)
+    cd . # do nothing, but shell syntax requires an instruction in a then-block
+elif [ -e ../gforge/translations/gforge.pot ] ; then   # in tools/ or tests/ or something
+    cd ../gforge
+elif [ -e ../translations/gforge.pot ] ; then          # In a subdir of gforge/
+    cd ..
+else
+    echo "Couldn't find translations directory..."
+    exit 1
+fi
+
+locales=$(ls translations/*.po \
+    | xargs -n1 -iFILE basename FILE .po \
+    | egrep '^[a-z][a-z](_[A-Z][A-Z]$)?' \
+    | sort)
+
+print_stats () {
+    for l in $(echo $locales | xargs -n 1 | sort) ; do
+	printf "* %5s: " $l
+	msgfmt --statistics -o /dev/null translations/$l.po
+    done
+}
+
+case $1 in
+    stats)
+	print_stats
+	;;
+    refresh)
+	rm translations/gforge.pot
+	
+	find -type f -\( -name \*.php -or -name users -or -name projects -\) \
+	    | grep -v -e {arch} -e svn-base \
+	    | grep -v ^./plugins/wiki \
+	    | LANG=C sort \
+	    | xargs xgettext -d gforge -o translations/gforge.pot -L PHP --from-code=iso-8859-1
+	    
+	for l in $locales ; do
+	    echo "Processing $l..."
+	    msgmerge -U translations/$l.po translations/gforge.pot
+	done
+	;;
+    build)
+	for l in $locales ; do
+	    mkdir -p locales/$l/LC_MESSAGES
+	    msgfmt -o locales/$l/LC_MESSAGES/gforge.mo translations/$l.po
+	done
+	;;
+    *)
+	echo "Unknown operation"
+	exit 1
+	;;
+esac


Property changes on: trunk/plugins/coclico/oslc/utils/manage-translations.sh
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/plugins/coclico/oslc/www/.htaccess
===================================================================
--- trunk/plugins/coclico/oslc/www/.htaccess	                        (rev 0)
+++ trunk/plugins/coclico/oslc/www/.htaccess	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,36 @@
+
+# This should be placed at the top of the directory whose path
+# corresponds to RewriteBase below.
+
+# The apache rewrite module should be activated for his to work
+
+# You should customize the following elements :
+#  - the RewriteBase bellow
+#  - optional : the TRACKER_TYPE (mantis (default), fusionforge, demo)
+#  - optional : the AUTH_TYPE (basic (default), oauth (for Mantis only))
+
+SetEnv TRACKER_TYPE fusionforge
+#SetEnv TRACKER_TYPE mantis
+
+# HTTP Basic authentication
+SetEnv AUTH_TYPE basic
+# OAuth authorization (only supported for Mantis at the moment)
+#SetEnv AUTH_TYPE oauth
+
+# See application.ini for contextual behaviour depending on this variable
+SetEnv APPLICATION_ENV development
+
+
+# "Intercept" anything below the RewriteBase to redirect to index.php
+#  which will do the URL parsing and so on
+
+RewriteEngine On
+
+RewriteBase /plugins/oslc/
+
+RewriteCond %{REQUEST_FILENAME} -s [OR]
+RewriteCond %{REQUEST_FILENAME} -l [OR]
+RewriteCond %{REQUEST_FILENAME} -d
+RewriteRule ^.*$ - [NC,L]
+RewriteRule ^.*$ index.php [NC,L]
+


Property changes on: trunk/plugins/coclico/oslc/www/.htaccess
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/plugins/coclico/oslc/www/admin/index.php
===================================================================
--- trunk/plugins/coclico/oslc/www/admin/index.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/www/admin/index.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,113 @@
+<?php
+
+/*
+ * oslc plugin
+ *
+ * Daniel Perez <danielperez.arg at gmail.com>
+ *
+ * This is an example to watch things in action. You can obviously modify things and logic as you see fit
+ */
+
+require_once('../../../env.inc.php');
+require_once $gfwww.'include/pre.php';
+require_once $gfconfig.'plugins/oslc/config.php';
+
+// the header that displays for the user portion of the plugin
+function oslc_Project_Header($params) {                                                                                                                                         
+	global $DOCUMENT_ROOT,$HTML,$id;
+	$params['toptab']='oslc'; 
+	$params['group']=$id;
+	/*                                                                                                                                                              
+		Show horizontal links                                                                                                                                   
+	*/                                                                                                                                                              
+	site_project_header($params);														
+}
+
+// the header that displays for the project portion of the plugin
+function oslc_User_Header($params) {
+	global $DOCUMENT_ROOT,$HTML,$user_id;
+	$params['toptab']='oslc'; 
+	$params['user']=$user_id;
+	/*                                                                                                                                                              
+	 Show horizontal links                                                                                                                                   
+	 */                                                                                                                                                              
+	site_user_header($params);    
+}
+
+
+	$user = session_get_user(); // get the session user
+
+	if (!$user || !is_object($user) || $user->isError() || !$user->isActive()) {
+		exit_error("Invalid User", "Cannot Process your request for this user.");
+	}
+
+	$type = getStringFromRequest('type');
+	$id = getStringFromRequest('id');
+	$pluginname = getStringFromRequest('pluginname');
+	
+	if (!$type) {
+		exit_error("Cannot Process your request","No TYPE specified"); // you can create items in Base.tab and customize this messages
+	} elseif (!$id) {
+		exit_error("Cannot Process your request","No ID specified");
+	} else {
+		if ($type == 'group') {
+			$group = group_get_object($id);
+			if ( !$group) {
+				exit_error("Invalid Project", "Inexistent Project");
+			}
+			if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the oslc plugin active
+				exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");			
+			}
+			$userperm = $group->getPermission($user);//we'll check if the user belongs to the group (optional)
+			if ( !$userperm->IsMember()) {
+				exit_error("Access Denied", "You are not a member of this project");
+			}
+			// other perms checks here...
+			oslc_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));    
+			// DO THE STUFF FOR THE PROJECT PART HERE
+			echo "We are in the Project oslc plugin <br>";
+			echo "Greetings from planet " . $world; // $world comes from the config file in /etc
+		} elseif ($type == 'user') {
+			$realuser = user_get_object($id);// 
+			if (!($realuser) || !($realuser->usesPlugin($pluginname))) {
+				exit_error("Error", "First activate the User's $pluginname plugin through Account Manteinance Page");
+			}
+			if ( (!$user) || ($user->getID() != $id)) { // if someone else tried to access the private oslc part of this user
+				exit_error("Access Denied", "You cannot access other user's personal $pluginname");
+			}
+			oslc_User_Header(array('title'=>'My '.$pluginname,'pagename'=>"$pluginname",'sectionvals'=>array($realuser->getUnixName())));    
+			// DO THE STUFF FOR THE USER PART HERE
+			echo "We are in the User oslc plugin <br>";
+			echo "Greetings from planet " . $world; // $world comes from the config file in /etc
+		} elseif ($type == 'admin') {
+			$group = group_get_object($id);
+			if ( !$group) {
+				exit_error("Invalid Project", "Inexistent Project");
+			}
+			if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the oslc plugin active
+				exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");			
+			}
+			$userperm = $group->getPermission($user);//we'll check if the user belongs to the group
+			if ( !$userperm->IsMember()) {
+				exit_error("Access Denied", "You are not a member of this project");
+			}
+			//only project admin can access here
+			if ( $userperm->isAdmin() ) {
+				oslc_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));    
+				// DO THE STUFF FOR THE PROJECT ADMINISTRATION PART HERE
+				echo "We are in the Project oslc plugin <font color=\"#ff0000\">ADMINISTRATION</font> <br>";
+				echo "Greetings from planet " . $world; // $world comes from the config file in /etc
+			} else {
+				exit_error("Access Denied", "You are not a project Admin");
+			}
+		}
+	}	 
+	
+	site_project_footer(array());
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>

Added: trunk/plugins/coclico/oslc/www/index.php
===================================================================
--- trunk/plugins/coclico/oslc/www/index.php	                        (rev 0)
+++ trunk/plugins/coclico/oslc/www/index.php	2010-09-23 15:38:51 UTC (rev 10655)
@@ -0,0 +1,124 @@
+<?php
+
+/*
+ * oslc plugin
+ *
+ * Sabri LABBENE <sabri.labbene at gmail.com>
+ *
+ * This is an example to watch things in action. You can obviously modify things and logic as you see fit
+ */
+
+require_once '../../../www/env.inc.php';
+require_once $gfwww.'include/pre.php';
+require_once $gfconfig.'plugins/oslc/config.php';
+
+// the header that displays for the user portion of the plugin
+function oslc_Project_Header($params) {                                                                                                                                         
+	global $DOCUMENT_ROOT,$HTML,$id;
+	$params['toptab']='oslc'; 
+	$params['group']=$id;
+	/*                                                                                                                                                              
+		Show horizontal links                                                                                                                                   
+	*/                                                                                                                                                              
+	site_project_header($params);														
+}
+
+// the header that displays for the project portion of the plugin
+function oslc_User_Header($params) {
+	global $DOCUMENT_ROOT,$HTML,$user_id;
+	$params['toptab']='oslc'; 
+	$params['user']=$user_id;
+	/*                                                                                                                                                              
+	 Show horizontal links                                                                                                                                   
+	 */                                                                                                                                                              
+	site_user_header($params);    
+}
+
+
+	$user = session_get_user(); // get the session user
+
+	if (!$user || !is_object($user) || $user->isError() || !$user->isActive()) {
+		exit_error("Invalid User", "Cannot Process your request for this user.");
+	}
+
+	$type = getStringFromRequest('type');
+	$id = getStringFromRequest('id');
+	$pluginname = getStringFromRequest('pluginname');
+	
+	if (!$type) {
+		exit_error("Cannot Process your request","No TYPE specified"); // you can create items in Base.tab and customize this messages
+	} elseif (!$id) {
+		exit_error("Cannot Process your request","No ID specified");
+	} else {
+		if ($type == 'group') {
+			$group = group_get_object($id);
+			if ( !$group) {
+				exit_error("Invalid Project", "Inexistent Project");
+			}
+			if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the oslc plugin active
+				exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");			
+			}
+			$userperm = $group->getPermission($user);//we'll check if the user belongs to the group (optional)
+			if ( !$userperm->IsMember()) {
+				exit_error("Access Denied", "You are not a member of this project");
+			}
+			// other perms checks here...
+			oslc_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));    
+			// DO THE STUFF FOR THE PROJECT PART HERE
+			//echo "We are in the Project oslc plugin <br>";
+			//echo "Greetings from planet " . $world . "<br>"; // $world comes from the config file in /etc
+						
+			// Run OSLC Zend application
+			/** Zend_Application */
+			require_once 'Zend/Application.php';  
+
+			// Create application, bootstrap, and run
+			$application = new Zend_Application(APPLICATION_ENV,APPLICATION_PATH . '/configs/application.ini');
+
+			// The next stop is in application/Bootstrap.php
+			$application->bootstrap()->run();
+			
+		} elseif ($type == 'user') {
+			$realuser = user_get_object($id);// 
+			if (!($realuser) || !($realuser->usesPlugin($pluginname))) {
+				exit_error("Error", "First activate the User's $pluginname plugin through Account Manteinance Page");
+			}
+			if ( (!$user) || ($user->getID() != $id)) { // if someone else tried to access the private oslc part of this user
+				exit_error("Access Denied", "You cannot access other user's personal $pluginname");
+			}
+			oslc_User_Header(array('title'=>'My '.$pluginname,'pagename'=>"$pluginname",'sectionvals'=>array($realuser->getUnixName())));    
+			// DO THE STUFF FOR THE USER PART HERE
+			echo "We are in the User oslc plugin <br>";
+			echo "Greetings from planet " . $world; // $world comes from the config file in /etc
+		} elseif ($type == 'admin') {
+			$group = group_get_object($id);
+			if ( !$group) {
+				exit_error("Invalid Project", "Inexistent Project");
+			}
+			if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the oslc plugin active
+				exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");			
+			}
+			$userperm = $group->getPermission($user);//we'll check if the user belongs to the group
+			if ( !$userperm->IsMember()) {
+				exit_error("Access Denied", "You are not a member of this project");
+			}
+			//only project admin can access here
+			if ( $userperm->isAdmin() ) {
+				oslc_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));    
+				// DO THE STUFF FOR THE PROJECT ADMINISTRATION PART HERE
+				echo "We are in the Project oslc plugin <font color=\"#ff0000\">ADMINISTRATION</font> <br>";
+				echo "Greetings from planet " . $world; // $world comes from the config file in /etc
+			} else {
+				exit_error("Access Denied", "You are not a project Admin");
+			}
+		}
+	}	 
+	
+	site_project_footer(array());
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>




More information about the Fusionforge-commits mailing list