4 |
## $Id$ |
## $Id$ |
5 |
## -------------------------------------------------------------------------------- |
## -------------------------------------------------------------------------------- |
6 |
## $Log$ |
## $Log$ |
7 |
|
## Revision 1.3 2003/02/14 14:18:36 joko |
8 |
|
## + new get-/setter-methods |
9 |
|
## |
10 |
|
## Revision 1.2 2003/02/11 09:48:57 joko |
11 |
|
## - moved notice output out of this module |
12 |
|
## + some fixes |
13 |
|
## |
14 |
## Revision 1.1 2003/02/09 16:27:06 joko |
## Revision 1.1 2003/02/09 16:27:06 joko |
15 |
## + initial commit |
## + initial commit |
16 |
## |
## |
31 |
|
|
32 |
use Data::Dumper; |
use Data::Dumper; |
33 |
use Getopt::Long; |
use Getopt::Long; |
34 |
|
use Data::Transfer::Sync; |
35 |
|
|
36 |
|
|
37 |
# get logger instance |
# get logger instance |
56 |
exit; |
exit; |
57 |
} |
} |
58 |
|
|
59 |
sub getoptions { |
sub readoptions { |
60 |
my $self = shift; |
my $self = shift; |
61 |
|
|
62 |
GetOptions( |
GetOptions( |
75 |
); |
); |
76 |
} |
} |
77 |
|
|
78 |
|
sub getoptions { |
79 |
|
my $self = shift; |
80 |
|
return $self->{opt}; |
81 |
|
} |
82 |
|
|
83 |
|
sub setoptions { |
84 |
|
my $self = shift; |
85 |
|
my $options = shift; |
86 |
|
# FIXME: is this really true? |
87 |
|
$self->{opt} = $options; |
88 |
|
} |
89 |
|
|
90 |
sub getoptions_old { |
sub getoptions_old { |
91 |
my $self = shift; |
my $self = shift; |
92 |
GetOptions( |
GetOptions( |
125 |
my $self = shift; |
my $self = shift; |
126 |
$self->_before_run(); |
$self->_before_run(); |
127 |
$self->prepare(); |
$self->prepare(); |
128 |
$self->tellWhatIAmDoing(); |
#$self->tellWhatIAmDoing(); |
129 |
$self->sync(); |
$self->sync(); |
130 |
} |
} |
131 |
|
|
|
my $c_string_default = ''; |
|
|
sub c_string { |
|
|
my $value = shift; |
|
|
$value ||= "[$c_string_default]"; |
|
|
return $value; |
|
|
} |
|
|
|
|
|
sub tellWhatIAmDoing { |
|
|
my $self = shift; |
|
|
|
|
|
$c_string_default = 'n/a'; |
|
|
my $source = c_string($self->{opt}->{'source'}); |
|
|
my $source_node = c_string($self->{opt}->{'source-node'}); |
|
|
my $source_type = c_string($self->{opt}->{'source-type'}); |
|
|
my $target = c_string($self->{opt}->{'target'}); |
|
|
my $target_node = c_string($self->{opt}->{'target-node'}); |
|
|
my $target_type = c_string($self->{opt}->{'target-type'}); |
|
|
|
|
|
my $mapping_module = c_string($self->{opt}->{'mapping-module'}); |
|
|
my $mode = uc c_string($self->{opt}->{'mode'}); |
|
|
|
|
|
my $ql = "$mode INTO $source NODE $source_node TYPE $source_type SELECT NODE $target_node TYPE $target_type FROM $target USING MODULE $mapping_module;"; |
|
|
#$logger->notice( __PACKAGE__ . ": $ql" ); |
|
|
$logger->notice( $ql ); |
|
|
|
|
|
return; |
|
|
|
|
|
my $actioning = ucfirst $self->{opt}->{'action'} . 'ing'; |
|
|
|
|
|
# FIXME: this is weird! |
|
|
my $long = <<EOT; |
|
|
|
|
|
- $actioning data of type $target_type and |
|
|
filtered by $target_node from the storage named $target |
|
|
to the storage named $source - filtered by $source_node. |
|
|
- Will attempt to convert the data to $source_type. |
|
|
EOT |
|
|
chomp($long); |
|
|
$logger->notice( __PACKAGE__ . ": $long" ); |
|
|
|
|
|
} |
|
|
|
|
132 |
sub prepare { |
sub prepare { |
133 |
my $self = shift; |
my $self = shift; |
134 |
|
|
174 |
$sync_version ||= 'V1'; |
$sync_version ||= 'V1'; |
175 |
|
|
176 |
# create a new synchronization object |
# create a new synchronization object |
177 |
my $sync = Data::Transfer::Sync->new( 'sync_version' => $sync_version ); |
my $sync = Data::Transfer::Sync->new( 'sync_version' => $sync_version, __parent => $self ); |
178 |
|
|
179 |
# trace |
# trace |
180 |
#print Dumper($self); |
#print Dumper($self); |
181 |
|
#print Dumper($self); |
182 |
|
#exit; |
183 |
|
|
184 |
|
|
185 |
# configure the synchronization-object |
# configure the synchronization-object |
186 |
$sync->configure( |
$sync->configure( |
188 |
storage => { |
storage => { |
189 |
#handle => $mapiStorage, |
#handle => $mapiStorage, |
190 |
handle => $self->{app}->{$self->{opt}->{source}}, |
handle => $self->{app}->{$self->{opt}->{source}}, |
191 |
writeProtected => 1, |
#isIdentAuthority => $self->{app}->{config}->{{$self->{opt}->{source}}, |
192 |
|
#isChecksumAuthority => 1, |
193 |
|
#writeProtected => 1, |
194 |
}, |
}, |
195 |
}, |
}, |
196 |
target => { |
target => { |
197 |
storage => { |
storage => { |
198 |
#handle => $ldapStorage, |
#handle => $ldapStorage, |
199 |
handle => $self->{app}->{$self->{opt}->{target}}, |
handle => $self->{app}->{$self->{opt}->{target}}, |
200 |
idAuthority => 1, |
#idAuthority => 1, |
201 |
isChecksumAuthority => 1, |
#isChecksumAuthority => 1, |
202 |
writeProtected => 0, |
#isWriteProtected => 0, |
203 |
}, |
}, |
204 |
}, |
}, |
205 |
verbose => 1, |
verbose => 1, |
206 |
); |
); |
207 |
|
|
208 |
|
# TODO: |
209 |
|
=pod |
210 |
|
$sync->configure( |
211 |
|
'source.storage.handle' => ..., |
212 |
|
'target.storage.handle' => ..., |
213 |
|
); |
214 |
|
=cut |
215 |
|
|
216 |
# trace |
# trace |
217 |
#print Dumper($sync); |
#print Dumper($sync); |