Skip to content

Commit 8af5b1c

Browse files
committed
#8184 add updated api endpoints - deprecate private url
1 parent 9285c92 commit 8af5b1c

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

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

+43
Original file line numberDiff line numberDiff line change
@@ -2171,6 +2171,7 @@ public Response getAssignments(@Context ContainerRequestContext crc, @PathParam(
21712171

21722172
@GET
21732173
@AuthRequired
2174+
@Deprecated(forRemoval = true, since = "2024-10-17")
21742175
@Path("{id}/privateUrl")
21752176
public Response getPrivateUrlData(@Context ContainerRequestContext crc, @PathParam("id") String idSupplied) {
21762177
return response( req -> {
@@ -2182,6 +2183,7 @@ public Response getPrivateUrlData(@Context ContainerRequestContext crc, @PathPar
21822183

21832184
@POST
21842185
@AuthRequired
2186+
@Deprecated(forRemoval = true, since = "2024-10-17")
21852187
@Path("{id}/privateUrl")
21862188
public Response createPrivateUrl(@Context ContainerRequestContext crc, @PathParam("id") String idSupplied,@DefaultValue("false") @QueryParam ("anonymizedAccess") boolean anonymizedAccess) {
21872189
if(anonymizedAccess && settingsSvc.getValueForKey(SettingsServiceBean.Key.AnonymizedFieldTypeNames)==null) {
@@ -2194,6 +2196,7 @@ public Response createPrivateUrl(@Context ContainerRequestContext crc, @PathPara
21942196

21952197
@DELETE
21962198
@AuthRequired
2199+
@Deprecated(forRemoval = true, since = "2024-10-17")
21972200
@Path("{id}/privateUrl")
21982201
public Response deletePrivateUrl(@Context ContainerRequestContext crc, @PathParam("id") String idSupplied) {
21992202
return response( req -> {
@@ -2207,6 +2210,46 @@ public Response deletePrivateUrl(@Context ContainerRequestContext crc, @PathPara
22072210
}
22082211
}, getRequestUser(crc));
22092212
}
2213+
2214+
@GET
2215+
@AuthRequired
2216+
@Path("{id}/previewUrl")
2217+
public Response getPreviewUrlData(@Context ContainerRequestContext crc, @PathParam("id") String idSupplied) {
2218+
return response( req -> {
2219+
PrivateUrl privateUrl = execCommand(new GetPrivateUrlCommand(req, findDatasetOrDie(idSupplied)));
2220+
return (privateUrl != null) ? ok(json(privateUrl))
2221+
: error(Response.Status.NOT_FOUND, "Private URL not found.");
2222+
}, getRequestUser(crc));
2223+
}
2224+
2225+
@POST
2226+
@AuthRequired
2227+
@Path("{id}/previewUrl")
2228+
public Response createPreviewUrl(@Context ContainerRequestContext crc, @PathParam("id") String idSupplied,@DefaultValue("false") @QueryParam ("anonymizedAccess") boolean anonymizedAccess) {
2229+
if(anonymizedAccess && settingsSvc.getValueForKey(SettingsServiceBean.Key.AnonymizedFieldTypeNames)==null) {
2230+
throw new NotAcceptableException("Anonymized Access not enabled");
2231+
}
2232+
return response(req ->
2233+
ok(json(execCommand(
2234+
new CreatePrivateUrlCommand(req, findDatasetOrDie(idSupplied), anonymizedAccess)))), getRequestUser(crc));
2235+
}
2236+
2237+
@DELETE
2238+
@AuthRequired
2239+
@Path("{id}/previewUrl")
2240+
public Response deletePreviewUrl(@Context ContainerRequestContext crc, @PathParam("id") String idSupplied) {
2241+
return response( req -> {
2242+
Dataset dataset = findDatasetOrDie(idSupplied);
2243+
PrivateUrl privateUrl = execCommand(new GetPrivateUrlCommand(req, dataset));
2244+
if (privateUrl != null) {
2245+
execCommand(new DeletePrivateUrlCommand(req, dataset));
2246+
return ok("Private URL deleted.");
2247+
} else {
2248+
return notFound("No Private URL to delete.");
2249+
}
2250+
}, getRequestUser(crc));
2251+
}
2252+
22102253

22112254
@GET
22122255
@AuthRequired

0 commit comments

Comments
 (0)