@Override
public void filter(final ContainerRequestContext ctx) throws IOException {
final String path = ctx.getUriInfo().getPath();
final Object session = ctx.getProperty(SESSION_PROPERTY);
final Session s;
if (nonNull(session)) {
s = (Session) session;
} else {
s = new HttpSession();
ctx.setProperty(SESSION_PROPERTY, s);
}
final String method = ctx.getMethod();
final Set<IRI> modes = accessService.getAccessModes(rdf.createIRI(TRELLIS_DATA_PREFIX + path), s);
if (ctx.getUriInfo().getQueryParameters().getOrDefault(HttpConstants.EXT, emptyList())
.contains(HttpConstants.ACL)) {
verifyCanControl(modes, s, path);
} else if (readable.contains(method)) {
verifyCanRead(modes, s, path);
} else if (writable.contains(method)) {
verifyCanWrite(modes, s, path);
} else if (appendable.contains(method)) {
verifyCanAppend(modes, s, path);
} else {
throw new NotAllowedException(status(METHOD_NOT_ALLOWED).build());
}
}