Commit 902af8ddb47d994f53bd000bbf3514cddf0dbc52

Authored by Carlos Alberto
1 parent 05c1e75d
Exists in master

Correções nos componentes de banco de dados

cit-esi-api/src/main/java/br/com/centralit/esi/api/data/service/impl/DataManager.java
... ... @@ -34,7 +34,6 @@ import br.com.centralit.esi.api.enumerated.RelationshipTypeEnum;
34 34 import br.com.centralit.esi.api.enumerated.SqlClauseTypeEnum;
35 35 import br.com.centralit.esi.api.parameter.service.ParameterService;
36 36 import br.com.centralit.esi.api.util.ConvertUtilsESI;
37   -import br.com.centralit.esi.exception.EsiBusinessException;
38 37 import br.com.centralit.esi.exception.EsiControlledException;
39 38 import br.com.centralit.esi.exception.EsiExecutionException;
40 39 import br.com.centralit.framework.esi.enumerated.VariableTypeEnum;
... ... @@ -126,7 +125,7 @@ public class DataManager {
126 125 }
127 126 }
128 127 if (!errors.equals("")) {
129   - throw new EsiBusinessException(errors);
  128 + throw new EsiExecutionException(errors);
130 129 }
131 130 }
132 131  
... ... @@ -196,7 +195,7 @@ public class DataManager {
196 195 result = DataObjectUtil.executeQuery(dataObject, connection, sql, map);
197 196 } catch (SQLException e) {
198 197 e.printStackTrace();
199   - throw new EsiBusinessException(e);
  198 + throw new EsiExecutionException(e);
200 199 }finally{
201 200 dataSourceService.close(connection);
202 201 }
... ... @@ -233,7 +232,7 @@ public class DataManager {
233 232 result = DataObjectUtil.executeQuery(dataObject, connection, query, map);
234 233  
235 234 } catch (Exception e) {
236   - throw new EsiBusinessException(e);
  235 + throw new EsiExecutionException(e);
237 236 }finally{
238 237 this.dataSourceService.close(connection);
239 238 }
... ... @@ -272,7 +271,7 @@ public class DataManager {
272 271 return map;
273 272 } catch (Exception e) {
274 273 this.dataSourceService.rollback(connection);
275   - throw new EsiBusinessException(e);
  274 + throw new EsiExecutionException(e);
276 275 }finally{
277 276 this.dataSourceService.close(connection);
278 277 }
... ... @@ -302,7 +301,7 @@ public class DataManager {
302 301 return map;
303 302 } catch (Exception e) {
304 303 this.dataSourceService.rollback(connection);
305   - throw new EsiBusinessException(e);
  304 + throw new EsiExecutionException(e);
306 305 }finally{
307 306 this.dataSourceService.close(connection);
308 307 }
... ... @@ -326,7 +325,7 @@ public class DataManager {
326 325 this.dataSourceService.commit(connection);
327 326 } catch (Exception e) {
328 327 this.dataSourceService.rollback(connection);
329   - throw new EsiBusinessException(e);
  328 + throw new EsiExecutionException(e);
330 329 }finally{
331 330 this.dataSourceService.close(connection);
332 331 }
... ... @@ -357,7 +356,7 @@ public class DataManager {
357 356 this.updateRelationships(dataObject, map);
358 357 } catch (Exception e) {
359 358 this.dataSourceService.rollback(connection);
360   - throw new EsiBusinessException(e);
  359 + throw new EsiExecutionException(e);
361 360 }finally{
362 361 this.dataSourceService.close(connection);
363 362 }
... ... @@ -386,7 +385,7 @@ public class DataManager {
386 385 this.updateRelationships(dataObject, map);
387 386 } catch (Exception e) {
388 387 this.dataSourceService.rollback(connection);
389   - throw new EsiBusinessException(e);
  388 + throw new EsiExecutionException(e);
390 389 }finally{
391 390 this.dataSourceService.close(connection);
392 391 }
... ... @@ -409,7 +408,7 @@ public class DataManager {
409 408 }
410 409 } catch (SQLException e) {
411 410 e.printStackTrace();
412   - throw new EsiBusinessException(e);
  411 + throw new EsiExecutionException(e);
413 412 }finally{
414 413 this.dataSourceService.close(connection);
415 414 }
... ... @@ -434,7 +433,7 @@ public class DataManager {
434 433 this.dataSourceService.commit(connection);
435 434 } catch (Exception e) {
436 435 this.dataSourceService.rollback(connection);
437   - throw new EsiBusinessException(e);
  436 + throw new EsiExecutionException(e);
438 437 }finally{
439 438 this.dataSourceService.close(connection);
440 439 }
... ... @@ -500,10 +499,10 @@ public class DataManager {
500 499 return DataObjectUtil.buildColumns(dataSource, connection, schemaName, tableName);
501 500 } catch (SQLException e) {
502 501 e.printStackTrace();
503   - throw new EsiBusinessException(e);
  502 + throw new EsiExecutionException(e);
504 503 }
505 504 }else{
506   - throw new EsiBusinessException("Conexão de banco de dados não encontrada");
  505 + throw new EsiExecutionException("Conexão de banco de dados não encontrada");
507 506 }
508 507 }
509 508  
... ...
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/component/ExecuteDBRollback.java 0 → 100644
... ... @@ -0,0 +1,24 @@
  1 +package br.com.centralit.esi.api.execution.component;
  2 +
  3 +import java.sql.Connection;
  4 +import java.sql.SQLException;
  5 +
  6 +import br.com.centralit.esi.api.runtime.RuntimeEnvironment;
  7 +import br.com.centralit.esi.exception.EsiExecutionException;
  8 +
  9 +public class ExecuteDBRollback {
  10 + public static void execute(RuntimeEnvironment runtimeEnvironment) {
  11 + String connName = (String) runtimeEnvironment.getObject("CONNECTIONNAME");
  12 + if (connName != null){
  13 + Connection connection = (Connection) runtimeEnvironment.getObject(connName);
  14 + if (connection != null){
  15 + try {
  16 + connection.rollback();
  17 + } catch (SQLException e) {
  18 + e.printStackTrace();
  19 + throw new EsiExecutionException(e);
  20 + }
  21 + }
  22 + }
  23 + }
  24 +}
