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

tape REST api: additional fix tohandling of prefixed paths #7691

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
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 @@ -159,6 +159,9 @@ public Response release(
JSONArray paths;
List<String> targetPaths;

FsPath userRoot = LoginAttributes.getUserRoot(getLoginAttributes(request));
FsPath rootPath = pathMapper.effectiveRoot(userRoot, ForbiddenException::new);

try {
JSONObject reqPayload = new JSONObject(requestPayload);
paths = reqPayload.getJSONArray("paths");
Expand All @@ -170,16 +173,16 @@ public Response release(
int len = paths.length();
targetPaths = new ArrayList<>();
for (int i = 0; i < len; ++i) {
targetPaths.add(paths.getString(i));
String requestPath = paths.getString(i);
String path = rootPath.chroot(requestPath).toString();
targetPaths.add(path);
}
} catch (JSONException e) {
throw newBadRequestException(requestPayload, e);
}

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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ public StageRequestInfo getStageInfo(@ApiParam("The unique id of the request.")
@PathParam("id") String id) {
Subject subject = getSubject();
Restriction restriction = getRestriction();
FsPath userRoot = LoginAttributes.getUserRoot(getLoginAttributes(request));
FsPath rootPath = pathMapper.effectiveRoot(userRoot, ForbiddenException::new);

BulkRequestInfo lastInfo = null;
List<BulkRequestTargetInfo> targetInfos = new ArrayList<>();
Expand All @@ -187,6 +189,7 @@ public StageRequestInfo getStageInfo(@ApiParam("The unique id of the request.")
offset = lastInfo.getNextId();
}

targetInfos.forEach(ti -> ti.setTarget(FsPath.create(ti.getTarget()).stripPrefix(rootPath)));
lastInfo.setTargets(targetInfos);

return new StageRequestInfo(lastInfo);
Expand Down Expand Up @@ -218,7 +221,9 @@ public Response cancel(
+ "does not belong to that stage request, this request will fail.", required = true)
String requestPayload) {

JSONObject reqPayload;
FsPath userRoot = LoginAttributes.getUserRoot(getLoginAttributes(request));
FsPath rootPath = pathMapper.effectiveRoot(userRoot, ForbiddenException::new);
JSONObject reqPayload;
JSONArray paths;
try {
reqPayload = new JSONObject(requestPayload);
Expand All @@ -233,7 +238,9 @@ public Response cancel(
List<String> targetPaths = new ArrayList<>();
int len = paths.length();
for (int i = 0; i < len; ++i) {
targetPaths.add(paths.getString(i));
String requestPath = paths.getString(i);
String path = rootPath.chroot(requestPath).toString();
targetPaths.add(path);
}

Subject subject = getSubject();
Expand Down Expand Up @@ -390,7 +397,8 @@ private BulkRequest toBulkRequest(String requestPayload, FsPath rootPath) {
if (!file.has("path")) {
throw new BadRequestException("file object " + i + " has no path.");
}
String path = file.getString("path");
String requestPath = file.getString("path");
String path = rootPath.chroot(requestPath).toString();
paths.add(path);
if (file.has("diskLifetime")) {
jsonLifetimes.put(path,
Expand Down