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

import edu.harvard.iq.dataverse.Dataverse;
import edu.harvard.iq.dataverse.MetadataBlock;
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;
import java.util.List;

/**
 * Lists the metadata blocks of a {@link Dataverse}.
 * 
 * @author michael
 */
@RequiredPermissions( Permission.Discover )
public class ListMetadataBlocksCommand extends AbstractCommand<List<MetadataBlock>>{
    
    private final Dataverse dv;
    
    public ListMetadataBlocksCommand(User aUser, Dataverse aDataverse) {
        super(aUser, aDataverse);
        dv = aDataverse;
    }

    @Override
    public List<MetadataBlock> execute(CommandContext ctxt) throws CommandException {
        return dv.getMetadataBlocks();
    }
    
}

@@ -541,19 +541,93 @@
 va.util.
-Lis
+Collections;%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport java.util.Se
 t;%0A%0A/**%0A
@@ -710,51 +710,73 @@
  */%0A
-@RequiredPermissions( Permission.Discover )
+// no annotations here, since permissions are dynamically decided
 %0Apub
@@ -1177,16 +1177,16 @@
 ocks();%0A
-
     %7D%0A  
@@ -1188,10 +1188,298 @@
  %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    %0A
 %7D%0A

use new, simplified permissions (and set dynamically)