Search in sources :

Example 86 with ResponseStatus

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;
}
Also used : BatchAck(org.jumpmind.symmetric.model.BatchAck) BatchAckResults(org.jumpmind.symmetric.web.rest.model.BatchAckResults) BatchAckResult(org.jumpmind.symmetric.model.BatchAckResult) ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) IAcknowledgeService(org.jumpmind.symmetric.service.IAcknowledgeService) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 87 with ResponseStatus

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;
}
Also used : RegistrationInfo(org.jumpmind.symmetric.web.rest.model.RegistrationInfo) NodeSecurity(org.jumpmind.symmetric.model.NodeSecurity) IRegistrationService(org.jumpmind.symmetric.service.IRegistrationService) ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) IOException(java.io.IOException) Date(java.util.Date) INodeService(org.jumpmind.symmetric.service.INodeService) Heartbeat(org.jumpmind.symmetric.web.rest.model.Heartbeat) IoException(org.jumpmind.exception.IoException) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 88 with ResponseStatus

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);
}
Also used : BusquedaCajaCriteria(sic.modelo.BusquedaCajaCriteria) Usuario(sic.modelo.Usuario) Calendar(java.util.Calendar) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 89 with ResponseStatus

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)));
}
Also used : BusquedaClienteCriteria(sic.modelo.BusquedaClienteCriteria) Localidad(sic.modelo.Localidad) Pais(sic.modelo.Pais) Provincia(sic.modelo.Provincia) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 90 with ResponseStatus

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);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Aggregations

ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)149 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)118 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)36 ApiOperation (io.swagger.annotations.ApiOperation)31 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)26 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)19 GetMapping (org.springframework.web.bind.annotation.GetMapping)18 ApiResponses (io.swagger.annotations.ApiResponses)14 User (org.hisp.dhis.user.User)14 Transactional (org.springframework.transaction.annotation.Transactional)14 Date (java.util.Date)13 Configuration (org.hisp.dhis.configuration.Configuration)12 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)12 Period (org.hisp.dhis.period.Period)11 ArrayList (java.util.ArrayList)10 QualifiedName (com.netflix.metacat.common.QualifiedName)9 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)9 ApiImplicitParam (io.swagger.annotations.ApiImplicitParam)9 Calendar (java.util.Calendar)9 Task (org.flowable.engine.task.Task)8