/[A3C]/bin/import-ldap.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /bin/import-ldap.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 132 by dpavlin, Thu May 29 22:37:20 2008 UTC revision 141 by dpavlin, Fri May 30 22:46:53 2008 UTC
# Line 16  Jifty->web->response(Jifty::Response->ne Line 16  Jifty->web->response(Jifty::Response->ne
16    
17  my $limit = 0;  my $limit = 0;
18  my @models;  my @models;
19    my $strix;
20    
21  GetOptions(  GetOptions(
22          'limit=i', => \$limit,          'limit=i', => \$limit,
23          'model=s', => \@models,          'model=s', => \@models,
24  );          'strix+', => \$strix,
25    ) or die "$0: $!";
26    
27  my $ldap = A3C::LDAP->new;  my $ldap = A3C::LDAP->new;
28    
29    sub sync_org {
30            my $org_uid = shift;
31            my $action = Jifty->web->new_action(
32                    class => 'SyncOrganization',
33                    moniker => 'sync',
34                    arguments => {
35                            org_uid => $org_uid,
36                    }
37            );
38            $action->run;
39            if ( $action->result->success ) {
40                    Jifty->log->info( $action->result->message );
41            } else {
42                    Jifty->log->error( "Can't sync $org_uid" );
43            }
44    }
45    
46    if ( $strix ) {
47            my $strix_sites = A3C::Model::StrixSiteCollection->new;
48            $strix_sites->unlimit;
49            my $o_nr = 1;
50            while ( my $site = $strix_sites->next ) {
51                    Jifty->log->info( 'sync organization ', $o_nr++, '/', $strix_sites->count, ' ', $site->site );
52                    sync_org( $site->site );
53            }
54            exit;
55    }
56    
57  if ( @models ) {  if ( @models ) {
58    
59          Jifty->log->info( 'syncing: ', join(',', @models) );          Jifty->log->info( 'syncing: ', join(',', @models) );
# Line 51  if ( @models ) { Line 82  if ( @models ) {
82                          next;                          next;
83                  }                  }
84                  my $org_uid = $o->$value_from || warn "can't find org_uid in $value_from in ",dump( $o->as_hash );                  my $org_uid = $o->$value_from || warn "can't find org_uid in $value_from in ",dump( $o->as_hash );
85                  my $action = Jifty->web->new_action(                  sync_org( $org_uid );
                         class => 'SyncOrganization',  
                         moniker => 'sync',  
                         arguments => {  
                                 org_uid => $org_uid,  
                         }  
                 );  
                 $action->run;  
                 if ( $action->result->success ) {  
                         Jifty->log->info( $action->result->message );  
                 } else {  
                         Jifty->log->error( "Can't sync ", $o->name );  
                 }  
86          }          }
87  }  }

Legend:
Removed from v.132  
changed lines
  Added in v.141

  ViewVC Help
Powered by ViewVC 1.1.26