use of org.springframework.web.bind.annotation.ResponseStatus in project symmetric-ds by JumpMind.
the class RestService method putAcknowledgeBatch.
@ApiOperation(value = "Acknowledge a set of batches for the specified engine")
@RequestMapping(value = "/engine/{engine}/acknowledgebatch", method = RequestMethod.PUT)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public final BatchAckResults putAcknowledgeBatch(@PathVariable("engine") String engineName, @ApiParam(value = "This the password for the nodeId being passed in. The password is stored in the node_security table.") @RequestParam(value = WebConstants.SECURITY_TOKEN) String securityToken, @RequestBody BatchResults batchResults) {
BatchAckResults finalResult = new BatchAckResults();
ISymmetricEngine engine = getSymmetricEngine(engineName);
List<BatchAckResult> results = null;
if (batchResults.getBatchResults().size() > 0) {
if (securityVerified(batchResults.getNodeId(), engine, securityToken)) {
IAcknowledgeService ackService = engine.getAcknowledgeService();
List<BatchAck> batchAcks = convertBatchResultsToAck(batchResults);
results = ackService.ack(batchAcks);
} else {
throw new NotAllowedException();
}
}
finalResult.setBatchAckResults(results);
return finalResult;
}
use of org.springframework.web.bind.annotation.ResponseStatus in project symmetric-ds by JumpMind.
the class RestService method postRegisterNode.
@ApiOperation(value = "Register the specified node for the specified engine")
@RequestMapping(value = "/engine/{engine}/registernode", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public final RegistrationInfo postRegisterNode(@PathVariable("engine") String engineName, @RequestParam(value = "externalId") String externalId, @RequestParam(value = "nodeGroupId") String nodeGroupId, @RequestParam(value = "databaseType") String databaseType, @RequestParam(value = "databaseVersion") String databaseVersion, @RequestParam(value = "hostName") String hostName) {
ISymmetricEngine engine = getSymmetricEngine(engineName);
IRegistrationService registrationService = engine.getRegistrationService();
INodeService nodeService = engine.getNodeService();
RegistrationInfo regInfo = new org.jumpmind.symmetric.web.rest.model.RegistrationInfo();
try {
org.jumpmind.symmetric.model.Node processedNode = registrationService.registerPullOnlyNode(externalId, nodeGroupId, databaseType, databaseVersion);
regInfo.setRegistered(processedNode.isSyncEnabled());
if (regInfo.isRegistered()) {
regInfo.setNodeId(processedNode.getNodeId());
NodeSecurity nodeSecurity = nodeService.findNodeSecurity(processedNode.getNodeId());
regInfo.setNodePassword(nodeSecurity.getNodePassword());
org.jumpmind.symmetric.model.Node modelNode = nodeService.findIdentity();
regInfo.setSyncUrl(modelNode.getSyncUrl());
// do an initial heartbeat
Heartbeat heartbeat = new Heartbeat();
heartbeat.setNodeId(regInfo.getNodeId());
heartbeat.setHostName(hostName);
Date now = new Date();
heartbeat.setCreateTime(now);
heartbeat.setLastRestartTime(now);
heartbeat.setHeartbeatTime(now);
this.heartbeatImpl(engine, heartbeat);
}
// TODO: Catch a RegistrationRedirectException and redirect.
} catch (IOException e) {
throw new IoException(e);
}
return regInfo;
}
use of org.springframework.web.bind.annotation.ResponseStatus in project sic by belluccifranco.
the class CajaController method getCajasCriteria.
@GetMapping("/cajas/busqueda/criteria")
@ResponseStatus(HttpStatus.OK)
public List<Caja> getCajasCriteria(@RequestParam(value = "idEmpresa") long idEmpresa, @RequestParam(value = "desde", required = false) Long desde, @RequestParam(value = "hasta", required = false) Long hasta, @RequestParam(value = "idUsuario", required = false) Long idUsuario) {
Calendar fechaDesde = Calendar.getInstance();
Calendar fechaHasta = Calendar.getInstance();
if (desde != null && hasta != null) {
fechaDesde.setTimeInMillis(desde);
fechaHasta.setTimeInMillis(hasta);
}
Usuario usuario = new Usuario();
if (idUsuario != null) {
usuario = usuarioService.getUsuarioPorId(idUsuario);
}
BusquedaCajaCriteria criteria = BusquedaCajaCriteria.builder().buscaPorFecha((desde != null) && (hasta != null)).fechaDesde(fechaDesde.getTime()).fechaHasta(fechaHasta.getTime()).empresa(empresaService.getEmpresaPorId(idEmpresa)).cantidadDeRegistros(0).buscaPorUsuario(idUsuario != null).usuario(usuario).build();
return cajaService.getCajasCriteria(criteria);
}
use of org.springframework.web.bind.annotation.ResponseStatus in project sic by belluccifranco.
the class ClienteController method buscarConCriteria.
@GetMapping("/clientes/busqueda/criteria")
@ResponseStatus(HttpStatus.OK)
public List<Cliente> buscarConCriteria(@RequestParam(value = "razonSocial", required = false) String razonSocial, @RequestParam(value = "nombreFantasia", required = false) String nombreFantasia, @RequestParam(value = "idFiscal", required = false) String idFiscal, @RequestParam(value = "idPais", required = false) Long idPais, @RequestParam(value = "idProvincia", required = false) Long idProvincia, @RequestParam(value = "idLocalidad", required = false) Long idLocalidad, @RequestParam(value = "idEmpresa") Long idEmpresa) {
Pais pais = null;
if (idPais != null) {
pais = paisService.getPaisPorId(idPais);
}
Provincia provincia = null;
if (idProvincia != null) {
provincia = provinciaService.getProvinciaPorId(idProvincia);
}
Localidad localidad = null;
if (idLocalidad != null) {
localidad = localidadService.getLocalidadPorId(idLocalidad);
}
return clienteService.buscarClientes(new BusquedaClienteCriteria((razonSocial != null), razonSocial, (nombreFantasia != null), nombreFantasia, (idFiscal != null), idFiscal, (idPais != null), pais, (idProvincia != null), provincia, (idLocalidad != null), localidad, empresaService.getEmpresaPorId(idEmpresa)));
}
use of org.springframework.web.bind.annotation.ResponseStatus in project sic by belluccifranco.
the class FacturaController method getReporteFacturaVenta.
@GetMapping("/facturas/{idFactura}/reporte")
@ResponseStatus(HttpStatus.OK)
public ResponseEntity<byte[]> getReporteFacturaVenta(@PathVariable long idFactura) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_PDF);
headers.add("content-disposition", "inline; filename=Factura.pdf");
headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
byte[] reportePDF = facturaService.getReporteFacturaVenta(facturaService.getFacturaPorId(idFactura));
return new ResponseEntity<>(reportePDF, headers, HttpStatus.OK);
}
Aggregations