Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WLG TAPE REST API: fix handling of frontend.root in release API #7637

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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