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.service.extender;
35
36 import fr.paris.lutece.plugins.extend.web.component.IResourceExtenderComponent;
37 import fr.paris.lutece.portal.service.i18n.I18nService;
38
39 import org.springframework.beans.factory.InitializingBean;
40
41 import org.springframework.util.Assert;
42
43 import java.util.Locale;
44 import org.apache.commons.lang3.StringUtils;
45
46
47
48
49
50
51 public abstract class AbstractResourceExtender implements IResourceExtender, InitializingBean
52 {
53 private String _strKey;
54 private String _strI18nTitleKey;
55 private boolean _bIsConfigRequired;
56 private boolean _bIsHistoryEnable;
57 private boolean _bIsStateEnable;
58 private IResourceExtenderComponent _resourceExtenderComponent;
59
60
61
62
63 @Override
64 public String getKey( )
65 {
66 return _strKey;
67 }
68
69
70
71
72 @Override
73 public void setKey( String strKey )
74 {
75 _strKey = strKey;
76 }
77
78
79
80
81 @Override
82 public String getTitle( Locale locale )
83 {
84 return I18nService.getLocalizedString( _strI18nTitleKey, locale );
85 }
86
87
88
89
90 @Override
91 public void setI18nTitleKey( String strI18nTitleKey )
92 {
93 _strI18nTitleKey = strI18nTitleKey;
94 }
95
96
97
98
99 @Override
100 public boolean isConfigRequired( )
101 {
102 return _bIsConfigRequired;
103 }
104
105
106
107
108
109 public void setConfigRequired( boolean bIsConfigRequired )
110 {
111 _bIsConfigRequired = bIsConfigRequired;
112 }
113
114
115
116
117 @Override
118 public boolean isHistoryEnable( )
119 {
120 return _bIsHistoryEnable;
121 }
122
123
124
125
126
127 public void setHistoryEnable( boolean bIsHistoryEnable )
128 {
129 _bIsHistoryEnable = bIsHistoryEnable;
130 }
131
132
133
134
135 public boolean isStateEnable( )
136 {
137 return _bIsStateEnable;
138 }
139
140
141
142
143
144 public void setStateEnable( boolean bIsStateEnable )
145 {
146 this._bIsStateEnable = bIsStateEnable;
147 }
148
149
150
151
152 public IResourceExtenderComponent getResourceExtenderComponent( )
153 {
154 return _resourceExtenderComponent;
155 }
156
157
158
159
160
161
162
163 public void setResourceExtenderComponent( IResourceExtenderComponent resourceExtenderComponent )
164 {
165 _resourceExtenderComponent = resourceExtenderComponent;
166 }
167
168
169
170
171 @Override
172 public void afterPropertiesSet( ) throws Exception
173 {
174 Assert.notNull( _strKey, "The property 'key' must be provided" );
175 Assert.notNull( _strI18nTitleKey, "The property 'i18nTitleKey' must be provided" );
176 Assert.notNull( _resourceExtenderComponent, "The property 'resourceExtenderComponent' must be provided" );
177 }
178
179
180
181
182 @Override
183 public boolean isInvoked( String strExtenderType )
184 {
185 if ( StringUtils.isNotBlank( strExtenderType ) )
186 {
187 return getKey( ).equals( strExtenderType );
188 }
189
190 return false;
191 }
192
193 }