/*
 * 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.authorization.users.User;
import edu.harvard.iq.dataverse.engine.command.AbstractCommand;
import edu.harvard.iq.dataverse.engine.command.CommandContext;
import edu.harvard.iq.dataverse.engine.command.RequiredPermissions;
import edu.harvard.iq.dataverse.engine.command.exception.CommandException;

/**
 *
 * @author Naomi
 */
@RequiredPermissions( Permission.Discover )
public class GetDatasetCommand extends AbstractCommand<Dataset>{
    private final Dataset ds;

    public GetDatasetCommand(User aUser, Dataset anAffectedDataset) {
        super(aUser, anAffectedDataset);
        ds = anAffectedDataset;
    }

    @Override
    public Dataset execute(CommandContext ctxt) throws CommandException {
        return ds;
    }
    
    
    
}

@@ -178,17 +178,16 @@
 or.%0A */%0A
-%0A
 package 
@@ -517,16 +517,88 @@
 ontext;%0A
+import static edu.harvard.iq.dataverse.engine.command.CommandHelper.CH;%0A
 import e
@@ -736,80 +736,176 @@
 on;%0A
-%0A/**%0A *%0A * @author Naomi%0A */%0A@RequiredPermissions( Permission.Discover )
+import java.util.Collections;%0Aimport java.util.Map;%0Aimport java.util.Set;%0A%0A/**%0A *%0A * @author Naomi%0A */%0A// no annotations here, since permissions are dynamically decided
 %0Apub
@@ -964,17 +964,19 @@
 Dataset%3E
-%7B
+ %7B%0A
 %0A    pri
@@ -1266,21 +1266,285 @@
   %7D%0A
+%0A
     
-%0A    %0A    
+@Override%0A    public Map%3CString, Set%3CPermission%3E%3E getRequiredPermissions() %7B%0A        return Collections.singletonMap(%22%22,%0A                ds.isReleased() ? Collections.%3CPermission%3EemptySet()%0A                : Collections.singleton(Permission.ViewUnpublishedDataset));%0A    %7D%0A
 %0A%7D%0A

use new, simplified permissions (and set dynamically)