- Timestamp:
- 06/25/20 09:25:24 (4 years ago)
- Location:
- trunk/LATMOS-Accounts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/bin/la-rename
r891 r2416 59 59 $labase->wexported(1); 60 60 61 my $obj = $labase->get_object($otype, $ARGV[0]) or do { 62 die "Object $otype $ARGV[0] not found\n"; 63 }; 61 if ($labase->can('SetCB')) { 62 $labase->SetCB( sub { 63 my ( $base, $res ) = @_; 64 if ($res) { 65 print $base->label . ': Object renamed' . "\n"; 66 $base->commit; 67 } else { 68 warn $base->label . ': Cannot rename object' . "\n"; 69 $base->rollback; 70 } 71 } ); 72 } 64 73 65 74 if (!$labase->rename_object($otype, @ARGV)) { 66 die " Error while renaming $otype $ARGV[0] to $ARGV[1]\n";75 die "Some errors occurs, please check\n"; 67 76 } 68 77 69 $labase->commit; -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/SynchAccess/base.pm
r2283 r2416 85 85 } 86 86 87 =head2 CB ( @Args ) 88 89 Run callback if set 90 91 =cut 92 93 sub CB { 94 my ( $self, @Args ) = @_; 95 96 if ($self->{cb}) { 97 return $self->{cb}->( @Args ); 98 } else { 99 return 1; 100 } 101 } 102 87 103 sub _return_all { 88 104 my ($self, $sub, @args) = @_; … … 90 106 foreach my $ba ($self->bases) { 91 107 my @res = $_->$sub(@args); 92 $self-> {cb}->($ba, @res) if($self->{cb});108 $self->CB($ba, @res); 93 109 push(@allres, @res); 94 110 } … … 114 130 foreach ($self->bases) { 115 131 my $res = $_->$sub(@args); 116 $self-> {cb}->($_, $res) if($self->{cb});132 $self->CB($_, $res); 117 133 $res or do { 118 134 la_log(LA_ERR, "SyncA: Erreur call $sub() for %s", $_); … … 128 144 foreach ($self->bases) { 129 145 my $res = $_->$sub(@args) and $failure = 1; 130 $self-> {cb}->($_, $res) if($self->{cb});146 $self->CB($_, $res); 131 147 } 132 148 $failure ? 0 : 1; … … 141 157 foreach ($self->bases) { 142 158 if ($_->is_supported_object($otype)) { 159 $_->get_object($otype, $uid) or do { 160 $_->log(LA_ERR, 161 "Cannot get object $otype/$uid", 162 ); 163 next; 164 }; 165 143 166 my $res = $_->rename_object($otype, $uid, $newuid); 144 $self-> {cb}->($_, $res) if($self->{cb});167 $self->CB($_, $res); 145 168 $res or do { 146 la_log(LA_ ERR,169 la_log(LA_WARN, 147 170 "Cannot get object $otype/$uid in %s/%s", 148 171 $_->type, 149 172 $_->label 150 173 ); 151 return;174 $_->rollback; 152 175 }; 153 176 }
Note: See TracChangeset
for help on using the changeset viewer.