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.plugins.extend.modules.comment.service;
35
36 import org.apache.commons.lang3.StringUtils;
37
38 import fr.paris.lutece.plugins.avatar.service.AvatarService;
39 import fr.paris.lutece.plugins.extend.modules.comment.business.Comment;
40 import fr.paris.lutece.plugins.extend.modules.comment.util.constants.CommentConstants;
41 import fr.paris.lutece.portal.service.util.AppPropertiesService;
42
43
44
45
46
47
48 public class CommentAvatarService implements ICommentAvatarService
49 {
50
51 private static ICommentAvatarService _singleton;
52 private static boolean _bUseLuteceUserNameAsAvatarKey;
53
54
55
56
57 @Override
58 public String getAvatar( Comment comment )
59 {
60 if ( _bUseLuteceUserNameAsAvatarKey && !StringUtils.isEmpty( comment.getLuteceUserName( ) ) )
61 {
62 return AvatarService.getAvatar( comment.getLuteceUserName( ) );
63 }
64 return AvatarService.getAvatar( comment.getEmail( ) );
65 }
66
67
68
69
70 @Override
71 public String getAvatarUrl( Comment comment )
72 {
73 if ( _bUseLuteceUserNameAsAvatarKey && !StringUtils.isEmpty( comment.getLuteceUserName( ) ) )
74 {
75 return AvatarService.getAvatarUrl( comment.getLuteceUserName( ) );
76 }
77 return AvatarService.getAvatarUrl( comment.getEmail( ) );
78 }
79
80
81
82
83
84 public static ICommentAvatarService getInstance( )
85 {
86
87 if ( _singleton == null )
88 {
89
90 _singleton = new CommentAvatarService( );
91 _bUseLuteceUserNameAsAvatarKey = AppPropertiesService.getPropertyBoolean( CommentConstants.PROPERTY_USE_LUTECE_USER_NAME_AS_AVATAR_KEY, false );
92 }
93
94 return _singleton;
95
96 }
97
98 }