/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package edu.harvard.iq.dataverse.engine.command.impl;
import edu.harvard.iq.dataverse.Dataset;
import edu.harvard.iq.dataverse.authorization.Permission;
import edu.harvard.iq.dataverse.engine.command.AbstractCommand;
import edu.harvard.iq.dataverse.engine.command.CommandContext;
import edu.harvard.iq.dataverse.engine.command.DataverseRequest;
import edu.harvard.iq.dataverse.engine.command.exception.CommandException;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
/**
*
* @author Naomi
*/
// no annotations here, since permissions are dynamically decided
public class GetDatasetCommand extends AbstractCommand<Dataset> {
private final Dataset ds;
public GetDatasetCommand(DataverseRequest aRequest, Dataset anAffectedDataset) {
super(aRequest, anAffectedDataset);
ds = anAffectedDataset;
}
@Override
public Dataset execute(CommandContext ctxt) throws CommandException {
return ds;
}
@Override
public Map<String, Set<Permission>> getRequiredPermissions() {
return Collections.singletonMap("",
ds.isReleased() ? Collections.<Permission>emptySet()
: Collections.singleton(Permission.ViewUnpublishedDataset));
}
}