Skip to content

Commit

Permalink
Reverted EditDatafilesPage.restrictFiles
Browse files Browse the repository at this point in the history
Used the non-command functionality for restricting files as this does not break due to the lack of editDataset permissions. The transaction still completes due to later transactions.
  • Loading branch information
matthew-a-dunlap committed Aug 11, 2017
1 parent a1792ad commit dbb93c0
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/main/java/edu/harvard/iq/dataverse/EditDatafilesPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
import edu.harvard.iq.dataverse.dataset.DatasetThumbnail;
import edu.harvard.iq.dataverse.engine.command.Command;
import edu.harvard.iq.dataverse.engine.command.exception.CommandException;
import edu.harvard.iq.dataverse.engine.command.exception.CommandExecutionException;
import edu.harvard.iq.dataverse.engine.command.impl.DeleteDataFileCommand;
import edu.harvard.iq.dataverse.engine.command.impl.RestrictFileCommand;
import edu.harvard.iq.dataverse.engine.command.impl.UpdateDatasetCommand;
import edu.harvard.iq.dataverse.engine.command.impl.UpdateDatasetThumbnailCommand;
import edu.harvard.iq.dataverse.ingest.IngestRequest;
Expand Down Expand Up @@ -698,7 +696,12 @@ public boolean isShowAccessPopup() {

public void setShowAccessPopup(boolean showAccessPopup) {} // dummy set method

public void restrictFiles(boolean restricted) throws CommandException{
//This function was reverted to its pre-commands state as the current command
//requires editDataset privlidges. If a non-admin user with only createDataset privlidges
//attempts to restrict a datafile before the dataset is created, the operation
//fails silently. This is because they are only granted editDataset permissions
//for that scope after the creation is completed. -Matthew 4.7.1
public void restrictFiles(boolean restricted) throws UnsupportedOperationException{

// since we are restricted files, first set the previously restricted file list, so we can compare for
// determining whether to show the access popup
Expand All @@ -721,17 +724,19 @@ public void restrictFiles(boolean restricted) throws CommandException{
fileNames = fileNames.concat(", " + fmd.getLabel());
}
}
//fmd.setRestricted(restricted);
Command cmd;
cmd = new RestrictFileCommand(fmd.getDataFile(), dvRequestService.getDataverseRequest(), restricted);
commandEngine.submit(cmd);

// if (workingVersion.isDraft() && !fmd.getDataFile().isReleased()) {
// // We do not really need to check that the working version is
// // a draft here - it must be a draft, if we've gotten this
// // far. But just in case. -- L.A. 4.2.1
// fmd.getDataFile().setRestricted(restricted);
// }
fmd.setRestricted(restricted);

// Command cmd;
// cmd = new RestrictFileCommand(fmd.getDataFile(), dvRequestService.getDataverseRequest(), restricted);
// commandEngine.submit(cmd);


if (workingVersion.isDraft() && !fmd.getDataFile().isReleased()) {
// We do not really need to check that the working version is
// a draft here - it must be a draft, if we've gotten this
// far. But just in case. -- L.A. 4.2.1
fmd.getDataFile().setRestricted(restricted);
}
}
if (fileNames != null) {
String successMessage = getBundleString("file.restricted.success");
Expand Down

0 comments on commit dbb93c0

Please sign in to comment.