|
20 | 20 | */ |
21 | 21 | package com.inrupt.client.acp; |
22 | 22 |
|
23 | | -import static com.inrupt.client.vocabulary.RDF.type; |
| 23 | +import static com.inrupt.client.acp.AccessControlResource.asIRI; |
24 | 24 |
|
25 | | -import com.inrupt.client.spi.RDFFactory; |
26 | 25 | import com.inrupt.client.vocabulary.ACP; |
| 26 | +import com.inrupt.client.vocabulary.RDF; |
27 | 27 | import com.inrupt.rdf.wrapping.commons.ValueMappings; |
28 | 28 | import com.inrupt.rdf.wrapping.commons.WrapperIRI; |
29 | 29 |
|
30 | 30 | import java.util.Set; |
31 | 31 |
|
32 | 32 | import org.apache.commons.rdf.api.Graph; |
33 | 33 | import org.apache.commons.rdf.api.IRI; |
34 | | -import org.apache.commons.rdf.api.RDF; |
35 | 34 | import org.apache.commons.rdf.api.RDFTerm; |
36 | 35 |
|
| 36 | +/** |
| 37 | + * An AccessControl type for use with Access Control Policies. |
| 38 | + * |
| 39 | + * <p>An access control applies {@link Policy} objects directly to a resource |
| 40 | + * via {@code acp:accessControl} or to container members via {@code acp:memberAccessControl} |
| 41 | + */ |
37 | 42 | public class AccessControl extends WrapperIRI { |
38 | 43 |
|
39 | | - static final RDF rdf = RDFFactory.getInstance(); |
| 44 | + /** |
| 45 | + * Create a new AccessControl. |
| 46 | + * |
| 47 | + * @param identifier the access control identifier |
| 48 | + * @param graph the underlying graph |
| 49 | + */ |
| 50 | + public AccessControl(final RDFTerm identifier, final Graph graph) { |
| 51 | + super(identifier, graph); |
| 52 | + graph.add((IRI) identifier, asIRI(RDF.type), asIRI(ACP.AccessControl)); |
| 53 | + } |
40 | 54 |
|
41 | | - public AccessControl(final RDFTerm original, final Graph graph) { |
42 | | - super(original, graph); |
43 | | - graph.add((IRI) original, rdf.createIRI(type.toString()), rdf.createIRI(ACP.AccessControl.toString())); |
| 55 | + public Set<Policy> apply() { |
| 56 | + return objects(asIRI(ACP.apply), Policy::asResource, ValueMappings.as(Policy.class)); |
44 | 57 | } |
45 | 58 |
|
46 | | - public static IRI asResource(final AccessControl accessControl, final Graph graph) { |
47 | | - graph.add(accessControl, rdf.createIRI(type.toString()), rdf.createIRI(ACP.AccessControl.toString())); |
| 59 | + static IRI asResource(final AccessControl accessControl, final Graph graph) { |
| 60 | + graph.add(accessControl, asIRI(RDF.type), asIRI(ACP.AccessControl)); |
48 | 61 | accessControl.apply().forEach(policy -> { |
49 | | - graph.add(accessControl, rdf.createIRI(ACP.apply.toString()), policy); |
| 62 | + graph.add(accessControl, asIRI(ACP.apply), policy); |
50 | 63 | Policy.asResource(policy, graph); |
51 | 64 | }); |
52 | 65 |
|
53 | 66 | return accessControl; |
54 | 67 | } |
55 | | - |
56 | | - public Set<Policy> apply() { |
57 | | - return objects(rdf.createIRI(ACP.apply.toString()), |
58 | | - Policy::asResource, ValueMappings.as(Policy.class)); |
59 | | - } |
60 | 68 | } |
61 | 69 |
|
0 commit comments