Skip to content

Commit

Permalink
additional logging
Browse files Browse the repository at this point in the history
  • Loading branch information
qqmyers committed Oct 17, 2024
1 parent ac1a0d9 commit ad3a582
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/api/Files.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ public Response restrictFileInDataset(@Context ContainerRequestContext crc, @Pat
} catch (CommandException ex) {
return error(BAD_REQUEST, "Problem trying to update restriction status on " + dataFile.getDisplayName() + ": " + ex.getLocalizedMessage());
}

logger.info("restrict api: dataset is locked: " + !dataFile.getOwner().getLocks().isEmpty());
logger.info("restrict api: dataset version version is: " + dataFile.getOwner().getLatestVersion().getVersion());
// update the dataset
try {
engineSvc.submit(new UpdateDatasetVersionCommand(dataFile.getOwner(), dataverseRequest));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ protected void executeImpl(CommandContext ctxt) throws CommandException {
throw new CommandExecutionException("Restricting files is not permitted on a public installation.", this);
}
// check if this file is already restricted or already unrestricted
logger.info("File Metadata Version version is: " + file.getFileMetadata().getDatasetVersion().getVersion());
if (restrict == file.getFileMetadata().isRestricted()) {
String text = restrict ? "restricted" : "unrestricted";
throw new CommandExecutionException("File " + file.getDisplayName() + " is already " + text, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public Dataset execute(CommandContext ctxt) throws CommandException {
// Get or create (currently only when called with fmVarMet != null) a new edit
// version
DatasetVersion editVersion = theDataset.getOrCreateEditVersion(fmVarMet);

logger.info("Starting Version num: " + editVersion.getVersion());

// Now merge the dataset
theDataset = ctxt.em().merge(theDataset);
Expand Down Expand Up @@ -327,9 +327,7 @@ public Dataset execute(CommandContext ctxt) throws CommandException {
} else {
logger.fine("No locks to remove");
}
ctxt.em().flush();
}
logger.info("Flushed at " + (System.currentTimeMillis()-startTime));
return theDataset;
}

Expand All @@ -339,6 +337,10 @@ public boolean onSuccess(CommandContext ctxt, Object r) {
// Indexing will be started immediately, unless an index is already busy for the given data
// (it will be scheduled then for later indexing of the newest version).
// See the documentation of asyncIndexDataset method for more details.

Dataset d = (Dataset) r;
logger.info("Is locked " + !d.getLocks().isEmpty());
logger.info("In success: Version num: " + d.getLatestVersion().getVersion());
ctxt.index().asyncIndexDataset((Dataset) r, true);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/edu/harvard/iq/dataverse/api/FilesIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ public void testRestrictFile() {
restrictResponse.then().assertThat()
.body("data.message", equalTo("File dataverseproject.png restricted."))
.statusCode(OK.getStatusCode());

System.out.println("Test restricting a second time: " + origFileId);
//restrict already restricted file bad
Response restrictResponseBad = UtilIT.restrictFile(origFileId.toString(), restrict, apiToken);
restrictResponseBad.prettyPrint();
Expand Down

0 comments on commit ad3a582

Please sign in to comment.