Skip to content

Commit 422aabb

Browse files
DmitryLitvintsevlemora
authored andcommitted
WLG TAPE REST API: fix handling of frontend.root in release API
Motivation: commit 922ea44 was incomplete - it did not fix release API Modification: apply similar patch to release resoure. Result: Release by relative path works Issue #7635 addressed Target: trunk Request: 10.x Request: 9.x
1 parent 9c52354 commit 422aabb

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

modules/dcache-frontend/src/main/java/org/dcache/restful/resources/tape/ReleaseResources.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
5959
*/
6060
package org.dcache.restful.resources.tape;
6161

62+
import static org.dcache.http.AuthenticationHandler.getLoginAttributes;
6263
import static org.dcache.restful.util.HttpServletRequests.getUserRootAwareTargetPrefix;
6364
import static org.dcache.restful.util.JSONUtils.newBadRequestException;
6465
import static org.dcache.restful.util.RequestUser.getRestriction;
6566
import static org.dcache.restful.util.RequestUser.getSubject;
6667

68+
import diskCacheV111.util.FsPath;
6769
import diskCacheV111.util.PnfsHandler;
6870
import io.swagger.annotations.Api;
6971
import io.swagger.annotations.ApiOperation;
@@ -81,15 +83,18 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
8183
import javax.servlet.http.HttpServletRequest;
8284
import javax.ws.rs.BadRequestException;
8385
import javax.ws.rs.Consumes;
86+
import javax.ws.rs.ForbiddenException;
8487
import javax.ws.rs.POST;
8588
import javax.ws.rs.Path;
8689
import javax.ws.rs.PathParam;
8790
import javax.ws.rs.Produces;
8891
import javax.ws.rs.core.Context;
8992
import javax.ws.rs.core.MediaType;
9093
import javax.ws.rs.core.Response;
94+
import org.dcache.auth.attributes.LoginAttributes;
9195
import org.dcache.auth.attributes.Restriction;
9296
import org.dcache.cells.CellStub;
97+
import org.dcache.http.PathMapper;
9398
import org.dcache.restful.util.HandlerBuilders;
9499
import org.dcache.restful.util.bulk.BulkServiceCommunicator;
95100
import org.dcache.services.bulk.BulkRequest;
@@ -116,6 +121,9 @@ public final class ReleaseResources {
116121
@Inject
117122
private BulkServiceCommunicator service;
118123

124+
@Inject
125+
private PathMapper pathMapper;
126+
119127
@Inject
120128
@Named("pnfs-stub")
121129
private CellStub pnfsmanager;
@@ -170,6 +178,8 @@ public Response release(
170178

171179
Subject subject = getSubject();
172180
Restriction restriction = getRestriction();
181+
FsPath userRoot = LoginAttributes.getUserRoot(getLoginAttributes(request));
182+
FsPath rootPath = pathMapper.effectiveRoot(userRoot, ForbiddenException::new);
173183

174184
/*
175185
* For WLCG, this is a fire-and-forget request, so it does not need to
@@ -184,7 +194,9 @@ public Response release(
184194

185195
PnfsHandler handler = HandlerBuilders.unrestrictedPnfsHandler(pnfsmanager);
186196

187-
request.setTargetPrefix(getUserRootAwareTargetPrefix(this.request, null, handler));
197+
request.setTargetPrefix(getUserRootAwareTargetPrefix(this.request,
198+
rootPath.toString(),
199+
handler));
188200

189201
BulkRequestMessage message = new BulkRequestMessage(request, restriction);
190202
message.setSubject(subject);

0 commit comments

Comments
 (0)