Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. private Acesso obterAcessoWs(String usuario, String senha) {
  2. def result
  3. try {
  4. result = rest.postForObject(format(urlRegistro, usuario, senha), null, ClienteReduzido)
  5. } catch (ResourceAccessException ignored) {
  6. throw new Exception('Não foi possível efetuar o registro das habilitações.\nVerifique a sua conexão com a internet.')
  7. }
  8.  
  9. if (result.status == 1) {
  10. throw new Exception(result.descricaoStatus)
  11. }
  12.  
  13. // Se não possuir nenhum sistema - Cliente Cancelado.
  14. if (!result.sistemasHabilitados || result.sistemasHabilitados.isEmpty()) {
  15. throw new Exception(result.descricaoStatus)
  16. }
  17.  
  18. final sistemas = result.sistemasHabilitados.collect { s -> fromWsValue(s.substring(0, s.indexOf('-')).toInteger())}
  19. final modulos = sistemas.value.inject { a, b -> a | b }
  20. def acesso = findAcesso()
  21.  
  22. if (!acesso) {
  23. acesso = new Acesso()
  24. }
  25.  
  26. acesso.usuario = usuario
  27. acesso.senha = senha
  28. acesso.modulos = modulos
  29. acesso.cnpj = result.cnpj
  30. acesso.cpf = result.cpf
  31. acesso.razaoSocial = result.razaoSocial
  32. acesso.data = new Date().format(FORMATO_DATA)
  33.  
  34. return acesso
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement