From b9b0c92bca7c8f51ad95249e9c1445e298fc03e7 Mon Sep 17 00:00:00 2001 From: Dmitry Litvintsev Date: Tue, 13 Aug 2024 07:09:51 -0500 Subject: [PATCH] WLG TAPE REST API: fix handling of frontend.root in release API Motivation: commit 922ea440d98f2edacb00b7b16d9768f359aff6a3 was incomplete - it did not fix release API Modification: apply similar patch to release resoure. Result: Release by relative path works Issue https://github.com/dCache/dcache/issues/7635 addressed Target: trunk Request: 10.x Request: 9.x --- .../restful/resources/tape/ReleaseResources.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/dcache-frontend/src/main/java/org/dcache/restful/resources/tape/ReleaseResources.java b/modules/dcache-frontend/src/main/java/org/dcache/restful/resources/tape/ReleaseResources.java index 77f737f3780..f278bfacb4c 100644 --- a/modules/dcache-frontend/src/main/java/org/dcache/restful/resources/tape/ReleaseResources.java +++ b/modules/dcache-frontend/src/main/java/org/dcache/restful/resources/tape/ReleaseResources.java @@ -59,11 +59,13 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ package org.dcache.restful.resources.tape; +import static org.dcache.http.AuthenticationHandler.getLoginAttributes; import static org.dcache.restful.util.HttpServletRequests.getUserRootAwareTargetPrefix; import static org.dcache.restful.util.JSONUtils.newBadRequestException; import static org.dcache.restful.util.RequestUser.getRestriction; import static org.dcache.restful.util.RequestUser.getSubject; +import diskCacheV111.util.FsPath; import diskCacheV111.util.PnfsHandler; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -81,6 +83,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import javax.servlet.http.HttpServletRequest; import javax.ws.rs.BadRequestException; import javax.ws.rs.Consumes; +import javax.ws.rs.ForbiddenException; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -88,8 +91,10 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.dcache.auth.attributes.LoginAttributes; import org.dcache.auth.attributes.Restriction; import org.dcache.cells.CellStub; +import org.dcache.http.PathMapper; import org.dcache.restful.util.HandlerBuilders; import org.dcache.restful.util.bulk.BulkServiceCommunicator; import org.dcache.services.bulk.BulkRequest; @@ -116,6 +121,9 @@ public final class ReleaseResources { @Inject private BulkServiceCommunicator service; + @Inject + private PathMapper pathMapper; + @Inject @Named("pnfs-stub") private CellStub pnfsmanager; @@ -170,6 +178,8 @@ public Response release( Subject subject = getSubject(); Restriction restriction = getRestriction(); + FsPath userRoot = LoginAttributes.getUserRoot(getLoginAttributes(request)); + FsPath rootPath = pathMapper.effectiveRoot(userRoot, ForbiddenException::new); /* * For WLCG, this is a fire-and-forget request, so it does not need to @@ -184,7 +194,9 @@ public Response release( PnfsHandler handler = HandlerBuilders.unrestrictedPnfsHandler(pnfsmanager); - request.setTargetPrefix(getUserRootAwareTargetPrefix(this.request, null, handler)); + request.setTargetPrefix(getUserRootAwareTargetPrefix(this.request, + rootPath.toString(), + handler)); BulkRequestMessage message = new BulkRequestMessage(request, restriction); message.setSubject(subject);