Skip to content

Commit d6001c9

Browse files
committed
#8184 remove deprecated code redundancy
1 parent 3266d88 commit d6001c9

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

src/main/java/edu/harvard/iq/dataverse/api/Datasets.java

+4-22
Original file line numberDiff line numberDiff line change
@@ -2174,41 +2174,23 @@ public Response getAssignments(@Context ContainerRequestContext crc, @PathParam(
21742174
@Deprecated(forRemoval = true, since = "2024-10-17")
21752175
@Path("{id}/privateUrl")
21762176
public Response getPrivateUrlData(@Context ContainerRequestContext crc, @PathParam("id") String idSupplied) {
2177-
return response( req -> {
2178-
PrivateUrl privateUrl = execCommand(new GetPrivateUrlCommand(req, findDatasetOrDie(idSupplied)));
2179-
return (privateUrl != null) ? ok(json(privateUrl))
2180-
: error(Response.Status.NOT_FOUND, "Private URL not found.");
2181-
}, getRequestUser(crc));
2177+
return getPreviewUrlData(crc, idSupplied);
21822178
}
21832179

21842180
@POST
21852181
@AuthRequired
21862182
@Deprecated(forRemoval = true, since = "2024-10-17")
21872183
@Path("{id}/privateUrl")
2188-
public Response createPrivateUrl(@Context ContainerRequestContext crc, @PathParam("id") String idSupplied,@DefaultValue("false") @QueryParam ("anonymizedAccess") boolean anonymizedAccess) {
2189-
if(anonymizedAccess && settingsSvc.getValueForKey(SettingsServiceBean.Key.AnonymizedFieldTypeNames)==null) {
2190-
throw new NotAcceptableException("Anonymized Access not enabled");
2191-
}
2192-
return response(req ->
2193-
ok(json(execCommand(
2194-
new CreatePrivateUrlCommand(req, findDatasetOrDie(idSupplied), anonymizedAccess)))), getRequestUser(crc));
2184+
public Response createPrivateUrl(@Context ContainerRequestContext crc, @PathParam("id") String idSupplied, @DefaultValue("false") @QueryParam("anonymizedAccess") boolean anonymizedAccess) {
2185+
return createPreviewUrl(crc, idSupplied, anonymizedAccess);
21952186
}
21962187

21972188
@DELETE
21982189
@AuthRequired
21992190
@Deprecated(forRemoval = true, since = "2024-10-17")
22002191
@Path("{id}/privateUrl")
22012192
public Response deletePrivateUrl(@Context ContainerRequestContext crc, @PathParam("id") String idSupplied) {
2202-
return response( req -> {
2203-
Dataset dataset = findDatasetOrDie(idSupplied);
2204-
PrivateUrl privateUrl = execCommand(new GetPrivateUrlCommand(req, dataset));
2205-
if (privateUrl != null) {
2206-
execCommand(new DeletePrivateUrlCommand(req, dataset));
2207-
return ok("Private URL deleted.");
2208-
} else {
2209-
return notFound("No Private URL to delete.");
2210-
}
2211-
}, getRequestUser(crc));
2193+
return deletePreviewUrl(crc, idSupplied);
22122194
}
22132195

22142196
@GET

0 commit comments

Comments
 (0)