本文整理汇总了Java中org.trellisldp.vocabulary.Trellis类的典型用法代码示例。如果您正苦于以下问题:Java Trellis类的具体用法?Java Trellis怎么用?Java Trellis使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Trellis类属于org.trellisldp.vocabulary包,在下文中一共展示了Trellis类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: checkModelConstraints
import org.trellisldp.vocabulary.Trellis; //导入依赖的package包/类
private Function<Triple, Stream<ConstraintViolation>> checkModelConstraints(final IRI model, final String domain) {
requireNonNull(model, "The interaction model must not be null!");
return triple -> {
final Stream.Builder<ConstraintViolation> builder = Stream.builder();
of(triple).filter(propertyFilter(model)).map(t -> new ConstraintViolation(Trellis.InvalidProperty, t))
.ifPresent(builder::accept);
of(triple).filter(typeFilter).map(t -> new ConstraintViolation(Trellis.InvalidType, t))
.ifPresent(builder::accept);
of(triple).filter(uriRangeFilter).map(t -> new ConstraintViolation(Trellis.InvalidRange, t))
.ifPresent(builder::accept);
of(triple).filter(inDomainRangeFilter(domain)).map(t -> new ConstraintViolation(Trellis.InvalidRange, t))
.ifPresent(builder::accept);
return builder.build();
};
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:21,代码来源:LdpConstraints.java
示例2: testExport
import org.trellisldp.vocabulary.Trellis; //导入依赖的package包/类
@Test
public void testExport() {
final Set<IRI> graphs = new HashSet<>();
graphs.add(Trellis.PreferAccessControl);
graphs.add(Trellis.PreferAudit);
graphs.add(Trellis.PreferServerManaged);
graphs.add(Trellis.PreferUserManaged);
when(mockResource.getIdentifier()).thenReturn(existing);
when(mockResource.stream(eq(graphs))).thenAnswer(inv ->
Stream.of(rdf.createTriple(existing, DC.title, rdf.createLiteral("A title"))));
when(mockResourceService.get(eq(existing))).thenReturn(of(mockResource));
final List<Quad> export = mockResourceService.export(graphs).collect(toList());
assertEquals(1L, export.size());
assertEquals(of(existing), export.get(0).getGraphName());
assertEquals(existing, export.get(0).getSubject());
assertEquals(DC.title, export.get(0).getPredicate());
assertEquals(rdf.createLiteral("A title"), export.get(0).getObject());
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:20,代码来源:ResourceServiceTest.java
示例3: testInvalidInsertedContentRelation
import org.trellisldp.vocabulary.Trellis; //导入依赖的package包/类
@Test
public void testInvalidInsertedContentRelation() {
models.stream().forEach(type -> {
final String subject = domain + "foo";
final Optional<ConstraintViolation> res = svc.constrainedBy(type, domain, asGraph("/hasInsertedContent.ttl",
subject)).findFirst();
if (type.equals(LDP.IndirectContainer) || type.equals(LDP.DirectContainer)) {
assertFalse(res.isPresent());
} else {
assertTrue(res.isPresent());
res.ifPresent(violation -> {
assertEquals(Trellis.InvalidProperty, violation.getConstraint());
assertTrue(violation.getTriples().contains(
rdf.createTriple(rdf.createIRI(subject), LDP.hasMemberRelation, DC.isPartOf)));
});
}
});
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:19,代码来源:LdpConstraintsTest.java
示例4: testInvalidLdpProps
import org.trellisldp.vocabulary.Trellis; //导入依赖的package包/类
@Test
public void testInvalidLdpProps() {
models.stream().forEach(type -> {
final String subject = domain + "foo";
final Optional<ConstraintViolation> res = svc.constrainedBy(type, domain, asGraph("/basicContainer.ttl",
subject)).findFirst();
if (type.equals(LDP.DirectContainer) || type.equals(LDP.IndirectContainer)) {
assertFalse(res.isPresent());
} else {
assertTrue(res.isPresent());
res.ifPresent(violation -> {
assertEquals(Trellis.InvalidProperty, violation.getConstraint());
assertTrue(violation.getTriples().contains(
rdf.createTriple(rdf.createIRI(subject), LDP.hasMemberRelation, DC.isPartOf)));
});
}
});
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:19,代码来源:LdpConstraintsTest.java
示例5: getAccessModes
import org.trellisldp.vocabulary.Trellis; //导入依赖的package包/类
@Override
public Set<IRI> getAccessModes(final IRI identifier, final Session session) {
requireNonNull(session, "A non-null session must be provided!");
if (Trellis.AdministratorAgent.equals(session.getAgent())) {
return unmodifiableSet(allModes);
}
if (nonNull(cache)) {
final Set<IRI> cachedModes = cache.get(getCacheKey(identifier, session.getAgent()), k ->
getAuthz(identifier, session.getAgent()));
final Optional<IRI> delegate = session.getDelegatedBy();
if (delegate.isPresent()) {
cachedModes.retainAll(cache.get(getCacheKey(identifier, delegate.get()), k ->
getAuthz(identifier, delegate.get())));
}
return cachedModes;
}
final Set<IRI> modes = getAuthz(identifier, session.getAgent());
session.getDelegatedBy().ifPresent(delegate -> modes.retainAll(getAuthz(identifier, delegate)));
return modes;
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:24,代码来源:WebACService.java
示例6: testAdmin1
import org.trellisldp.vocabulary.Trellis; //导入依赖的package包/类
@Test
public void testAdmin1() {
when(mockSession.getAgent()).thenReturn(Trellis.AdministratorAgent);
assertTrue(testService.getAccessModes(nonexistentIRI, mockSession).contains(ACL.Append));
assertTrue(testService.getAccessModes(resourceIRI, mockSession).contains(ACL.Append));
assertTrue(testService.getAccessModes(childIRI, mockSession).contains(ACL.Append));
assertTrue(testService.getAccessModes(parentIRI, mockSession).contains(ACL.Append));
assertTrue(testService.getAccessModes(rootIRI, mockSession).contains(ACL.Append));
assertTrue(testService.getAccessModes(nonexistentIRI, mockSession).contains(ACL.Control));
assertTrue(testService.getAccessModes(resourceIRI, mockSession).contains(ACL.Control));
assertTrue(testService.getAccessModes(childIRI, mockSession).contains(ACL.Control));
assertTrue(testService.getAccessModes(parentIRI, mockSession).contains(ACL.Control));
assertTrue(testService.getAccessModes(rootIRI, mockSession).contains(ACL.Control));
assertTrue(testService.getAccessModes(nonexistentIRI, mockSession).contains(ACL.Write));
assertTrue(testService.getAccessModes(resourceIRI, mockSession).contains(ACL.Write));
assertTrue(testService.getAccessModes(childIRI, mockSession).contains(ACL.Write));
assertTrue(testService.getAccessModes(parentIRI, mockSession).contains(ACL.Write));
assertTrue(testService.getAccessModes(rootIRI, mockSession).contains(ACL.Write));
assertTrue(testService.getAccessModes(nonexistentIRI, mockSession).contains(ACL.Read));
assertTrue(testService.getAccessModes(resourceIRI, mockSession).contains(ACL.Read));
assertTrue(testService.getAccessModes(childIRI, mockSession).contains(ACL.Read));
assertTrue(testService.getAccessModes(parentIRI, mockSession).contains(ACL.Read));
assertTrue(testService.getAccessModes(rootIRI, mockSession).contains(ACL.Read));
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:25,代码来源:WebACServiceTest.java
示例7: getAllAuthorizationsFor
import org.trellisldp.vocabulary.Trellis; //导入依赖的package包/类
private Stream<Authorization> getAllAuthorizationsFor(final Resource resource, final Boolean top) {
LOGGER.debug("Checking ACL for: {}", resource.getIdentifier());
final Optional<IRI> parent = resourceService.getContainer(resource.getIdentifier());
if (resource.hasAcl()) {
try (final Graph graph = resource.stream(Trellis.PreferAccessControl).collect(toGraph())) {
final List<Authorization> authorizations = getAuthorizationFromGraph(graph);
if (!top && authorizations.stream().anyMatch(getInheritedAuth(resource.getIdentifier()))) {
return authorizations.stream().filter(getInheritedAuth(resource.getIdentifier()));
}
return authorizations.stream().filter(getAccessToAuth(resource.getIdentifier()));
} catch (final Exception ex) {
throw new RuntimeRepositoryException(ex);
}
}
// Nothing here, check the parent
LOGGER.debug("No ACL for {}; looking up parent resource", resource.getIdentifier());
return parent.flatMap(resourceService::get).map(res -> getAllAuthorizationsFor(res, false))
.orElseGet(Stream::empty);
}
开发者ID:trellis-ldp-archive,项目名称:trellis-webac,代码行数:21,代码来源:WebACService.java
示例8: testEntity
import org.trellisldp.vocabulary.Trellis; //导入依赖的package包/类
@Test
public void testEntity() {
final Triple triple = rdf.createTriple(identifier, RDFS.label, rdf.createLiteral("A label"));
when(mockResource.stream(eq(Trellis.PreferUserManaged))).thenAnswer(x -> of(triple));
when(mockLdpRequest.getPath()).thenReturn("resource");
final PatchHandler patchHandler = new PatchHandler(mockLdpRequest, insert,
mockResourceService, mockIoService, null);
final Response res = patchHandler.updateResource(mockResource).build();
assertEquals(NO_CONTENT, res.getStatusInfo());
verify(mockIoService).update(any(Graph.class), eq(insert), eq(identifier.getIRIString()));
verify(mockResourceService).put(eq(identifier), eq(LDP.RDFSource), any(Dataset.class));
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:18,代码来源:PatchHandlerTest.java
示例9: setUp
import org.trellisldp.vocabulary.Trellis; //导入依赖的package包/类
@BeforeEach
public void setUp() throws JMSException {
initMocks(this);
when(mockEvent.getTarget()).thenReturn(of(rdf.createIRI("trellis:repository/resource")));
when(mockEvent.getAgents()).thenReturn(singleton(Trellis.AdministratorAgent));
when(mockEvent.getCreated()).thenReturn(time);
when(mockEvent.getIdentifier()).thenReturn(rdf.createIRI("urn:test"));
when(mockEvent.getTypes()).thenReturn(singleton(AS.Update));
when(mockEvent.getTargetTypes()).thenReturn(singleton(LDP.RDFSource));
when(mockEvent.getInbox()).thenReturn(empty());
when(mockConnection.createSession(anyBoolean(), eq(AUTO_ACKNOWLEDGE))).thenReturn(mockSession);
when(mockSession.createQueue(eq(queueName))).thenReturn(mockQueue);
when(mockSession.createTextMessage(anyString())).thenReturn(mockMessage);
when(mockSession.createProducer(any(Queue.class))).thenReturn(mockProducer);
doNothing().when(mockProducer).send(any(TextMessage.class));
}
开发者ID:trellis-ldp,项目名称:trellis-jms,代码行数:19,代码来源:JmsPublisherTest.java
示例10: quadHandler
import org.trellisldp.vocabulary.Trellis; //导入依赖的package包/类
private Consumer<Quad> quadHandler(final String prefix) {
return quad -> {
if (quad.getGraphName().equals(of(LDP.PreferContainment)) ||
quad.getGraphName().equals(of(LDP.PreferMembership))) {
hasContainerModificationQuads = true;
} else {
hasModificationQuads = true;
}
if (prefix.equals("D")) {
patchDeleted.add(quad);
} else if (prefix.equals("A") && !deleted.contains(quad)) {
if (quad.getGraphName().filter(Trellis.PreferServerManaged::equals).isPresent() &&
quad.getPredicate().equals(type)) {
interactionModel = (IRI) quad.getObject();
}
patchAdded.add(quad);
}
};
}
开发者ID:trellis-ldp-archive,项目名称:trellis-rosid-file,代码行数:20,代码来源:RDFPatch.java
示例11: maybeEmitModifiedQuad
import org.trellisldp.vocabulary.Trellis; //导入依赖的package包/类
private void maybeEmitModifiedQuad(final Instant moment) {
if (!hasModified && !time.isBefore(moment.truncatedTo(MILLIS))) {
if (shouldSetModificationForContainers()) {
momentIfContainer = moment;
}
if (shouldSetModificationForNonContainers()) {
momentIfNotContainer = moment;
}
if (LDP.RDFSource.equals(interactionModel) || LDP.NonRDFSource.equals(interactionModel)) {
if (nonNull(momentIfNotContainer)) {
patchAdded.add(rdf.createQuad(Trellis.PreferServerManaged, identifier, DC.modified,
rdf.createLiteral(momentIfNotContainer.toString(), XSD.dateTime)));
hasModified = true;
}
} else if (nonNull(interactionModel) && nonNull(momentIfContainer)) {
patchAdded.add(rdf.createQuad(Trellis.PreferServerManaged, identifier, DC.modified,
rdf.createLiteral(momentIfContainer.toString(), XSD.dateTime)));
hasModified = true;
}
}
}
开发者ID:trellis-ldp-archive,项目名称:trellis-rosid-file,代码行数:22,代码来源:RDFPatch.java
示例12: testWriteResource
import org.trellisldp.vocabulary.Trellis; //导入依赖的package包/类
@Test
public void testWriteResource() {
final Dataset data = rdf.createDataset();
data.add(rdf.createQuad(Trellis.PreferUserManaged, testResource, DC.title, rdf.createLiteral("A title")));
data.add(rdf.createQuad(Trellis.PreferServerManaged, testResource, type, LDP.RDFSource));
assertFalse(service.get(testResource).isPresent());
assertFalse(service.get(testResource, now()).isPresent());
assertTrue(service.put(testResource, data));
final Optional<Resource> res = service.get(testResource, now());
assertTrue(res.isPresent());
res.ifPresent(r -> {
assertEquals(LDP.RDFSource, r.getInteractionModel());
assertEquals(testResource, r.getIdentifier());
assertTrue(r.stream().anyMatch(q -> q.getPredicate().equals(DC.title)));
assertTrue(r.getModified().isBefore(now()));
});
final Optional<Resource> res2 = service.get(testResource);
assertTrue(res2.isPresent());
res2.ifPresent(r -> {
assertEquals(LDP.RDFSource, r.getInteractionModel());
assertEquals(testResource, r.getIdentifier());
assertTrue(r.stream().anyMatch(q -> q.getPredicate().equals(DC.title)));
assertTrue(r.getModified().isBefore(now()));
});
}
开发者ID:trellis-ldp-archive,项目名称:trellis-rosid-file,代码行数:27,代码来源:FileResourceServiceTest.java
示例13: testAuthFilterNotSecure
import org.trellisldp.vocabulary.Trellis; //导入依赖的package包/类
@Test
public void testAuthFilterNotSecure() throws IOException {
final MultivaluedMap<String, String> headers = new MultivaluedHashMap<>();
when(mockContext.getHeaders()).thenReturn(headers);
when(mockContext.getSecurityContext()).thenReturn(mockSecurityContext);
when(mockSecurityContext.isSecure()).thenReturn(false);
final AuthFilter<String, Principal> filter = new AnonymousAuthFilter.Builder()
.setAuthenticator(new AnonymousAuthenticator()).buildAuthFilter();
filter.filter(mockContext);
verify(mockContext).setSecurityContext(securityCaptor.capture());
assertEquals(Trellis.AnonymousAgent.getIRIString(), securityCaptor.getValue().getUserPrincipal().getName());
assertFalse(securityCaptor.getValue().isUserInRole("role"));
assertFalse(securityCaptor.getValue().isSecure());
assertEquals("NONE", securityCaptor.getValue().getAuthenticationScheme());
}
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:20,代码来源:AnonymousAuthFilterTest.java
示例14: testWriteResource
import org.trellisldp.vocabulary.Trellis; //导入依赖的package包/类
@Test
public void testWriteResource() throws Exception {
final Dataset data = rdf.createDataset();
data.add(rdf.createQuad(Trellis.PreferUserManaged, testResource, DC.title, rdf.createLiteral("A title")));
data.add(rdf.createQuad(Trellis.PreferServerManaged, testResource, type, LDP.RDFSource));
assertFalse(service.get(testResource).isPresent());
assertFalse(service.get(testResource, now()).isPresent());
assertTrue(service.put(testResource, LDP.RDFSource, data).get());
final Optional<Resource> res = service.get(testResource, now());
assertTrue(res.isPresent());
res.ifPresent(r -> {
assertEquals(LDP.RDFSource, r.getInteractionModel());
assertEquals(testResource, r.getIdentifier());
assertTrue(r.stream().anyMatch(q -> q.getPredicate().equals(DC.title)));
assertTrue(r.getModified().isBefore(now()));
});
final Optional<Resource> res2 = service.get(testResource);
assertTrue(res2.isPresent());
res2.ifPresent(r -> {
assertEquals(LDP.RDFSource, r.getInteractionModel());
assertEquals(testResource, r.getIdentifier());
assertTrue(r.stream().anyMatch(q -> q.getPredicate().equals(DC.title)));
assertTrue(r.getModified().isBefore(now()));
});
}
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:27,代码来源:FileResourceServiceTest.java
示例15: testAuthFilterSecure
import org.trellisldp.vocabulary.Trellis; //导入依赖的package包/类
@Test
public void testAuthFilterSecure() throws IOException {
final MultivaluedMap<String, String> headers = new MultivaluedHashMap<>();
when(mockContext.getHeaders()).thenReturn(headers);
when(mockContext.getSecurityContext()).thenReturn(mockSecurityContext);
when(mockSecurityContext.isSecure()).thenReturn(true);
final AuthFilter<String, Principal> filter = new AnonymousAuthFilter.Builder()
.setAuthenticator(new AnonymousAuthenticator()).buildAuthFilter();
filter.filter(mockContext);
verify(mockContext).setSecurityContext(securityCaptor.capture());
assertEquals(Trellis.AnonymousAgent.getIRIString(), securityCaptor.getValue().getUserPrincipal().getName());
assertFalse(securityCaptor.getValue().isUserInRole("role"));
assertTrue(securityCaptor.getValue().isSecure());
assertEquals("NONE", securityCaptor.getValue().getAuthenticationScheme());
}
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:20,代码来源:AnonymousAuthFilterTest.java
示例16: testInvalidAccessControlProperty
import org.trellisldp.vocabulary.Trellis; //导入依赖的package包/类
@Test
public void testInvalidAccessControlProperty() {
models.stream().forEach(type -> {
final String subject = domain + "foo";
final Optional<ConstraintViolation> res = svc.constrainedBy(type, domain,
asGraph("/hasAccessControlTriples.ttl", subject))
.filter(v -> v.getConstraint().equals(Trellis.InvalidProperty)).findFirst();
assertTrue(res.isPresent());
res.ifPresent(violation -> {
assertEquals(Trellis.InvalidProperty, violation.getConstraint());
assertTrue(violation.getTriples().contains(
rdf.createTriple(rdf.createIRI(subject), ACL.accessControl, rdf.createIRI(domain + "bar"))));
});
});
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:16,代码来源:LdpConstraintsTest.java
示例17: testWriteData
import org.trellisldp.vocabulary.Trellis; //导入依赖的package包/类
@Test
public void testWriteData() {
final Optional<Resource> res = VersionedResource.find(directory, "trellis:repository/versioned", MAX);
assertTrue(res.isPresent());
assertEquals(7L, res.get().stream().count());
assertTrue(VersionedResource.write(directory, empty(), of(rdf.createQuad(Trellis.PreferUserManaged,
rdf.createIRI("trellis:repository/versioned"), RDFS.label,
rdf.createLiteral("Another label"))), now()));
assertEquals(8L, res.get().stream().count());
}
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:11,代码来源:VersionedResourceTest.java
示例18: testInvalidType
import org.trellisldp.vocabulary.Trellis; //导入依赖的package包/类
@Test
public void testInvalidType() {
models.stream().forEach(ldpType -> {
final String subject = domain + "foo";
final Optional<ConstraintViolation> res = svc.constrainedBy(ldpType, domain, asGraph("/withLdpType.ttl",
subject)).filter(v -> Trellis.InvalidType.equals(v.getConstraint())).findFirst();
assertTrue(res.isPresent());
res.ifPresent(violation -> {
assertEquals(Trellis.InvalidType, violation.getConstraint());
assertEquals(1L, violation.getTriples().size());
assertTrue(violation.getTriples().contains(rdf.createTriple(rdf.createIRI(subject), type,
LDP.Resource)));
});
});
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:16,代码来源:LdpConstraintsTest.java
示例19: testInvalidInbox
import org.trellisldp.vocabulary.Trellis; //导入依赖的package包/类
@Test
public void testInvalidInbox() {
final Optional<ConstraintViolation> res = svc.constrainedBy(LDP.RDFSource, domain,
asGraph("/invalidInbox.ttl", domain + "foo")).findFirst();
assertTrue(res.isPresent());
res.ifPresent(violation -> {
assertEquals(Trellis.InvalidRange, violation.getConstraint());
assertTrue(violation.getTriples().contains(rdf.createTriple(rdf.createIRI(domain + "foo"),
LDP.inbox, rdf.createLiteral("invalid range", "en"))));
});
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:12,代码来源:LdpConstraintsTest.java
示例20: testBasicConstraints1
import org.trellisldp.vocabulary.Trellis; //导入依赖的package包/类
@Test
public void testBasicConstraints1() {
final Optional<ConstraintViolation> res = svc.constrainedBy(LDP.Container, domain,
asGraph("/invalidContainer1.ttl", domain + "foo")).findFirst();
assertTrue(res.isPresent());
res.ifPresent(violation -> {
assertEquals(Trellis.InvalidProperty, violation.getConstraint());
assertTrue(violation.getTriples().contains(rdf.createTriple(rdf.createIRI(domain + "foo"),
LDP.isMemberOfRelation, rdf.createIRI(domain + "resource"))));
});
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:12,代码来源:LdpConstraintsTest.java
注:本文中的org.trellisldp.vocabulary.Trellis类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论