package edu.harvard.iq.dataverse.engine.command.impl;

import edu.harvard.iq.dataverse.Dataverse;
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 GetDataverseCommand extends AbstractCommand<Dataverse>{
    private final Dataverse dv;

    public GetDataverseCommand(User aUser, Dataverse anAffectedDataverse) {
        super(aUser, anAffectedDataverse);
        dv = anAffectedDataverse;
    }

    @Override
    public Dataverse execute(CommandContext ctxt) throws CommandException {
        return dv;
    }
    
}

@@ -481,80 +481,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
@@ -1023,15 +1023,294 @@
 ;%0A    %7D%0A
+%0A    @Override%0A    public Map%3CString, Set%3CPermission%3E%3E getRequiredPermissions() %7B%0A        return Collections.singletonMap(%22%22,%0A                dv.isReleased() ? Collections.%3CPermission%3EemptySet()%0A                : Collections.singleton(Permission.ViewUnpublishedDataverse));%0A    %7D
     %0A%7D%0A

use new, simplified permissions (and set dynamically)