/* * (non-Javadoc) * * @see * com.tramex.sisoprega.common.crud.Cruddable#Delete(com.tramex.sisoprega. * common.GatewayRequest) */ @Override public BaseResponse Delete(GatewayRequest request) { this.log.entering(this.getClass().getCanonicalName(), "Delete"); BaseResponse response = new BaseResponse(); try { PenCapacity barnyardCa = entityFromRequest(request, PenCapacity.class); if (barnyardCa.getCapacityId() == 0) { this.log.warning("VAL04 - Entity ID Omission."); response.setError( new Error( "VAL04", "Se ha omitido el id de la capacidad del corral al intentar eliminar el registro.", "proxy.BarnyardCapacity.Delete")); } else { barnyardCa = dataModel.readSingleDataModel( "BARNYARD_CAPACITY_BY_ID", "capacityId", barnyardCa.getCapacityId(), PenCapacity.class); this.log.info( "Deleting BarnyardCapacity[" + barnyardCa.toString() + "] by principal[" + getLoggedUser() + "]"); dataModel.deleteDataModel(barnyardCa, getLoggedUser()); response.setError(new Error("0", "SUCCESS", "proxy.BarnyardCapacity.Delete")); this.log.info( "BarnyardCapacity successfully deleted by principal [" + getLoggedUser() + "]"); } } catch (Exception e) { this.log.severe("Exception found while deleting barnyard capacity"); this.log.throwing(this.getClass().getName(), "Delete", e); response.setError( new Error( "DEL01", "Error al intentar borrar datos, es probable que esta entidad tenga otras entidades relacionadas, " + "por ejemplo, un corrar que cuenta con recepciones no puede ser eliminado sin antes resolver la recepción.", "proxy.BarnyardCapacity.Delete")); } this.log.exiting(this.getClass().getCanonicalName(), "Delete"); return response; }
@Override public BaseResponse Delete(GatewayRequest request) { this.log.entering(this.getClass().getCanonicalName(), "Create"); BaseResponse response = new BaseResponse(); String exceptionFrom = "proxy.PdfUploaderBean.Create"; Pedimento pedimento = null; try { pedimento = entityFromRequest(request, Pedimento.class); this.log.fine("Got pedimento from request: " + pedimento); if (pedimento.getFechaPedimento() != null && pedimento.getFolio() != null && pedimento.getRancherId() != 0) { String uploadPath = PDF_UPLOADER_PROPERTIES.getProperty("uploadPath"); String fechaPedimento = new SimpleDateFormat("yyyyMMdd").format(pedimento.getFechaPedimento()); String datesFile = uploadPath + "/" + pedimento.getRancherId() + "/" + fechaPedimento; String zipFile = uploadPath + "/" + pedimento.getRancherId() + "/" + pedimento.getFolio() + ".zip"; removeLineFromFile(datesFile, pedimento.getFolio()); deleteFile(zipFile); } else { String exceptionId = "VAL04"; String exceptionDescription = "Se han omitido detalles necesarios para el borrado de un pedimento, por favor indique: fecha, folio y ganadero"; response.setError(new Error(exceptionId, exceptionDescription, exceptionFrom)); } } catch (Exception e) { this.log.severe("Exception found while deleting PEDIMENTO"); this.log.throwing(this.getClass().getName(), "Delete", e); String exceptionId = "DEL01"; String exceptionDescription = "Error al intentar borrar un pedimento, intente mas tarde."; response.setError(new Error(exceptionId, exceptionDescription, exceptionFrom)); } this.log.exiting(this.getClass().getCanonicalName(), "Create"); return response; }