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