Added Resume
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@96027 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
17f7b3a774
commit
d987d8bd9f
|
@ -25,6 +25,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.share.ShareInfo;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResumeMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResumeSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.ValidationsTasksMetadata;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplyMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySession;
|
||||
|
@ -236,6 +238,26 @@ public interface TDGWTService extends RemoteService {
|
|||
public void startTaskResubmit(TaskResubmitSession taskResubmitSession)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
|
||||
/**
|
||||
* Get Operation Monitor during the resume task
|
||||
*
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public TaskResumeMonitor getTaskResumeMonitor()
|
||||
throws TDGWTServiceException;
|
||||
|
||||
/**
|
||||
* Resume task
|
||||
*
|
||||
* @param taskResumeSession
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public void startTaskResume(TaskResumeSession taskResumeSession)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
|
||||
|
||||
// Validations
|
||||
/**
|
||||
|
|
|
@ -24,6 +24,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.share.ShareInfo;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResumeMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResumeSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.ValidationsTasksMetadata;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplyMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySession;
|
||||
|
@ -108,7 +110,10 @@ public interface TDGWTServiceAsync {
|
|||
//Task
|
||||
void getTaskResubmitMonitor(AsyncCallback<TaskResubmitMonitor> callback);
|
||||
void startTaskResubmit(TaskResubmitSession taskResubmitSession,AsyncCallback<Void> callback);
|
||||
void getTaskResumeMonitor(AsyncCallback<TaskResumeMonitor> callback);
|
||||
void startTaskResume(TaskResumeSession taskResumeSession,AsyncCallback<Void> callback);
|
||||
|
||||
|
||||
//Validations
|
||||
void getValidationsTasksMetadata(TRId trId,AsyncCallback<ValidationsTasksMetadata> callback);
|
||||
void getTableValidationsMetadata(TRId trId,AsyncCallback<TabValidationsMetadata> callback);
|
||||
|
|
|
@ -46,6 +46,10 @@ public class SessionConstants {
|
|||
protected static final String TASK_RESUBMIT_MONITOR = "TASK_RESUBMIT_MONITOR";
|
||||
protected static final String TASK_RESUBMIT_TASK = "TASK_RESUBMIT_TASK";
|
||||
|
||||
protected static final String TASK_RESUME_SESSION = "TASK_RESUME_SESSION";
|
||||
protected static final String TASK_RESUME_MONITOR = "TASK_RESUME_MONITOR";
|
||||
protected static final String TASK_RESUME_TASK = "TASK_RESUME_TASK";
|
||||
|
||||
protected static final String REPLACE_COLUMN_SESSION = "REPLACE_COLUMN_SESSION";
|
||||
protected static final String REPLACE_COLUMN_MONITOR = "REPLACE_COLUMN_MONITOR";
|
||||
protected static final String REPLACE_COLUMN_TASK = "REPLACE_COLUMN_TASK";
|
||||
|
|
|
@ -27,6 +27,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResumeMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResumeSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplyMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
||||
|
@ -776,6 +778,74 @@ public class SessionUtil {
|
|||
httpSession.setAttribute(SessionConstants.TASK_RESUBMIT_TASK, task);
|
||||
}
|
||||
|
||||
//
|
||||
public static TaskResumeSession getTaskResumeSession(
|
||||
HttpSession httpSession) {
|
||||
TaskResumeSession taskResumeSession = (TaskResumeSession) httpSession
|
||||
.getAttribute(SessionConstants.TASK_RESUME_SESSION);
|
||||
if (taskResumeSession != null) {
|
||||
return taskResumeSession;
|
||||
} else {
|
||||
taskResumeSession = new TaskResumeSession();
|
||||
httpSession.setAttribute(SessionConstants.TASK_RESUME_SESSION,
|
||||
taskResumeSession);
|
||||
return taskResumeSession;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setTaskResumeSession(HttpSession httpSession,
|
||||
TaskResumeSession taskResumeSession) {
|
||||
TaskResumeSession tr = (TaskResumeSession) httpSession
|
||||
.getAttribute(SessionConstants.TASK_RESUME_SESSION);
|
||||
if (tr != null) {
|
||||
httpSession.removeAttribute(SessionConstants.TASK_RESUME_SESSION);
|
||||
}
|
||||
httpSession.setAttribute(SessionConstants.TASK_RESUME_SESSION, taskResumeSession);
|
||||
|
||||
}
|
||||
|
||||
public static TaskResumeMonitor getTaskResumeMonitor(
|
||||
HttpSession httpSession) {
|
||||
TaskResumeMonitor taskResumeMonitor = (TaskResumeMonitor) httpSession
|
||||
.getAttribute(SessionConstants.TASK_RESUME_MONITOR);
|
||||
if (taskResumeMonitor != null) {
|
||||
return taskResumeMonitor;
|
||||
} else {
|
||||
taskResumeMonitor = new TaskResumeMonitor();
|
||||
httpSession.setAttribute(SessionConstants.TASK_RESUME_MONITOR,
|
||||
taskResumeMonitor);
|
||||
return taskResumeMonitor;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setTaskResumeMonitor(HttpSession httpSession,
|
||||
TaskResumeMonitor TaskResumeMonitor) {
|
||||
TaskResumeMonitor trm = (TaskResumeMonitor) httpSession
|
||||
.getAttribute(SessionConstants.TASK_RESUME_MONITOR);
|
||||
if (trm != null) {
|
||||
httpSession.removeAttribute(SessionConstants.TASK_RESUME_MONITOR);
|
||||
}
|
||||
httpSession.setAttribute(SessionConstants.TASK_RESUME_MONITOR, TaskResumeMonitor);
|
||||
|
||||
}
|
||||
|
||||
public static Task getTaskResumeTask(HttpSession httpSession) {
|
||||
Task monitor = (Task) httpSession.getAttribute(SessionConstants.TASK_RESUME_TASK);
|
||||
if (monitor == null) {
|
||||
logger.error("TASK_RESUME_TASK was not acquired");
|
||||
}
|
||||
return monitor;
|
||||
}
|
||||
|
||||
public static void setTaskResumeTask(HttpSession httpSession, Task task) {
|
||||
Task monitor = (Task) httpSession.getAttribute(SessionConstants.TASK_RESUME_TASK);
|
||||
if (monitor != null)
|
||||
httpSession.removeAttribute(SessionConstants.TASK_RESUME_TASK);
|
||||
httpSession.setAttribute(SessionConstants.TASK_RESUME_TASK, task);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
public static EditRowSession getEditRowSession(
|
||||
|
|
|
@ -137,6 +137,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.task.JobS;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.State;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResumeMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResumeSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskS;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.ValidationsTasksMetadata;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplyMonitor;
|
||||
|
@ -326,20 +328,19 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
ArrayList<TRMetadata> trMetadatas = getTRMetadata(currentTR
|
||||
.getTrId());
|
||||
updateTabResourceInformation(currentTR, trMetadatas);
|
||||
|
||||
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
TabularResource tr = service
|
||||
.getTabularResource(new TabularResourceId(Long.valueOf(currentTR
|
||||
.getId())));
|
||||
.getTabularResource(new TabularResourceId(Long
|
||||
.valueOf(currentTR.getTrId().getId())));
|
||||
|
||||
currentTR.setDate(sdf.format(tr.getCreationDate().getTime()));
|
||||
currentTR.setValid(tr.isValid());
|
||||
currentTR.setFinalized(tr.isFinalized());
|
||||
|
||||
|
||||
SessionUtil.setTabResource(session, currentTR);
|
||||
logger.debug("GetTabResourceInformation() updated information:"
|
||||
+ currentTR.toString());
|
||||
|
@ -2251,7 +2252,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
TabularResourceId tabularResourceId = new TabularResourceId(
|
||||
new Long(trId.getId()));
|
||||
|
||||
|
||||
TabularResource tr = service.getTabularResource(tabularResourceId);
|
||||
Table table = service.getLastTable(tabularResourceId);
|
||||
|
||||
|
@ -2972,8 +2973,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Check finalized status of a tabular resource
|
||||
|
@ -3002,14 +3001,14 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
} catch (TDGWTSessionExpiredException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error checking if it is a finalized tabular resource: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
logger.error(
|
||||
"Error checking if it is a finalized tabular resource: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
throw new TDGWTServiceException(
|
||||
"Error checking if it is a finalized tabular resource: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -3955,17 +3954,17 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
} else {
|
||||
logger.debug("Is a edit row");
|
||||
|
||||
Expression exp=ExpressionGenerator.genEditRowParamaterCondition(service, editRowSession);
|
||||
|
||||
|
||||
Expression exp = ExpressionGenerator.genEditRowParamaterCondition(
|
||||
service, editRowSession);
|
||||
|
||||
operationDefinition = OperationDefinitionMap.map(
|
||||
OperationsId.ModifyTuplesValuesByExpression.toString(),
|
||||
service);
|
||||
|
||||
|
||||
|
||||
map.put(Constants.PARAMETER_ADD_ROW_COMPOSITE, compositeValue);
|
||||
map.put(Constants.PARAMETER_EDIT_ROW_CONDITION, exp);
|
||||
|
||||
|
||||
invocation = new OperationExecution(
|
||||
operationDefinition.getOperationId(), map);
|
||||
}
|
||||
|
@ -5414,8 +5413,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
new Long(tabResource.getTrId().getId()));
|
||||
|
||||
TabularResource tr = service.getTabularResource(tabularResourceId);
|
||||
tr.finalize(tabResource.isFinalized());
|
||||
|
||||
|
||||
if (tabResource.getName() != null) {
|
||||
NameMetadata name = new NameMetadata(tabResource.getName());
|
||||
tr.setMetadata(name);
|
||||
|
@ -5438,6 +5437,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
tabResource.getRight());
|
||||
tr.setMetadata(rights);
|
||||
}
|
||||
|
||||
if(tabResource.isFinalized()){
|
||||
if(!tr.isFinalized()){
|
||||
tr.finalize();
|
||||
}
|
||||
}
|
||||
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
throw e;
|
||||
|
@ -6545,30 +6550,33 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
validations.add(validation);
|
||||
i++;
|
||||
}
|
||||
//TODO Fix refColumn
|
||||
|
||||
InvocationS invocationS=null;
|
||||
// TODO Fix refColumn
|
||||
|
||||
InvocationS invocationS = null;
|
||||
if (job.getInvocation() != null) {
|
||||
HashMap<String,Object> mapSent=new HashMap<String,Object>();
|
||||
Map<String,Object> map=job.getInvocation().getParameters();
|
||||
Set<String> keys=map.keySet();
|
||||
Iterator<String> iterator=keys.iterator();
|
||||
while(iterator.hasNext()){
|
||||
String key=iterator.next();
|
||||
Object o=map.get(key);
|
||||
HashMap<String, Object> mapSent = new HashMap<String, Object>();
|
||||
Map<String, Object> map = job.getInvocation()
|
||||
.getParameters();
|
||||
Set<String> keys = map.keySet();
|
||||
Iterator<String> iterator = keys.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
String key = iterator.next();
|
||||
Object o = map.get(key);
|
||||
mapSent.put(key, o.toString());
|
||||
}
|
||||
|
||||
RefColumn refColumn=ExtractReferences.extract(job.getInvocation());
|
||||
|
||||
|
||||
RefColumn refColumn = ExtractReferences.extract(job
|
||||
.getInvocation());
|
||||
|
||||
invocationS = new InvocationS(job.getInvocation()
|
||||
.getColumnId(), job.getInvocation()
|
||||
.getIdentifier(), job.getInvocation()
|
||||
.getOperationId(), mapSent, task.getId().getValue(),refColumn);
|
||||
.getOperationId(), mapSent, task.getId()
|
||||
.getValue(), refColumn);
|
||||
}
|
||||
JobS jobS = new JobS(String.valueOf(j), job.getProgress(),
|
||||
job.getHumaReadableStatus(), job.getDescription(),
|
||||
validations,invocationS);
|
||||
validations, invocationS);
|
||||
jobSList.add(jobS);
|
||||
j++;
|
||||
|
||||
|
@ -6740,9 +6748,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ColumnData getConnection(RefColumn refColumn)
|
||||
throws TDGWTServiceException {
|
||||
|
@ -6754,24 +6760,29 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
TableId tableId = new TableId(
|
||||
new Long(refColumn.getTableId()));
|
||||
|
||||
Table table=service.getTable(tableId);
|
||||
TableDescriptorMetadata tableDesc=table.getMetadata(TableDescriptorMetadata.class);
|
||||
if(tableDesc==null){
|
||||
logger.error("Error in getConnection(): No TableDescriptorMetadata found for table "+table);
|
||||
throw new TDGWTServiceException("Error in getConnection(): No TableDescriptorMetadata found for table "+table);
|
||||
TableId tableId = new TableId(new Long(refColumn.getTableId()));
|
||||
|
||||
Table table = service.getTable(tableId);
|
||||
TableDescriptorMetadata tableDesc = table
|
||||
.getMetadata(TableDescriptorMetadata.class);
|
||||
if (tableDesc == null) {
|
||||
logger.error("Error in getConnection(): No TableDescriptorMetadata found for table "
|
||||
+ table);
|
||||
throw new TDGWTServiceException(
|
||||
"Error in getConnection(): No TableDescriptorMetadata found for table "
|
||||
+ table);
|
||||
}
|
||||
if(tableDesc.getRefId()==0){
|
||||
logger.error("Error refId=0 for Table:"+table.toString());
|
||||
throw new TDGWTServiceException("Error refId=0 for Table:"+table.toString());
|
||||
if (tableDesc.getRefId() == 0) {
|
||||
logger.error("Error refId=0 for Table:" + table.toString());
|
||||
throw new TDGWTServiceException("Error refId=0 for Table:"
|
||||
+ table.toString());
|
||||
}
|
||||
logger.debug("Table connect to tabular resource: "+tableDesc.getRefId());
|
||||
TRId tId=new TRId(String.valueOf(tableDesc.getRefId()));
|
||||
TRId trId=retrieveTabularResourceBasicData(tId);
|
||||
ColumnData columnData=getColumn(refColumn.getColumnId(), trId);
|
||||
|
||||
logger.debug("Table connect to tabular resource: "
|
||||
+ tableDesc.getRefId());
|
||||
TRId tId = new TRId(String.valueOf(tableDesc.getRefId()));
|
||||
TRId trId = retrieveTabularResourceBasicData(tId);
|
||||
ColumnData columnData = getColumn(refColumn.getColumnId(), trId);
|
||||
|
||||
return columnData;
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
throw e;
|
||||
|
@ -6783,8 +6794,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//TODO
|
||||
// TODO
|
||||
@Override
|
||||
public void startTaskResubmit(TaskResubmitSession taskResubmitSession)
|
||||
throws TDGWTServiceException {
|
||||
|
@ -6792,23 +6802,26 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.setTaskResubmitSession(session, taskResubmitSession);
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
logger.debug("StartTaskResubmit: "+taskResubmitSession);
|
||||
logger.debug("StartTaskResubmit: " + taskResubmitSession);
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
if(taskResubmitSession==null){
|
||||
if (taskResubmitSession == null) {
|
||||
logger.error("TaskResubmitSession is null");
|
||||
throw new TDGWTServiceException("Error in resubmit task: TaskResubmitSession is null");
|
||||
throw new TDGWTServiceException(
|
||||
"Error in resubmit task: TaskResubmitSession is null");
|
||||
}
|
||||
if(taskResubmitSession.getTaskId()==null
|
||||
|| taskResubmitSession.getTaskId().isEmpty()){
|
||||
logger.error("Task Id is: "+taskResubmitSession.getTaskId());
|
||||
throw new TDGWTServiceException("Error in resubmit task, Task Id is: "+taskResubmitSession.getTaskId());
|
||||
if (taskResubmitSession.getTaskId() == null
|
||||
|| taskResubmitSession.getTaskId().isEmpty()) {
|
||||
logger.error("Task Id is: " + taskResubmitSession.getTaskId());
|
||||
throw new TDGWTServiceException(
|
||||
"Error in resubmit task, Task Id is: "
|
||||
+ taskResubmitSession.getTaskId());
|
||||
}
|
||||
|
||||
TaskId taskId=new TaskId(taskResubmitSession.getTaskId());
|
||||
|
||||
|
||||
TaskId taskId = new TaskId(taskResubmitSession.getTaskId());
|
||||
|
||||
Task trTask = service.resubmit(taskId);
|
||||
logger.debug("Resubmit Task on service: TaskId " + trTask.getId());
|
||||
SessionUtil.setTaskResubmitTask(session, trTask);
|
||||
|
@ -6821,10 +6834,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
throw new TDGWTServiceException("Error in resubmit task: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public TaskResubmitMonitor getTaskResubmitMonitor()
|
||||
throws TDGWTServiceException {
|
||||
|
@ -6849,8 +6861,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
} else {
|
||||
logger.debug("Services TaskStatus: " + task.getStatus());
|
||||
|
||||
taskResubmitMonitor
|
||||
.setStatus(TaskStateMap.map(task.getStatus()));
|
||||
taskResubmitMonitor.setStatus(TaskStateMap.map(task
|
||||
.getStatus()));
|
||||
|
||||
TRId trId;
|
||||
TabResource tabResource;
|
||||
|
@ -6918,7 +6930,152 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
} catch (TDGWTSessionExpiredException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.debug("Error in TaskResubmitMonitor: " + e.getLocalizedMessage());
|
||||
logger.debug("Error in TaskResubmitMonitor: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException("Error: " + e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//TODO
|
||||
@Override
|
||||
public void startTaskResume(TaskResumeSession taskResumeSession)
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.setTaskResumeSession(session, taskResumeSession);
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
logger.debug("StartTaskResume: " + taskResumeSession);
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
if (taskResumeSession == null) {
|
||||
logger.error("TaskResumeSession is null");
|
||||
throw new TDGWTServiceException(
|
||||
"Error in resume: TaskResumeSession is null");
|
||||
}
|
||||
if (taskResumeSession.getTaskId() == null
|
||||
|| taskResumeSession.getTaskId().isEmpty()) {
|
||||
logger.error("Task Id is: " + taskResumeSession.getTaskId());
|
||||
throw new TDGWTServiceException(
|
||||
"Error in resume task, Task Id is: "
|
||||
+ taskResumeSession.getTaskId());
|
||||
}
|
||||
|
||||
TaskId taskId = new TaskId(taskResumeSession.getTaskId());
|
||||
|
||||
Task trTask = service.resubmit(taskId);
|
||||
logger.debug("Resume Task on service: TaskId " + trTask.getId());
|
||||
SessionUtil.setTaskResumeTask(session, trTask);
|
||||
return;
|
||||
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException("Error in resume task: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskResumeMonitor getTaskResumeMonitor()
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
TaskResumeSession taskResumeSession = SessionUtil
|
||||
.getTaskResumeSession(session);
|
||||
|
||||
Task task = SessionUtil.getTaskResumeTask(session);
|
||||
TaskResumeMonitor taskResumeMonitor = new TaskResumeMonitor();
|
||||
|
||||
if (task == null) {
|
||||
logger.debug("Task null");
|
||||
throw new TDGWTServiceException(
|
||||
"Error in TaskResumeMonitor task null");
|
||||
} else {
|
||||
TaskStatus status = task.getStatus();
|
||||
if (status == null) {
|
||||
logger.debug("Services TaskStatus : null");
|
||||
throw new TDGWTServiceException(
|
||||
"Error in TaskResumeMonitor Status null");
|
||||
} else {
|
||||
logger.debug("Services TaskStatus: " + task.getStatus());
|
||||
|
||||
taskResumeMonitor.setStatus(TaskStateMap.map(task
|
||||
.getStatus()));
|
||||
|
||||
TRId trId;
|
||||
TabResource tabResource;
|
||||
switch (taskResumeMonitor.getStatus()) {
|
||||
case FAILED:
|
||||
if (task.getResult() != null) {
|
||||
logger.debug("Task exception:"
|
||||
+ task.getErrorCause());
|
||||
task.getErrorCause().printStackTrace();
|
||||
taskResumeMonitor.setError(new Throwable(task
|
||||
.getErrorCause()));
|
||||
} else {
|
||||
logger.debug("Task exception: Error In TaskResumeMonitor");
|
||||
taskResumeMonitor.setError(new Throwable(
|
||||
"Error task resume"));
|
||||
}
|
||||
taskResumeMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
case SUCCEDED:
|
||||
logger.debug("Task Result:" + task.getResult());
|
||||
taskResumeMonitor.setProgress(task.getProgress());
|
||||
trId = new TRId();
|
||||
trId.setId(taskResumeSession.getTrId().getId());
|
||||
trId = retrieveTabularResourceBasicData(trId);
|
||||
taskResumeMonitor.setTrId(trId);
|
||||
tabResource = SessionUtil.getTabResource(session);
|
||||
tabResource.setTrId(trId);
|
||||
SessionUtil.setTabResource(session, tabResource);
|
||||
SessionUtil.setTRId(session, trId);
|
||||
break;
|
||||
case IN_PROGRESS:
|
||||
taskResumeMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
case VALIDATING_RULES:
|
||||
taskResumeMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
case GENERATING_VIEW:
|
||||
break;
|
||||
case ABORTED:
|
||||
break;
|
||||
case STOPPED:
|
||||
logger.debug("Task Result:" + task.getResult());
|
||||
taskResumeMonitor.setProgress(task.getProgress());
|
||||
|
||||
trId = retrieveTabularResourceBasicData(taskResumeSession
|
||||
.getTrId());
|
||||
|
||||
taskResumeMonitor.setTrId(trId);
|
||||
tabResource = SessionUtil.getTabResource(session);
|
||||
tabResource.setTrId(trId);
|
||||
SessionUtil.setTabResource(session, tabResource);
|
||||
SessionUtil.setTRId(session, trId);
|
||||
break;
|
||||
case INITIALIZING:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
SessionUtil.setTaskResumeTask(session, task);
|
||||
}
|
||||
|
||||
logger.debug("TaskResumeMonitor(): " + taskResumeMonitor);
|
||||
return taskResumeMonitor;
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.debug("Error in TaskResumeMonitor: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException("Error: " + e.getLocalizedMessage());
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package org.gcube.portlets.user.td.gwtservice.shared.task;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.OperationMonitor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
*
|
||||
*/
|
||||
public class TaskResumeMonitor extends OperationMonitor implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1547897501452634298L;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package org.gcube.portlets.user.td.gwtservice.shared.task;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
*
|
||||
*/
|
||||
public class TaskResumeSession implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4503878699159491057L;
|
||||
|
||||
protected TRId trId;
|
||||
protected String taskId;
|
||||
|
||||
public TaskResumeSession(){
|
||||
|
||||
}
|
||||
|
||||
public TaskResumeSession(TRId trId, String taskId){
|
||||
this.trId=trId;
|
||||
this.taskId=taskId;
|
||||
}
|
||||
|
||||
public TRId getTrId() {
|
||||
return trId;
|
||||
}
|
||||
|
||||
public void setTrId(TRId trId) {
|
||||
this.trId = trId;
|
||||
}
|
||||
|
||||
public String getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public void setTaskId(String taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TaskResumeSession [trId=" + trId + ", taskId=" + taskId + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue