1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.portal.business.page;
35
36 import fr.paris.lutece.portal.business.portlet.Portlet;
37 import fr.paris.lutece.portal.service.portal.PortalService;
38 import fr.paris.lutece.portal.service.rbac.RBACResource;
39 import fr.paris.lutece.portal.service.resource.IExtendableResource;
40 import fr.paris.lutece.portal.service.security.SecurityService;
41
42 import java.sql.Timestamp;
43
44 import java.util.ArrayList;
45 import java.util.List;
46
47 import javax.servlet.http.HttpServletRequest;
48
49
50
51
52
53 public class Page implements RBACResource, IExtendableResource
54 {
55
56
57 public static final String RESOURCE_TYPE = "PAGE";
58 public static final String IMAGE_RESOURCE_TYPE_ID = "page_thumbnail";
59 public static final String ROLE_NONE = "none";
60 private static final String THEME_DEFAULT = "default";
61 private static final String SERVLET_IMAGE_PATH = "image";
62 private static final String CONSTANT_QUESTION_MARK = "?";
63 private static final String CONSTANT_AND = "&";
64 private static final String CONSTANT_EQUALS = "=";
65 private static final String MARK_RESOURCE_TYPE = "resource_type";
66 private static final String MARK_RESOURCE_ID = "id";
67
68
69 private int _nId;
70 private int _nParentPageId;
71 private int _nOrigParentPageId;
72 private int _nOrder;
73 private int _nStatus;
74 private int _nPageTemplateId;
75 private int _nNodeStatus;
76 private String _strMimeType;
77 private String _strRole;
78 private String _strName;
79 private String _strDescription;
80 private String _strTemplate;
81 private String _strCodeTheme;
82 private byte[] _strImageContent;
83 private Timestamp _dateUpdate;
84 private List<Portlet> _listPortlets = new ArrayList<Portlet>( );
85 private String _strMetaKeywords;
86 private String _strMetaDescription;
87 private Integer _nIdAuthorizationNode;
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110 public void setId( int nId )
111 {
112 _nId = nId;
113 }
114
115
116
117
118
119
120 public int getId( )
121 {
122 return _nId;
123 }
124
125
126
127
128
129
130 public void setParentPageId( int nParentPageId )
131 {
132 _nParentPageId = nParentPageId;
133 }
134
135
136
137
138
139
140 public int getParentPageId( )
141 {
142 return _nParentPageId;
143 }
144
145
146
147
148
149
150
151
152 void setOrigParentPageId( int nParentPageId )
153 {
154 _nOrigParentPageId = nParentPageId;
155 }
156
157
158
159
160
161
162
163
164 public int getOrigParentPageId( )
165 {
166 return _nOrigParentPageId;
167 }
168
169
170
171
172
173
174 public byte[] getImageContent( )
175 {
176 return _strImageContent;
177 }
178
179
180
181
182
183
184 public void setImageContent( byte[] strImageContent )
185 {
186 _strImageContent = strImageContent;
187 }
188
189
190
191
192
193
194 public String getMimeType( )
195 {
196 return _strMimeType;
197 }
198
199
200
201
202
203
204 public void setMimeType( String strMimeType )
205 {
206 _strMimeType = strMimeType;
207 }
208
209
210
211
212
213
214 public void setName( String strName )
215 {
216 _strName = strName;
217 }
218
219
220
221
222
223
224 public String getName( )
225 {
226 return _strName;
227 }
228
229
230
231
232
233
234 public void setPageTemplateId( int nPageTemplateId )
235 {
236 _nPageTemplateId = nPageTemplateId;
237 }
238
239
240
241
242
243
244 public int getPageTemplateId( )
245 {
246 return _nPageTemplateId;
247 }
248
249
250
251
252
253
254 public void setTemplate( String strTemplate )
255 {
256 _strTemplate = strTemplate;
257 }
258
259
260
261
262
263
264 public String getTemplate( )
265 {
266 return _strTemplate;
267 }
268
269
270
271
272
273
274 public void setOrder( int nOrder )
275 {
276 _nOrder = nOrder;
277 }
278
279
280
281
282
283
284 public int getOrder( )
285 {
286 return _nOrder;
287 }
288
289
290
291
292
293
294 public void setStatus( int nStatus )
295 {
296 _nStatus = nStatus;
297 }
298
299
300
301
302
303
304 public int getStatus( )
305 {
306 return _nStatus;
307 }
308
309
310
311
312
313
314 public void setDescription( String strDescription )
315 {
316 _strDescription = strDescription;
317 }
318
319
320
321
322
323
324 public String getDescription( )
325 {
326 return _strDescription;
327 }
328
329
330
331
332
333
334 public void setNodeStatus( int nNodeStatus )
335 {
336 _nNodeStatus = nNodeStatus;
337 }
338
339
340
341
342
343
344 public int getNodeStatus( )
345 {
346 return _nNodeStatus;
347 }
348
349
350
351
352
353
354 public List<Portlet> getPortlets( )
355 {
356 return _listPortlets;
357 }
358
359
360
361
362
363
364 public void setPortlets( List<Portlet> listPortlets )
365 {
366 _listPortlets = listPortlets;
367 }
368
369
370
371
372
373
374 public void setDateUpdate( Timestamp dateUpdate )
375 {
376 _dateUpdate = dateUpdate;
377 }
378
379
380
381
382
383
384 public Timestamp getDateUpdate( )
385 {
386 return _dateUpdate;
387 }
388
389
390
391
392
393
394 public String getRole( )
395 {
396 return _strRole;
397 }
398
399
400
401
402
403
404 public void setRole( String strRole )
405 {
406 _strRole = ( ( strRole == null ) || ( strRole.equals( "" ) ) ) ? ROLE_NONE : strRole;
407 }
408
409
410
411
412
413
414 public String getCodeTheme( )
415 {
416 return _strCodeTheme;
417 }
418
419
420
421
422
423
424 public void setCodeTheme( String strCodeTheme )
425 {
426 _strCodeTheme = ( ( strCodeTheme == null ) || ( strCodeTheme.equals( "" ) ) ) ? THEME_DEFAULT : strCodeTheme;
427 }
428
429
430
431
432
433
434
435 public boolean isVisible( HttpServletRequest request )
436 {
437 if ( SecurityService.isAuthenticationEnable( ) )
438 {
439 if ( !getRole( ).equals( ROLE_NONE ) )
440 {
441 return SecurityService.getInstance( ).isUserInRole( request, getRole( ) );
442 }
443 }
444
445 return true;
446 }
447
448
449
450
451
452
453
454
455 @Override
456 public String getResourceTypeCode( )
457 {
458 return RESOURCE_TYPE;
459 }
460
461
462
463
464
465 @Override
466 public String getResourceId( )
467 {
468 return "" + getId( );
469 }
470
471
472
473
474
475 public String getMetaKeywords( )
476 {
477 return _strMetaKeywords;
478 }
479
480
481
482
483
484 public void setMetaKeywords( String strMetaKeywords )
485 {
486 _strMetaKeywords = strMetaKeywords;
487 }
488
489
490
491
492
493 public String getMetaDescription( )
494 {
495 return _strMetaDescription;
496 }
497
498
499
500
501
502 public void setMetaDescription( String strMetaDescription )
503 {
504 _strMetaDescription = strMetaDescription;
505 }
506
507
508
509
510
511 public void setIdAuthorizationNode( Integer nIdAutorizationNode )
512 {
513 _nIdAuthorizationNode = nIdAutorizationNode;
514 }
515
516
517
518
519
520 public Integer getIdAuthorizationNode( )
521 {
522 return _nIdAuthorizationNode;
523 }
524
525
526
527
528 @Override
529 public String getIdExtendableResource( )
530 {
531 return Integer.toString( _nId );
532 }
533
534
535
536
537 @Override
538 public String getExtendableResourceType( )
539 {
540 return RESOURCE_TYPE;
541 }
542
543
544
545
546 @Override
547 public String getExtendableResourceName( )
548 {
549 return ( _nId == 1 ) ? PortalService.getSiteName( ) : _strName;
550 }
551
552
553
554
555 @Override
556 public String getExtendableResourceDescription( )
557 {
558 return _strDescription;
559 }
560
561
562
563
564 @Override
565 public String getExtendableResourceImageUrl( )
566 {
567 if ( ( _strImageContent != null ) && ( _strImageContent.length > 0 ) )
568 {
569 StringBuilder sbUrl = new StringBuilder( SERVLET_IMAGE_PATH );
570 sbUrl.append( CONSTANT_QUESTION_MARK );
571 sbUrl.append( MARK_RESOURCE_TYPE );
572 sbUrl.append( CONSTANT_EQUALS );
573 sbUrl.append( IMAGE_RESOURCE_TYPE_ID );
574 sbUrl.append( CONSTANT_AND );
575 sbUrl.append( MARK_RESOURCE_ID );
576 sbUrl.append( CONSTANT_EQUALS );
577 sbUrl.append( _nId );
578
579 return sbUrl.toString( );
580 }
581 else
582 {
583
584 return null;
585 }
586 }
587 }