1
2
3
4
5 package ecar.portal;
6
7 import java.util.ArrayList;
8 import java.util.Iterator;
9 import java.util.List;
10
11 import javax.servlet.http.HttpServletRequest;
12
13 import comum.database.SentinelaUtil;
14 import comum.util.Mensagem;
15
16 import ecar.dao.PaginaAreaSiteDao;
17 import ecar.exception.ECARException;
18 import ecar.login.SegurancaECAR;
19 import ecar.pojo.PaginaAreaSitePa;
20 import ecar.portal.bean.MenuTopoBean;
21 import ecar.portal.bean.PortalBean;
22 import gov.pr.celepar.sentinela.comunicacao.SentinelaParam;
23
24
25
26
27
28
29 public class Portal {
30
31 protected PortalBean portalBean = new PortalBean();
32 private HttpServletRequest request;
33 private Mensagem msg;
34
35 private static final String IND_CAPA_SIM = "S";
36
37
38 private PaginaAreaSiteDao paginaAreaSiteDao = null;
39
40
41
42
43
44
45
46
47
48
49 public Portal(HttpServletRequest request) throws ECARException {
50 this.request = request;
51 this.msg = new Mensagem(this.getRequest().getSession().getServletContext());
52 this.paginaAreaSiteDao = new PaginaAreaSiteDao(null);
53
54 this.carregarMenuOpcoesTopo();
55 }
56
57
58
59
60
61
62
63
64
65
66 private void carregarMenuOpcoesTopo() throws ECARException {
67
68
69
70 List linksFuncoesUsuarioSentinela = new ArrayList();
71
72
73 SentinelaUtil sentinelaUtil = new SentinelaUtil(this.request);
74 SentinelaParam[] menuSentinela;
75
76
77
78 menuSentinela = sentinelaUtil.getSentinelaInterface().getMenu();
79
80 if(menuSentinela != null) {
81 String ignorarApos = this.getRequest().getContextPath() + "/";
82 for(int i = 0; i < menuSentinela.length; i++) {
83
84 if(menuSentinela[i].getParamAux()[0] != null && !"".equals(menuSentinela[i].getParamAux()[0])) {
85 int indice = menuSentinela[i].getParamAux()[0].indexOf(ignorarApos);
86
87 String linkAposContexto = menuSentinela[i].getParamAux()[0].substring(indice + ignorarApos.length());
88
89 linksFuncoesUsuarioSentinela.add(linkAposContexto);
90 }
91 }
92
93 }
94
95
96
97
98
99 menuSentinela = sentinelaUtil.getSentinelaInterface().getFuncoesGenericas();
100
101 if(menuSentinela != null) {
102 String ignorarApos = this.getRequest().getContextPath() + "/";
103 for(int i = 0; i < menuSentinela.length; i++) {
104
105 if(menuSentinela[i].getParamAux()[0] != null && !"".equals(menuSentinela[i].getParamAux()[0])) {
106
107 String linkAposContexto = menuSentinela[i].getParamAux()[0].substring(1);
108
109 linksFuncoesUsuarioSentinela.add(linkAposContexto);
110 }
111 }
112
113 }
114
115
116
117 List listMenu = this.getPaginaAreaSiteDao().getPaginaAreaSitePa(IND_CAPA_SIM);
118
119 ArrayList menu = new ArrayList();
120
121 MenuTopoBean menuTopoBean = new MenuTopoBean();
122
123
124 menuTopoBean.setTitulo("INICIAL");
125 menuTopoBean.setDescricao("Retorna a tela inicial");
126 if (this.getRequest().getSession().getAttribute("seguranca") != null){
127 menuTopoBean.setLink(this.getRequest().getContextPath() + "/" + ((SegurancaECAR)this.getRequest().getSession().getAttribute("seguranca")).getPaginaInicialUsuario());
128 }
129
130 menu.add(menuTopoBean);
131
132 String contexto = this.getRequest().getContextPath() + "/";
133 Iterator it = listMenu.iterator();
134 while(it.hasNext()) {
135 PaginaAreaSitePa p = (PaginaAreaSitePa)it.next();
136
137 if(linksFuncoesUsuarioSentinela.contains(p.getUrlPas())){
138
139 menuTopoBean = new MenuTopoBean();
140
141 menuTopoBean.setTitulo(p.getNomePas());
142 menuTopoBean.setDescricao(p.getTextoPas());
143 menuTopoBean.setLink(contexto + p.getUrlPas());
144 menuTopoBean.setTituloPagina(p.getTituloPas());
145
146 menu.add(menuTopoBean);
147 }
148 }
149
150 this.portalBean.setMenuTopoBean(menu);
151
152 getRequest().getSession().setAttribute("menuHorizontal", menu);
153
154
155
156
157 }
158
159
160
161
162
163
164
165
166
167 public PortalBean getPortalBean() {
168 return portalBean;
169 }
170
171
172
173
174
175
176
177
178
179 protected HttpServletRequest getRequest() {
180 return request;
181 }
182
183
184
185
186
187
188
189
190
191 protected Mensagem getMensagem() {
192 return msg;
193 }
194
195
196
197
198
199
200
201
202
203 protected PaginaAreaSiteDao getPaginaAreaSiteDao() {
204 return paginaAreaSiteDao;
205 }
206 }