Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Acesso obterAcessoWs(String usuario, String senha) {
- def result
- try {
- result = rest.postForObject(format(urlRegistro, usuario, senha), null, ClienteReduzido)
- } catch (ResourceAccessException ignored) {
- throw new Exception('Não foi possível efetuar o registro das habilitações.\nVerifique a sua conexão com a internet.')
- }
- if (result.status == 1) {
- throw new Exception(result.descricaoStatus)
- }
- // Se não possuir nenhum sistema - Cliente Cancelado.
- if (!result.sistemasHabilitados || result.sistemasHabilitados.isEmpty()) {
- throw new Exception(result.descricaoStatus)
- }
- final sistemas = result.sistemasHabilitados.collect { s -> fromWsValue(s.substring(0, s.indexOf('-')).toInteger())}
- final modulos = sistemas.value.inject { a, b -> a | b }
- def acesso = findAcesso()
- if (!acesso) {
- acesso = new Acesso()
- }
- acesso.usuario = usuario
- acesso.senha = senha
- acesso.modulos = modulos
- acesso.cnpj = result.cnpj
- acesso.cpf = result.cpf
- acesso.razaoSocial = result.razaoSocial
- acesso.data = new Date().format(FORMATO_DATA)
- return acesso
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement