| 1 | package RDF::ACL; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use Data::UUID; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use Error qw(:try); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use RDF::TrineX::Functions -shortcuts; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use RDF::Query; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use RDF::Query::Client; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 5 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 5 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 5 | ▶ | use constant EXCEPTION => 'Error::Simple'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 5 | ▶ | use constant NS_ACL => 'http://www.w3.org/ns/auth/acl#'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 5 | ▶ | use constant NS_RDF => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 5 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 5 | our $VERSION = '0.104'; | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | sub rdf_query | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 19 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rdf_query: called CC=6 SCAR=18.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 19 | my ($query, $model) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 19 | ▶ | my $class = (blessed($model) and $model->isa('RDF::Trine::Model')) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($model) and $model->isa("RDF::Trine::Model")
MC/DC0%0/2
builtin::blessed($model) and $model->isa("RDF::Trine::Model")
builtin::blessed($model)
$model->isa("RDF::Trine::Model")
Truth table33%1/3
A and B
A= builtin::blessed($model)B= $model->isa("RDF::Trine::Model")
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | ? 'RDF::Query' | ||||||||||||||||||||||||||||||||||||||||||
| 27 | : 'RDF::Query::Client'; | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 19 | my $results = $class->new($query)->execute($model); | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 19 | ▶ | if ($results->is_boolean) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 12 | { return $results->get_boolean } | |||||||||||||||||||||||||||||||||||||||||
| 32 | 7 | ▶ | if ($results->is_bindings) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 6 | { return $results } | |||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | ▶ | if ($results->is_graph) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | { my $m = rdf_parse(); $m->add_hashref($results->as_hashref); return $m } | |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | sub new | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 5 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 5 | my $model = shift; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 5 | ▶ | unless (blessed($model) && $model->isa('RDF::Trine::Model')) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($model) and $model->isa("RDF::Trine::Model")
MC/DC0%0/2
builtin::blessed($model) and $model->isa("RDF::Trine::Model")
builtin::blessed($model)
$model->isa("RDF::Trine::Model")
Truth table33%1/3
A and B
A= builtin::blessed($model)B= $model->isa("RDF::Trine::Model")
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | { | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 5 | $model = rdf_parse($model, @_); | |||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 5 | my $self = bless { | |||||||||||||||||||||||||||||||||||||||||
| 51 | 'model' => $model, | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 'i_am' => undef , | ||||||||||||||||||||||||||||||||||||||||||
| 53 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 5 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | sub new_remote | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_remote: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $ep = shift; | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my $self = bless { | |||||||||||||||||||||||||||||||||||||||||
| 64 | 'endpoint' => $ep, | ||||||||||||||||||||||||||||||||||||||||||
| 65 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | sub check | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 12 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check: called CC=8 SCAR=29.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 12 | my ($self, $webid, $item, $level, @datas) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 12 | ▶ | EXCEPTION->throw("Must provide WebID to be checked.") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | unless defined $webid; | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 12 | ▶ | EXCEPTION->throw("Must provide item URI to be checked.") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | unless defined $item; | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 12 | my $model = $self->_union_model(@datas); | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 12 | my $aclvocab = NS_ACL; | |||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 12 | ▶ | if (defined $level) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | { | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 12 | ▶ | if ($level =~ /^(access|read|write|control|append)$/i) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | { | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 12 | $level = $aclvocab . (ucfirst lc $level); | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 12 | my $sparql = <<"SPARQL"; | |||||||||||||||||||||||||||||||||||||||||
| 92 | PREFIX acl: <$aclvocab> | ||||||||||||||||||||||||||||||||||||||||||
| 93 | ASK WHERE { | ||||||||||||||||||||||||||||||||||||||||||
| 94 | { | ||||||||||||||||||||||||||||||||||||||||||
| 95 | { ?authorisation acl:agentClass ?agentclass . <$webid> a ?agentclass . } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | UNION { ?authorisation acl:agent <$webid> . } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | UNION { ?authorisation acl:agentClass <http://xmlns.com/foaf/0.1/Agent> . } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | { | ||||||||||||||||||||||||||||||||||||||||||
| 100 | { ?authorisation acl:accessToClass ?accessclass . <$item> a ?accessclass . } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | UNION { ?authorisation acl:accessTo <$item> . } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | UNION { ?authorisation acl:accessToClass <http://www.w3.org/2000/01/rdf-schema#Resource> . } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | { | ||||||||||||||||||||||||||||||||||||||||||
| 105 | ?authorisation acl:mode <$level> . | ||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | SPARQL | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 12 | return rdf_query($sparql, $model); | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | else | ||||||||||||||||||||||||||||||||||||||||||
| 114 | { | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my $sparql = <<"SPARQL"; | |||||||||||||||||||||||||||||||||||||||||
| 116 | PREFIX acl: <$aclvocab> | ||||||||||||||||||||||||||||||||||||||||||
| 117 | SELECT DISTINCT ?level | ||||||||||||||||||||||||||||||||||||||||||
| 118 | WHERE { | ||||||||||||||||||||||||||||||||||||||||||
| 119 | { | ||||||||||||||||||||||||||||||||||||||||||
| 120 | { ?authorisation acl:agentClass ?agentclass . <$webid> a ?agentclass . } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | UNION { ?authorisation acl:agent <$webid> . } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | UNION { ?authorisation acl:agentClass <http://xmlns.com/foaf/0.1/Agent> . } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | { | ||||||||||||||||||||||||||||||||||||||||||
| 125 | { ?authorisation acl:accessToClass ?accessclass . <$item> a ?accessclass . } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | UNION { ?authorisation acl:accessTo <$item> . } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | UNION { ?authorisation acl:accessToClass <http://www.w3.org/2000/01/rdf-schema#Resource> . } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | { | ||||||||||||||||||||||||||||||||||||||||||
| 130 | ?authorisation acl:mode ?level . | ||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | SPARQL | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $iterator = rdf_query($sparql, $model); | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my @rv; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | while (my $result = $iterator->next) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | { | ||||||||||||||||||||||||||||||||||||||||||
| 139 | push @rv, $result->{'level'}->uri | ||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if blessed($result->{'level'}) && $result->{'level'}->can('uri'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($result->{"level"}) and $result->{"level"}->can("uri")
MC/DC0%0/2
builtin::blessed($result->{"level"}) and $result->{"level"}->can("uri")
builtin::blessed($result->{"level"})
$result->{"level"}->can("uri")
Truth table0%0/3
A and B
A= builtin::blessed($result->{"level"})B= $result->{"level"}->can("uri")
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | return @rv; | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | sub why | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
why: called CC=8 SCAR=22.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 4 | my ($self, $webid, $item, $level, @datas) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 4 | ▶ | EXCEPTION->throw("Must provide WebID to be checked.") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | unless defined $webid; | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 4 | ▶ | EXCEPTION->throw("Must provide item URI to be checked.") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | unless defined $item; | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 4 | ▶ | EXCEPTION->throw("Must provide item URI to be checked.") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | unless defined $item; | ||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 4 | my $model = $self->_union_model(@datas); | |||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 4 | my $aclvocab = NS_ACL; | |||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 4 | ▶ | if ($level =~ /^(access|read|write|control|append)$/i) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | { | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 4 | $level = $aclvocab . (ucfirst lc $level); | |||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 4 | my $sparql = <<"SPARQL"; | |||||||||||||||||||||||||||||||||||||||||
| 169 | PREFIX acl: <$aclvocab> | ||||||||||||||||||||||||||||||||||||||||||
| 170 | SELECT DISTINCT ?authorisation | ||||||||||||||||||||||||||||||||||||||||||
| 171 | WHERE { | ||||||||||||||||||||||||||||||||||||||||||
| 172 | { | ||||||||||||||||||||||||||||||||||||||||||
| 173 | { ?authorisation acl:agentClass ?agentclass . <$webid> a ?agentclass . } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | UNION { ?authorisation acl:agent <$webid> . } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | UNION { ?authorisation acl:agentClass <http://xmlns.com/foaf/0.1/Agent> . } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | { | ||||||||||||||||||||||||||||||||||||||||||
| 178 | { ?authorisation acl:accessToClass ?accessclass . <$item> a ?accessclass . } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | UNION { ?authorisation acl:accessTo <$item> . } | ||||||||||||||||||||||||||||||||||||||||||
| 180 | UNION { ?authorisation acl:accessToClass <http://www.w3.org/2000/01/rdf-schema#Resource> . } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | { | ||||||||||||||||||||||||||||||||||||||||||
| 183 | ?authorisation acl:mode <$level> . | ||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | SPARQL | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 4 | my $iterator = rdf_query($sparql, $model); | |||||||||||||||||||||||||||||||||||||||||
| 189 | 4 | my @rv; | |||||||||||||||||||||||||||||||||||||||||
| 190 | 4 | ▶ | while (my $result = $iterator->next) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | { | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 5 | ▶ | if (blessed($result->{'authorisation'}) && $result->{'authorisation'}->can('uri')) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($result->{"authorisation"}) and $result->{"authorisation"}->can("uri")
MC/DC0%0/2
builtin::blessed($result->{"authorisation"}) and $result->{"authorisation"}->can("uri")
builtin::blessed($result->{"authorisation"})
$result->{"authorisation"}->can("uri")
Truth table33%1/3
A and B
A= builtin::blessed($result->{"authorisation"})B= $result->{"authorisation"}->can("uri")
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | { | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 5 | push @rv, $result->{'authorisation'}->uri; | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | else | ||||||||||||||||||||||||||||||||||||||||||
| 197 | { | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | push @rv, undef; | |||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 4 | return @rv; | |||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | sub allow | ||||||||||||||||||||||||||||||||||||||||||
| 205 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
allow: called CC=21 SCAR=31.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 8 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 8 | ▶ | EXCEPTION->throw("This ACL is not mutable.") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | unless $self->is_mutable; | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | EXCEPTION->throw("Must provide an 'item', 'item_class' or 'container' argument.") | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 8 | ▶ | unless (defined $args{'item'} or defined $args{'item_class'} or defined $args{'container'}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $args{"item"} or defined $args{"item_class"} or defined $args{"container"}
defined $args{"item"} or defined $args{"item_class"}
MC/DC0%0/3
defined $args{"item"} or defined $args{"item_class"} or defined $args{"container"}
defined $args{"item"}
defined $args{"item_class"}
defined $args{"container"}
Truth table75%3/4
A or B or C
A= defined $args{"item"}B= defined $args{"item_class"}C= defined $args{"container"}
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | EXCEPTION->throw("Cannot provide 'container' with an 'item' or 'item_class' argument.") | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 8 | ▶ | if ((defined $args{'container'}) and (defined $args{'item'} or defined $args{'item_class'})); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $args{"container"} and defined $args{"item"} || defined $args{"item_class"}
defined $args{"item"} or defined $args{"item_class"}
MC/DC0%0/3
defined $args{"container"} and defined $args{"item"} || defined $args{"item_class"}
defined $args{"container"}
defined $args{"item"}
defined $args{"item_class"}
Truth table50%2/4
A and B or C
A= defined $args{"container"}B= defined $args{"item"}C= defined $args{"item_class"}
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | $args{'agent_class'} = 'http://xmlns.com/foaf/0.1/Agent' | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 8 | ▶ | unless (defined $args{'webid'} or defined $args{'agent'} or defined $args{'agent_class'}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $args{"webid"} or defined $args{"agent"} or defined $args{"agent_class"}
defined $args{"webid"} or defined $args{"agent"}
MC/DC0%0/3
defined $args{"webid"} or defined $args{"agent"} or defined $args{"agent_class"}
defined $args{"webid"}
defined $args{"agent"}
defined $args{"agent_class"}
Truth table50%2/4
A or B or C
A= defined $args{"webid"}B= defined $args{"agent"}C= defined $args{"agent_class"}
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | $args{'level'} = NS_ACL.'Read' | ||||||||||||||||||||||||||||||||||||||||||
| 221 | 8 | ▶ | unless defined $args{'level'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 8 | my $predicate_map = { | |||||||||||||||||||||||||||||||||||||||||
| 224 | 'level' => NS_ACL . 'mode' , | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 'item' => NS_ACL . 'accessTo' , | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 'item_class' => NS_ACL . 'accessToClass' , | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 'container' => NS_ACL . 'defaultForNew' , | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 'agent' => NS_ACL . 'agent' , | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 'agent_class' => NS_ACL . 'agentClass' , | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 'webid' => NS_ACL . 'agent' , | ||||||||||||||||||||||||||||||||||||||||||
| 231 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 8 | my $data = {}; | |||||||||||||||||||||||||||||||||||||||||
| 234 | 8 | my $authid = $self->_uuid; | |||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 8 | $data->{$authid}->{NS_RDF.'type'} = [ | |||||||||||||||||||||||||||||||||||||||||
| 237 | { 'type'=>'uri', 'value'=>NS_ACL.'Authorization' }, | ||||||||||||||||||||||||||||||||||||||||||
| 238 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 8 | foreach my $p (keys %$predicate_map) | |||||||||||||||||||||||||||||||||||||||||
| 241 | { | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 51 | ▶ | next unless defined $args{$p}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | 24 | ▶ | unless (ref $args{$p} eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | { | ||||||||||||||||||||||||||||||||||||||||||
| 246 | 8 | $args{$p} = [ $args{$p} ]; | |||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 24 | foreach my $val (@{$args{$p}}) | |||||||||||||||||||||||||||||||||||||||||
| 250 | { | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 25 | ▶ | if (defined $self->who_am_i and $p =~ /^(item|container)$/) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $self->who_am_i and $p =~ /^(item|container)$/
MC/DC100%2/2
defined $self->who_am_i and $p =~ /^(item|container)$/
defined $self->who_am_i
$p =~ /^(item|container)$/
Truth table100%3/3
A and B
A= defined $self->who_am_iB= $p =~ /^(item|container)$/
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | { | ||||||||||||||||||||||||||||||||||||||||||
| 253 | 2 | my $control = $self->check($self->who_am_i, $val, 'Control'); | |||||||||||||||||||||||||||||||||||||||||
| 254 | 2 | ▶ | EXCEPTION->throw("WebID <".$self->who_am_i."> does not have access control for resource <$val>.") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | unless $control; | ||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 24 | ▶ | if ($p eq 'level' and $val =~ /^(access|read|write|control|append)$/i) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$p eq "level" and $val =~ /^(access|read|write|control|append)$/i
MC/DC50%1/2
$p eq "level" and $val =~ /^(access|read|write|control|append)$/i
$p eq "level"
$val =~ /^(access|read|write|control|append)$/i
Truth table66%2/3
A and B
A= $p eq "level"B= $val =~ /^(access|read|write|control|append)$/i
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | { | ||||||||||||||||||||||||||||||||||||||||||
| 260 | 9 | $val = NS_ACL . (ucfirst lc $val); | |||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 24 | push @{ $data->{$authid}->{$predicate_map->{$p}} }, | |||||||||||||||||||||||||||||||||||||||||
| 264 | { 'type'=>'uri', 'value'=>$val }; | ||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | 7 | $self->model->add_hashref($data); | |||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 7 | return $authid; | |||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | sub deny | ||||||||||||||||||||||||||||||||||||||||||
| 274 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deny: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 4 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 4 | ▶ | EXCEPTION->throw("This ACL is not mutable.") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | unless $self->is_mutable; | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | 4 | ▶ | if (defined $self->who_am_i) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | { | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 2 | my $aclvocab = NS_ACL; | |||||||||||||||||||||||||||||||||||||||||
| 283 | 2 | my $sparql = <<"SPARQL"; | |||||||||||||||||||||||||||||||||||||||||
| 284 | PREFIX acl: <$aclvocab> | ||||||||||||||||||||||||||||||||||||||||||
| 285 | SELECT DISTINCT ?resource | ||||||||||||||||||||||||||||||||||||||||||
| 286 | WHERE | ||||||||||||||||||||||||||||||||||||||||||
| 287 | { | ||||||||||||||||||||||||||||||||||||||||||
| 288 | { <$id> acl:accessTo ?resource . } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | UNION { <$id> acl:accessTo ?resource . } | ||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | SPARQL | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 2 | my $iterator = rdf_query($sparql, $self->model); | |||||||||||||||||||||||||||||||||||||||||
| 293 | 2 | ▶ | while (my $result = $iterator->next) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | { | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 2 | ▶ | next unless $result->{'resource'}->is_resource; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | 2 | ▶ | next if $self->check($self->who_am_i, $result->{'resource'}->uri, 'Control'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 1 | EXCEPTION->throw("WebID <".$self->who_am_i."> does not have access control for resource <".$result->{'resource'}->uri.">."); | |||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 3 | my $auth = RDF::Trine::Node::Resource->new($id); | |||||||||||||||||||||||||||||||||||||||||
| 303 | 3 | my $count = $self->model->count_statements($auth, undef, undef); | |||||||||||||||||||||||||||||||||||||||||
| 304 | 3 | $self->model->remove_statements($auth, undef, undef); | |||||||||||||||||||||||||||||||||||||||||
| 305 | 3 | return $count; | |||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | sub created | ||||||||||||||||||||||||||||||||||||||||||
| 309 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
created: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 1 | my ($self, $item, $container) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | 1 | ▶ | EXCEPTION->throw("This ACL is not mutable.") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | unless $self->is_mutable; | ||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | 1 | my $aclvocab = NS_ACL; | |||||||||||||||||||||||||||||||||||||||||
| 316 | 1 | my $graph = rdf_query(<<"QUERY", $self->model); | |||||||||||||||||||||||||||||||||||||||||
| 317 | PREFIX acl: <$aclvocab> | ||||||||||||||||||||||||||||||||||||||||||
| 318 | CONSTRUCT { ?auth ?p ?o . } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | WHERE { | ||||||||||||||||||||||||||||||||||||||||||
| 320 | ?auth ?p ?o ; | ||||||||||||||||||||||||||||||||||||||||||
| 321 | acl:defaultForNew <$container> . | ||||||||||||||||||||||||||||||||||||||||||
| 322 | FILTER ( sameTerm(?p, acl:mode) || sameTerm(?p, acl:agent) || sameTerm(?p, acl:agentClass) || sameTerm(?p, <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>) ) | ||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | QUERY | ||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 1 | my $data = $graph->as_hashref; | |||||||||||||||||||||||||||||||||||||||||
| 327 | 1 | my $newdata = {}; | |||||||||||||||||||||||||||||||||||||||||
| 328 | 1 | my @rv; | |||||||||||||||||||||||||||||||||||||||||
| 329 | 1 | foreach my $k (keys %$data) | |||||||||||||||||||||||||||||||||||||||||
| 330 | { | ||||||||||||||||||||||||||||||||||||||||||
| 331 | 1 | my $authid = $self->_uuid; | |||||||||||||||||||||||||||||||||||||||||
| 332 | 1 | $newdata->{$authid} = $data->{$k}; | |||||||||||||||||||||||||||||||||||||||||
| 333 | 1 | $newdata->{$authid}->{$aclvocab.'accessTo'} = [{ | |||||||||||||||||||||||||||||||||||||||||
| 334 | 'type' => 'uri', 'value' => $item | ||||||||||||||||||||||||||||||||||||||||||
| 335 | }]; | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 1 | push @rv, $authid; | |||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 1 | $self->model->add_hashref($newdata); | |||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | 1 | return @rv; | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | sub i_am | ||||||||||||||||||||||||||||||||||||||||||
| 344 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
i_am: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 346 | 3 | my $old = $self->who_am_i; | |||||||||||||||||||||||||||||||||||||||||
| 347 | 3 | $self->{'i_am'} = shift; | |||||||||||||||||||||||||||||||||||||||||
| 348 | 3 | return URI->new($old); | |||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | sub who_am_i | ||||||||||||||||||||||||||||||||||||||||||
| 352 | 39 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
who_am_i: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | 39 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 354 | 39 | return $self->{'i_am'}; | |||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | sub save | ||||||||||||||||||||||||||||||||||||||||||
| 358 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
save: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 1 | my ($self, $fmt, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | 1 | ▶ | EXCEPTION->throw("This ACL is not serialisable.") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | if $self->is_remote; | ||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | 1 | return rdf_string( | |||||||||||||||||||||||||||||||||||||||||
| 365 | $self->model, | ||||||||||||||||||||||||||||||||||||||||||
| 366 | type => $fmt, | ||||||||||||||||||||||||||||||||||||||||||
| 367 | output => $file, | ||||||||||||||||||||||||||||||||||||||||||
| 368 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | sub is_remote | ||||||||||||||||||||||||||||||||||||||||||
| 372 | 17 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_remote: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 17 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 374 | 17 | return defined $self->endpoint; | |||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | sub is_mutable | ||||||||||||||||||||||||||||||||||||||||||
| 378 | 13 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_mutable: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 13 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 380 | 13 | return defined $self->model; | |||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | sub model | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 48 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
model: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 48 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 386 | 48 | return $self->{'model'}; | |||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | sub endpoint | ||||||||||||||||||||||||||||||||||||||||||
| 390 | 17 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
endpoint: called CC=2 SCAR=8.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | 17 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 392 | 17 | ▶ | return undef unless defined $self->{'endpoint'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | return URI->new(''.$self->{'endpoint'}); | |||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | # PRIVATE METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | # * $acl->_uuid | ||||||||||||||||||||||||||||||||||||||||||
| 399 | # | ||||||||||||||||||||||||||||||||||||||||||
| 400 | # Returns a unique throwaway URI. | ||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | sub _uuid | ||||||||||||||||||||||||||||||||||||||||||
| 403 | 9 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_uuid: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | 9 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | $self->{'uuid_generator'} = Data::UUID->new | ||||||||||||||||||||||||||||||||||||||||||
| 407 | 9 | ▶ | unless defined $self->{'uuid_generator'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | 9 | return 'urn:uuid:' . $self->{'uuid_generator'}->create_str; | |||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | # * $acl->_union_model(@graphs) | ||||||||||||||||||||||||||||||||||||||||||
| 413 | # | ||||||||||||||||||||||||||||||||||||||||||
| 414 | # Creates a temporary model that is the union of the ACL | ||||||||||||||||||||||||||||||||||||||||||
| 415 | # object's default data source plus additional graphs. | ||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | sub _union_model | ||||||||||||||||||||||||||||||||||||||||||
| 418 | 16 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_union_model: called CC=6 SCAR=19.6
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | 16 | my ($self, @graphs) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 420 | 16 | my $model; | |||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | 16 | ▶ | if ($self->is_remote) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 423 | { | ||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | $model = $self->endpoint; | |||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | EXCEPTION->throw("Cannot provide additional data to consider for remote ACL.") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 427 | if @graphs; | ||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||
| 429 | elsif (@graphs) | ||||||||||||||||||||||||||||||||||||||||||
| 430 | { | ||||||||||||||||||||||||||||||||||||||||||
| 431 | 5 | $model = rdf_parse($self->model, model => RDF::TrineX::Functions::model()); | |||||||||||||||||||||||||||||||||||||||||
| 432 | 5 | foreach my $given (@graphs) | |||||||||||||||||||||||||||||||||||||||||
| 433 | { | ||||||||||||||||||||||||||||||||||||||||||
| 434 | 10 | ▶ | my @given = ref($given) eq 'ARRAY' ? @$given : $given; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | 10 | rdf_parse(@given, model => $model); | |||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 438 | else | ||||||||||||||||||||||||||||||||||||||||||
| 439 | { | ||||||||||||||||||||||||||||||||||||||||||
| 440 | 11 | $model = $self->model; | |||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | 16 | return $model; | |||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | 5 | __PACKAGE__ | |||||||||||||||||||||||||||||||||||||||||
| 447 | __END__ | ||||||||||||||||||||||||||||||||||||||||||