... ...
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/component/ExecuteRollbackTransactionSql.java
... ... @@ -1,32 +0,0 @@
1   -package br.com.centralit.esi.api.execution.component;
2   -
3   -import java.sql.Connection;
4   -import java.sql.SQLException;
5   -
6   -import br.com.centralit.esi.api.runtime.RuntimeEnvironment;
7   -import br.com.centralit.esi.exception.EsiExecutionException;
8   -
9   -public class ExecuteRollbackTransactionSql {
10   - public static void execute(RuntimeEnvironment runtimeEnvironment) {
11   - String connName = (String) runtimeEnvironment.getObject("CONNECTIONNAME");
12   - if (connName != null){
13   - Connection connection = (Connection) runtimeEnvironment.getObject(connName);
14   - if (connection != null){
15   - try {
16   - connection.rollback();
17   - } catch (SQLException e) {
18   - e.printStackTrace();
19   - throw new EsiExecutionException(e);
20   - } finally{
21   - try {
22   - connection.close();
23   - } catch (SQLException e) {
24   - e.printStackTrace();
25   - }
26   - connection = null;
27   - }
28   - }
29   - runtimeEnvironment.addOrUpdateObject(connName, null);
30   - }
31   - }
32   -}
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/component/WorkItemDatabaseRollbackServiceImpl.java
... ... @@ -5,7 +5,7 @@ import org.springframework.stereotype.Service;
5 5  
6 6 import br.com.centralit.esi.api.design.model.FlowElement;
7 7 import br.com.centralit.esi.api.design.model.connector.DatabaseRollback;
8   -import br.com.centralit.esi.api.execution.component.ExecuteRollbackTransactionSql;
  8 +import br.com.centralit.esi.api.execution.component.ExecuteDBRollback;
9 9 import br.com.centralit.esi.api.execution.dao.WorkItemDao;
10 10 import br.com.centralit.esi.api.execution.model.ProcessInstance;
11 11 import br.com.centralit.esi.api.execution.model.WorkItem;
... ... @@ -36,7 +36,7 @@ public class WorkItemDatabaseRollbackServiceImpl extends WorkItemServiceImpl<Dat
36 36 runtimeEnvironment.addOrUpdateObject("CONNECTIONNAME",
37 37 element.getConnectionName());
38 38  
39   - ExecuteRollbackTransactionSql.execute(runtimeEnvironment);
  39 + ExecuteDBRollback.execute(runtimeEnvironment);
40 40  
41 41 complete(runtimeEnvironment, workItem);
42 42 return retrieveTargets(runtimeEnvironment,workItem);
... ...
cit-esi-api/src/main/java/br/com/centralit/esi/exception/EsiExecutionException.java
... ... @@ -12,7 +12,7 @@ public class EsiExecutionException extends BusinessException {
12 12 super();
13 13 this.setCodigoErro(702);
14 14 }
15   - public EsiExecutionException(Throwable e){
  15 + public EsiExecutionException(Exception e){
16 16 super(e);
17 17 this.setCodigoErro(702);
18 18 }
... ... @@ -20,4 +20,13 @@ public class EsiExecutionException extends BusinessException {
20 20 super(s);
21 21 this.setCodigoErro(702);
22 22 }
  23 + public EsiExecutionException(Throwable e){
  24 + super(e);
  25 + if (e instanceof BusinessException && ((BusinessException) e).getCodigoErro() != null) {
  26 + this.setCodigoErro(((BusinessException) e).getCodigoErro());
  27 + }else{
  28 + this.setCodigoErro(702);
  29 + }
  30 + }
  31 +
23 32 }
... ...