/[cvs]/nfo/perl/scripts/outlook2ldap/libs/Torus/Core.pm
ViewVC logotype

Diff of /nfo/perl/scripts/outlook2ldap/libs/Torus/Core.pm

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

revision 1.2 by joko, Sat Jan 18 18:23:20 2003 UTC revision 1.4 by joko, Mon Jan 20 16:18:02 2003 UTC
# Line 1  Line 1 
1    ##    ------------------------------------------------------------------------
2    ##    $Id$
3    ##    ------------------------------------------------------------------------
4    ##    $Log$
5    ##    Revision 1.4  2003/01/20 16:18:02  joko
6    ##    + connect to mapi via 'my $mapiLocator = Data::Storage::Locator->new( ... )'
7    ##
8    ##    Revision 1.3  2003/01/19 03:35:25  joko
9    ##    + added cvs-header
10    ##    ------------------------------------------------------------------------
11    
12    
13  package Torus::Core;  package Torus::Core;
14    
15    use strict;
16    use warnings;
17    
18    =pod
19  use base qw(  use base qw(
20    DesignPattern::Object    DesignPattern::Object
21    DesignPattern::Object::Logger    DesignPattern::Object::Logger
22  );  );
23    =cut
24    
25  use strict;  use mixin::with qw( Torus );
26  use warnings;  
27    
28    use Data::Dumper;
29    
30  use loadConfig;  use Data::Storage;
31  #use Torus::Driver::ldap;  use Data::Storage::Locator;
32  use Data::Transfer::Sync;  use Data::Transfer::Sync;
33    
 my $logger = Log::Dispatch::Config->instance;  
