line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package EWS::Folder::Role::Reader; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
1
|
|
|
1
|
|
738
|
$EWS::Folder::Role::Reader::VERSION = '1.143070'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use Moose::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
7
|
1
|
|
|
1
|
|
5776
|
use EWS::Folder::ResultSet; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
8
|
1
|
|
|
1
|
|
8
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
938
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub _list_messages { |
11
|
0
|
|
|
0
|
|
|
my ($self, $kind, $response) = @_; |
12
|
0
|
0
|
|
|
|
|
if ( $response->{Fault} ) { |
13
|
0
|
|
|
|
|
|
my $msg; |
14
|
0
|
|
|
|
|
|
$msg->{"${kind}ResponseMessage"}->{ResponseCode} = $response->{Fault}->{faultstring}; |
15
|
0
|
|
|
|
|
|
return $msg; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
else { |
18
|
0
|
|
|
|
|
|
return @{ $response->{"${kind}Result"} |
19
|
|
|
|
|
|
|
->{ResponseMessages} |
20
|
0
|
|
|
|
|
|
->{"cho_CreateItemResponseMessage"} }; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _check_for_errors { |
25
|
0
|
|
|
0
|
|
|
my ($self, $kind, $response) = @_; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
foreach my $msg ( $self->_list_messages($kind, $response) ) { |
28
|
0
|
|
0
|
|
|
|
my $code = $msg->{"${kind}ResponseMessage"}->{ResponseCode} || ''; |
29
|
0
|
0
|
|
|
|
|
croak "Fault returned from Exchange Server: $code\n" |
30
|
|
|
|
|
|
|
if $code ne 'NoError'; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _PagingOffset { |
35
|
0
|
|
|
0
|
|
|
my ($self, $kind, $response) = @_; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
foreach my $msg ( $self->_list_messages($kind, $response) ) { |
38
|
0
|
0
|
|
|
|
|
if ( exists $msg->{"${kind}ResponseMessage"}->{RootFolder} ) { |
39
|
0
|
0
|
|
|
|
|
if ( ! $msg->{"${kind}ResponseMessage"}->{RootFolder}->{IncludesLastItemInRange} ) { |
40
|
0
|
|
|
|
|
|
return $msg->{"${kind}ResponseMessage"}->{RootFolder}->{IndexedPagingOffset}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
0
|
|
|
|
|
|
return 0; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _list_folderitems { |
48
|
0
|
|
|
0
|
|
|
my ($self, $kind, $response) = @_; |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
return map { exists $_->{Folder} ? $_->{Folder} : $_ } |
51
|
0
|
0
|
|
|
|
|
map { exists $_->{TasksFolder} ? $_->{TasksFolder} : $_ } |
52
|
0
|
0
|
|
|
|
|
map { exists $_->{ContactsFolder} ? $_->{ContactsFolder} : $_ } |
53
|
0
|
0
|
|
|
|
|
map { exists $_->{CalendarFolder} ? $_->{CalendarFolder} : $_ } |
54
|
0
|
0
|
|
|
|
|
map { @{ $_->{Folders}->{cho_Folder} || [] } } |
|
0
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
map { exists $_->{RootFolder} ? $_->{RootFolder} : $_ } |
56
|
0
|
|
|
|
|
|
map { $_->{"${kind}ResponseMessage"} } |
|
0
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$self->_list_messages($kind, $response); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# Find list of items within the view, then Get details for each one |
61
|
|
|
|
|
|
|
# (item:Body is only available this way, it's not returned by FindItem) |
62
|
|
|
|
|
|
|
sub retrieve{ |
63
|
0
|
|
|
0
|
0
|
|
my ($self, $opts) = @_; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my @items; |
66
|
0
|
|
|
|
|
|
my $IndexedPagingOffset = 0; |
67
|
0
|
|
|
|
|
|
do { |
68
|
|
|
|
|
|
|
# Find all folders underneath the 'Top of Information Store' |
69
|
|
|
|
|
|
|
my $find_response = scalar $self->client->FindFolder->( |
70
|
|
|
|
|
|
|
(exists $opts->{impersonate} ? ( |
71
|
|
|
|
|
|
|
Impersonation => { |
72
|
|
|
|
|
|
|
ConnectingSID => { |
73
|
|
|
|
|
|
|
PrimarySmtpAddress => $opts->{impersonate}, |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
}, |
76
|
|
|
|
|
|
|
) : ()), |
77
|
|
|
|
|
|
|
RequestVersion => { |
78
|
|
|
|
|
|
|
Version => $self->client->server_version, |
79
|
|
|
|
|
|
|
}, |
80
|
|
|
|
|
|
|
Traversal => 'Deep', |
81
|
|
|
|
|
|
|
FolderShape => { |
82
|
|
|
|
|
|
|
BaseShape => 'IdOnly', |
83
|
|
|
|
|
|
|
AdditionalProperties => { |
84
|
|
|
|
|
|
|
cho_Path => [ |
85
|
|
|
|
|
|
|
{ExtendedFieldURI => { |
86
|
|
|
|
|
|
|
PropertyTag => '3592', |
87
|
|
|
|
|
|
|
PropertyType => 'Integer', |
88
|
|
|
|
|
|
|
}}, |
89
|
|
|
|
|
|
|
map {{ |
90
|
0
|
|
|
|
|
|
FieldURI => { |
91
|
|
|
|
|
|
|
FieldURI => $_, |
92
|
|
|
|
|
|
|
}, |
93
|
|
|
|
|
|
|
}} qw/ |
94
|
|
|
|
|
|
|
folder:DisplayName |
95
|
|
|
|
|
|
|
folder:FolderClass |
96
|
|
|
|
|
|
|
folder:ChildFolderCount |
97
|
|
|
|
|
|
|
folder:TotalCount |
98
|
|
|
|
|
|
|
folder:ManagedFolderInformation |
99
|
|
|
|
|
|
|
folder:ParentFolderId |
100
|
|
|
|
|
|
|
/, |
101
|
|
|
|
|
|
|
], |
102
|
|
|
|
|
|
|
}, |
103
|
|
|
|
|
|
|
}, |
104
|
|
|
|
|
|
|
IndexedPageFolderView => { |
105
|
|
|
|
|
|
|
MaxEntriesReturned => '100', |
106
|
|
|
|
|
|
|
Offset => $IndexedPagingOffset, |
107
|
|
|
|
|
|
|
BasePoint => 'Beginning', |
108
|
|
|
|
|
|
|
}, |
109
|
|
|
|
|
|
|
ParentFolderIds => { |
110
|
|
|
|
|
|
|
cho_FolderId => [ |
111
|
|
|
|
|
|
|
{ |
112
|
|
|
|
|
|
|
DistinguishedFolderId => { |
113
|
|
|
|
|
|
|
(exists $opts->{folderId} ? ( |
114
|
0
|
0
|
|
|
|
|
Id => $self->FolderId, |
|
|
0
|
|
|
|
|
|
115
|
|
|
|
|
|
|
) : Id => "msgfolderroot",) |
116
|
|
|
|
|
|
|
}, |
117
|
|
|
|
|
|
|
}, |
118
|
|
|
|
|
|
|
], |
119
|
|
|
|
|
|
|
}, |
120
|
|
|
|
|
|
|
); |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
$self->_check_for_errors('FindFolder', $find_response); |
123
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
push( @items, $self->_list_folderitems('FindFolder', $find_response)); |
125
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
$IndexedPagingOffset = $self->_PagingOffset('FindFolder', $find_response); |
127
|
|
|
|
|
|
|
} while ( $IndexedPagingOffset > 0 ); |
128
|
|
|
|
|
|
|
|
129
|
0
|
0
|
|
|
|
|
return return EWS::Folder::ResultSet->new({items => []}) |
130
|
|
|
|
|
|
|
if scalar @items == 0; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# Now add to that the details for the actual 'Top of Information Store' folder. |
133
|
|
|
|
|
|
|
my $get_response = scalar $self->client->GetFolder->( |
134
|
|
|
|
|
|
|
(exists $opts->{impersonate} ? ( |
135
|
|
|
|
|
|
|
Impersonation => { |
136
|
|
|
|
|
|
|
ConnectingSID => { |
137
|
|
|
|
|
|
|
PrimarySmtpAddress => $opts->{impersonate}, |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
}, |
140
|
|
|
|
|
|
|
) : ()), |
141
|
|
|
|
|
|
|
RequestVersion => { |
142
|
|
|
|
|
|
|
Version => $self->client->server_version, |
143
|
|
|
|
|
|
|
}, |
144
|
|
|
|
|
|
|
FolderShape => { |
145
|
|
|
|
|
|
|
BaseShape => 'IdOnly', |
146
|
|
|
|
|
|
|
AdditionalProperties => { |
147
|
|
|
|
|
|
|
cho_Path => [ |
148
|
|
|
|
|
|
|
{ExtendedFieldURI => { |
149
|
|
|
|
|
|
|
PropertyTag => '3592', |
150
|
|
|
|
|
|
|
PropertyType => 'Integer', |
151
|
|
|
|
|
|
|
}}, |
152
|
|
|
|
|
|
|
map {{ |
153
|
0
|
|
|
|
|
|
FieldURI => { |
154
|
|
|
|
|
|
|
FieldURI => $_, |
155
|
|
|
|
|
|
|
}, |
156
|
|
|
|
|
|
|
}} qw/ |
157
|
|
|
|
|
|
|
folder:DisplayName |
158
|
|
|
|
|
|
|
folder:FolderClass |
159
|
|
|
|
|
|
|
folder:ChildFolderCount |
160
|
|
|
|
|
|
|
folder:ManagedFolderInformation |
161
|
|
|
|
|
|
|
folder:ParentFolderId |
162
|
|
|
|
|
|
|
/, |
163
|
|
|
|
|
|
|
], |
164
|
|
|
|
|
|
|
}, |
165
|
|
|
|
|
|
|
}, |
166
|
|
|
|
|
|
|
FolderIds => { |
167
|
|
|
|
|
|
|
cho_FolderId => [ |
168
|
|
|
|
|
|
|
{DistinguishedFolderId => { |
169
|
|
|
|
|
|
|
(exists $opts->{folderId} ? ( |
170
|
0
|
0
|
|
|
|
|
Id => $self->FolderId, |
|
|
0
|
|
|
|
|
|
171
|
|
|
|
|
|
|
) : Id => "msgfolderroot",) |
172
|
|
|
|
|
|
|
}}, |
173
|
|
|
|
|
|
|
], |
174
|
|
|
|
|
|
|
}, |
175
|
|
|
|
|
|
|
); |
176
|
|
|
|
|
|
|
|
177
|
0
|
|
|
|
|
|
$self->_check_for_errors('GetFolder', $get_response); |
178
|
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
|
push( @items, $self->_list_folderitems('GetFolder', $get_response)); |
180
|
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
|
return EWS::Folder::ResultSet->new({ |
182
|
|
|
|
|
|
|
items => [ @items ] |
183
|
|
|
|
|
|
|
}); |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
1
|
|
|
1
|
|
6
|
no Moose::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
187
|
|
|
|
|
|
|
1; |
188
|
|
|
|
|
|
|
|