From fe4880c51b1f1f062b647aad6ca859998ab47635 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Wed, 16 Apr 2014 09:10:31 +0000 Subject: [PATCH] Minor Update git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@94872 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../gwtservice/client/rpc/TDGWTService.java | 24 ++++++- .../client/rpc/TDGWTServiceAsync.java | 6 ++ .../td/gwtservice/server/SessionUtil.java | 2 +- .../gwtservice/server/TDGWTServiceImpl.java | 70 +++++++++---------- 4 files changed, 64 insertions(+), 38 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java index 702c43f..e2e4435 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java @@ -15,6 +15,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceExcept import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadMonitor; import org.gcube.portlets.user.td.gwtservice.shared.file.HeaderPresence; import org.gcube.portlets.user.td.gwtservice.shared.history.OpHistory; +import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSession; +import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSessionMonitor; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportMonitor; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportMonitor; @@ -223,7 +225,27 @@ public interface TDGWTService extends RemoteService { */ public ArrayList getValidationColumns(TRId trId, String columnName) throws TDGWTServiceException; - + + //RollBack + /** + * Call rollback on tabular resource + * + * @param rollBackSession + * @throws TDGWTServiceException + */ + public void rollBack(RollBackSession rollBackSession) + throws TDGWTServiceException; + + /** + * Get Operation Monitor during the rollback + * + * @return + * @throws TDGWTServiceException + */ + public RollBackSessionMonitor getRollBackMonitor() + throws TDGWTServiceException; + + // Share /** * Retrieves information sharing on the tabular resource diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java index 550bcf4..7727931 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java @@ -14,6 +14,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVRowError; import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadMonitor; import org.gcube.portlets.user.td.gwtservice.shared.file.HeaderPresence; import org.gcube.portlets.user.td.gwtservice.shared.history.OpHistory; +import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSession; +import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSessionMonitor; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportMonitor; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportMonitor; @@ -98,6 +100,10 @@ public interface TDGWTServiceAsync { void getColumn(String columnLocalId,TRId trId, AsyncCallback callback); void getValidationColumns(TRId trId, String columnName, AsyncCallback> callback); + //RollBack + void rollBack(RollBackSession rollBackSession,AsyncCallback callback); + void getRollBackMonitor(AsyncCallback callback); + //Share void getShareInfo(TRId trId, AsyncCallback callback); diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java index 85de664..b23c616 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java @@ -1327,7 +1327,7 @@ public class SessionUtil { return monitor; } - public static void setRollBackTask(HttpSession httpSession, Task task) { + public static void setRollBackSessionTask(HttpSession httpSession, Task task) { Task monitor = (Task) httpSession.getAttribute(ROLLBACK_TASK); if (monitor != null) httpSession.removeAttribute(ROLLBACK_TASK); diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java index 3c8f251..0d6b677 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java @@ -114,6 +114,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadState; import org.gcube.portlets.user.td.gwtservice.shared.file.HeaderPresence; import org.gcube.portlets.user.td.gwtservice.shared.history.OpHistory; import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSession; +import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSessionMonitor; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportMonitor; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportMonitor; @@ -5944,7 +5945,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements * * {@inheritDoc} */ - + @Override public void rollBack(RollBackSession rollBackSession) throws TDGWTServiceException { try { @@ -5967,7 +5968,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements throw new TDGWTServiceException("Task not started"); } logger.debug("Start Task on service: TaskId " + trTask.getId()); - SessionUtil.setRollBackTask(session, trTask); + SessionUtil.setRollBackSessionTask(session, trTask); return; } catch (Throwable e) { @@ -5982,87 +5983,84 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements /** * * {@inheritDoc} - + */ @Override - public ReplaceBatchColumnMonitor getReplaceBatchColumnMonitor() + public RollBackSessionMonitor getRollBackMonitor() throws TDGWTServiceException { try { HttpSession session = this.getThreadLocalRequest().getSession(); - ReplaceBatchColumnSession replaceBatchColumnSession = SessionUtil - .getReplaceBatchColumnSession(session); + RollBackSession rollBackSession = SessionUtil + .getRollBackSession(session); - Task task = SessionUtil.getReplaceBatchColumnTask(session); - ReplaceBatchColumnMonitor replaceBatchColumnMonitor = new ReplaceBatchColumnMonitor(); + Task task = SessionUtil.getRollBackSessionTask(session); + RollBackSessionMonitor rollBackMonitor = new RollBackSessionMonitor(); if (task == null) { logger.debug("Task null"); throw new TDGWTServiceException( - "Error in ReplaceBatchColumnMonitor task null"); + "Error in RollBackMonitor task null"); } else { TaskStatus status = task.getStatus(); if (status == null) { logger.debug("Services TaskStatus : null"); throw new TDGWTServiceException( - "Error in ReplaceBatchColumnMonitor Status null"); + "Error in RollBackSessionMonitor Status null"); } else { logger.debug("Services TaskStatus: " + task.getStatus()); - replaceBatchColumnMonitor.setStatus(TaskStateMap.map(task + rollBackMonitor.setStatus(TaskStateMap.map(task .getStatus())); TRId trId; TabResource tabResource; - switch (replaceBatchColumnMonitor.getStatus()) { + switch (rollBackMonitor.getStatus()) { case FAILED: if (task.getResult() != null) { logger.debug("Task exception:" + task.getErrorCause()); - replaceBatchColumnMonitor.setError(new Throwable( + rollBackMonitor.setError(new Throwable( task.getErrorCause())); } else { - logger.debug("Task exception: Error In ReplaceBatchColumnMonitor"); - replaceBatchColumnMonitor.setError(new Throwable( - "Error replacing the Column value")); + logger.debug("Task exception: Error In RollBackSessionMonitor"); + rollBackMonitor.setError(new Throwable( + "Error in roll back")); } - replaceBatchColumnMonitor.setProgress(task + rollBackMonitor.setProgress(task .getProgress()); break; case SUCCEDED: logger.debug("Task Result:" + task.getResult()); - replaceBatchColumnMonitor.setProgress(task + rollBackMonitor.setProgress(task .getProgress()); trId = new TRId(); - trId.setId(replaceBatchColumnSession.getTrId().getId()); + trId.setId(rollBackSession.getTrId().getId()); trId = retrieveTabularResourceBasicData(trId); - replaceBatchColumnMonitor.setTrId(trId); + rollBackMonitor.setTrId(trId); tabResource = SessionUtil.getTabResource(session); tabResource.setTrId(trId); SessionUtil.setTabResource(session, tabResource); SessionUtil.setTRId(session, trId); break; case IN_PROGRESS: - replaceBatchColumnMonitor.setProgress(task + rollBackMonitor.setProgress(task .getProgress()); break; case VALIDATING_RULES: - replaceBatchColumnMonitor.setProgress(task + rollBackMonitor.setProgress(task .getProgress()); break; case ABORTED: break; case STOPPED: logger.debug("Task Result:" + task.getResult()); - replaceBatchColumnMonitor.setProgress(task + rollBackMonitor.setProgress(task .getProgress()); - trId = new TRId(); - trId.setId(replaceBatchColumnSession.getColumnData() - .getTrId().getId()); + + trId = retrieveTabularResourceBasicData(rollBackSession.getTrId()); - trId = retrieveTabularResourceBasicData(trId); - - replaceBatchColumnMonitor.setTrId(trId); + rollBackMonitor.setTrId(trId); tabResource = SessionUtil.getTabResource(session); tabResource.setTrId(trId); SessionUtil.setTabResource(session, tabResource); @@ -6074,22 +6072,22 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements break; } } - SessionUtil.setReplaceBatchColumnTask(session, task); + SessionUtil.setRollBackSessionTask(session, task); } - logger.info("ReplaceBatchColumnMonitor(): " - + replaceBatchColumnMonitor); - return replaceBatchColumnMonitor; + logger.info("RollBackSessionMonitor(): " + + rollBackMonitor); + return rollBackMonitor; } catch (Throwable e) { - logger.debug("Error in ReplaceBatchColumnMonitor: " + logger.debug("Error in RollBackSessionMonitor: " + e.getLocalizedMessage()); e.printStackTrace(); - throw new TDGWTServiceException("Error in replace batch: " + throw new TDGWTServiceException("Error in rollback: " + e.getLocalizedMessage()); } } - */ + }