34    
35    # get logger instance
36    my $logger = Log::Dispatch::Config->instance;
37    
38  my $DEBUGLEVEL = $config->get("debug_level");  my $DEBUGLEVEL;
39  my $TRACELEVEL = $config->get("trace_level");  my $TRACELEVEL;
40  my $bool_started;  my $bool_started;
41    
42    sub initDebugLevel {
43      my $self = shift;
44    
45      $DEBUGLEVEL = $self->{config}->get("debug_level");
46      $TRACELEVEL = $self->{config}->get("trace_level");
47    
48     }
49    
50    
51    
52    
53  sub addItem {  sub addItem {
54    
# Line 58  sub startSync { Line 88  sub startSync {
88    my $self = shift;    my $self = shift;
89    my $opts = shift;    my $opts = shift;
90    
91    my $ldapLocator = Data::Storage::Locator->new(  #print Dumper($self);
92      ldap => {  
93        type => "NetLDAP",  #print Dumper($opts);
94  #      dsn => "ldap:host=192.168.1.56;binddn='cn=root, dc=labnet, dc=de';pass=Geheim",  #exit;
95        dsn => "ldap:host=192.168.10.150;binddn='cn=root, o=netfrag.org, c=de';pass=secret",  
96        #schema => 'BizWorks::BackendDbSchema',    my $host = $self->{config}->get("ldapserver_host");
97        #classnames => [qw( SystemEvent LangText )],    my $binddn = $self->{config}->get("ldapserver_binddn");
98        #classnames => [qw( SystemEvent Person Address LangText )],    my $pass = $self->{config}->get("ldapserver_pass");
99        #test_availability => 1,    my $basedn = $self->{config}->get("ldapserver_basedn");
100        #test_integrity => 1,    
101        #test_emptyness => 1,    my $dsn = "ldap:host=$host;binddn='$binddn';pass=$pass";
102        # TODO: re-enable this! (multiple-target-logging!)    $logger->notice(__PACKAGE__ . "->startSync: using dsn: $dsn");
       #logger => 1,  
       want_transactions => 0,  
       syncable => 1,  
     },  
   );  
   my $ldapStorage = Data::Storage->new($ldapLocator);  
   $ldapStorage->connect();  
103    
104    my $mapiStorage;    # connect to LDAP
105        my $ldapLocator = Data::Storage::Locator->new(
106          ldap => {
107            type => "NetLDAP",
108            #dsn => "ldap:host=192.168.1.56;binddn='cn=root, dc=labnet, dc=de';pass=Geheim",
109            #dsn => "ldap:host=192.168.10.150;binddn='cn=root, o=netfrag.org, c=de';pass=secret",
110            dsn => $dsn,
111            #basedn => "o=netfrag.org, c=de",
112            basedn => $basedn,
113            #schema => 'BizWorks::BackendDbSchema',
114            #classnames => [qw( SystemEvent LangText )],
115            #classnames => [qw( SystemEvent Person Address LangText )],
116            #test_availability => 1,
117            #test_integrity => 1,
118            #test_emptyness => 1,
119            # TODO: re-enable this! (multiple-target-logging!)
120            #logger => 1,
121            want_transactions => 0,
122            syncable => 1,
123          },
124        );
125        my $ldapStorage = Data::Storage->new($ldapLocator);
126        $ldapStorage->connect();
127    
128      # connect to MAPI
129        my $mapiLocator = Data::Storage::Locator->new(
130          outlook => {
131            type => "MAPI",
132            #dsn => "ldap:host=192.168.1.56;binddn='cn=root, dc=labnet, dc=de';pass=Geheim",
133            #dsn => "ldap:host=192.168.10.150;binddn='cn=root, o=netfrag.org, c=de';pass=secret",
134            #dsn => $dsn,
135            #basedn => "o=netfrag.org, c=de",
136            #basedn => $basedn,
137            #schema => 'BizWorks::BackendDbSchema',
138            #classnames => [qw( SystemEvent LangText )],
139            #classnames => [qw( SystemEvent Person Address LangText )],
140            #test_availability => 1,
141            #test_integrity => 1,
142            #test_emptyness => 1,
143            # TODO: re-enable this! (multiple-target-logging!)
144            #logger => 1,
145            #want_transactions => 0,
146            syncable => 1,
147            showProfileChooser => $self->{config}->get("mapi_showProfileChooser"),
148            ProfileName => $self->{config}->get("mapi_ProfileName"),
149            ProfilePass => $self->{config}->get("mapi_ProfilePass"),
150          },
151        );
152        my $mapiStorage = Data::Storage->new($mapiLocator);
153        $mapiStorage->connect();
154        
155    
156    # create a new synchronization object    # create a new synchronization object
157    my $sync = Data::Transfer::Sync->new();    my $sync = Data::Transfer::Sync->new();
158    
159      # read, mungle & check the options
160        $sync->prepareOptionsV2($opts);
161    
162    # resolve mapping metadata for syncing requested resource      if (!$sync->checkOptionsV2()) {
     # if now mapping is given explicitely, try to use mapping named like "target"  
     $opts->{mapping} ||= $opts->{target};  
     # was: ($nodemapping and $propmapping were package-globals)  
     # is: (both mappings are retrieved from mapping-module/package/object  
     # resolve mapping module  
     my $modulename = $self->{config}->{mappings}->{$opts->{mapping}};  
     $opts->{mapping_module} = $modulename;  
   
 #print Dumper($opts);  
   
   # mungle & check the options  
   # TODO: refactor this and the innards.....  
   
     #$opts = $sync->prepareSyncOptions($opts);  
     if (!$sync->prepareOptions($opts)) {  
       $logger->critical( __PACKAGE__ . "->startSync: 'Data::Transfer::Sync::prepareSyncOptions' failed.");  
     }  
   
 #print Dumper($opts);  
       
     if (!$sync->checkOptions($opts)) {  
163        $logger->critical( __PACKAGE__ . "->startSync: 'Data::Transfer::Sync::checkOptions' failed.");        $logger->critical( __PACKAGE__ . "->startSync: 'Data::Transfer::Sync::checkOptions' failed.");
164        return;        return;
165      }      }
166    
167    #print Dumper($opts);
168    
169    
170    =pod
171    # branch to execution path for special targets    # branch to execution path for special targets
172    # detect for option 'handler' which could be a CODEref    # detect for option 'handler' which could be a CODEref
173      if ($opts->{handler} && ref $opts->{handler} eq 'CODE') {      if ($opts->{handler} && ref $opts->{handler} eq 'CODE') {
# Line 118  sub startSync { Line 175  sub startSync {
175        $opts->{handler}->($self, $opts);        $opts->{handler}->($self, $opts);
176        return;        return;
177      }      }
178    =cut
   # determine write-protection(s) from options  
     my @write_protects;  
     push @write_protects, 'L' if $opts->{source_write_protect};  
     push @write_protects, 'R' if $opts->{target_write_protect};  
179        
180    # configure synchronization-object    # configure synchronization-object
181    $sync->configure(    $sync->configureV2(
     storages => {  
182        #L => $self->{bizWorks}->{$opts->{source}},        #L => $self->{bizWorks}->{$opts->{source}},
183        L => $mapiStorage,      source => {
184        #R => $self->{bizWorks}->{$opts->{target}},        storage => {
185        R => $ldapStorage,          handle => $mapiStorage,
186            writeProtected => 1,
187          },
188        },
189        #R => $self->{bizWorks}->{$opts->{target}},
190        target => {
191          storage => {
192            handle => $ldapStorage,
193            idAuthority => 1,
194            checksumAuthority => 1,
195            writeProtected => 0,
196          },
197      },      },
     id_authorities => [qw( L ) ],  
     checksum_authorities => [qw( L ) ],  
     write_protected => \@write_protects,  
198      verbose => 1,      verbose => 1,
199    );    );
200        
201    # patch options    # patch options
202    $opts->{source} = "L:$opts->{source_node}" if $opts->{source_node};    #$opts->{source} = "L:$opts->{source_node}" if $opts->{source_node};
203    $opts->{target} = "R:$opts->{target_node}" if $opts->{target_node};    #$opts->{target} = "R:$opts->{target_node}" if $opts->{target_node};
204    
205  #print Dumper($opts);  #print Dumper($opts);
206    
207    $sync->syncNodes($opts);  #  $sync->syncNodes($opts);
208      $sync->syncNodes();
209    
210      #$mapiStorage->disconnect();
211    
212  }  }
213    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.4

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed