Search in sources :

Example 1 with Command

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);
        }
    }
}
Also used : LinkDatasetCommand(edu.harvard.iq.dataverse.engine.command.impl.LinkDatasetCommand) GetPrivateUrlCommand(edu.harvard.iq.dataverse.engine.command.impl.GetPrivateUrlCommand) DestroyDatasetCommand(edu.harvard.iq.dataverse.engine.command.impl.DestroyDatasetCommand) CreateDatasetCommand(edu.harvard.iq.dataverse.engine.command.impl.CreateDatasetCommand) ReturnDatasetToAuthorCommand(edu.harvard.iq.dataverse.engine.command.impl.ReturnDatasetToAuthorCommand) SubmitDatasetForReviewCommand(edu.harvard.iq.dataverse.engine.command.impl.SubmitDatasetForReviewCommand) CreatePrivateUrlCommand(edu.harvard.iq.dataverse.engine.command.impl.CreatePrivateUrlCommand) UpdateDatasetCommand(edu.harvard.iq.dataverse.engine.command.impl.UpdateDatasetCommand) RestrictFileCommand(edu.harvard.iq.dataverse.engine.command.impl.RestrictFileCommand) GetLatestPublishedDatasetVersionCommand(edu.harvard.iq.dataverse.engine.command.impl.GetLatestPublishedDatasetVersionCommand) PublishDatasetCommand(edu.harvard.iq.dataverse.engine.command.impl.PublishDatasetCommand) PublishDataverseCommand(edu.harvard.iq.dataverse.engine.command.impl.PublishDataverseCommand) Command(edu.harvard.iq.dataverse.engine.command.Command) DeaccessionDatasetVersionCommand(edu.harvard.iq.dataverse.engine.command.impl.DeaccessionDatasetVersionCommand) DeletePrivateUrlCommand(edu.harvard.iq.dataverse.engine.command.impl.DeletePrivateUrlCommand) DeleteDatasetVersionCommand(edu.harvard.iq.dataverse.engine.command.impl.DeleteDatasetVersionCommand) RequestRsyncScriptCommand(edu.harvard.iq.dataverse.engine.command.impl.RequestRsyncScriptCommand) RestrictFileCommand(edu.harvard.iq.dataverse.engine.command.impl.RestrictFileCommand)

Example 2 with Command

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();
}
Also used : RestrictFileCommand(edu.harvard.iq.dataverse.engine.command.impl.RestrictFileCommand) Command(edu.harvard.iq.dataverse.engine.command.Command) CreateDatasetCommand(edu.harvard.iq.dataverse.engine.command.impl.CreateDatasetCommand) UpdateDatasetCommand(edu.harvard.iq.dataverse.engine.command.impl.UpdateDatasetCommand) RestrictFileCommand(edu.harvard.iq.dataverse.engine.command.impl.RestrictFileCommand)

Aggregations

Command (edu.harvard.iq.dataverse.engine.command.Command)2 CreateDatasetCommand (edu.harvard.iq.dataverse.engine.command.impl.CreateDatasetCommand)2 RestrictFileCommand (edu.harvard.iq.dataverse.engine.command.impl.RestrictFileCommand)2 UpdateDatasetCommand (edu.harvard.iq.dataverse.engine.command.impl.UpdateDatasetCommand)2 CreatePrivateUrlCommand (edu.harvard.iq.dataverse.engine.command.impl.CreatePrivateUrlCommand)1 DeaccessionDatasetVersionCommand (edu.harvard.iq.dataverse.engine.command.impl.DeaccessionDatasetVersionCommand)1 DeleteDatasetVersionCommand (edu.harvard.iq.dataverse.engine.command.impl.DeleteDatasetVersionCommand)1 DeletePrivateUrlCommand (edu.harvard.iq.dataverse.engine.command.impl.DeletePrivateUrlCommand)1 DestroyDatasetCommand (edu.harvard.iq.dataverse.engine.command.impl.DestroyDatasetCommand)1 GetLatestPublishedDatasetVersionCommand (edu.harvard.iq.dataverse.engine.command.impl.GetLatestPublishedDatasetVersionCommand)1 GetPrivateUrlCommand (edu.harvard.iq.dataverse.engine.command.impl.GetPrivateUrlCommand)1 LinkDatasetCommand (edu.harvard.iq.dataverse.engine.command.impl.LinkDatasetCommand)1 PublishDatasetCommand (edu.harvard.iq.dataverse.engine.command.impl.PublishDatasetCommand)1 PublishDataverseCommand (edu.harvard.iq.dataverse.engine.command.impl.PublishDataverseCommand)1 RequestRsyncScriptCommand (edu.harvard.iq.dataverse.engine.command.impl.RequestRsyncScriptCommand)1 ReturnDatasetToAuthorCommand (edu.harvard.iq.dataverse.engine.command.impl.ReturnDatasetToAuthorCommand)1 SubmitDatasetForReviewCommand (edu.harvard.iq.dataverse.engine.command.impl.SubmitDatasetForReviewCommand)1