[vhffs-dev] [2018] Reworked Services::Cvs, Services::Svn, Services::Git, Services:: Mercurial, Services::Bazaar

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 2018
Author:   gradator
Date:     2012-02-18 20:54:24 +0100 (Sat, 18 Feb 2012)
Log Message:
-----------
Reworked Services::Cvs, Services::Svn, Services::Git, Services::Mercurial, Services::Bazaar

Using prepared statement on all SQL queries
SCMs are now all using the same methods
Code cleaning/improvements

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Panel/Cvs.pm
    trunk/vhffs-api/src/Vhffs/Services/Bazaar.pm
    trunk/vhffs-api/src/Vhffs/Services/Cron.pm
    trunk/vhffs-api/src/Vhffs/Services/Cvs.pm
    trunk/vhffs-api/src/Vhffs/Services/Git.pm
    trunk/vhffs-api/src/Vhffs/Services/MailingList.pm
    trunk/vhffs-api/src/Vhffs/Services/Mercurial.pm
    trunk/vhffs-api/src/Vhffs/Services/Repository.pm
    trunk/vhffs-api/src/Vhffs/Services/Svn.pm
    trunk/vhffs-api/src/Vhffs/Services/Web.pm
    trunk/vhffs-api/src/examples/show_dumper_cvs.pl
    trunk/vhffs-robots/src/cvs_create.pl
    trunk/vhffs-robots/src/cvs_delete.pl
    trunk/vhffs-robots/src/cvs_public.pl
    trunk/vhffs-robots/src/cvs_viewvcconf.pl

Modified: trunk/vhffs-api/src/Vhffs/Panel/Cvs.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Cvs.pm	2012-02-18 02:27:48 UTC (rev 2017)
+++ trunk/vhffs-api/src/Vhffs/Panel/Cvs.pm	2012-02-18 19:54:24 UTC (rev 2018)
@@ -183,7 +183,7 @@
 		return;
 	}
 
-	my $cvs = Vhffs::Services::Cvs::get_by_cvsroot($vhffs, $repo_name);
+	my $cvs = Vhffs::Services::Cvs::get_by_reponame($vhffs, $repo_name);
 	unless( defined $cvs ) {
 		$panel->render('misc/message.tt', { message => gettext( 'Cannot get informations on this object' ) } );
 		return;
@@ -201,17 +201,23 @@
 		} elsif( not defined($cgi->param('public')) ) {
 			$panel->add_error( gettext("CGI Error !") );
 		} else {
-			my $want_public = int($cgi->param('public'));
-			if($want_public != $cvs->is_public) {
-				$cvs->set_public($want_public);
-				$cvs->set_status(Vhffs::Constants::WAITING_FOR_MODIFICATION);
+			my $public = $cgi->param('public');
+			if($public == 1 and not $cvs->is_public) {
+				$cvs->set_public;
+				$cvs->set_status( Vhffs::Constants::WAITING_FOR_MODIFICATION );
+			} elsif($public == 0 and $cvs->is_public) {
+				$cvs->set_private;
+				$cvs->set_status( Vhffs::Constants::WAITING_FOR_MODIFICATION );
+			}
+
+			if($cvs->get_status == Vhffs::Constants::WAITING_FOR_MODIFICATION) {
 				if($cvs->commit > 0) {
 					my $url = '?do=groupview;group='.$cvs->get_group->get_groupname.';msg='.gettext('Modifications applied. Please wait while your repository is being updated');
 					$panel->redirect($url);
 					return;
-				} else {
-					$panel->add_error(gettext('An error occured during CVS repository update'));
 				}
+
+				$panel->add_error(gettext('An error occured during CVS repository update'));
 			}
 		}
 	}

Modified: trunk/vhffs-api/src/Vhffs/Services/Bazaar.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Bazaar.pm	2012-02-18 02:27:48 UTC (rev 2017)
+++ trunk/vhffs-api/src/Vhffs/Services/Bazaar.pm	2012-02-18 19:54:24 UTC (rev 2018)
@@ -2,31 +2,31 @@
 # Copyright (c) vhffs project and its contributors
 # All rights reserved.
 #
-# Redistribution and use in source and binary forms, with or without 
-# modification, are permitted provided that the following conditions 
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
 # are met:
 #
-# 1. Redistributions of source code must retain the above copyright 
+# 1. Redistributions of source code must retain the above copyright
 #   notice, this list of conditions and the following disclaimer.
 #2. Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in 
-#   the documentation and/or other materials provided with the 
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
 #   distribution.
-#3. Neither the name of vhffs nor the names of its contributors 
-#   may be used to endorse or promote products derived from this 
+#3. Neither the name of vhffs nor the names of its contributors
+#   may be used to endorse or promote products derived from this
 #   software without specific prior written permission.
 #
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
 # This file is a part of VHFFS4 Hosting Platform
@@ -42,227 +42,193 @@
 use DBI;
 
 sub check_name($) {
-    my $name = shift;
-    return ($name =~ /^[a-z0-9]+\/[a-z0-9\-_]{3,64}$/);
+	my $name = shift;
+	return ($name =~ /^[a-z0-9]+\/[a-z0-9\-_]{3,64}$/);
 }
 
-sub delete
-{
-    my $self = shift;
-    my $query;
-    my $request;
+sub supports_notifications {
+	return 1;
+}
 
-    $query = "DELETE FROM vhffs_bazaar WHERE object_id='".$self->{'object_id'}."'";
-    $request = $self->{'db'}->prepare($query);
-    $request->execute or return -1;
+sub _new {
+	my ($class, $main, $bazaar_id, $reponame, $owner_uid, $owner_gid, $public, $ml_name, $oid, $date_creation, $description, $state) = @_;
 
-    return -1 if( $self->SUPER::delete < 0 );
+	my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_BAZAAR);
+	return undef unless(defined $self);
+
+	$self->{bazaar_id} = $bazaar_id;
+	$self->{reponame} = $reponame;
+	$self->{public} = $public;
+	$self->{ml_name} = $ml_name;
+
+	return $self;
 }
 
-sub create
-{
-   my ($main, $rname, $description, $user, $group) = @_;
+sub create {
+	my ($main, $rname, $description, $user, $group) = @_;
 
-    return undef unless(defined($user) && defined($group));
-    return undef unless(check_name($rname));
+	return undef unless(defined($user) && defined($group));
+	return undef unless(check_name($rname));
 
-    my $bazaar;
+	my $bazaar;
 
-    my $dbh = $main->get_db_object();
-    local $dbh->{RaiseError} = 1;
-    local $dbh->{PrintError} = 0;
-    $dbh->begin_work;
+	my $dbh = $main->get_db_object();
+	local $dbh->{RaiseError} = 1;
+	local $dbh->{PrintError} = 0;
+	$dbh->begin_work;
 
-    eval {
-        my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_BAZAAR);
+	eval {
+		my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_BAZAAR);
 
-        die('Unable to create parent object') unless(defined $parent);
+		die('Unable to create parent object') unless(defined $parent);
 
-        my $sql = 'INSERT INTO vhffs_bazaar(reponame, public, ml_name, object_id) VALUES(?, 1, \'\', ?)';
-        my $sth = $dbh->prepare($sql);
-        $sth->execute($rname, $parent->get_oid) or return undef;
+		my $sql = 'INSERT INTO vhffs_bazaar(reponame, public, ml_name, object_id) VALUES(?, 1, \'\', ?)';
+		my $sth = $dbh->prepare($sql);
+		$sth->execute($rname, $parent->get_oid) or return undef;
 
-        $dbh->commit;
-        $bazaar = get_by_reponame($main, $rname);
-    };
+		$dbh->commit;
+		$bazaar = get_by_reponame($main, $rname);
+	};
 
-    if($@) {
-        warn "Unable to create bazaar repository $rname: $@\n";
-        $dbh->rollback;
-    }
+	if($@) {
+		warn "Unable to create bazaar repository $rname: $@\n";
+		$dbh->rollback;
+	}
 
-    return $bazaar;
+	return $bazaar;
 }
 
-sub get_by_reponame($$) {
-    my ($main, $reponame) = @_;
-    my @params;
+=head2 fill_object
 
-    my $sql = 'SELECT s.bazaar_id, s.reponame, o.owner_uid, o.owner_gid, s.public, s.ml_name, o.object_id, o.date_creation, o.description, o.state FROM vhffs_bazaar s INNER JOIN vhffs_object o ON o.object_id = s.object_id WHERE s.reponame = ?';
+See C<Vhffs::Object::fill_object>.
 
-    my $dbh = $main->get_db_object();
+=cut
+sub fill_object {
+	my ($class, $obj) = @_;
+	my $sql = q{SELECT bazaar_id, reponame, public, ml_name
+		FROM vhffs_bazaar WHERE object_id = ?};
+	return $class->SUPER::_fill_object($obj, $sql);
+}
 
-    return undef unless(@params = $dbh->selectrow_array($sql, undef, $reponame));
+sub getall {
+	my ($vhffs, $state, $name, $group) = @_;
 
-    return _new Vhffs::Services::Bazaar($main, @params);
+	my $bazaar = [];
+	my @params;
 
-}
+	my $sql = 'SELECT b.bazaar_id, b.reponame, o.owner_uid, o.owner_gid, b.public, b.ml_name, o.object_id, o.date_creation, o.description, o.state
+		FROM vhffs_bazaar b INNER JOIN vhffs_object o ON b.object_id = o.object_id WHERE 1=1';
 
-=head2 fill_object
+	if(defined $state) {
+		$sql .= ' AND o.state = ?';
+		push(@params, $state);
+	}
+	if(defined $name) {
+		$sql .= ' AND b.reponame LIKE ?';
+		push(@params, '%'.$name.'%');
+	}
+	if(defined($group)) {
+		$sql .= ' AND o.owner_gid = ?';
+		push(@params, $group->get_gid);
+	}
+	$sql .= ' ORDER BY b.reponame';
 
-See C<Vhffs::Object::fill_object>.
+	my $dbh = $vhffs->get_db_object();
 
-=cut
+	my $sth = $dbh->prepare($sql);
+	$sth->execute(@params) or return undef;
 
-sub fill_object {
-    my ($class, $obj) = @_;
-    my $sql = q{SELECT bazaar_id, reponame, public, ml_name FROM vhffs_bazaar
-        WHERE object_id = ?};
-    return $class->SUPER::_fill_object($obj, $sql);
+	while(my $s = $sth->fetchrow_arrayref()) {
+		push(@$bazaar, _new Vhffs::Services::Bazaar($vhffs, @$s));
+	}
+	return $bazaar;
 }
 
-sub _new
-{
-    my ($class, $main, $bazaar_id, $reponame, $owner_uid, $owner_gid, $public, $ml_name, $oid, $date_creation, $description, $state) = @_;
+sub get_by_reponame($$) {
+	my ($main, $reponame) = @_;
+	my @params;
 
-    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_BAZAAR);
-    return undef unless(defined $self);
+	my $sql = 'SELECT b.bazaar_id, b.reponame, o.owner_uid, o.owner_gid, b.public, b.ml_name, o.object_id, o.date_creation, o.description, o.state
+		FROM vhffs_bazaar b INNER JOIN vhffs_object o ON o.object_id = b.object_id WHERE b.reponame = ?';
 
-    $self->{bazaar_id} = $bazaar_id;
-    $self->{reponame} = $reponame;
-    $self->{public} = $public;
-    $self->{ml_name} = $ml_name;
+	my $dbh = $main->get_db_object();
 
-    return $self;
+	return undef unless(@params = $dbh->selectrow_array($sql, undef, $reponame));
+
+	return _new Vhffs::Services::Bazaar($main, @params);
 }
 
-sub supports_notifications {
-    return 1;
+sub delete {
+	my $self = shift;
+
+	my $query = 'DELETE FROM vhffs_bazaar WHERE bazaar_id=?';
+	my $request = $self->{'db'}->prepare($query);
+	$request->execute( $self->{bazaar_id} ) or return -1;
+
+	return $self->SUPER::delete;
 }
 
-sub commit
-{
-    my $self = shift;
+sub commit {
+	my $self = shift;
 
-    my $dbh = $self->get_db_object;
-    my $sql = 'UPDATE vhffs_bazaar SET public = ?, ml_name = ? WHERE bazaar_id = ?';
-    $dbh->do($sql, undef, $self->{public}, $self->{ml_name}, $self->{bazaar_id});
+	my $dbh = $self->get_db_object;
+	my $sql = 'UPDATE vhffs_bazaar SET public = ?, ml_name = ? WHERE bazaar_id = ?';
+	$dbh->do($sql, undef, $self->{public}, $self->{ml_name}, $self->{bazaar_id});
 
-    $self->SUPER::commit;
+	return $self->SUPER::commit;
 }
 
-sub set_public
-{
-    my $self = shift;
-    $self->{'public'} = 1;
+sub set_public {
+	my $self = shift;
+	$self->{'public'} = 1;
 }
 
-sub set_private
-{
-    my $self = shift;
-    $self->{'public'} = 0;
+sub set_private {
+	my $self = shift;
+	$self->{'public'} = 0;
 }
 
 sub set_ml_name {
-    my ($self, $ml_name) = @_;
-    return -1 unless(Vhffs::Functions::valid_mail($ml_name) || $ml_name =~ /^\s*$/);
-    $self->{ml_name} = $ml_name;
+	my ($self, $ml_name) = @_;
+	return -1 unless(Vhffs::Functions::valid_mail($ml_name) || $ml_name =~ /^\s*$/);
+	$self->{ml_name} = $ml_name;
 }
 
-sub is_public
-{
-    my $self = shift;
-    
-    return -1 if( ! defined $self->{'public'} );
-
-    if( $self->{'public'} == 1 ) {
-        return 1;
-    } else {
-        return 0;
-    }
+sub is_public {
+	my $self = shift;	
+	return $self->{'public'};
 }
 
 sub get_ml_name {
-    my $self = shift;
-    return $self->{ml_name};
+	my $self = shift;
+	return $self->{ml_name};
 }
 
-sub get_reponame
-{
-    my $self = shift;
-    return $self->{'reponame'};
+sub get_reponame {
+	my $self = shift;
+	return $self->{'reponame'};
 }
 
-sub get_label
-{
-    my $self = shift;
-    return $self->{reponame};
+sub get_label {
+	my $self = shift;
+	return $self->{reponame};
 }
 
-sub getall
-{
-    my ($vhffs, $state, $name, $group) = @_;
-
-    my $bazaar = [];
-    my @params;
-
-    my $sql = 'SELECT s.bazaar_id, s.reponame, o.owner_uid, o.owner_gid, s.public, s.ml_name, o.object_id, o.date_creation, o.description, o.state FROM vhffs_bazaar s, vhffs_object o WHERE o.object_id = s.object_id';
-    
-
-    if(defined $state) {
-        $sql .= ' AND o.state = ?';
-        push(@params, $state);
-    }
-    if(defined $name) {
-        $sql .= ' AND s.name = ?';
-        push(@params, $name);
-    }
-    if(defined($group)) {
-        $sql .= ' AND o.owner_gid = ?';
-        push(@params, $group->get_gid);
-    }
-    $sql .= ' ORDER BY s.reponame';
-
-    my $dbh = $vhffs->get_db_object();
-
-    my $sth = $dbh->prepare($sql);
-    $sth->execute(@params) or die($sql) ; #return undef;
-
-    while(my $s = $sth->fetchrow_arrayref()) {
-        push(@$bazaar, _new Vhffs::Services::Bazaar($vhffs, @$s));
-    }
-    return $bazaar;
+sub get_dir {
+	my $self = shift;
+	return $self->get_base_dir.'/'.$self->get_reponame;
 }
 
-sub getall_by_group
-{
-    my ($vhffs, $group) = @_;
+=head2 get_base_dir
 
-    my $bazaar = [];
-    my @params;
+	my $basedir = $bazaar->get_base_dir();
 
-    return undef unless( defined $group );
+Returns the directory containing all the repositories.
 
-    my $sql = 'SELECT s.bazaar_id, s.reponame, o.owner_uid, o.owner_gid, s.public, o.object_id, o.date_creation, o.description, o.state FROM vhffs_bazaar s INNER
- JOIN vhffs_object o ON o.object_id = s.object_id WHERE o.owner_gid = ? ORDER BY s.reponame';
-
-    my $dbh = $vhffs->get_db_object();
-
-    my $sth = $dbh->prepare($sql);
-    $sth->execute($group->get_gid) or return undef;
-
-    while(my $s = $sth->fetchrow_arrayref()) {
-        push(@$bazaar, _new Vhffs::Services::Bazaar($vhffs, @$s));
-    }
-    return $bazaar;
+=cut
+sub get_base_dir {
+	my $self = shift;
+	return $self->{'main'}->get_config->get_datadir.'/bazaar/bazaarroot';
 }
 
-sub get_dir
-{
-    my $self = shift;
-    return undef if( ! defined $self );
-    
-    return( $self->{'main'}->get_config->get_datadir . "/bazaar/bazaarroot/" . $self->get_reponame );
-}
-
 1;

Modified: trunk/vhffs-api/src/Vhffs/Services/Cron.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Cron.pm	2012-02-18 02:27:48 UTC (rev 2017)
+++ trunk/vhffs-api/src/Vhffs/Services/Cron.pm	2012-02-18 19:54:24 UTC (rev 2018)
@@ -411,28 +411,7 @@
 	return $request->execute( $self->{'cron_id'} );
 }
 
-sub getall_per_group
-{
-	my ($main, $group) = @_;
-	my @result;
-	my $repos = [];
-	return undef if ( ! defined $group );
 
-	my $sql = 'SELECT c.cron_id, c.cronpath, c.interval, c.reportmail, c.lastrundate, c.lastrunreturncode, c.nextrundate, c.running, o.owner_uid, o.owner_gid, o.object_id, o.date_creation, o.description, o.state FROM vhffs_cron c INNER JOIN vhffs_object o ON o.object_id = c.object_id WHERE o.owner_gid = ?';
-
-	my $dbh = $main->get_db_object();
-	my $sth = $dbh->prepare($sql);
-	$sth->execute($group->get_gid) or return undef;
-
-	while(my $r = $sth->fetchrow_arrayref()) {
-		push(@$repos, _new Vhffs::Services::Cron($main, @$r));
-	}
-	return $repos;
-}
-
-
-
-
 1;
 
 __END__

Modified: trunk/vhffs-api/src/Vhffs/Services/Cvs.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Cvs.pm	2012-02-18 02:27:48 UTC (rev 2017)
+++ trunk/vhffs-api/src/Vhffs/Services/Cvs.pm	2012-02-18 19:54:24 UTC (rev 2018)
@@ -2,31 +2,31 @@
 # Copyright (c) vhffs project and its contributors
 # All rights reserved.
 #
-# Redistribution and use in source and binary forms, with or without 
-# modification, are permitted provided that the following conditions 
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
 # are met:
 #
-# 1. Redistributions of source code must retain the above copyright 
+# 1. Redistributions of source code must retain the above copyright
 #   notice, this list of conditions and the following disclaimer.
 #2. Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in 
-#   the documentation and/or other materials provided with the 
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
 #   distribution.
-#3. Neither the name of vhffs nor the names of its contributors 
-#   may be used to endorse or promote products derived from this 
+#3. Neither the name of vhffs nor the names of its contributors
+#   may be used to endorse or promote products derived from this
 #   software without specific prior written permission.
 #
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
 =pod
@@ -56,249 +56,206 @@
 
 =head2 check_name
 
-    die("Invalid CVS root\n") unless(Vhffs::Services::Cvs::check_name($cvsroot));
+	die("Invalid CVS root\n") unless(Vhffs::Services::Cvs::check_name($cvsroot));
 
 Checks whether a cvsroot is valid or not.
 
 =cut
-
 sub check_name($) {
-    my $name = shift;
-    return ($name =~ /^[a-z0-9]+\/[a-z0-9\-_]{3,64}$/);
+	my $name = shift;
+	return ($name =~ /^[a-z0-9]+\/[a-z0-9\-_]{3,64}$/);
 }
 
-sub delete
-{
-	my $self = shift;
+sub supports_notifications {
+	return 0;
+}
 
-    my $query = "DELETE FROM vhffs_cvs WHERE object_id='".$self->{'object_id'}."'";
-    my $request = $self->{'db'}->prepare($query);
-    $request->execute or return -1;
-
-	return -1 if( $self->SUPER::delete < 0 );
-	return 1;
+sub _new {
+	my ($class, $main, $cvs_id, $cvsroot, $owner_uid, $owner_gid, $public, $oid, $date_creation, $description, $state) = @_;
+	
+	my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_CVS);
+	return undef unless(defined $self);
+	
+	$self->{cvsroot} = $cvsroot;
+	$self->{cvs_id} = $cvs_id;
+	$self->{public} = $public;
+	return $self;
 }
 
 =pod
 
 =head2 create
 
-    my $cvs = Vhffs::Services::Cvs::create($main, $cvsroot, $description, $user, $group);
-    die("Unable to create cvs\n") unless($cvs);
+	my $cvs = Vhffs::Services::Cvs::create($main, $cvsroot, $description, $user, $group);
+	die("Unable to create cvs\n") unless($cvs);
 
 Creates a new CVS service in database and returns the corresponding fully functional object.
 
 =cut
+sub create {
+	my ($main, $cvsroot, $description, $user, $group) = @_;
+	return undef unless(defined($user) && defined($group));
+	return undef unless(check_name($cvsroot));
 
-sub create
-{
-    my ($main, $cvsroot, $description, $user, $group) = @_;
-    return undef unless(defined($user) && defined($group));
-    return undef unless(check_name($cvsroot));
+	my $cvs;
+	my $dbh = $main->get_db_object();
+	local $dbh->{RaiseError} = 1;
+	local $dbh->{PrintError} = 0;
+	$dbh->begin_work;
+	eval {
 
-    my $cvs;
-    my $dbh = $main->get_db_object();
-    local $dbh->{RaiseError} = 1;
-    local $dbh->{PrintError} = 0;
-    $dbh->begin_work;
-    eval {
+		my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_CVS);
 
-        my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_CVS);
+		die('Unable to create parent object') unless(defined($parent));
 
-        die('Unable to create parent object') unless(defined($parent));
+		my $sql = 'INSERT INTO vhffs_cvs(cvsroot, public, object_id) VALUES (?, TRUE, ?)';
+		my $sth = $dbh->prepare($sql);
+		$sth->execute($cvsroot, $parent->get_oid);
 
-        my $sql = 'INSERT INTO vhffs_cvs(cvsroot, public, object_id) VALUES (?, TRUE, ?)';
-        my $sth = $dbh->prepare($sql);
-        $sth->execute($cvsroot, $parent->get_oid);
+		$dbh->commit;
+		$cvs = get_by_reponame($main, $cvsroot);
+	};
 
-        $dbh->commit;
-        $cvs = get_by_cvsroot($main, $cvsroot);
-    };
+	if($@) {
+		warn 'Error creating cvs service: '.$@."\n";
+		$dbh->rollback;
+	}
+	return $cvs;
 
-    if($@) {
-        warn "Error creating cvs service: $@\n";
-        $dbh->rollback;
-    }
-    return $cvs;
-
 }
 
-sub commit
-{
-	my $self = shift;	
+=head2 fill_object
 
-    my $sql = 'UPDATE vhffs_cvs SET cvsroot = ?, public = ? WHERE cvs_id = ?';
-    $self->get_db_object()->do($sql, undef, $self->{'cvsroot'},
-                                        $self->{'public'}, $self->{'cvs_id'})
-                                            or return -1;
+See C<Vhffs::Object::fill_object>.
 
-	return -2 if( $self->SUPER::commit < 0 );
-	return 1;
+=cut
+sub fill_object {
+	my ($class, $obj) = @_;
+	my $sql = q{SELECT cvsroot, cvs_id, public FROM vhffs_cvs WHERE object_id = ?};
+	return $class->SUPER::_fill_object($obj, $sql);
 }
 
-sub supports_notifications {
-    return 0;
-}
+sub getall {
+	my ($vhffs, $state, $name, $group) = @_;
 
-=head2 set_public
+	my $cvs = [];
+	my @params;
 
-    $cvs->set_public(0);
+	my $sql = 'SELECT c.cvs_id, c.cvsroot, o.owner_uid, o.owner_gid, c.public, o.object_id, o.date_creation, o.description, o.state
+		FROM vhffs_cvs c INNER JOIN vhffs_object o ON c.object_id = o.object_id WHERE 1=1';
 
-Defines if a CVS repository is public (param == 1) or not (0).
-
-=cut
-
-sub set_public
-{
-	my ($self, $public) = @_;
-	$self->{'public'} = $public;
-}
-
-sub is_public
-{
-	my $self = shift;
-	
-	return -1 if( ! defined $self->{'public'} );
-
-	if( $self->{'public'} == 1 )
-	{
-		return 1;
+	if(defined $state) {
+		$sql .= ' AND o.state=?';
+		push(@params, $state);
 	}
-	else
-	{
-		return 0;
+	if(defined $name) {
+		$sql .= ' AND c.cvsroot LIKE ?';
+		push(@params, '%'.$name.'%');
 	}
-}
+	if(defined $group) {
+		$sql .= ' AND o.owner_gid=?';
+		push(@params, $group->get_gid);
+	}
+	$sql .= ' ORDER BY c.cvsroot';
 
-sub get_label {
-    return $_[0]->{cvsroot};
-}
+	my $dbh = $vhffs->get_db_object();
 
-sub get_cvsroot
-{
-	my $self = shift;
-	return $self->{'cvsroot'};
-}
+	my $sth = $dbh->prepare( $sql );
+	$sth->execute(@params) or return undef;
 
-sub get_reponame {
-    my ($self) = @_;
-    return $self->get_cvsroot;
+	while(my $s = $sth->fetchrow_arrayref()) {
+		push(@$cvs, _new Vhffs::Services::Cvs($vhffs, @$s));
+	}
+	return $cvs;
 }
 
+sub get_by_reponame {
+	my($main, $cvsroot) = @_;
+	my $sql = 'SELECT c.cvs_id, c.cvsroot, o.owner_uid, o.owner_gid, c.public, c.object_id, o.date_creation, o.description, o.state FROM vhffs_cvs c
+		INNER JOIN vhffs_object o ON c.object_id = o.object_id WHERE c.cvsroot = ?';
+	my $dbh = $main->get_db_object();
+	my @params;
+	return undef unless(@params = $dbh->selectrow_array($sql, undef, $cvsroot));
 
-sub set_cvsroot
-{
-	my ($self , $value) = @_;	
-	$self->{'cvsroot'} = $value;
+	return _new Vhffs::Services::Cvs($main, @params);
 }
 
+sub delete {
+	my $self = shift;
 
+	my $query = 'DELETE FROM vhffs_cvs WHERE cvs_id=?';
+	my $request = $self->{'db'}->prepare($query);
+	$request->execute( $self->{cvs_id} ) or return -1;
 
-sub get_dir
-{
-    my $self = shift;
-    return undef if( ! defined $self );
-    
-    return( $self->{'main'}->get_config->get_datadir . "/cvs/cvsroot/" . $self->get_cvsroot );
+	return $self->SUPER::delete;
 }
 
-sub get_by_cvsroot {
-    my($main, $cvsroot) = @_;
-    my $sql = 'SELECT c.cvs_id, c.cvsroot, o.owner_uid, o.owner_gid, c.public, c.object_id, o.date_creation, o.description, o.state FROM vhffs_cvs c INNER JOIN vhffs_object o ON c.object_id = o.object_id WHERE c.cvsroot = ?';
-    my $dbh = $main->get_db_object();
-    my @params;
-    return undef unless(@params = $dbh->selectrow_array($sql, undef, $cvsroot));
+sub commit {
+	my $self = shift;	
 
-    return _new Vhffs::Services::Cvs($main, @params);
-}
+	my $sql = 'UPDATE vhffs_cvs SET cvsroot = ?, public = ? WHERE cvs_id = ?';
+	$self->get_db_object()->do($sql, undef, $self->{'cvsroot'},
+		                                $self->{'public'}, $self->{'cvs_id'})
+		                                    or return -1;
 
-sub _new {
-    my ($class, $main, $cvs_id, $cvsroot, $owner_uid, $owner_gid, $public, $oid, $date_creation, $description, $state) = @_;
-    
-    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_CVS);
-    return undef unless(defined $self);
-    
-    $self->{cvsroot} = $cvsroot;
-    $self->{cvs_id} = $cvs_id;
-    $self->{public} = $public;
-    return $self;
+	return -2 if( $self->SUPER::commit < 0 );
+	return 1;
 }
 
+=head2 set_public
 
-=head2 fill_object
+	$cvs->set_public;
 
-See C<Vhffs::Object::fill_object>.
+Set a CVS repository public.
 
 =cut
-sub fill_object {
-    my ($class, $obj) = @_;
-    my $sql = q{SELECT cvsroot, cvs_id, public FROM vhffs_cvs
-        WHERE object_id = ?};
-    return $class->SUPER::_fill_object($obj, $sql);
+sub set_public {
+	my $self = shift;
+	$self->{'public'} = 1;
 }
 
-sub getall
-{
-    my ($vhffs, $state, $name, $group) = @_;
+=head2 set_private
 
-    my $query;
-    my $request;
-    my @params;
+	$cvs->set_private;
 
-    my $objs = [];
-    my $result;
-    my $tmp;
+Set a CVS repository private.
 
-    $query = 'SELECT c.cvs_id, c.cvsroot, o.owner_uid, o.owner_gid, c.public, o.object_id, o.date_creation, o.description, o.state FROM vhffs_cvs c INNER JOIN vhffs_object o ON c.object_id = o.object_id';
-    if(defined $state) {
-        $query .= ' AND o.state=?';
-        push(@params, $state);
-    }
-    if(defined $name) {
-        $query .= ' AND c.cvsroot LIKE ?';
-        push(@params, '%'.$name.'%');
-    }
+=cut
+sub set_private {
+	my $self = shift;
+	$self->{'public'} = 0;
+}
 
-    if(defined $group) {
-        $query .= ' AND o.owner_gid=?';
-        push(@params, $group->get_gid);
-    }
-    $query .= " ORDER BY c.cvsroot";
-    $request = $vhffs->{'db'}->prepare( $query );
-    my $rows = $request->execute(@params);
+sub is_public {
+	my $self = shift;
+	return $self->{'public'};
+}
 
-    return undef if( ! $rows );
+sub get_label {
+	my $self = shift;
+	return $self->{cvsroot};
+}
 
-    while( $result = $request->fetchrow_arrayref )
-    {
-        $tmp = _new Vhffs::Services::Cvs( $vhffs, @{$result} ) ;
-        push @{$objs} , $tmp;
-    }
-    return $objs;
+sub get_reponame {
+	my ($self) = @_;
+	return $self->{'cvsroot'};
 }
 
-sub getall_per_group
-{
-    my ($main, $group) = @_;
-    my @result;
-    my $cvsroot;
-    return undef if ( ! defined $group );
-    
-    my $query = 'SELECT c.cvs_id, c.cvsroot, o.owner_uid, o.owner_gid, c.public, o.object_id, o.date_creation, o.description, o.state FROM vhffs_cvs c INNER JOIN vhffs_object o ON c.object_id = o.object_id WHERE o.owner_gid=? ORDER BY c.cvsroot';
+sub get_dir {
+	my $self = shift;
+	return $self->get_base_dir.'/'.$self->get_reponame;
+}
 
-    my $request = $main->{'db'}->prepare( $query ) or return -1;
+=head2 get_base_dir
 
-    
-    return undef if ( ! $request->execute($group->get_gid) );
-    
-    while( my $repos = $request->fetchrow_arrayref()  )
-    {
-        push(@result, _new Vhffs::Services::Cvs($main, @{$repos}))
-    }
-    
+	my $basedir = $cvs->get_base_dir();
 
-    return \@result;
+Returns the directory containing all the repositories.
 
+=cut
+sub get_base_dir {
+	my $self = shift;
+	return $self->{'main'}->get_config->get_datadir.'/cvs/cvsroot';
 }
 
 1;

Modified: trunk/vhffs-api/src/Vhffs/Services/Git.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Git.pm	2012-02-18 02:27:48 UTC (rev 2017)
+++ trunk/vhffs-api/src/Vhffs/Services/Git.pm	2012-02-18 19:54:24 UTC (rev 2018)
@@ -3,31 +3,31 @@
 # Copyright 2007 (c) Julien Danjou <julien@xxxxxxxxxxx>
 # All rights reserved.
 #
-# Redistribution and use in source and binary forms, with or without 
-# modification, are permitted provided that the following conditions 
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
 # are met:
 #
-# 1. Redistributions of source code must retain the above copyright 
+# 1. Redistributions of source code must retain the above copyright
 #   notice, this list of conditions and the following disclaimer.
 #2. Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in 
-#   the documentation and/or other materials provided with the 
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
 #   distribution.
-#3. Neither the name of vhffs nor the names of its contributors 
-#   may be used to endorse or promote products derived from this 
+#3. Neither the name of vhffs nor the names of its contributors
+#   may be used to endorse or promote products derived from this
 #   software without specific prior written permission.
 #
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
 # This file is a part of VHFFS4 Hosting Platform
@@ -43,70 +43,60 @@
 use DBI;
 
 sub check_name($) {
-    my $name = shift;
-    return ($name =~ /^[a-z0-9]+\/[a-z0-9\-_]{3,64}\.git$/);
+	my $name = shift;
+	return ($name =~ /^[a-z0-9]+\/[a-z0-9\-_]{3,64}\.git$/);
 }
 
-sub delete
-{
-    my $self = shift;
-    my $query;
-    my $request;
-
-    $query = "DELETE FROM vhffs_git WHERE object_id='".$self->{'object_id'}."'";
-    $request = $self->{'db'}->prepare($query);
-    $request->execute or return -1;
-
-    return -1 if( $self->SUPER::delete < 0 );
+sub supports_notifications {
+	return 1;
 }
 
-sub create
-{
-   my ($main, $rname, $description, $user, $group) = @_;
+sub _new {
+	my ($class, $main, $git_id, $reponame, $owner_uid, $owner_gid, $public, $ml_name, $oid, $date_creation, $description, $state) = @_;
 
-    return undef unless(defined($user) && defined($group));
-    return undef unless(check_name($rname));
+	my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_GIT);
+	return undef unless(defined $self);
 
-    my $git;
+	$self->{git_id} = $git_id;
+	$self->{reponame} = $reponame;
+	$self->{public} = $public;
+	$self->{ml_name} = $ml_name;
 
-    my $dbh = $main->get_db_object();
-    local $dbh->{RaiseError} = 1;
-    local $dbh->{PrintError} = 0;
-    $dbh->begin_work;
+	return $self;
+}
 
-    eval {
-        my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_GIT);
+sub create {
+	my ($main, $rname, $description, $user, $group) = @_;
 
-        die('Unable to create parent object') unless(defined $parent);
+	return undef unless(defined($user) && defined($group));
+	return undef unless(check_name($rname));
 
-        my $sql = 'INSERT INTO vhffs_git(reponame, public, ml_name, object_id) VALUES(?, 1, \'\', ?)';
-        my $sth = $dbh->prepare($sql);
-        $sth->execute($rname, $parent->get_oid) or return undef;
+	my $git;
 
-        $dbh->commit;
-        $git = get_by_reponame($main, $rname);
-    };
+	my $dbh = $main->get_db_object();
+	local $dbh->{RaiseError} = 1;
+	local $dbh->{PrintError} = 0;
+	$dbh->begin_work;
 
-    if($@) {
-        warn "Unable to create git repository $rname: $@\n";
-        $dbh->rollback;
-    }
+	eval {
+		my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_GIT);
 
-    return $git;
-}
+		die('Unable to create parent object') unless(defined $parent);
 
-sub get_by_reponame($$) {
-    my ($main, $reponame) = @_;
-    my @params;
+		my $sql = 'INSERT INTO vhffs_git(reponame, public, ml_name, object_id) VALUES(?, 1, \'\', ?)';
+		my $sth = $dbh->prepare($sql);
+		$sth->execute($rname, $parent->get_oid) or return undef;
 
-    my $sql = 'SELECT s.git_id, s.reponame, o.owner_uid, o.owner_gid, s.public, s.ml_name, o.object_id, o.date_creation, o.description, o.state FROM vhffs_git s INNER JOIN vhffs_object o ON o.object_id = s.object_id WHERE s.reponame = ?';
+		$dbh->commit;
+		$git = get_by_reponame($main, $rname);
+	};
 
-    my $dbh = $main->get_db_object();
+	if($@) {
+		warn "Unable to create git repository $rname: $@\n";
+		$dbh->rollback;
+	}
 
-    return undef unless(@params = $dbh->selectrow_array($sql, undef, $reponame));
-
-    return _new Vhffs::Services::Git($main, @params);
-
+	return $git;
 }
 
 =head2 fill_object
@@ -114,156 +104,134 @@
 See C<Vhffs::Object::fill_object>.
 
 =cut
-
 sub fill_object {
-    my ($class, $obj) = @_;
-    my $sql = q{SELECT git_id, reponame, public, ml_name FROM vhffs_git
-        WHERE object_id = ?};
-    return $class->SUPER::_fill_object($obj, $sql);
+	my ($class, $obj) = @_;
+	my $sql = q{SELECT git_id, reponame, public, ml_name FROM vhffs_git
+		WHERE object_id = ?};
+	return $class->SUPER::_fill_object($obj, $sql);
 }
 
-sub _new
-{
-    my ($class, $main, $git_id, $reponame, $owner_uid, $owner_gid, $public, $ml_name, $oid, $date_creation, $description, $state) = @_;
+sub getall {
+	my ($vhffs, $state, $name, $group) = @_;
 
-    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_GIT);
-    return undef unless(defined $self);
+	my $git = [];
+	my @params;
 
-    $self->{git_id} = $git_id;
-    $self->{reponame} = $reponame;
-    $self->{public} = $public;
-    $self->{ml_name} = $ml_name;
+	my $sql = 'SELECT g.git_id, g.reponame, o.owner_uid, o.owner_gid, g.public, g.ml_name, o.object_id, o.date_creation, o.description, o.state
+		FROM vhffs_git g INNER JOIN vhffs_object o ON g.object_id = o.object_id WHERE 1=1';
 
-    return $self;
-}
+	if(defined $state) {
+		$sql .= ' AND o.state = ?';
+		push(@params, $state);
+	}
+	if(defined $name) {
+		$sql .= ' AND g.reponame LIKE ?';
+		push(@params, '%'.$name.'%');
+	}
+	if(defined($group)) {
+		$sql .= ' AND o.owner_gid = ?';
+		push(@params, $group->get_gid);
+	}
+	$sql .= ' ORDER BY g.reponame';
 
-sub commit
-{
-    my $self = shift;
+	my $dbh = $vhffs->get_db_object();
 
-    my $dbh = $self->get_db_object;
-    my $sql = 'UPDATE vhffs_git SET public = ?, ml_name = ? WHERE git_id = ?';
-    $dbh->do($sql, undef, $self->{public}, $self->{ml_name}, $self->{git_id});
+	my $sth = $dbh->prepare($sql);
+	$sth->execute(@params) or die($sql) ; #return undef;
 
-    $self->SUPER::commit;
+	while(my $s = $sth->fetchrow_arrayref()) {
+		push(@$git, _new Vhffs::Services::Git($vhffs, @$s));
+	}
+	return $git;
 }
 
-sub supports_notifications {
-    return 1;
-}
+sub get_by_reponame($$) {
+	my ($main, $reponame) = @_;
+	my @params;
 
-sub set_public
-{
-    my $self = shift;
-    $self->{'public'} = 1;
-}
+	my $sql = 'SELECT g.git_id, g.reponame, o.owner_uid, o.owner_gid, g.public, g.ml_name, o.object_id, o.date_creation, o.description, o.state FROM vhffs_git g
+		INNER JOIN vhffs_object o ON o.object_id = g.object_id WHERE g.reponame = ?';
 
-sub set_private
-{
-    my $self = shift;
-    $self->{'public'} = 0;
-}
+	my $dbh = $main->get_db_object();
 
-sub set_ml_name {
-    my ($self, $ml_name) = @_;
-    return -1 unless(Vhffs::Functions::valid_mail($ml_name) || $ml_name =~ /^\s*$/);
-    $self->{ml_name} = $ml_name;
-}
+	return undef unless(@params = $dbh->selectrow_array($sql, undef, $reponame));
 
-sub is_public
-{
-    my $self = shift;
-    
-    return -1 if( ! defined $self->{'public'} );
-
-    if( $self->{'public'} == 1 ) {
-        return 1;
-    } else {
-        return 0;
-    }
+	return _new Vhffs::Services::Git($main, @params);
 }
 
-sub get_ml_name {
-    my $self = shift;
-    return $self->{ml_name};
-}
+sub delete {
+	my $self = shift;
+	my $query;
+	my $request;
 
-sub get_reponame
-{
-    my $self = shift;
-    return $self->{'reponame'};
-}
+	$query = 'DELETE FROM vhffs_git WHERE git_id=?';
+	$request = $self->{'db'}->prepare($query);
+	$request->execute( $self->{git_id} ) or return -1;
 
-sub get_label
-{
-    my $self = shift;
-    return $self->{reponame};
+	return $self->SUPER::delete;
 }
 
-sub getall
-{
-    my ($vhffs, $state, $name, $group) = @_;
+sub commit {
+	my $self = shift;
 
-    my $git = [];
-    my @params;
+	my $dbh = $self->get_db_object;
+	my $sql = 'UPDATE vhffs_git SET public = ?, ml_name = ? WHERE git_id = ?';
+	$dbh->do($sql, undef, $self->{public}, $self->{ml_name}, $self->{git_id});
 
-    my $sql = 'SELECT s.git_id, s.reponame, o.owner_uid, o.owner_gid, s.public, s.ml_name, o.object_id, o.date_creation, o.description, o.state FROM vhffs_git s, vhffs_object o WHERE o.object_id = s.object_id';
-    
+	$self->SUPER::commit;
+}
 
-    if(defined $state) {
-        $sql .= ' AND o.state = ?';
-        push(@params, $state);
-    }
-    if(defined $name) {
-        $sql .= ' AND s.name = ?';
-        push(@params, $name);
-    }
-    if(defined($group)) {
-        $sql .= ' AND o.owner_gid = ?';
-        push(@params, $group->get_gid);
-    }
-    $sql .= ' ORDER BY s.reponame';
+sub set_public {
+	my $self = shift;
+	$self->{'public'} = 1;
+}
 
-    my $dbh = $vhffs->get_db_object();
+sub set_private {
+	my $self = shift;
+	$self->{'public'} = 0;
+}
 
-    my $sth = $dbh->prepare($sql);
-    $sth->execute(@params) or die($sql) ; #return undef;
+sub set_ml_name {
+	my ($self, $ml_name) = @_;
+	return -1 unless(Vhffs::Functions::valid_mail($ml_name) || $ml_name =~ /^\s*$/);
+	$self->{ml_name} = $ml_name;
+}
 
-    while(my $s = $sth->fetchrow_arrayref()) {
-        push(@$git, _new Vhffs::Services::Git($vhffs, @$s));
-    }
-    return $git;
+sub is_public {
+	my $self = shift;
+	return $self->{'public'};
 }
 
-sub getall_by_group
-{
-    my ($vhffs, $group) = @_;
+sub get_label {
+	my $self = shift;
+	return $self->{reponame};
+}
 
-    my $git = [];
-    my @params;
+sub get_reponame {
+	my $self = shift;
+	return $self->{'reponame'};
+}
 
-    return undef unless( defined $group );
+sub get_ml_name {
+	my $self = shift;
+	return $self->{ml_name};
+}
 
-    my $sql = 'SELECT s.git_id, s.reponame, o.owner_uid, o.owner_gid, s.public, o.object_id, o.date_creation, o.description, o.state FROM vhffs_git s INNER
- JOIN vhffs_object o ON o.object_id = s.object_id WHERE o.owner_gid = ? ORDER BY s.reponame';
+sub get_dir {
+	my $self = shift;
+	return $self->get_base_dir.'/'.$self->get_reponame;
+}
 
-    my $dbh = $vhffs->get_db_object();
+=head2 get_base_dir
 
-    my $sth = $dbh->prepare($sql);
-    $sth->execute($group->get_gid) or return undef;
+	my $basedir = $git->get_base_dir();
 
-    while(my $s = $sth->fetchrow_arrayref()) {
-        push(@$git, _new Vhffs::Services::Git($vhffs, @$s));
-    }
-    return $git;
-}
+Returns the directory containing all the repositories.
 
-sub get_dir
-{
-    my $self = shift;
-    return undef if( ! defined $self );
-    
-    return( $self->{'main'}->get_config->get_datadir . "/git/gitroot/" . $self->get_reponame );
+=cut
+sub get_base_dir {
+	my $self = shift;
+	return $self->{'main'}->get_config->get_datadir.'/git/gitroot';
 }
 
 1;

Modified: trunk/vhffs-api/src/Vhffs/Services/MailingList.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/MailingList.pm	2012-02-18 02:27:48 UTC (rev 2017)
+++ trunk/vhffs-api/src/Vhffs/Services/MailingList.pm	2012-02-18 19:54:24 UTC (rev 2018)
@@ -536,17 +536,6 @@
 }
 
 
-
-#Returns all the lists for a group
-# FIXME useless
-sub getall_by_group
-{
-    my $vhffs = shift;
-    my $group = shift;
-
-    return getall($vhffs, undef, undef, $group);
-}
-
 =head2 get_label
 
 See C<Vhffs::Object::get_label>.

Modified: trunk/vhffs-api/src/Vhffs/Services/Mercurial.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Mercurial.pm	2012-02-18 02:27:48 UTC (rev 2017)
+++ trunk/vhffs-api/src/Vhffs/Services/Mercurial.pm	2012-02-18 19:54:24 UTC (rev 2018)
@@ -2,31 +2,31 @@
 # Copyright (c) vhffs project and its contributors
 # All rights reserved.
 #
-# Redistribution and use in source and binary forms, with or without 
-# modification, are permitted provided that the following conditions 
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
 # are met:
 #
-# 1. Redistributions of source code must retain the above copyright 
+# 1. Redistributions of source code must retain the above copyright
 #   notice, this list of conditions and the following disclaimer.
 #2. Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in 
-#   the documentation and/or other materials provided with the 
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
 #   distribution.
-#3. Neither the name of vhffs nor the names of its contributors 
-#   may be used to endorse or promote products derived from this 
+#3. Neither the name of vhffs nor the names of its contributors
+#   may be used to endorse or promote products derived from this
 #   software without specific prior written permission.
 #
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
 # This file is a part of VHFFS4 Hosting Platform
@@ -42,70 +42,60 @@
 use DBI;
 
 sub check_name($) {
-    my $name = shift;
-    return ($name =~ /^[a-z0-9]+\/[a-z0-9\-_]{3,64}$/);
+	my $name = shift;
+	return ($name =~ /^[a-z0-9]+\/[a-z0-9\-_]{3,64}$/);
 }
 
-sub delete
-{
-    my $self = shift;
-    my $query;
-    my $request;
-
-    $query = "DELETE FROM vhffs_mercurial WHERE object_id='".$self->{'object_id'}."'";
-    $request = $self->{'db'}->prepare($query);
-    $request->execute or return -1;
-
-    return -1 if( $self->SUPER::delete < 0 );
+sub supports_notifications {
+	return 1;
 }
 
-sub create
-{
-   my ($main, $rname, $description, $user, $group) = @_;
+sub _new {
+	my ($class, $main, $mercurial_id, $reponame, $owner_uid, $owner_gid, $public, $ml_name, $oid, $date_creation, $description, $state) = @_;
 
-    return undef unless(defined($user) && defined($group));
-    return undef unless(check_name($rname));
+	my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_MERCURIAL);
+	return undef unless(defined $self);
 
-    my $mercurial;
+	$self->{mercurial_id} = $mercurial_id;
+	$self->{reponame} = $reponame;
+	$self->{public} = $public;
+	$self->{ml_name} = $ml_name;
 
-    my $dbh = $main->get_db_object();
-    local $dbh->{RaiseError} = 1;
-    local $dbh->{PrintError} = 0;
-    $dbh->begin_work;
+	return $self;
+}
 
-    eval {
-        my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_MERCURIAL);
+sub create {
+	my ($main, $rname, $description, $user, $group) = @_;
 
-        die('Unable to create parent object') unless(defined $parent);
+	return undef unless(defined($user) && defined($group));
+	return undef unless(check_name($rname));
 
-        my $sql = 'INSERT INTO vhffs_mercurial(reponame, public, ml_name, object_id) VALUES(?, 1, \'\', ?)';
-        my $sth = $dbh->prepare($sql);
-        $sth->execute($rname, $parent->get_oid) or return undef;
+	my $mercurial;
 
-        $dbh->commit;
-        $mercurial = get_by_reponame($main, $rname);
-    };
+	my $dbh = $main->get_db_object();
+	local $dbh->{RaiseError} = 1;
+	local $dbh->{PrintError} = 0;
+	$dbh->begin_work;
 
-    if($@) {
-        warn "Unable to create mercurial repository $rname: $@\n";
-        $dbh->rollback;
-    }
+	eval {
+		my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_MERCURIAL);
 
-    return $mercurial;
-}
+		die('Unable to create parent object') unless(defined $parent);
 
-sub get_by_reponame($$) {
-    my ($main, $reponame) = @_;
-    my @params;
+		my $sql = 'INSERT INTO vhffs_mercurial(reponame, public, ml_name, object_id) VALUES(?, 1, \'\', ?)';
+		my $sth = $dbh->prepare($sql);
+		$sth->execute($rname, $parent->get_oid) or return undef;
 
-    my $sql = 'SELECT s.mercurial_id, s.reponame, o.owner_uid, o.owner_gid, s.public, s.ml_name, o.object_id, o.date_creation, o.description, o.state FROM vhffs_mercurial s INNER JOIN vhffs_object o ON o.object_id = s.object_id WHERE s.reponame = ?';
+		$dbh->commit;
+		$mercurial = get_by_reponame($main, $rname);
+	};
 
-    my $dbh = $main->get_db_object();
+	if($@) {
+		warn "Unable to create mercurial repository $rname: $@\n";
+		$dbh->rollback;
+	}
 
-    return undef unless(@params = $dbh->selectrow_array($sql, undef, $reponame));
-
-    return _new Vhffs::Services::Mercurial($main, @params);
-
+	return $mercurial;
 }
 
 =head2 fill_object
@@ -113,156 +103,134 @@
 See C<Vhffs::Object::fill_object>.
 
 =cut
-
 sub fill_object {
-    my ($class, $obj) = @_;
-    my $sql = q{SELECT mercurial_id, reponame, public, ml_name FROM vhffs_mercurial
-        WHERE object_id = ?};
-    return $class->SUPER::_fill_object($obj, $sql);
+	my ($class, $obj) = @_;
+	my $sql = q{SELECT mercurial_id, reponame, public, ml_name FROM vhffs_mercurial
+		WHERE object_id = ?};
+	return $class->SUPER::_fill_object($obj, $sql);
 }
 
-sub _new
-{
-    my ($class, $main, $mercurial_id, $reponame, $owner_uid, $owner_gid, $public, $ml_name, $oid, $date_creation, $description, $state) = @_;
+sub getall {
+	my ($vhffs, $state, $name, $group) = @_;
 
-    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_MERCURIAL);
-    return undef unless(defined $self);
+	my $mercurial = [];
+	my @params;
 
-    $self->{mercurial_id} = $mercurial_id;
-    $self->{reponame} = $reponame;
-    $self->{public} = $public;
-    $self->{ml_name} = $ml_name;
+	my $sql = 'SELECT m.mercurial_id, m.reponame, o.owner_uid, o.owner_gid, m.public, m.ml_name, o.object_id, o.date_creation, o.description, o.state
+		FROM vhffs_mercurial m INNER JOIN vhffs_object o ON m.object_id = o.object_id WHERE 1=1';
 
-    return $self;
-}
+	if(defined $state) {
+		$sql .= ' AND o.state = ?';
+		push(@params, $state);
+	}
+	if(defined $name) {
+		$sql .= ' AND m.reponame LIKE ?';
+		push(@params, '%'.$name.'%');
+	}
+	if(defined($group)) {
+		$sql .= ' AND o.owner_gid = ?';
+		push(@params, $group->get_gid);
+	}
+	$sql .= ' ORDER BY m.reponame';
 
-sub commit
-{
-    my $self = shift;
+	my $dbh = $vhffs->get_db_object();
 
-    my $dbh = $self->get_db_object;
-    my $sql = 'UPDATE vhffs_mercurial SET public = ?, ml_name = ? WHERE mercurial_id = ?';
-    $dbh->do($sql, undef, $self->{public}, $self->{ml_name}, $self->{mercurial_id});
+	my $sth = $dbh->prepare($sql);
+	$sth->execute(@params) or die($sql) ; #return undef;
 
-    $self->SUPER::commit;
+	while(my $s = $sth->fetchrow_arrayref()) {
+		push(@$mercurial, _new Vhffs::Services::Mercurial($vhffs, @$s));
+	}
+	return $mercurial;
 }
 
-sub supports_notifications {
-    return 1;
-}
+sub get_by_reponame($$) {
+	my ($main, $reponame) = @_;
+	my @params;
 
-sub set_public
-{
-    my $self = shift;
-    $self->{'public'} = 1;
-}
+	my $sql = 'SELECT m.mercurial_id, m.reponame, o.owner_uid, o.owner_gid, m.public, m.ml_name, o.object_id, o.date_creation, o.description, o.state FROM vhffs_mercurial m
+		INNER JOIN vhffs_object o ON o.object_id = m.object_id WHERE m.reponame = ?';
 
-sub set_private
-{
-    my $self = shift;
-    $self->{'public'} = 0;
-}
+	my $dbh = $main->get_db_object();
 
-sub set_ml_name {
-    my ($self, $ml_name) = @_;
-    return -1 unless(Vhffs::Functions::valid_mail($ml_name) || $ml_name =~ /^\s*$/);
-    $self->{ml_name} = $ml_name;
-}
+	return undef unless(@params = $dbh->selectrow_array($sql, undef, $reponame));
 
-sub is_public
-{
-    my $self = shift;
-    
-    return -1 if( ! defined $self->{'public'} );
-
-    if( $self->{'public'} == 1 ) {
-        return 1;
-    } else {
-        return 0;
-    }
+	return _new Vhffs::Services::Mercurial($main, @params);
 }
 
-sub get_ml_name {
-    my $self = shift;
-    return $self->{ml_name};
-}
+sub delete {
+	my $self = shift;
+	my $query;
+	my $request;
 
-sub get_reponame
-{
-    my $self = shift;
-    return $self->{'reponame'};
-}
+	$query = 'DELETE FROM vhffs_mercurial WHERE mercurial_id=?';
+	$request = $self->{'db'}->prepare($query);
+	$request->execute( $self->{mercurial_id} ) or return -1;
 
-sub get_label
-{
-    my $self = shift;
-    return $self->{reponame};
+	return $self->SUPER::delete;
 }
 
-sub getall
-{
-    my ($vhffs, $state, $name, $group) = @_;
+sub commit {
+	my $self = shift;
 
-    my $mercurial = [];
-    my @params;
+	my $dbh = $self->get_db_object;
+	my $sql = 'UPDATE vhffs_mercurial SET public = ?, ml_name = ? WHERE mercurial_id = ?';
+	$dbh->do($sql, undef, $self->{public}, $self->{ml_name}, $self->{mercurial_id});
 
-    my $sql = 'SELECT s.mercurial_id, s.reponame, o.owner_uid, o.owner_gid, s.public, s.ml_name, o.object_id, o.date_creation, o.description, o.state FROM vhffs_mercurial s, vhffs_object o WHERE o.object_id = s.object_id';
-    
+	$self->SUPER::commit;
+}
 
-    if(defined $state) {
-        $sql .= ' AND o.state = ?';
-        push(@params, $state);
-    }
-    if(defined $name) {
-        $sql .= ' AND s.name = ?';
-        push(@params, $name);
-    }
-    if(defined($group)) {
-        $sql .= ' AND o.owner_gid = ?';
-        push(@params, $group->get_gid);
-    }
-    $sql .= ' ORDER BY s.reponame';
+sub set_public {
+	my $self = shift;
+	$self->{'public'} = 1;
+}
 
-    my $dbh = $vhffs->get_db_object();
+sub set_private {
+	my $self = shift;
+	$self->{'public'} = 0;
+}
 
-    my $sth = $dbh->prepare($sql);
-    $sth->execute(@params) or die($sql) ; #return undef;
+sub set_ml_name {
+	my ($self, $ml_name) = @_;
+	return -1 unless(Vhffs::Functions::valid_mail($ml_name) || $ml_name =~ /^\s*$/);
+	$self->{ml_name} = $ml_name;
+}
 
-    while(my $s = $sth->fetchrow_arrayref()) {
-        push(@$mercurial, _new Vhffs::Services::Mercurial($vhffs, @$s));
-    }
-    return $mercurial;
+sub is_public {
+	my $self = shift;
+	return $self->{'public'};
 }
 
-sub getall_by_group
-{
-    my ($vhffs, $group) = @_;
+sub get_label {
+	my $self = shift;
+	return $self->{reponame};
+}
 
-    my $mercurial = [];
-    my @params;
+sub get_reponame {
+	my $self = shift;
+	return $self->{'reponame'};
+}
 
-    return undef unless( defined $group );
+sub get_ml_name {
+	my $self = shift;
+	return $self->{ml_name};
+}
 
-    my $sql = 'SELECT s.mercurial_id, s.reponame, o.owner_uid, o.owner_gid, s.public, o.object_id, o.date_creation, o.description, o.state FROM vhffs_mercurial s INNER
- JOIN vhffs_object o ON o.object_id = s.object_id WHERE o.owner_gid = ? ORDER BY s.reponame';
+sub get_dir {
+	my $self = shift;
+	return $self->get_base_dir.'/'.$self->get_reponame;
+}
 
-    my $dbh = $vhffs->get_db_object();
+=head2 get_base_dir
 
-    my $sth = $dbh->prepare($sql);
-    $sth->execute($group->get_gid) or return undef;
+	my $basedir = $mercurial->get_base_dir();
 
-    while(my $s = $sth->fetchrow_arrayref()) {
-        push(@$mercurial, _new Vhffs::Services::Mercurial($vhffs, @$s));
-    }
-    return $mercurial;
-}
+Returns the directory containing all the repositories.
 
-sub get_dir
-{
-    my $self = shift;
-    return undef if( ! defined $self );
-    
-    return( $self->{'main'}->get_config->get_datadir . "/mercurial/mercurialroot/" . $self->get_reponame );
+=cut
+sub get_base_dir {
+	my $self = shift;
+	return $self->{'main'}->get_config->get_datadir.'/mercurial/mercurialroot';
 }
 
 1;

Modified: trunk/vhffs-api/src/Vhffs/Services/Repository.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Repository.pm	2012-02-18 02:27:48 UTC (rev 2017)
+++ trunk/vhffs-api/src/Vhffs/Services/Repository.pm	2012-02-18 19:54:24 UTC (rev 2018)
@@ -275,28 +275,6 @@
 }
 
 
-sub getall_per_group
-{
-	my ($main, $group) = @_;
-	my @result;
-	my $repos = [];
-	return undef if ( ! defined $group );
-
-    my $sql = 'SELECT r.repository_id, r.name, o.owner_uid, o.owner_gid, r.quota, r.quota_used, o.object_id, o.date_creation, o.description, o.state FROM vhffs_repository r INNER JOIN vhffs_object o ON o.object_id = r.object_id WHERE o.owner_gid = ?';
-
-    my $dbh = $main->get_db_object();
-    my $sth = $dbh->prepare($sql);
-    $sth->execute($group->get_gid) or return undef;
-
-    while(my $r = $sth->fetchrow_arrayref()) {
-        push(@$repos, _new Vhffs::Services::Repository($main, @$r));
-    }
-    return $repos;
-}
-
-
-
-
 1;
 
 __END__

Modified: trunk/vhffs-api/src/Vhffs/Services/Svn.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Svn.pm	2012-02-18 02:27:48 UTC (rev 2017)
+++ trunk/vhffs-api/src/Vhffs/Services/Svn.pm	2012-02-18 19:54:24 UTC (rev 2018)
@@ -2,31 +2,31 @@
 # Copyright (c) vhffs project and its contributors
 # All rights reserved.
 #
-# Redistribution and use in source and binary forms, with or without 
-# modification, are permitted provided that the following conditions 
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
 # are met:
 #
-# 1. Redistributions of source code must retain the above copyright 
+# 1. Redistributions of source code must retain the above copyright
 #   notice, this list of conditions and the following disclaimer.
 #2. Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in 
-#   the documentation and/or other materials provided with the 
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
 #   distribution.
-#3. Neither the name of vhffs nor the names of its contributors 
-#   may be used to endorse or promote products derived from this 
+#3. Neither the name of vhffs nor the names of its contributors
+#   may be used to endorse or promote products derived from this
 #   software without specific prior written permission.
 #
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
 use strict;
@@ -44,70 +44,60 @@
 use DBI;
 
 sub check_name($) {
-    my $name = shift;
-    return ($name =~ /^[a-z0-9]+\/[a-z0-9\-_]{3,64}$/);
+	my $name = shift;
+	return ($name =~ /^[a-z0-9]+\/[a-z0-9\-_]{3,64}$/);
 }
 
-sub delete
-{
-    my $self = shift;
-    my $query;
-    my $request;
-
-    $query = "DELETE FROM vhffs_svn WHERE object_id='".$self->{'object_id'}."'";
-    $request = $self->{'db'}->prepare($query);
-    $request->execute or return -1;
-
-    return -1 if( $self->SUPER::delete < 0 );
+sub supports_notifications {
+	return 1;
 }
 
-sub create
-{
-   my ($main, $rname, $description, $user, $group) = @_;
+sub _new {
+	my ($class, $main, $svn_id, $reponame, $owner_uid, $owner_gid, $public, $ml_name, $oid, $date_creation, $description, $state) = @_;
 
-    return undef unless(defined($user) && defined($group));
-    return undef unless(check_name($rname));
+	my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_SVN);
+	return undef unless(defined $self);
 
-    my $svn;
+	$self->{svn_id} = $svn_id;
+	$self->{reponame} = $reponame;
+	$self->{public} = $public;
+	$self->{ml_name} = $ml_name;
 
-    my $dbh = $main->get_db_object();
-    local $dbh->{RaiseError} = 1;
-    local $dbh->{PrintError} = 0;
-    $dbh->begin_work;
+	return $self;
+}
 
-    eval {
-        my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_SVN);
+sub create {
+	my ($main, $rname, $description, $user, $group) = @_;
 
-        die('Unable to create parent object') unless(defined $parent);
+	return undef unless(defined($user) && defined($group));
+	return undef unless(check_name($rname));
 
-        my $sql = 'INSERT INTO vhffs_svn(reponame, public, ml_name, object_id) VALUES(?, 1, \'\', ?)';
-        my $sth = $dbh->prepare($sql);
-        $sth->execute($rname, $parent->get_oid) or return undef;
+	my $svn;
 
-        $dbh->commit;
-        $svn = get_by_reponame($main, $rname);
-    };
+	my $dbh = $main->get_db_object();
+	local $dbh->{RaiseError} = 1;
+	local $dbh->{PrintError} = 0;
+	$dbh->begin_work;
 
-    if($@) {
-        warn "Unable to create svn repository $rname: $@\n";
-        $dbh->rollback;
-    }
+	eval {
+		my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_SVN);
 
-    return $svn;
-}
+		die('Unable to create parent object') unless(defined $parent);
 
-sub get_by_reponame($$) {
-    my ($main, $reponame) = @_;
-    my @params;
+		my $sql = 'INSERT INTO vhffs_svn(reponame, public, ml_name, object_id) VALUES(?, 1, \'\', ?)';
+		my $sth = $dbh->prepare($sql);
+		$sth->execute($rname, $parent->get_oid) or return undef;
 
-    my $sql = 'SELECT s.svn_id, s.reponame, o.owner_uid, o.owner_gid, s.public, s.ml_name, o.object_id, o.date_creation, o.description, o.state FROM vhffs_svn s INNER JOIN vhffs_object o ON o.object_id = s.object_id WHERE s.reponame = ?';
+		$dbh->commit;
+		$svn = get_by_reponame($main, $rname);
+	};
 
-    my $dbh = $main->get_db_object();
+	if($@) {
+		warn "Unable to create svn repository $rname: $@\n";
+		$dbh->rollback;
+	}
 
-    return undef unless(@params = $dbh->selectrow_array($sql, undef, $reponame));
-
-    return _new Vhffs::Services::Svn($main, @params);
-
+	return $svn;
 }
 
 =head2 fill_object
@@ -115,148 +105,117 @@
 See C<Vhffs::Object::fill_object>.
 
 =cut
-
 sub fill_object {
-    my ($class, $obj) = @_;
-    my $sql = q{SELECT svn_id, reponame, public, ml_name FROM vhffs_svn
-        WHERE object_id = ?};
-    return $class->SUPER::_fill_object($obj, $sql);
+	my ($class, $obj) = @_;
+	my $sql = q{SELECT svn_id, reponame, public, ml_name FROM vhffs_svn
+		WHERE object_id = ?};
+	return $class->SUPER::_fill_object($obj, $sql);
 }
 
-sub _new
-{
-    my ($class, $main, $svn_id, $reponame, $owner_uid, $owner_gid, $public, $ml_name, $oid, $date_creation, $description, $state) = @_;
+sub getall {
+	my ($vhffs, $state, $name, $group) = @_;
 
-    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_SVN);
-    return undef unless(defined $self);
+	my $svn = [];
+	my @params;
 
-    $self->{svn_id} = $svn_id;
-    $self->{reponame} = $reponame;
-    $self->{public} = $public;
-    $self->{ml_name} = $ml_name;
+	my $sql = 'SELECT s.svn_id, s.reponame, o.owner_uid, o.owner_gid, s.public, s.ml_name, o.object_id, o.date_creation, o.description, o.state
+		FROM vhffs_svn s INNER JOIN vhffs_object o ON s.object_id = o.object_id WHERE 1=1';
 
-    return $self;
-}
+	if(defined $state) {
+		$sql .= ' AND o.state = ?';
+		push(@params, $state);
+	}
+	if(defined $name) {
+		$sql .= ' AND s.reponame LIKE ?';
+		push(@params, '%'.$name.'%');
+	}
+	if(defined($group)) {
+		$sql .= ' AND o.owner_gid = ?';
+		push(@params, $group->get_gid);
+	}
+	$sql .= ' ORDER BY s.reponame';
 
-sub commit
-{
-    my $self = shift;    
+	my $dbh = $vhffs->get_db_object();
 
-    my $dbh = $self->get_db_object;
-    my $sql = 'UPDATE vhffs_svn SET public = ?, ml_name = ? WHERE svn_id = ?';
-    $dbh->do($sql, undef, $self->{public}, $self->{ml_name}, $self->{svn_id});
+	my $sth = $dbh->prepare($sql);
+	$sth->execute(@params) or return undef;
 
-    $self->SUPER::commit;
+	while(my $s = $sth->fetchrow_arrayref()) {
+		push(@$svn, _new Vhffs::Services::Svn($vhffs, @$s));
+	}
+	return $svn;
 }
 
-sub supports_notifications {
-    return 1;
-}
+sub get_by_reponame($$) {
+	my ($main, $reponame) = @_;
+	my @params;
 
-sub set_public
-{
-    my $self = shift;
-    $self->{'public'} = 1;
-}
+	my $sql = 'SELECT s.svn_id, s.reponame, o.owner_uid, o.owner_gid, s.public, s.ml_name, o.object_id, o.date_creation, o.description, o.state FROM vhffs_svn s
+		INNER JOIN vhffs_object o ON o.object_id = s.object_id WHERE s.reponame = ?';
 
-sub set_private
-{
-    my $self = shift;
-    $self->{'public'} = 0;
+	my $dbh = $main->get_db_object();
+
+	return undef unless(@params = $dbh->selectrow_array($sql, undef, $reponame));
+
+	return _new Vhffs::Services::Svn($main, @params);
 }
 
-sub is_public
-{
-    my $self = shift;
-    
-    return -1 if( ! defined $self->{'public'} );
+sub delete {
+	my $self = shift;
+	my $query;
+	my $request;
 
-    if( $self->{'public'} == 1 ) {
-        return 1;
-    } else {
-        return 0;
-    }
+	$query = 'DELETE FROM vhffs_svn WHERE svn_id=?';
+	$request = $self->{'db'}->prepare($query);
+	$request->execute( $self->{svn_id} ) or return -1;
+
+	return $self->SUPER::delete;
 }
 
-sub get_reponame
-{
-    my $self = shift;
-    return $self->{'reponame'};
+sub commit {
+	my $self = shift;
+
+	my $dbh = $self->get_db_object;
+	my $sql = 'UPDATE vhffs_svn SET public = ?, ml_name = ? WHERE svn_id = ?';
+	$dbh->do($sql, undef, $self->{public}, $self->{ml_name}, $self->{svn_id});
+
+	$self->SUPER::commit;
 }
 
-sub get_label
-{
-    my $self = shift;
-    return $self->{reponame};
+sub set_public {
+	my $self = shift;
+	$self->{'public'} = 1;
 }
 
-sub get_ml_name {
-    my $self = shift;
-    return $self->{ml_name};
+sub set_private {
+	my $self = shift;
+	$self->{'public'} = 0;
 }
 
 sub set_ml_name {
-    my ($self, $ml_name) = @_;
-    $self->{ml_name} = $ml_name;
+	my ($self, $ml_name) = @_;
+	return -1 unless(Vhffs::Functions::valid_mail($ml_name) || $ml_name =~ /^\s*$/);
+	$self->{ml_name} = $ml_name;
 }
 
-sub getall
-{
-    my ($vhffs, $state, $name, $group) = @_;
+sub is_public {
+	my $self = shift;
+	return $self->{'public'};
+}
 
-    my $svn = [];
-    my @params;
+sub get_label {
+	my $self = shift;
+	return $self->{reponame};
+}
 
-    my $sql = 'SELECT s.svn_id, s.reponame, o.owner_uid, o.owner_gid, s.public, s.ml_name, o.object_id, o.date_creation, o.description, o.state FROM vhffs_svn s, vhffs_object o WHERE o.object_id = s.object_id';
-    
-
-    if(defined $state) {
-        $sql .= ' AND o.state = ?';
-        push(@params, $state);
-    }
-    if(defined $name) {
-        $sql .= ' AND s.name = ?';
-        push(@params, $name);
-    }
-    if(defined($group)) {
-        $sql .= ' AND o.owner_gid = ?';
-        push(@params, $group->get_gid);
-    }
-    $sql .= ' ORDER BY s.reponame';
-
-    my $dbh = $vhffs->get_db_object();
-
-    my $sth = $dbh->prepare($sql);
-    $sth->execute(@params) or return undef;
-
-    while(my $s = $sth->fetchrow_arrayref()) {
-        push(@$svn, _new Vhffs::Services::Svn($vhffs, @$s));
-    }
-    return $svn;
+sub get_reponame {
+	my $self = shift;
+	return $self->{'reponame'};
 }
 
-
-sub getall_by_group
-{
-    my ($vhffs, $group) = @_;
-
-    my $svn = [];
-    my @params;
-
-    return undef unless( defined $group );
-
-    my $sql = 'SELECT s.svn_id, s.reponame, o.owner_uid, o.owner_gid, s.public, o.object_id, o.date_creation, o.description, o.state FROM vhffs_svn s INNER
- JOIN vhffs_object o ON o.object_id = s.object_id WHERE o.owner_gid = ? ORDER BY s.reponame';
-
-    my $dbh = $vhffs->get_db_object();
-
-    my $sth = $dbh->prepare($sql);
-    $sth->execute($group->get_gid) or return undef;
-
-    while(my $s = $sth->fetchrow_arrayref()) {
-        push(@$svn, _new Vhffs::Services::Svn($vhffs, @$s));
-    }
-    return $svn;
+sub get_ml_name {
+	my $self = shift;
+	return $self->{ml_name};
 }
 
 =head2 get_dir
@@ -267,13 +226,9 @@
 (C<datadir>/svn/svnroot/groupname/repository).
 
 =cut
-
-sub get_dir
-{
-    my $self = shift;
-    return undef if( ! defined $self );
-    
-    return( $self->{'main'}->get_config->get_datadir . "/svn/svnroot/" . $self->get_reponame );
+sub get_dir {
+	my $self = shift;
+	return $self->get_base_dir.'/'.$self->get_reponame;
 }
 
 =head2 get_base_dir
@@ -283,13 +238,9 @@
 Returns the directory containing all the repositories.
 
 =cut
-
-sub get_base_dir
-{
-	return undef unless( defined $_[0] );
-	return $_[0]->{main}->get_config->get_datadir.'/svn/svnroot/';
+sub get_base_dir {
+	my $self = shift;
+	return $self->{main}->get_config->get_datadir.'/svn/svnroot';
 }
 
-
-
 1;

Modified: trunk/vhffs-api/src/Vhffs/Services/Web.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Web.pm	2012-02-18 02:27:48 UTC (rev 2017)
+++ trunk/vhffs-api/src/Vhffs/Services/Web.pm	2012-02-18 19:54:24 UTC (rev 2018)
@@ -244,34 +244,6 @@
 }
 
 
-sub getall_by_group
-{
-    my ($vhffs, $group) = @_;
-
-    my $sql;
-    my $sth;
-
-    my $objs = [];
-    my $result;
-    my $tmp;
-
-    
-    $sql = 'SELECT h.httpd_id, h.servername, o.owner_uid, o.owner_gid, h.object_id, o.date_creation, o.description, o.state FROM vhffs_httpd h INNER JOIN vhffs_object o ON o.object_id = h.object_id AND o.owner_gid = ? ORDER BY servername';
-
-
-    $sth = $vhffs->get_db_object()->prepare( $sql );
-
-    my $rows = $sth->execute($group->get_gid());
-
-    return undef unless($rows);
-
-    while( $result = $sth->fetchrow_arrayref )
-    {
-        push @{$objs}, _new Vhffs::Services::Web($vhffs, @{$result});
-    }
-    return $objs;
-}
-
 =head2 fill_object
 
 See C<Vhffs::Object::fill_object>.

Modified: trunk/vhffs-api/src/examples/show_dumper_cvs.pl
===================================================================
--- trunk/vhffs-api/src/examples/show_dumper_cvs.pl	2012-02-18 02:27:48 UTC (rev 2017)
+++ trunk/vhffs-api/src/examples/show_dumper_cvs.pl	2012-02-18 19:54:24 UTC (rev 2018)
@@ -26,7 +26,7 @@
 
 $config = $princ->get_config;
 
-my $cvs = Vhffs::Services::Cvs::get_by_cvsroot( $princ , $ARGV[0] ) ;
+my $cvs = Vhffs::Services::Cvs::get_by_reponame( $princ , $ARGV[0] ) ;
 
 print Dumper $cvs;
 

Modified: trunk/vhffs-robots/src/cvs_create.pl
===================================================================
--- trunk/vhffs-robots/src/cvs_create.pl	2012-02-18 02:27:48 UTC (rev 2017)
+++ trunk/vhffs-robots/src/cvs_create.pl	2012-02-18 19:54:24 UTC (rev 2018)
@@ -48,11 +48,11 @@
 {
 	if( Vhffs::Robots::Cvs::create_cvs( $c ) != 0 )
 	{
-		Vhffs::Robots::vhffs_log( sprintf( 'CVS: repository %s is created' , $c->get_cvsroot ) , $vhffs);
+		Vhffs::Robots::vhffs_log( sprintf( 'CVS: repository %s is created' , $c->get_reponame ) , $vhffs);
 	}
 	else
 	{
-		Vhffs::Robots::vhffs_log( sprintf( 'CVS: cannot create %s CVS repository' , $c->get_cvsroot ) , $vhffs);
+		Vhffs::Robots::vhffs_log( sprintf( 'CVS: cannot create %s CVS repository' , $c->get_reponame ) , $vhffs);
 	}
 }
 

Modified: trunk/vhffs-robots/src/cvs_delete.pl
===================================================================
--- trunk/vhffs-robots/src/cvs_delete.pl	2012-02-18 02:27:48 UTC (rev 2017)
+++ trunk/vhffs-robots/src/cvs_delete.pl	2012-02-18 19:54:24 UTC (rev 2018)
@@ -48,15 +48,15 @@
 foreach my $cvs ( @{$repos} )
 {
 	if( Vhffs::Robots::Cvs::delete_cvs( $cvs ) != 0 ) {
-		Vhffs::Robots::vhffs_log( sprintf( 'Cannot delete files from %s', $cvs->get_cvsroot ), $vhffs);
+		Vhffs::Robots::vhffs_log( sprintf( 'Cannot delete files from %s', $cvs->get_reponame ), $vhffs);
 	} else {
-		Vhffs::Robots::vhffs_log( sprintf( 'Delete files from %s', $cvs->get_cvsroot ), $vhffs);
+		Vhffs::Robots::vhffs_log( sprintf( 'Delete files from %s', $cvs->get_reponame ), $vhffs);
 	}
 
 	if( $cvs->delete < 0 ) {
-		Vhffs::Robots::vhffs_log( sprintf( 'Cannot delete CVS object %s', $cvs->get_cvsroot ), $vhffs);
+		Vhffs::Robots::vhffs_log( sprintf( 'Cannot delete CVS object %s', $cvs->get_reponame ), $vhffs);
 	} else {
-		Vhffs::Robots::vhffs_log( sprintf( 'Delete CVS object %s', $cvs->get_cvsroot ), $vhffs);
+		Vhffs::Robots::vhffs_log( sprintf( 'Delete CVS object %s', $cvs->get_reponame ), $vhffs);
 	}
 }
 

Modified: trunk/vhffs-robots/src/cvs_public.pl
===================================================================
--- trunk/vhffs-robots/src/cvs_public.pl	2012-02-18 02:27:48 UTC (rev 2017)
+++ trunk/vhffs-robots/src/cvs_public.pl	2012-02-18 19:54:24 UTC (rev 2018)
@@ -59,12 +59,12 @@
 
 	if( $cvs->is_public == 1 )
 	{
-		Vhffs::Robots::vhffs_log( sprintf( 'CVS fixperm (public) for %s', $cvs->get_cvsroot ), $vhffs);
+		Vhffs::Robots::vhffs_log( sprintf( 'CVS fixperm (public) for %s', $cvs->get_reponame ), $vhffs);
 		$cvs->add_history('CVS is now public');
 		chmod 02775 , $cvs->get_dir;
 
 		# fix readers file
-		Vhffs::Robots::vhffs_log( sprintf('CVS, put repository %s public' , $cvs->get_cvsroot), $vhffs);
+		Vhffs::Robots::vhffs_log( sprintf('CVS, put repository %s public' , $cvs->get_reponame), $vhffs);
 		open( FILE , '>'.$readers_file ) or die( 'cannot open '.$readers_file );
 		print FILE 'anonymous'."\n";
 		close( FILE );
@@ -78,7 +78,7 @@
 	}
 	else
 	{
-		Vhffs::Robots::vhffs_log( sprintf( 'CVS fixperm (private) for %s', $cvs->get_cvsroot ), $vhffs);
+		Vhffs::Robots::vhffs_log( sprintf( 'CVS fixperm (private) for %s', $cvs->get_reponame ), $vhffs);
 		$cvs->add_history('CVS is now private');
 		chmod 02770 , $cvs->get_dir;
 

Modified: trunk/vhffs-robots/src/cvs_viewvcconf.pl
===================================================================
--- trunk/vhffs-robots/src/cvs_viewvcconf.pl	2012-02-18 02:27:48 UTC (rev 2017)
+++ trunk/vhffs-robots/src/cvs_viewvcconf.pl	2012-02-18 19:54:24 UTC (rev 2018)
@@ -55,7 +55,7 @@
 	{
 		if( $cvs->is_public == 1 )
 		{
-			my $cvspath = $cvs->get_cvsroot;
+			my $cvspath = $cvs->get_reponame;
 			$cvspath =~ s/\//_/;
 			push @$cvsroots, $cvspath.': '.$cvs->get_dir;
 		}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/