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 733ef43..f73ad72 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 @@ -5764,23 +5764,22 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements .getTabularResource(tabularResourceId); List history = tabularResource.getHistory(); long historyId = 0; - String opDesc=null, opName=null; + String opDesc = null, opName = null; HistoryStep lastStep = null; OpHistory op = null; - + if (history != null && history.size() > 0) { lastStep = history.get(0); if (lastStep != null) { opDesc = lastStep.getOperationDescription(); opName = opDesc; historyId = lastStep.getId().getValue(); - op = new OpHistory(historyId, opName, - opDesc, sdf.format(lastStep - .getExecutionDate().getTime())); + op = new OpHistory(historyId, opName, opDesc, + sdf.format(lastStep.getExecutionDate().getTime())); } } - + logger.debug("Last Operation Info :" + op); return op; @@ -5815,22 +5814,21 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements Long.valueOf(trId.getId())); TabularResource tabularResource = service .getTabularResource(tabularResourceId); - + List history = tabularResource.getHistory(); long historyId = 0; - String opDesc=null, opName=null; + String opDesc = null, opName = null; HistoryStep lastStep = null; OpHistory op = null; - + if (history != null && history.size() > 0) { lastStep = history.get(0); if (lastStep != null) { opDesc = lastStep.getOperationDescription(); opName = opDesc; historyId = lastStep.getId().getValue(); - op = new OpHistory(historyId, opName, - opDesc, sdf.format(lastStep - .getExecutionDate().getTime())); + op = new OpHistory(historyId, opName, opDesc, + sdf.format(lastStep.getExecutionDate().getTime())); } } @@ -5876,9 +5874,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements List history = tabularResource.getHistory(); ArrayList opHistoryList = new ArrayList(); - + long historyId = 0; - String opDesc=null, opName=null; + String opDesc = null, opName = null; OpHistory op = null; for (HistoryStep step : history) { @@ -5886,9 +5884,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements historyId = step.getId().getValue(); opDesc = step.getOperationDescription(); opName = step.getOperationDescription(); - op = new OpHistory(historyId, opName, - opDesc, sdf.format(step - .getExecutionDate().getTime())); + op = new OpHistory(historyId, opName, opDesc, + sdf.format(step.getExecutionDate().getTime())); opHistoryList.add(op); } } @@ -5931,7 +5928,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements ArrayList opHistoryList = new ArrayList(); long historyId = 0; - String opDesc=null, opName=null; + String opDesc = null, opName = null; OpHistory op = null; for (HistoryStep step : history) { @@ -5939,13 +5936,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements historyId = step.getId().getValue(); opDesc = step.getOperationDescription(); opName = step.getOperationDescription(); - op = new OpHistory(historyId, opName, - opDesc, sdf.format(step - .getExecutionDate().getTime())); + op = new OpHistory(historyId, opName, opDesc, + sdf.format(step.getExecutionDate().getTime())); opHistoryList.add(op); } } - + logger.debug("History :" + opHistoryList); return opHistoryList; @@ -5980,22 +5976,25 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements List history = tabularResource.getHistory(); long historyId = 0; - String opDesc=null, opName=null; + String opDesc = null, opName = null; OpHistory op = null; - RollBackSession rollBackSession=null; + RollBackSession rollBackSession = null; if (history != null) { - HistoryStep step = history.get(1); - if (step != null) { - historyId = step.getId().getValue(); - opDesc= step.getOperationDescription(); - opName= opDesc; - op = new OpHistory(historyId, opName, - opDesc, sdf.format(step - .getExecutionDate().getTime())); - logger.debug("Discard :"+op); - rollBackSession=new RollBackSession(trId,historyId); - rollBack(rollBackSession); - + if (history.size() > 1) { + HistoryStep step = history.get(history.size() - 2); + if (step != null) { + historyId = step.getId().getValue(); + opDesc = step.getOperationDescription(); + opName = opDesc; + op = new OpHistory(historyId, opName, opDesc, + sdf.format(step.getExecutionDate().getTime())); + logger.debug("Discard :" + op); + rollBackSession = new RollBackSession(trId, historyId); + rollBack(rollBackSession); + + } else { + logger.debug("Discard : step null"); + } } else { logger.debug("Discard : no previous step exist"); }