Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.28 KB | None | 0 0
  1. @RequestMapping(method = RequestMethod.POST, path = "/cotacao/{chave}", produces = MediaType.APPLICATION_XML_VALUE)
  2.     public ResponseEntity<String> addUpdateCotacao(@PathVariable("chave") String chave, @RequestBody String cotacaoJSon,
  3.             HttpServletRequest request) {
  4.         try {
  5.             logService.log(
  6.                     String.format("%s: %s(%s)(%s)", request.getRemoteAddr(), "addUpdateCotacao", chave, cotacaoJSon));
  7.             Usuario usuario = usuarioService.getByChaveDeAcesso(chave);
  8.             validarUsuario(usuario, chave);
  9.  
  10.             Map<String, LigacaoSuperus> ligacaoSuperus = new HashMap<>();
  11.             CotacaoParser cotacaoJsonParser = new CotacaoJsonParser(cotacaoJSon, ligacaoSuperus);
  12.             Cotacao cotacao = cotacaoService.buildCotacaoFromParser(cotacaoJsonParser, usuario);
  13.             return new CotacaoResponseEntityXmlBuilder(cotacao, ligacaoSuperus).build();       
  14.         } catch (ExceptionValidacao e) {
  15.             logger.warn(e.getMessage(), e);
  16.             logService.log(MessageFormat.format("{0}\n\n{1}", e.getMessage(), ExceptionUtils.getStackTrace(e)));
  17.             return ResponseEntity.badRequest().body(e.getMessage());
  18.         } catch (Exception e) {
  19.             logger.warn(e.getMessage(), e);
  20.             logService.log(MessageFormat.format("{0}\n\n{1}", e.getMessage(), ExceptionUtils.getStackTrace(e)));
  21.             return ResponseEntity.badRequest().body(e.getMessage());
  22.         }
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement