/[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.1 by joko, Sat Jan 18 15:38:10 2003 UTC revision 1.4 by joko, Mon Jan 20 16:18:02 2003 UTC
# Line 1  Line 1 
1  package Torus::Core;  ##    ------------------------------------------------------------------------
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  require Exporter;  package Torus::Core;
 our @ISA = qw(Exporter);  
 our @EXPORT = qw( );  
14    
15  use strict;  use strict;
16  use warnings;  use warnings;
17    
18  use loadConfig;  =pod
19  use Torus::Driver::ldap;  use base qw(
20      DesignPattern::Object
21      DesignPattern::Object::Logger
22    );
23    =cut
24    
25    use mixin::with qw( Torus );
26    
27    
28    use Data::Dumper;
29    
30    use Data::Storage;
31    use Data::Storage::Locator;
32    use Data::Transfer::Sync;
33    
34  my $DEBUGLEVEL = $config->get("debug_level");  
35  my $TRACELEVEL = $config->get("trace_level");  # get logger instance
36    my $logger = Log::Dispatch::Config->instance;
37    
38    my $DEBUGLEVEL;
39    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 48  sub addItem { Line 83  sub addItem {
83    
84  }  }
85    
86    sub startSync {
87    
88      my $self = shift;
89      my $opts = shift;
90    
91    #print Dumper($self);
92    
93    #print Dumper($opts);
94    #exit;
95    
96      my $host = $self->{config}->get("ldapserver_host");
97      my $binddn = $self->{config}->get("ldapserver_binddn");
98      my $pass = $self->{config}->get("ldapserver_pass");
99      my $basedn = $self->{config}->get("ldapserver_basedn");
100      
101      my $dsn = "ldap:host=$host;binddn='$binddn';pass=$pass";
102      $logger->notice(__PACKAGE__ . "->startSync: using dsn: $dsn");
103    
104      # 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
157      my $sync = Data::Transfer::Sync->new();
158    
159      # read, mungle & check the options
160        $sync->prepareOptionsV2($opts);
161    
162        if (!$sync->checkOptionsV2()) {
163          $logger->critical( __PACKAGE__ . "->startSync: 'Data::Transfer::Sync::checkOptions' failed.");
164          return;
165        }
166    
167    #print Dumper($opts);
168    
169    
170    =pod
171      # branch to execution path for special targets
172      # detect for option 'handler' which could be a CODEref
173        if ($opts->{handler} && ref $opts->{handler} eq 'CODE') {
174          $logger->info( __PACKAGE__ . "->startSync: Running (special handler code - no generic sync!) on '$opts->{target}' with MODE $opts->{mode}, NODE $opts->{target_node}");
175          $opts->{handler}->($self, $opts);
176          return;
177        }
178    =cut
179      
180      # configure synchronization-object
181      $sync->configureV2(
182          #L => $self->{bizWorks}->{$opts->{source}},
183        source => {
184          storage => {
185            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        },
198        verbose => 1,
199      );
200      
201      # patch options
202      #$opts->{source} = "L:$opts->{source_node}" if $opts->{source_node};
203      #$opts->{target} = "R:$opts->{target_node}" if $opts->{target_node};
204    
205    #print Dumper($opts);
206    
207    #  $sync->syncNodes($opts);
208      $sync->syncNodes();
209    
210      #$mapiStorage->disconnect();
211    
212    }
213    
214  1;  1;

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

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