@Test void testTestPutUncontainedMissing() { filter.filter(mockContext); verify(mockContext).setMethod(eq(POST)); verify(mockHeaders).putSingle(eq(SLUG), eq(PATH)); }
@Override public void filter(final ContainerRequestContext ctx) { final IRI identifier = services.getResourceService() .getResourceIdentifier(getBaseUrl(baseUrl, ctx.getUriInfo()), ctx.getUriInfo().getPath()); if (PUT.equals(ctx.getMethod()) && createUncontained) { final Resource res = services.getResourceService().get(identifier).toCompletableFuture().join(); final List<PathSegment> segments = ctx.getUriInfo().getPathSegments(); if ((MISSING_RESOURCE.equals(res) || DELETED_RESOURCE.equals(res)) && segments.stream().map(PathSegment::getPath).anyMatch(s -> !s.isEmpty())) { ctx.setMethod(POST); ctx.setRequestUri(ctx.getUriInfo().getBaseUriBuilder().path(getAllButLastSegment(segments)).build()); ctx.getHeaders().putSingle(SLUG, getLastSegment(segments)); } } else if ("MKCOL".equals(ctx.getMethod())) { final List<PathSegment> segments = ctx.getUriInfo().getPathSegments(); final String slug = getLastSegment(segments); if (slug.isEmpty()) { ctx.abortWith(status(CONFLICT).build()); } else { ctx.setRequestUri(ctx.getUriInfo().getBaseUriBuilder().path(getAllButLastSegment(segments)).build()); ctx.setMethod(POST); ctx.getHeaders().putSingle(SLUG, getLastSegment(segments)); ctx.getHeaders().putSingle(LINK, Link.fromUri(LDP.BasicContainer.getIRIString()).rel(TYPE).build().toString()); } } else if (DELETE.equals(ctx.getMethod())) { recursiveDelete(services, HttpSession.from(ctx.getSecurityContext()), identifier, getBaseUrl(baseUrl, ctx.getUriInfo())); } }
TrellisWebDAVRequestFilter implements ContainerRequestFilter { @Override public void filter(final ContainerRequestContext ctx) { final IRI identifier = services.getResourceService() .getResourceIdentifier(getBaseUrl(baseUrl, ctx.getUriInfo()), ctx.getUriInfo().getPath()); if (PUT.equals(ctx.getMethod()) && createUncontained) { final Resource res = services.getResourceService().get(identifier).toCompletableFuture().join(); final List<PathSegment> segments = ctx.getUriInfo().getPathSegments(); if ((MISSING_RESOURCE.equals(res) || DELETED_RESOURCE.equals(res)) && segments.stream().map(PathSegment::getPath).anyMatch(s -> !s.isEmpty())) { ctx.setMethod(POST); ctx.setRequestUri(ctx.getUriInfo().getBaseUriBuilder().path(getAllButLastSegment(segments)).build()); ctx.getHeaders().putSingle(SLUG, getLastSegment(segments)); } } else if ("MKCOL".equals(ctx.getMethod())) { final List<PathSegment> segments = ctx.getUriInfo().getPathSegments(); final String slug = getLastSegment(segments); if (slug.isEmpty()) { ctx.abortWith(status(CONFLICT).build()); } else { ctx.setRequestUri(ctx.getUriInfo().getBaseUriBuilder().path(getAllButLastSegment(segments)).build()); ctx.setMethod(POST); ctx.getHeaders().putSingle(SLUG, getLastSegment(segments)); ctx.getHeaders().putSingle(LINK, Link.fromUri(LDP.BasicContainer.getIRIString()).rel(TYPE).build().toString()); } } else if (DELETE.equals(ctx.getMethod())) { recursiveDelete(services, HttpSession.from(ctx.getSecurityContext()), identifier, getBaseUrl(baseUrl, ctx.getUriInfo())); } } }
TrellisWebDAVRequestFilter implements ContainerRequestFilter { @Override public void filter(final ContainerRequestContext ctx) { final IRI identifier = services.getResourceService() .getResourceIdentifier(getBaseUrl(baseUrl, ctx.getUriInfo()), ctx.getUriInfo().getPath()); if (PUT.equals(ctx.getMethod()) && createUncontained) { final Resource res = services.getResourceService().get(identifier).toCompletableFuture().join(); final List<PathSegment> segments = ctx.getUriInfo().getPathSegments(); if ((MISSING_RESOURCE.equals(res) || DELETED_RESOURCE.equals(res)) && segments.stream().map(PathSegment::getPath).anyMatch(s -> !s.isEmpty())) { ctx.setMethod(POST); ctx.setRequestUri(ctx.getUriInfo().getBaseUriBuilder().path(getAllButLastSegment(segments)).build()); ctx.getHeaders().putSingle(SLUG, getLastSegment(segments)); } } else if ("MKCOL".equals(ctx.getMethod())) { final List<PathSegment> segments = ctx.getUriInfo().getPathSegments(); final String slug = getLastSegment(segments); if (slug.isEmpty()) { ctx.abortWith(status(CONFLICT).build()); } else { ctx.setRequestUri(ctx.getUriInfo().getBaseUriBuilder().path(getAllButLastSegment(segments)).build()); ctx.setMethod(POST); ctx.getHeaders().putSingle(SLUG, getLastSegment(segments)); ctx.getHeaders().putSingle(LINK, Link.fromUri(LDP.BasicContainer.getIRIString()).rel(TYPE).build().toString()); } } else if (DELETE.equals(ctx.getMethod())) { recursiveDelete(services, HttpSession.from(ctx.getSecurityContext()), identifier, getBaseUrl(baseUrl, ctx.getUriInfo())); } } TrellisWebDAVRequestFilter(); }
TrellisWebDAVRequestFilter implements ContainerRequestFilter { @Override public void filter(final ContainerRequestContext ctx) { final IRI identifier = services.getResourceService() .getResourceIdentifier(getBaseUrl(baseUrl, ctx.getUriInfo()), ctx.getUriInfo().getPath()); if (PUT.equals(ctx.getMethod()) && createUncontained) { final Resource res = services.getResourceService().get(identifier).toCompletableFuture().join(); final List<PathSegment> segments = ctx.getUriInfo().getPathSegments(); if ((MISSING_RESOURCE.equals(res) || DELETED_RESOURCE.equals(res)) && segments.stream().map(PathSegment::getPath).anyMatch(s -> !s.isEmpty())) { ctx.setMethod(POST); ctx.setRequestUri(ctx.getUriInfo().getBaseUriBuilder().path(getAllButLastSegment(segments)).build()); ctx.getHeaders().putSingle(SLUG, getLastSegment(segments)); } } else if ("MKCOL".equals(ctx.getMethod())) { final List<PathSegment> segments = ctx.getUriInfo().getPathSegments(); final String slug = getLastSegment(segments); if (slug.isEmpty()) { ctx.abortWith(status(CONFLICT).build()); } else { ctx.setRequestUri(ctx.getUriInfo().getBaseUriBuilder().path(getAllButLastSegment(segments)).build()); ctx.setMethod(POST); ctx.getHeaders().putSingle(SLUG, getLastSegment(segments)); ctx.getHeaders().putSingle(LINK, Link.fromUri(LDP.BasicContainer.getIRIString()).rel(TYPE).build().toString()); } } else if (DELETE.equals(ctx.getMethod())) { recursiveDelete(services, HttpSession.from(ctx.getSecurityContext()), identifier, getBaseUrl(baseUrl, ctx.getUriInfo())); } } TrellisWebDAVRequestFilter(); @Inject void setServiceBundler(final ServiceBundler services); void setCreateUncontained(final boolean createUncontained); void setBaseUrl(final String baseUrl); @Override void filter(final ContainerRequestContext ctx); }
TrellisWebDAVRequestFilter implements ContainerRequestFilter { @Override public void filter(final ContainerRequestContext ctx) { final IRI identifier = services.getResourceService() .getResourceIdentifier(getBaseUrl(baseUrl, ctx.getUriInfo()), ctx.getUriInfo().getPath()); if (PUT.equals(ctx.getMethod()) && createUncontained) { final Resource res = services.getResourceService().get(identifier).toCompletableFuture().join(); final List<PathSegment> segments = ctx.getUriInfo().getPathSegments(); if ((MISSING_RESOURCE.equals(res) || DELETED_RESOURCE.equals(res)) && segments.stream().map(PathSegment::getPath).anyMatch(s -> !s.isEmpty())) { ctx.setMethod(POST); ctx.setRequestUri(ctx.getUriInfo().getBaseUriBuilder().path(getAllButLastSegment(segments)).build()); ctx.getHeaders().putSingle(SLUG, getLastSegment(segments)); } } else if ("MKCOL".equals(ctx.getMethod())) { final List<PathSegment> segments = ctx.getUriInfo().getPathSegments(); final String slug = getLastSegment(segments); if (slug.isEmpty()) { ctx.abortWith(status(CONFLICT).build()); } else { ctx.setRequestUri(ctx.getUriInfo().getBaseUriBuilder().path(getAllButLastSegment(segments)).build()); ctx.setMethod(POST); ctx.getHeaders().putSingle(SLUG, getLastSegment(segments)); ctx.getHeaders().putSingle(LINK, Link.fromUri(LDP.BasicContainer.getIRIString()).rel(TYPE).build().toString()); } } else if (DELETE.equals(ctx.getMethod())) { recursiveDelete(services, HttpSession.from(ctx.getSecurityContext()), identifier, getBaseUrl(baseUrl, ctx.getUriInfo())); } } TrellisWebDAVRequestFilter(); @Inject void setServiceBundler(final ServiceBundler services); void setCreateUncontained(final boolean createUncontained); void setBaseUrl(final String baseUrl); @Override void filter(final ContainerRequestContext ctx);  }