Skip to content

Commit

Permalink
Removed: unused/incorrect code
Browse files Browse the repository at this point in the history
  • Loading branch information
GPortas committed Dec 24, 2024
1 parent 67e3fe0 commit b7352aa
Showing 1 changed file with 0 additions and 48 deletions.
48 changes: 0 additions & 48 deletions src/main/java/edu/harvard/iq/dataverse/api/Dataverses.java
Original file line number Diff line number Diff line change
Expand Up @@ -1734,54 +1734,6 @@ public Response getUserPermissionsOnDataverse(@Context ContainerRequestContext c
return ok(jsonObjectBuilder);
}

// TODO
@PUT
@AuthRequired
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("{identifier}/featuredItems")
public Response updateFeaturedItems(@Context ContainerRequestContext crc,
@PathParam("identifier") String dvIdtf,
@FormDataParam("title") String title,
@FormDataParam("content") String content,
@FormDataParam("order") int order,
@FormDataParam("file") InputStream fileInputStream,
@FormDataParam("file") FormDataContentDisposition contentDispositionHeader) {
Dataverse dataverse;
try {
dataverse = findDataverseOrDie(dvIdtf);
} catch (WrappedResponse wr) {
return wr.getResponse();
}
try {
String fileName = contentDispositionHeader.getFileName();
File uploadedFile = new File(createTempDir(dataverse), fileName);
if (!uploadedFile.exists()) {
uploadedFile.createNewFile();
}
File file = FileUtil.inputStreamToFile(fileInputStream);
if (file.length() > 1000000) {
return error(Response.Status.BAD_REQUEST, "File is larger than maximum size: " + systemConfig.getUploadLogoSizeLimit() + ".");
}
Files.copy(fileInputStream, uploadedFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
throw new RuntimeException(e);
}
return ok("");
}

private File createTempDir(Dataverse editDv) {
try {
// Create the temporary space if not yet existing (will silently ignore preexisting)
// Note that the docroot directory is checked within ConfigCheckService for presence and write access.
java.nio.file.Path tempRoot = java.nio.file.Path.of(JvmSettings.DOCROOT_DIRECTORY.lookup(), "featuredItems");
Files.createDirectories(tempRoot);

return Files.createTempDirectory(tempRoot, editDv.getId().toString()).toFile();
} catch (IOException e) {
throw new RuntimeException("Error creating temp directory", e); // improve error handling
}
}

@POST
@AuthRequired
@Consumes(MediaType.MULTIPART_FORM_DATA)
Expand Down

0 comments on commit b7352aa

Please sign in to comment.