line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package RDF::AllegroGraph::Catalog3; |
2
|
|
|
|
|
|
|
|
3
|
15
|
|
|
15
|
|
84
|
use strict; |
|
15
|
|
|
|
|
31
|
|
|
15
|
|
|
|
|
611
|
|
4
|
15
|
|
|
15
|
|
115
|
use warnings; |
|
15
|
|
|
|
|
29
|
|
|
15
|
|
|
|
|
622
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require Exporter; |
7
|
15
|
|
|
15
|
|
81
|
use base qw(RDF::AllegroGraph::Catalog); |
|
15
|
|
|
|
|
52
|
|
|
15
|
|
|
|
|
8139
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=pod |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
RDF::AllegroGraph::Catalog3 - AllegroGraph catalog handle for AGv3 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# implementation of RDF::AllegroGraph::Catalog |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
15
|
|
|
15
|
|
12091
|
use RDF::AllegroGraph::Repository3; |
|
15
|
|
|
|
|
59
|
|
|
15
|
|
|
|
|
1121
|
|
22
|
15
|
|
|
15
|
|
15370
|
use RDF::AllegroGraph::Utils; |
|
15
|
|
|
|
|
45
|
|
|
15
|
|
|
|
|
738
|
|
23
|
|
|
|
|
|
|
|
24
|
15
|
|
|
15
|
|
93
|
use JSON; |
|
15
|
|
|
|
|
33
|
|
|
15
|
|
|
|
|
123
|
|
25
|
15
|
|
|
15
|
|
2189
|
use HTTP::Status; |
|
15
|
|
|
|
|
33
|
|
|
15
|
|
|
|
|
6053
|
|
26
|
15
|
|
|
15
|
|
95
|
use Fcntl; |
|
15
|
|
|
|
|
29
|
|
|
15
|
|
|
|
|
5720
|
|
27
|
15
|
|
|
15
|
|
91
|
use Data::Dumper; |
|
15
|
|
|
|
|
26
|
|
|
15
|
|
|
|
|
5300
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new { |
30
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
31
|
0
|
|
|
|
|
|
my %options = @_; |
32
|
0
|
0
|
|
|
|
|
die "no NAME" unless $options{NAME}; |
33
|
0
|
0
|
|
|
|
|
die "no SERVER" unless $options{SERVER}; |
34
|
0
|
|
|
|
|
|
return bless \%options, $class; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub repositories { |
38
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
39
|
0
|
|
|
|
|
|
my $resp = $self->{SERVER}->{ua}->get ($self->{SERVER}->{ADDRESS} . '/catalogs' . $self->{NAME} . '/repositories'); |
40
|
0
|
0
|
|
|
|
|
die "protocol error: ".$resp->status_line unless $resp->is_success; |
41
|
0
|
|
|
|
|
|
my $repo = from_json ($resp->content); |
42
|
|
|
|
|
|
|
return |
43
|
0
|
|
|
|
|
|
map { RDF::AllegroGraph::Repository3->new (%$_, CATALOG => $self) } |
|
0
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
map { RDF::AllegroGraph::Utils::_hash_to_perl ($_) } |
45
|
|
|
|
|
|
|
@$repo; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub repository { |
49
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
50
|
0
|
|
|
|
|
|
my $id = shift; |
51
|
0
|
|
0
|
|
|
|
my $mode = shift || O_RDONLY; |
52
|
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
if (my ($repo) = grep { $_->id eq $id } $self->repositories) { |
|
0
|
0
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
return $repo; |
55
|
|
|
|
|
|
|
} elsif ($mode == O_CREAT) { |
56
|
0
|
|
|
|
|
|
(my $repoid = $id) =~ s|^/.+?/|/|; # get rid of the catalog name |
57
|
15
|
|
|
15
|
|
96
|
use HTTP::Request; |
|
15
|
|
|
|
|
40
|
|
|
15
|
|
|
|
|
6210
|
|
58
|
0
|
|
|
|
|
|
my $requ = HTTP::Request->new (PUT => $self->{SERVER}->{ADDRESS} . '/catalogs' . $self->{NAME} . '/repositories' . $repoid); |
59
|
0
|
|
|
|
|
|
my $resp = $self->{SERVER}->{ua}->request ($requ); |
60
|
0
|
0
|
|
|
|
|
die "protocol error: ".$resp->status_line unless $resp->code == RC_NO_CONTENT; |
61
|
0
|
|
|
|
|
|
return $self->repository ($id); # recursive, but without forced create |
62
|
|
|
|
|
|
|
} else { |
63
|
0
|
|
|
|
|
|
die "cannot open repository '$id'"; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub version { |
68
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
69
|
0
|
|
|
|
|
|
my $resp = $self->{SERVER}->{ua}->get ($self->{SERVER}->{ADDRESS} . '/catalogs' . $self->{NAME} . '/AGVersion'); |
70
|
0
|
0
|
|
|
|
|
die "protocol error: ".$resp->status_line unless $resp->is_success; |
71
|
0
|
|
0
|
|
|
|
return $resp->content =~ m/^"?(.*?)"?$/ && $1; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub protocol { |
75
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $resp = $self->{SERVER}->{ua}->get ($self->{SERVER}->{ADDRESS} . '/catalogs' . $self->{NAME} . '/protocol'); |
78
|
0
|
0
|
|
|
|
|
die "protocol error: ".$resp->status_line unless $resp->is_success; |
79
|
0
|
|
0
|
|
|
|
return $resp->content =~ m/^"?(.*?)"?$/ && $1; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |