Added checkItemConfigurations
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/workspace-task-executor-library@167325 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d9b9bd9ac6
commit
24f55cba33
|
@ -57,11 +57,12 @@ public class DataMinerAccessPoint {
|
||||||
dataMinerService = new DataMinerService();
|
dataMinerService = new DataMinerService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the task.
|
* Removes the task.
|
||||||
*
|
*
|
||||||
* @param algConfiguration the alg configuration
|
* @param algConfiguration the alg configuration
|
||||||
* @return
|
* @return the task execution status
|
||||||
*/
|
*/
|
||||||
private TaskExecutionStatus removeTask(BaseTaskConfiguration algConfiguration){
|
private TaskExecutionStatus removeTask(BaseTaskConfiguration algConfiguration){
|
||||||
|
|
||||||
|
@ -82,12 +83,12 @@ public class DataMinerAccessPoint {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the task.
|
* Gets the running task.
|
||||||
*
|
*
|
||||||
* @param taskConfiguration the task configuration
|
* @param taskConfiguration the task configuration
|
||||||
* @return the task
|
* @return the running task
|
||||||
*/
|
*/
|
||||||
private TaskExecutionStatus getTask(BaseTaskConfiguration taskConfiguration){
|
public TaskExecutionStatus getRunningTask(BaseTaskConfiguration taskConfiguration){
|
||||||
return mapExecutionTask.get(taskConfiguration.getConfigurationKey());
|
return mapExecutionTask.get(taskConfiguration.getConfigurationKey());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -102,7 +103,7 @@ public class DataMinerAccessPoint {
|
||||||
*/
|
*/
|
||||||
public void abortRunningTask(TaskConfiguration taskConfiguration) throws TaskErrorException, TaskNotExecutableException{
|
public void abortRunningTask(TaskConfiguration taskConfiguration) throws TaskErrorException, TaskNotExecutableException{
|
||||||
|
|
||||||
TaskExecutionStatus task = getTask(taskConfiguration);
|
TaskExecutionStatus task = getRunningTask(taskConfiguration);
|
||||||
|
|
||||||
if(task==null)
|
if(task==null)
|
||||||
throw new TaskErrorException("The task with configuration: "+taskConfiguration+" is not running");
|
throw new TaskErrorException("The task with configuration: "+taskConfiguration+" is not running");
|
||||||
|
@ -176,7 +177,7 @@ public class DataMinerAccessPoint {
|
||||||
|
|
||||||
//TODO ???
|
//TODO ???
|
||||||
|
|
||||||
TaskExecutionStatus theTaskStatus = getTask(taskConfiguration);
|
TaskExecutionStatus theTaskStatus = getRunningTask(taskConfiguration);
|
||||||
|
|
||||||
if(theTaskStatus==null)
|
if(theTaskStatus==null)
|
||||||
throw new TaskErrorException("No Task is running with the configuration: "+taskConfiguration.getConfigurationKey());
|
throw new TaskErrorException("No Task is running with the configuration: "+taskConfiguration.getConfigurationKey());
|
||||||
|
|
|
@ -10,10 +10,12 @@ import org.gcube.common.workspacetaskexecutor.shared.ExecutableTask;
|
||||||
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskComputation;
|
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskComputation;
|
||||||
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration;
|
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration;
|
||||||
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskExecutionStatus;
|
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskExecutionStatus;
|
||||||
|
import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotConfiguredException;
|
||||||
import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotExecutableException;
|
import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotExecutableException;
|
||||||
import org.gcube.common.workspacetaskexecutor.shared.exception.TaskConfigurationNotFoundException;
|
import org.gcube.common.workspacetaskexecutor.shared.exception.TaskConfigurationNotFoundException;
|
||||||
import org.gcube.common.workspacetaskexecutor.shared.exception.TaskErrorException;
|
import org.gcube.common.workspacetaskexecutor.shared.exception.TaskErrorException;
|
||||||
import org.gcube.common.workspacetaskexecutor.shared.exception.TaskNotExecutableException;
|
import org.gcube.common.workspacetaskexecutor.shared.exception.TaskNotExecutableException;
|
||||||
|
import org.gcube.common.workspacetaskexecutor.shared.exception.WorkspaceFolderLocked;
|
||||||
import org.gcube.common.workspacetaskexecutor.util.JsonUtil;
|
import org.gcube.common.workspacetaskexecutor.util.JsonUtil;
|
||||||
import org.gcube.common.workspacetaskexecutor.util.WsUtil;
|
import org.gcube.common.workspacetaskexecutor.util.WsUtil;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
@ -174,11 +176,37 @@ public class WorkspaceDataMinerTaskExecutor implements ExecutableTask<TaskConfig
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check item configurations.
|
||||||
|
*
|
||||||
|
* @param workspaceItemId the workspace item id
|
||||||
|
* @return the list
|
||||||
|
* @throws ItemNotConfiguredException the item not configured exception
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
public List<TaskConfiguration> checkItemConfigurations(String workspaceItemId) throws ItemNotConfiguredException, Exception{
|
||||||
|
List<TaskConfiguration> confs = getListOfTaskConfigurations(workspaceItemId);
|
||||||
|
|
||||||
|
if(confs==null)
|
||||||
|
throw new ItemNotConfiguredException("The item "+workspaceItemId+" has not "+TaskConfiguration.class.getSimpleName()+" saved");
|
||||||
|
|
||||||
|
DataMinerAccessPoint dmAP = getDataMinerAccessPoint();
|
||||||
|
|
||||||
|
for (TaskConfiguration taskConfiguration : confs) {
|
||||||
|
TaskExecutionStatus taskStatus = dmAP.getRunningTask(taskConfiguration);
|
||||||
|
if(taskStatus!=null)
|
||||||
|
throw new WorkspaceFolderLocked(workspaceItemId, "The item: "+workspaceItemId+ "is locked by running Task: "+taskStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
return confs;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.common.workspacetaskexecutor.CheckableTask#isItemExecutable(java.lang.String)
|
* @see org.gcube.common.workspacetaskexecutor.CheckableTask#isItemExecutable(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean isItemExecutable(String workspaceItemId) throws ItemNotExecutableException, Exception {
|
public Boolean isItemExecutable(String workspaceItemId) throws Exception {
|
||||||
logger.debug("Is Item "+workspaceItemId+" Executable starts...");
|
logger.debug("Is Item "+workspaceItemId+" Executable starts...");
|
||||||
checkOwner();
|
checkOwner();
|
||||||
WorkspaceItem item = WsUtil.getItem(usernameOwner, workspaceItemId);
|
WorkspaceItem item = WsUtil.getItem(usernameOwner, workspaceItemId);
|
||||||
|
|
|
@ -24,10 +24,9 @@ public interface ExecutableItem<T extends BaseTaskConfiguration> {
|
||||||
*
|
*
|
||||||
* @param itemId the item id
|
* @param itemId the item id
|
||||||
* @return the boolean
|
* @return the boolean
|
||||||
* @throws ItemNotExecutableException the item not executable exception
|
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
Boolean isItemExecutable(String itemId) throws ItemNotExecutableException, Exception;
|
Boolean isItemExecutable(String itemId) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package org.gcube.common.workspacetaskexecutor.shared.exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class ItemNotExecutableException.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* Apr 27, 2018
|
||||||
|
*/
|
||||||
|
public class ItemNotConfiguredException extends Exception {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -6125541690663669233L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new item not synched.
|
||||||
|
*/
|
||||||
|
public ItemNotConfiguredException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new item not synched.
|
||||||
|
*
|
||||||
|
* @param arg0 the arg 0
|
||||||
|
*/
|
||||||
|
public ItemNotConfiguredException(String arg0) {
|
||||||
|
super(arg0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
package org.gcube.common.workspacetaskexecutor.shared.exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class WorkspaceFolderLocked.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* May 4, 2018
|
||||||
|
*/
|
||||||
|
public class WorkspaceFolderLocked extends Exception {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 7375143436359627673L;
|
||||||
|
private String folderId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new item not synched.
|
||||||
|
*/
|
||||||
|
public WorkspaceFolderLocked() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new item not synched.
|
||||||
|
*
|
||||||
|
* @param folderId the folder id
|
||||||
|
* @param arg0 the arg 0
|
||||||
|
*/
|
||||||
|
public WorkspaceFolderLocked(String folderId, String arg0) {
|
||||||
|
super(arg0);
|
||||||
|
this.folderId = folderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the folder id.
|
||||||
|
*
|
||||||
|
* @return the folderId
|
||||||
|
*/
|
||||||
|
public String getFolderId() {
|
||||||
|
|
||||||
|
return folderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue