@Override public String get() throws Exception { if (this.checkpermission("get")) { int id = ParameterCook.prepareId(oRequest); String data = null; Connection oConnection = null; ConnectionInterface oDataConnectionSource = null; try { oDataConnectionSource = getSourceConnection(); oConnection = oDataConnectionSource.newConnection(); EstadoDao oEstadoDao = new EstadoDao(oConnection); EstadoBean oEstadoBean = new EstadoBean(id); oEstadoBean = oEstadoDao.get(oEstadoBean, AppConfigurationHelper.getJsonDepth()); Gson gson = AppConfigurationHelper.getGson(); data = JsonMessage.getJson("200", AppConfigurationHelper.getGson().toJson(oEstadoBean)); } catch (Exception ex) { ExceptionBooster.boost( new Exception(this.getClass().getName() + ":get ERROR: " + ex.getMessage())); } finally { if (oConnection != null) { oConnection.close(); } if (oDataConnectionSource != null) { oDataConnectionSource.disposeConnection(); } } return data; } else { return JsonMessage.getJsonMsg("401", "Unauthorized"); } }
@Override public String remove() throws Exception { if (this.checkpermission("remove")) { Integer id = ParameterCook.prepareId(oRequest); String resultado = null; Connection oConnection = null; ConnectionInterface oDataConnectionSource = null; try { oDataConnectionSource = getSourceConnection(); oConnection = oDataConnectionSource.newConnection(); oConnection.setAutoCommit(false); EstadoDao oEstadoDao = new EstadoDao(oConnection); resultado = JsonMessage.getJson("200", (String) oEstadoDao.remove(id).toString()); oConnection.commit(); } catch (Exception ex) { if (oConnection != null) { oConnection.rollback(); } ExceptionBooster.boost( new Exception(this.getClass().getName() + ":remove ERROR: " + ex.getMessage())); } finally { if (oConnection != null) { oConnection.close(); } if (oDataConnectionSource != null) { oDataConnectionSource.disposeConnection(); } } return resultado; } else { return JsonMessage.getJsonMsg("401", "Unauthorized"); } }