Commit bb93ca86d3556ed75906ca31767c6fa168532805
1 parent
44c271da
Exists in
master
redmine #4773 recuperacao de usuario logado por modulos "keepSessionAlive"
Showing
1 changed file
with
78 additions
and
0 deletions
Show diff stats
cit-esi-listener-web/src/main/java/br/com/centralit/controller/UsuarioESIListenerController.java
0 → 100644
... | ... | @@ -0,0 +1,78 @@ |
1 | +package br.com.centralit.controller; | |
2 | + | |
3 | +import org.apache.log4j.Logger; | |
4 | +import org.springframework.beans.factory.annotation.Autowired; | |
5 | +import org.springframework.security.core.context.SecurityContextHolder; | |
6 | +import org.springframework.stereotype.Controller; | |
7 | +import org.springframework.web.bind.annotation.RequestBody; | |
8 | +import org.springframework.web.bind.annotation.RequestMapping; | |
9 | +import org.springframework.web.bind.annotation.RequestMethod; | |
10 | +import org.springframework.web.bind.annotation.ResponseBody; | |
11 | + | |
12 | +import br.com.centralit.api.service.OrganizacaoService; | |
13 | +import br.com.centralit.api.service.UnidadeService; | |
14 | +import br.com.centralit.framework.json.ResponseBodyWrapper; | |
15 | +import br.com.centralit.framework.json.Views; | |
16 | +import br.com.centralit.framework.model.Organizacao; | |
17 | +import br.com.centralit.framework.model.Usuario; | |
18 | + | |
19 | +/** | |
20 | + * <p> | |
21 | + * <img src="http://centralit.com.br/images/logo_central.png"> | |
22 | + * </p> | |
23 | + * | |
24 | + * <p> | |
25 | + * <b>Company: </b> Central IT - Governança Corporativa - | |
26 | + * </p> | |
27 | + * | |
28 | + * <p> | |
29 | + * <b>Title: </b> UsuarioESIListenerController | |
30 | + * </p> | |
31 | + * | |
32 | + * <p> | |
33 | + * <b>Description: </b> | |
34 | + * </p> | |
35 | + * | |
36 | + * @since 09/05/2016 - 15:02:22 | |
37 | + * @version 1.0.0 | |
38 | + * @author rogerio.cassimiro | |
39 | + */ | |
40 | +@Controller | |
41 | +@RequestMapping("/rest/usuarioModulo") | |
42 | +public class UsuarioESIListenerController { | |
43 | + | |
44 | + @Autowired | |
45 | + private OrganizacaoService organizacaoService; | |
46 | + | |
47 | + @Autowired | |
48 | + private UnidadeService unidadeService; | |
49 | + | |
50 | + /** | |
51 | + * Método responsável por atualizar a organização no contexto do módulo. Quando o usuario usa a opção de mudança de organização no portal. | |
52 | + * @author rogerio.cassimiro | |
53 | + * @param organizacao | |
54 | + * @return {@link ResponseBody} | |
55 | + */ | |
56 | + @RequestMapping(value = "/atualizarUsuario", method = RequestMethod.POST) | |
57 | + @ResponseBody | |
58 | + public ResponseBodyWrapper atualizarUsuario(@RequestBody Organizacao organizacao) { | |
59 | + | |
60 | + ( (Usuario) SecurityContextHolder.getContext().getAuthentication().getPrincipal() ).setOrganizacao(organizacaoService.find(organizacao.getId())); | |
61 | + | |
62 | + ResponseBodyWrapper responseBody = new ResponseBodyWrapper(Boolean.TRUE, Views.GenericView.class); | |
63 | + | |
64 | + return responseBody; | |
65 | + } | |
66 | + | |
67 | + /** | |
68 | + * Método responsável por reativar a sessão do módulo | |
69 | + * @author rogerio.cassimiro | |
70 | + */ | |
71 | + @RequestMapping(value = "/keepSessionAlive", method = RequestMethod.POST) | |
72 | + @ResponseBody | |
73 | + public void keepSessionAlive() { | |
74 | + | |
75 | + Logger.getLogger(UsuarioESIListenerController.class).info("Restaurando sess\u00e3o do modulo ESI Listener."); | |
76 | + } | |
77 | + | |
78 | +} | ... | ... |