package LATMOS::Accounts::SynchAccess; use strict; use warnings; use base qw(LATMOS::Accounts::SynchAccess::base); use LATMOS::Accounts::SynchAccess::Objects; use LATMOS::Accounts::Log; our $VERSION = (q$Rev$ =~ /^Rev: (\d+) /)[0]; =head1 NAME LATMOS::Accounts::SynchAccess =head1 FUNCTIONS =cut =head2 get_object ($otype, $uid) Compatibility function: return a set of objects for which action must be done. =cut sub get_object { my ($self, $otype, $uid) = @_; my @subobj; foreach ($self->bases) { if ($_->is_supported_object($otype)) { my $u = $_->get_object($otype, $uid) or do { $_->log(LA_ERR, "Cannot get object $otype/$uid", ); return; }; push(@subobj, $u); } } return LATMOS::Accounts::SynchAccess::Objects->new( [ @subobj ] ); } =head2 get_object_ifexists ($otype, $uid) Compatibility function: return a set of objects for which action must be done. Instead get_object, if the named object does not exists in a database no error is returned =cut sub get_object_ifexists { my ($self, $otype, $uid) = @_; my @subobj; foreach ($self->bases) { $_->log(LA_DEBUG, "trying to get object $otype/$uid", ); if ($_->is_supported_object($otype)) { my $u = $_->get_object($otype, $uid) or do { $_->log(LA_WARN, "Cannot get object $otype/$uid", ); next }; push(@subobj, $u); } } if (!@subobj) { la_log(LA_ERR, "No object $otype/$uid found in any bases"); return; } return LATMOS::Accounts::SynchAccess::Objects->new( [ @subobj ] ); } 1; __END__ =head1 AUTHOR Olivier Thauvin, Eolivier.thauvin@aerov.jussieu.frE =head1 COPYRIGHT AND LICENSE Copyright (C) 2008, 2009, 2010, 2011, 2012 CNRS SA/CETP/LATMOS This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available. =cut