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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Mon Jan 20 16:18:02 2003 UTC (21 years, 5 months ago) by joko
Branch: MAIN
CVS Tags: v009, HEAD
Changes since 1.3: +88 -40 lines
+ connect to mapi via 'my $mapiLocator = Data::Storage::Locator->new( ... )'

1 ## ------------------------------------------------------------------------
2 ## $Id: Core.pm,v 1.3 2003/01/19 03:35:25 joko Exp $
3 ## ------------------------------------------------------------------------
4 ## $Log: Core.pm,v $
5 ## Revision 1.3 2003/01/19 03:35:25 joko
6 ## + added cvs-header
7 ## ------------------------------------------------------------------------
8
9
10 package Torus::Core;
11
12 use strict;
13 use warnings;
14
15 =pod
16 use base qw(
17 DesignPattern::Object
18 DesignPattern::Object::Logger
19 );
20 =cut
21
22 use mixin::with qw( Torus );
23
24
25 use Data::Dumper;
26
27 use Data::Storage;
28 use Data::Storage::Locator;
29 use Data::Transfer::Sync;
30
31
32 # get logger instance
33 my $logger = Log::Dispatch::Config->instance;
34
35 my $DEBUGLEVEL;
36 my $TRACELEVEL;
37 my $bool_started;
38
39 sub initDebugLevel {
40 my $self = shift;
41
42 $DEBUGLEVEL = $self->{config}->get("debug_level");
43 $TRACELEVEL = $self->{config}->get("trace_level");
44
45 }
46
47
48
49
50 sub addItem {
51
52 my $torusObjectType = shift;
53 my $mapiEntry = shift;
54 my $basedn = shift;
55 my $ldapEntry;
56
57 if (!$bool_started) {
58 Torus::Driver::ldap::connectStore();
59 }
60
61 $bool_started = 1;
62
63 if ($DEBUGLEVEL > 3) {
64 print STDOUT "=" x 3, " ", __PACKAGE__, " ", "=" x 30, "\n";
65 print STDOUT "recieved torus-object (type=$torusObjectType)", "\n";
66 print STDOUT "trying to write to (basedn='$basedn')", "\n";
67 }
68
69 if ($torusObjectType eq 'MapiContact') {
70 $basedn = Torus::Driver::ldap::createOuSafe($basedn);
71 my $entry = Torus::Driver::ldap::prepareEntry($basedn, $mapiEntry);
72 if (my $result = Torus::Driver::ldap::addEntry($entry)) {
73 #my $error = 0;
74 #$error = 1 if $result->code >= 0;
75 #Torus::Driver::ldap::traceEntry($mapiEntry, $entry, { error => $error, prefix => $result->error }) if $TRACELEVEL >= 2;
76 #undef $result;
77 Torus::Driver::ldap::processResult($entry->{identifier}, $result);
78 }
79 }
80
81 }
82
83 sub startSync {
84
85 my $self = shift;
86 my $opts = shift;
87
88 #print Dumper($self);
89
90 #print Dumper($opts);
91 #exit;
92
93 my $host = $self->{config}->get("ldapserver_host");
94 my $binddn = $self->{config}->get("ldapserver_binddn");
95 my $pass = $self->{config}->get("ldapserver_pass");
96 my $basedn = $self->{config}->get("ldapserver_basedn");
97
98 my $dsn = "ldap:host=$host;binddn='$binddn';pass=$pass";
99 $logger->notice(__PACKAGE__ . "->startSync: using dsn: $dsn");
100
101 # connect to LDAP
102 my $ldapLocator = Data::Storage::Locator->new(
103 ldap => {
104 type => "NetLDAP",
105 #dsn => "ldap:host=192.168.1.56;binddn='cn=root, dc=labnet, dc=de';pass=Geheim",
106 #dsn => "ldap:host=192.168.10.150;binddn='cn=root, o=netfrag.org, c=de';pass=secret",
107 dsn => $dsn,
108 #basedn => "o=netfrag.org, c=de",
109 basedn => $basedn,
110 #schema => 'BizWorks::BackendDbSchema',
111 #classnames => [qw( SystemEvent LangText )],
112 #classnames => [qw( SystemEvent Person Address LangText )],
113 #test_availability => 1,
114 #test_integrity => 1,
115 #test_emptyness => 1,
116 # TODO: re-enable this! (multiple-target-logging!)
117 #logger => 1,
118 want_transactions => 0,
119 syncable => 1,
120 },
121 );
122 my $ldapStorage = Data::Storage->new($ldapLocator);
123 $ldapStorage->connect();
124
125 # connect to MAPI
126 my $mapiLocator = Data::Storage::Locator->new(
127 outlook => {
128 type => "MAPI",
129 #dsn => "ldap:host=192.168.1.56;binddn='cn=root, dc=labnet, dc=de';pass=Geheim",
130 #dsn => "ldap:host=192.168.10.150;binddn='cn=root, o=netfrag.org, c=de';pass=secret",
131 #dsn => $dsn,
132 #basedn => "o=netfrag.org, c=de",
133 #basedn => $basedn,
134 #schema => 'BizWorks::BackendDbSchema',
135 #classnames => [qw( SystemEvent LangText )],
136 #classnames => [qw( SystemEvent Person Address LangText )],
137 #test_availability => 1,
138 #test_integrity => 1,
139 #test_emptyness => 1,
140 # TODO: re-enable this! (multiple-target-logging!)
141 #logger => 1,
142 #want_transactions => 0,
143 syncable => 1,
144 showProfileChooser => $self->{config}->get("mapi_showProfileChooser"),
145 ProfileName => $self->{config}->get("mapi_ProfileName"),
146 ProfilePass => $self->{config}->get("mapi_ProfilePass"),
147 },
148 );
149 my $mapiStorage = Data::Storage->new($mapiLocator);
150 $mapiStorage->connect();
151
152
153 # create a new synchronization object
154 my $sync = Data::Transfer::Sync->new();
155
156 # read, mungle & check the options
157 $sync->prepareOptionsV2($opts);
158
159 if (!$sync->checkOptionsV2()) {
160 $logger->critical( __PACKAGE__ . "->startSync: 'Data::Transfer::Sync::checkOptions' failed.");
161 return;
162 }
163
164 #print Dumper($opts);
165
166
167 =pod
168 # branch to execution path for special targets
169 # detect for option 'handler' which could be a CODEref
170 if ($opts->{handler} && ref $opts->{handler} eq 'CODE') {
171 $logger->info( __PACKAGE__ . "->startSync: Running (special handler code - no generic sync!) on '$opts->{target}' with MODE $opts->{mode}, NODE $opts->{target_node}");
172 $opts->{handler}->($self, $opts);
173 return;
174 }
175 =cut
176
177 # configure synchronization-object
178 $sync->configureV2(
179 #L => $self->{bizWorks}->{$opts->{source}},
180 source => {
181 storage => {
182 handle => $mapiStorage,
183 writeProtected => 1,
184 },
185 },
186 #R => $self->{bizWorks}->{$opts->{target}},
187 target => {
188 storage => {
189 handle => $ldapStorage,
190 idAuthority => 1,
191 checksumAuthority => 1,
192 writeProtected => 0,
193 },
194 },
195 verbose => 1,
196 );
197
198 # patch options
199 #$opts->{source} = "L:$opts->{source_node}" if $opts->{source_node};
200 #$opts->{target} = "R:$opts->{target_node}" if $opts->{target_node};
201
202 #print Dumper($opts);
203
204 # $sync->syncNodes($opts);
205 $sync->syncNodes();
206
207 #$mapiStorage->disconnect();
208
209 }
210
211 1;

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