use of edu.harvard.iq.dataverse.engine.command.Command in project dataverse by IQSS.
the class DatasetPage method restrictFiles.
public void restrictFiles(boolean restricted) throws CommandException {
// when the code between the 2 beans is merged in 4.3.
if (editMode != EditMode.CREATE) {
previouslyRestrictedFiles = new ArrayList<>();
for (FileMetadata fmd : workingVersion.getFileMetadatas()) {
if (fmd.isRestricted()) {
previouslyRestrictedFiles.add(fmd);
}
}
Command cmd;
String fileNames = null;
for (FileMetadata fmw : workingVersion.getFileMetadatas()) {
for (FileMetadata fmd : this.getSelectedFiles()) {
if (restricted && !fmw.isRestricted()) {
// message isn't used, normally)
if (fileNames == null) {
fileNames = fmd.getLabel();
} else {
fileNames = fileNames.concat(fmd.getLabel());
}
}
if (fmd.getDataFile().equals(fmw.getDataFile())) {
cmd = new RestrictFileCommand(fmw.getDataFile(), dvRequestService.getDataverseRequest(), restricted);
commandEngine.submit(cmd);
// fmw.setRestricted(restricted);
// if (workingVersion.isDraft() && !fmw.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
// fmw.getDataFile().setRestricted(restricted);
// }
}
}
}
if (fileNames != null) {
String successMessage = JH.localize("file.restricted.success");
logger.fine(successMessage);
successMessage = successMessage.replace("{0}", fileNames);
JsfHelper.addFlashMessage(successMessage);
}
}
}
use of edu.harvard.iq.dataverse.engine.command.Command in project dataverse by IQSS.
the class FilePage method restrictFile.
public String restrictFile(boolean restricted) throws CommandException {
String fileNames = null;
String termsOfAccess = this.fileMetadata.getDatasetVersion().getTermsOfUseAndAccess().getTermsOfAccess();
Boolean allowRequest = this.fileMetadata.getDatasetVersion().getTermsOfUseAndAccess().isFileAccessRequest();
editDataset = this.file.getOwner();
Command cmd;
for (FileMetadata fmw : editDataset.getEditVersion().getFileMetadatas()) {
if (fmw.getDataFile().equals(this.fileMetadata.getDataFile())) {
fileNames += fmw.getLabel();
// fmw.setRestricted(restricted);
cmd = new RestrictFileCommand(fmw.getDataFile(), dvRequestService.getDataverseRequest(), restricted);
commandEngine.submit(cmd);
}
}
editDataset.getEditVersion().getTermsOfUseAndAccess().setTermsOfAccess(termsOfAccess);
editDataset.getEditVersion().getTermsOfUseAndAccess().setFileAccessRequest(allowRequest);
if (fileNames != null) {
String successMessage = JH.localize("file.restricted.success");
successMessage = successMessage.replace("{0}", fileNames);
JsfHelper.addFlashMessage(successMessage);
}
save();
init();
return returnToDraftVersion();
}
Aggregations