line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package EWS::Contacts::Role::Reader; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
1
|
|
|
1
|
|
696
|
$EWS::Contacts::Role::Reader::VERSION = '1.143070'; |
4
|
|
|
|
|
|
|
} |
5
|
1
|
|
|
1
|
|
798
|
use Moose::Role; |
|
1
|
|
|
|
|
4561
|
|
|
1
|
|
|
|
|
5
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5871
|
use EWS::Contacts::ResultSet; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
8
|
1
|
|
|
1
|
|
7
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
829
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub _list_messages { |
11
|
0
|
|
|
0
|
|
|
my ($self, $kind, $response) = @_; |
12
|
0
|
|
|
|
|
|
return @{ $response->{"${kind}Result"} |
13
|
|
|
|
|
|
|
->{ResponseMessages} |
14
|
0
|
|
|
|
|
|
->{cho_CreateItemResponseMessage} }; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _check_for_errors { |
18
|
0
|
|
|
0
|
|
|
my ($self, $kind, $response) = @_; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
foreach my $msg ( $self->_list_messages($kind, $response) ) { |
21
|
0
|
|
0
|
|
|
|
my $code = $msg->{"${kind}ResponseMessage"}->{ResponseCode} || ''; |
22
|
0
|
0
|
|
|
|
|
croak "Fault returned from Exchange Server: $code\n" |
23
|
|
|
|
|
|
|
if $code ne 'NoError'; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _list_contactitems { |
28
|
0
|
|
|
0
|
|
|
my ($self, $kind, $response) = @_; |
29
|
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
if($kind eq 'ResolveNames'){ |
31
|
0
|
|
|
|
|
|
return map { $_->{Contact} } |
32
|
0
|
0
|
|
|
|
|
grep { defined $_->{'Contact'}->{'DisplayName'} and length $_->{'Contact'}->{'DisplayName'} } |
33
|
0
|
|
|
|
|
|
map { @{ $_->{Resolution} } } |
|
0
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
map { $_->{ResolutionSet} } |
35
|
0
|
|
|
|
|
|
map { $_->{ResolveNamesResponseMessage} } |
|
0
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$self->_list_messages($kind, $response); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
0
|
|
|
|
|
|
return map { $_->{Contact} } |
40
|
0
|
0
|
|
|
|
|
grep { defined $_->{'Contact'}->{'DisplayName'} and length $_->{'Contact'}->{'DisplayName'} } |
41
|
0
|
0
|
|
|
|
|
map { @{ $_->{Items}->{cho_Item} || [] } } |
|
0
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
map { exists $_->{RootFolder} ? $_->{RootFolder} : $_ } |
43
|
0
|
|
|
|
|
|
map { $_->{"${kind}ResponseMessage"} } |
|
0
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$self->_list_messages($kind, $response); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _get_contacts { |
49
|
0
|
|
|
0
|
|
|
my ($self, $opts) = @_; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
return scalar $self->client->FindItem->( |
52
|
|
|
|
|
|
|
(exists $opts->{impersonate} ? ( |
53
|
|
|
|
|
|
|
Impersonation => { |
54
|
|
|
|
|
|
|
ConnectingSID => { |
55
|
|
|
|
|
|
|
PrimarySmtpAddress => $opts->{impersonate}, |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
}, |
58
|
|
|
|
|
|
|
) : ()), |
59
|
|
|
|
|
|
|
RequestVersion => { |
60
|
|
|
|
|
|
|
Version => $self->client->server_version, |
61
|
|
|
|
|
|
|
}, |
62
|
|
|
|
|
|
|
ItemShape => { BaseShape => 'AllProperties' }, |
63
|
|
|
|
|
|
|
ParentFolderIds => { |
64
|
|
|
|
|
|
|
cho_FolderId => [ |
65
|
|
|
|
|
|
|
{ DistinguishedFolderId => |
66
|
|
|
|
|
|
|
{ |
67
|
|
|
|
|
|
|
Id => 'contacts', |
68
|
|
|
|
|
|
|
(exists $opts->{email} ? ( |
69
|
|
|
|
|
|
|
Mailbox => { |
70
|
|
|
|
|
|
|
EmailAddress => $opts->{email}, |
71
|
|
|
|
|
|
|
}, |
72
|
0
|
0
|
|
|
|
|
) : ()), # optional |
|
|
0
|
|
|
|
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
] |
76
|
|
|
|
|
|
|
}, |
77
|
|
|
|
|
|
|
Traversal => 'Shallow', |
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# find primarysmtp if passed an account id. |
82
|
|
|
|
|
|
|
# then find contacts in the account. |
83
|
|
|
|
|
|
|
sub retrieve { |
84
|
0
|
|
|
0
|
0
|
|
my ($self, $opts) = @_; |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
my $get_response = $self->_get_contacts($opts); |
87
|
|
|
|
|
|
|
|
88
|
0
|
0
|
0
|
|
|
|
if (exists $get_response->{'ResponseCode'} and defined $get_response->{'ResponseCode'} |
|
|
|
0
|
|
|
|
|
89
|
|
|
|
|
|
|
and $get_response->{'ResponseCode'} eq 'ErrorNonPrimarySmtpAddress') { |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
$self->retrieve({ |
92
|
|
|
|
|
|
|
%$opts, |
93
|
0
|
|
|
|
|
|
email => $get_response->{'MessageXml'}->{'Value'}->{'_'}, |
94
|
|
|
|
|
|
|
}); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
$self->_check_for_errors('FindItem', $get_response); |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
return EWS::Contacts::ResultSet->new({ |
100
|
|
|
|
|
|
|
items => [ $self->_list_contactitems('FindItem', $get_response) ] |
101
|
|
|
|
|
|
|
}); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub _get_resolvenames { |
105
|
0
|
|
|
0
|
|
|
my ($self, $opts) = @_; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
return scalar $self->client->ResolveNames->( |
108
|
|
|
|
|
|
|
(exists $opts->{impersonate} ? ( |
109
|
|
|
|
|
|
|
Impersonation => { |
110
|
|
|
|
|
|
|
ConnectingSID => { |
111
|
|
|
|
|
|
|
PrimarySmtpAddress => $opts->{impersonate}, |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
}, |
114
|
|
|
|
|
|
|
) : ()), |
115
|
|
|
|
|
|
|
RequestVersion => { |
116
|
|
|
|
|
|
|
Version => $self->client->server_version, |
117
|
|
|
|
|
|
|
}, |
118
|
|
|
|
|
|
|
ReturnFullContactData => 'true', |
119
|
|
|
|
|
|
|
UnresolvedEntry => $opts->{unresolved_entry} |
120
|
0
|
0
|
|
|
|
|
); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub retrieve_gal { |
124
|
0
|
|
|
0
|
0
|
|
my ($self, $opts) = @_; |
125
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
my $get_response = $self->_get_resolvenames($opts); |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
return EWS::Contacts::ResultSet->new({ |
129
|
|
|
|
|
|
|
items => [ $self->_list_contactitems('ResolveNames', $get_response) ] |
130
|
|
|
|
|
|
|
}); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
1
|
|
|
1
|
|
7
|
no Moose::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
13
|
|
134
|
|
|
|
|
|
|
1; |