| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package RDF::AllegroGraph::Server4; |
|
2
|
|
|
|
|
|
|
|
|
3
|
15
|
|
|
15
|
|
88
|
use strict; |
|
|
15
|
|
|
|
|
34
|
|
|
|
15
|
|
|
|
|
580
|
|
|
4
|
15
|
|
|
15
|
|
82
|
use warnings; |
|
|
15
|
|
|
|
|
29
|
|
|
|
15
|
|
|
|
|
488
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
15
|
|
|
15
|
|
78
|
use base qw(RDF::AllegroGraph::Server); |
|
|
15
|
|
|
|
|
30
|
|
|
|
15
|
|
|
|
|
1453
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
15
|
|
|
15
|
|
2491
|
use JSON; |
|
|
15
|
|
|
|
|
34512
|
|
|
|
15
|
|
|
|
|
184
|
|
|
9
|
15
|
|
|
15
|
|
1958
|
use Data::Dumper; |
|
|
15
|
|
|
|
|
33
|
|
|
|
15
|
|
|
|
|
1030
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
15
|
|
|
15
|
|
9518
|
use RDF::AllegroGraph::Catalog4; |
|
|
15
|
|
|
|
|
119
|
|
|
|
15
|
|
|
|
|
745
|
|
|
12
|
15
|
|
|
15
|
|
88
|
use HTTP::Request::Common; |
|
|
15
|
|
|
|
|
34
|
|
|
|
15
|
|
|
|
|
935
|
|
|
13
|
15
|
|
|
15
|
|
145
|
use HTTP::Status; |
|
|
15
|
|
|
|
|
30
|
|
|
|
15
|
|
|
|
|
7995
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=pod |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
RDF::AllegroGraph::Server4 - AllegroGraph server handle for v4 AG servers |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 INTERFACE |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 Methods |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=over |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=item B |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
I<@cats> = I<$server>->catalogs |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
This method lists the catalogs available on the remote server. The result is a list of relative |
|
32
|
|
|
|
|
|
|
paths. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub catalogs { |
|
37
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
38
|
0
|
|
|
|
|
|
my $resp = $self->{ua}->get ($self->{ADDRESS} . '/catalogs'); |
|
39
|
0
|
0
|
|
|
|
|
die "protocol error: ".$resp->status_line unless $resp->is_success; |
|
40
|
0
|
|
|
|
|
|
my $cats = from_json ($resp->content); |
|
41
|
|
|
|
|
|
|
return |
|
42
|
0
|
0
|
|
|
|
|
map { $_ => RDF::AllegroGraph::Catalog4->new (NAME => $_, SERVER => $self) } |
|
|
0
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
map { $_ =~ m{/} ? $_ : "/$_" } # canonicalize everything to look /.... |
|
44
|
0
|
|
|
|
|
|
map { $_->{id} } # look only at the id component (the other is the uri) |
|
45
|
|
|
|
|
|
|
@$cats; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=pod |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item B |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
This method returns a handle to a named catalog. If it already exists on the |
|
53
|
|
|
|
|
|
|
server, the handle is simply returned. Otherwise - if the C is set to C - |
|
54
|
|
|
|
|
|
|
a new catalog will be created. Otherwise an exception is raised. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
|
57
|
|
|
|
|
|
|
|
|
58
|
15
|
|
|
15
|
|
138
|
use Fcntl; |
|
|
15
|
|
|
|
|
37
|
|
|
|
15
|
|
|
|
|
6304
|
|
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub catalog { |
|
61
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
62
|
0
|
|
|
|
|
|
my $id = shift; |
|
63
|
0
|
|
0
|
|
|
|
my $mode = shift || O_RDONLY; |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my %cats = $self->catalogs; # let's have a look first, what's there... |
|
66
|
0
|
0
|
|
|
|
|
if ($cats{$id}) { |
|
|
|
0
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
return $cats{$id}; |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} elsif ($mode == O_CREAT) { |
|
70
|
0
|
0
|
|
|
|
|
if ($id =~ m{^(/[^/]+)$}) { |
|
71
|
0
|
|
|
|
|
|
my $uri = $self->{ADDRESS} . '/catalogs' . $1; |
|
72
|
15
|
|
|
15
|
|
87
|
use HTTP::Request; |
|
|
15
|
|
|
|
|
34
|
|
|
|
15
|
|
|
|
|
14301
|
|
|
73
|
0
|
|
|
|
|
|
my $requ = HTTP::Request->new (PUT => $uri); |
|
74
|
0
|
|
|
|
|
|
my $resp = $self->{ua}->request ($requ); |
|
75
|
0
|
0
|
|
|
|
|
die "protocol error: ".$resp->status_line unless $resp->code == RC_NO_CONTENT; |
|
76
|
0
|
|
|
|
|
|
return RDF::AllegroGraph::Catalog4->new (NAME => $id, SERVER => $self); |
|
77
|
|
|
|
|
|
|
} else { |
|
78
|
0
|
|
|
|
|
|
die "cannot handle catalog id '$id'"; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
} else { |
|
82
|
0
|
|
|
|
|
|
die "cannot open catalog '$id' (does not exist on the server"; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=pod |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item B |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
I<%models> = I<$server>->models |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This method lists all models available on the server. Returned is a hash reference. The keys are the |
|
93
|
|
|
|
|
|
|
model identifiers, all of the form C. The values are repository objects. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub models { |
|
98
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
99
|
0
|
|
|
|
|
|
my %cats = $self->catalogs; # find all catalogs |
|
100
|
|
|
|
|
|
|
return |
|
101
|
0
|
|
|
|
|
|
map { $_->id => $_ } # generate a hash, because the id is a good key |
|
|
0
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
map { $_->repositories } # generate from the catalog all its repos |
|
103
|
|
|
|
|
|
|
values %cats; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=pod |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item B |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
I<$server>->model (I<$mod_id>, I => I, ...) |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This method tries to find an repository in a certain catalog. This I is always of the form |
|
113
|
|
|
|
|
|
|
C. The following options are understood: |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=over |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item C (default: C) |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This POSIX file mode determines how the model will be opened. |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=back |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
If the model already does exist, then an L object will be |
|
124
|
|
|
|
|
|
|
returned. If the specified catalog does not exist, then a C exception will be raised. |
|
125
|
|
|
|
|
|
|
Otherwise, if the repository there does not exist and the C option is C, then it will |
|
126
|
|
|
|
|
|
|
be generated. Otherwise an exception C will be raised. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub model { |
|
132
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
133
|
0
|
|
|
|
|
|
my $id = shift; |
|
134
|
0
|
|
|
|
|
|
my %options = @_; |
|
135
|
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
my ($catid, $repoid); # we will have to figure them out |
|
137
|
0
|
0
|
|
|
|
|
if (($catid, $repoid) = ($id =~ m|^(/.+?)(/.+)$|)) { |
|
|
|
0
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
} elsif ($id =~ m|^/[^/]+$|) { |
|
139
|
0
|
|
|
|
|
|
($catid, $repoid) = ('/', $id); |
|
140
|
|
|
|
|
|
|
} else { |
|
141
|
0
|
|
|
|
|
|
die "id must be of the form /somecat/somerep or /somerep"; |
|
142
|
|
|
|
|
|
|
} |
|
143
|
0
|
|
|
|
|
|
my %catalogs = $self->catalogs; |
|
144
|
0
|
0
|
|
|
|
|
die "no catalog '$catid'" unless $catalogs{$catid}; |
|
145
|
|
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
return $catalogs{$catid}->repository ($id, $options{mode}); |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=pod |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item B (since v0.06) |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This method triggers the server to reconsult the configuration. As it is only available to the |
|
154
|
|
|
|
|
|
|
I user, lesser accounts will fail at that. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub reconfigure { |
|
159
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
160
|
0
|
|
|
|
|
|
my $resp = $self->{ua}->post ($self->{ADDRESS} . '/reconfigure'); |
|
161
|
0
|
0
|
|
|
|
|
die "protocol error: ".$resp->status_line unless $resp->is_success; |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=pod |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item B (since v0.06) |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
This method triggers the server to reopen the logfile (say for logfile rotation). As it is only available to the |
|
169
|
|
|
|
|
|
|
I user, lesser accounts will fail at that. |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
B: Since you will not be able to move the log file via this API, this is a somewhat strange |
|
172
|
|
|
|
|
|
|
function. |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=cut |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub reopen_log { |
|
177
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
178
|
0
|
|
|
|
|
|
my $resp = $self->{ua}->post ($self->{ADDRESS} . '/reopenLog'); |
|
179
|
0
|
0
|
|
|
|
|
die "protocol error: ".$resp->status_line unless $resp->is_success; |
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=pod |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=back |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 AUTHOR |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Robert Barta, C<< >> |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Copyright 20(09|11) Robert Barta, all rights reserved. |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl |
|
195
|
|
|
|
|
|
|
itself. |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
L, L |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=cut |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
1; |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
__END__ |