Skip to content

Commit

Permalink
WLG TAPE REST API: fix handling of frontend.root in release API
Browse files Browse the repository at this point in the history
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  dCache#7635
addressed

Target: trunk
Request: 10.x
Request: 9.x
  • Loading branch information
DmitryLitvintsev committed Aug 13, 2024
1 parent 9c52354 commit fb4b8c6
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -81,15 +83,18 @@ 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;
import javax.ws.rs.Produces;
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;
Expand All @@ -116,6 +121,9 @@ public final class ReleaseResources {
@Inject
private BulkServiceCommunicator service;

@Inject
private PathMapper pathMapper;

@Inject
@Named("pnfs-stub")
private CellStub pnfsmanager;
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down

0 comments on commit fb4b8c6

Please sign in to comment.