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.CommandContext;
import edu.harvard.iq.dataverse.engine.command.RequiredPermissions;
import edu.harvard.iq.dataverse.engine.command.exception.CommandException;
import edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException;

/**
 * Deletes a data set.
 * @author michael
 */
@RequiredPermissions( Permission.DeleteDatasetDraft )
public class DeleteDatasetCommand extends DestroyDatasetCommand {
	
	private final Dataset doomed;

	public DeleteDatasetCommand(Dataset doomed, User aUser) {
		super(doomed, aUser);
		this.doomed = doomed;
	}
	
	@Override
	protected void executeImpl(CommandContext ctxt) throws CommandException {
		if ( doomed.isReleased() ) {
			throw new IllegalCommandException("Cannot delete a released dataset", this);
		}
		super.executeImpl(ctxt);
	}
	
}

@@ -205,16 +205,84 @@
 s.User;%0A
+import edu.harvard.iq.dataverse.engine.command.AbstractVoidCommand;%0A
 import e
@@ -482,90 +482,8 @@
 ion;
-%0Aimport edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException;
 %0A%0A/*
@@ -507,16 +507,19 @@
 ta set.%0A
+ *%0A
  * @auth
@@ -554,17 +554,16 @@
 issions(
- 
 Permissi
@@ -583,17 +583,16 @@
 setDraft
- 
 )%0Apublic
@@ -631,22 +631,20 @@
 nds 
-DestroyDataset
+AbstractVoid
 Comm
@@ -649,19 +649,21 @@
 mmand %7B%0A
-%09%0A%09
+%0A    
 private 
@@ -685,17 +685,20 @@
 oomed;%0A%0A
-%09
+    
 public D
@@ -721,64 +721,214 @@
 and(
-Dataset doomed, User aUser) %7B%0A%09%09super(doomed, aUser);%0A%09%09
+User aUser, Dataset dataset) %7B%0A        super(aUser, dataset);%0A        this.doomed = dataset;%0A    %7D%0A    %0A    public DeleteDatasetCommand(Dataset dataset, User aUser) %7B%0A        super(aUser, dataset);%0A        
 this
@@ -942,21 +942,31 @@
  = d
-oomed;%0A%09%7D%0A%09%0A%09
+ataset;%0A    %7D    %0A%0A    
 @Ove
@@ -971,17 +971,20 @@
 verride%0A
-%09
+    
 protecte
@@ -1053,153 +1053,186 @@
 n %7B%0A
-%09%09if ( doomed.isReleased() ) %7B%0A%09%09%09throw new IllegalCommandException(%22Cannot delete a released dataset%22, this);%0A%09%09%7D%0A%09%09super.executeImpl(ctxt);%0A%09
+        // TODO: REMOVE THIS COMMAND%0A        // for now it just calls DeleteDatasetVersion%0A        ctxt.engine().submit(new DeleteDatasetVersionCommand(getUser(), doomed));%0A    
 %7D%0A
-%09
 %0A%7D%0A

REMOVE THIS COMMAND for now it just calls DeleteDatasetVersion