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.service.insert;
35
36 import fr.paris.lutece.portal.service.i18n.I18nService;
37 import fr.paris.lutece.portal.service.i18n.Localizable;
38 import fr.paris.lutece.portal.service.plugin.Plugin;
39 import fr.paris.lutece.portal.service.plugin.PluginService;
40 import fr.paris.lutece.portal.service.rbac.RBACResource;
41 import fr.paris.lutece.portal.service.util.AppException;
42 import fr.paris.lutece.portal.web.insert.InsertServiceSelectionBean;
43
44 import java.util.Locale;
45
46 import javax.servlet.http.HttpServletRequest;
47
48
49
50
51 public class InsertService implements RBACResource, Localizable
52 {
53 public static final String RESOURCE_TYPE = "INSERT_SERVICE";
54
55
56 private String _strId;
57
58
59 private String _strNameKey;
60
61
62 private String _strLabelKey;
63
64
65 private String _strActionBean;
66
67
68 private String _strPluginName;
69 private Locale _locale;
70
71
72
73
74
75
76 public String getId( )
77 {
78 return _strId;
79 }
80
81
82
83
84
85
86
87 public void setId( String strId )
88 {
89 _strId = strId;
90 }
91
92
93
94
95
96
97 public String getNameKey( )
98 {
99 return _strNameKey;
100 }
101
102
103
104
105
106
107 public String getName( )
108 {
109 return I18nService.getLocalizedString( _strNameKey, _locale );
110 }
111
112
113
114
115
116
117
118 public void setNameKey( String strNameKey )
119 {
120 _strNameKey = strNameKey;
121 }
122
123
124
125
126
127
128 public String getLabelKey( )
129 {
130 return _strLabelKey;
131 }
132
133
134
135
136
137
138 public String getLabel( )
139 {
140 return I18nService.getLocalizedString( _strLabelKey, _locale );
141 }
142
143
144
145
146
147
148
149 public void setLabelKey( String strLabelKey )
150 {
151 _strLabelKey = strLabelKey;
152 }
153
154
155
156
157
158
159 public String getActionBeanString( )
160 {
161 return _strActionBean;
162 }
163
164
165
166
167
168
169
170 public void setActionBeanString( String strActionBean )
171 {
172 _strActionBean = strActionBean;
173 }
174
175
176
177
178
179
180
181 public void setActionBeanClassName( String strSelectionBean )
182 {
183 _strActionBean = strSelectionBean;
184 }
185
186
187
188
189
190
191 public String getPluginName( )
192 {
193 return _strPluginName;
194 }
195
196
197
198
199
200
201
202 public void setPluginName( String strPluginName )
203 {
204 _strPluginName = strPluginName;
205 }
206
207
208
209
210
211
212
213 public InsertServiceSelectionBean getSelectionActionBean( )
214 {
215 try
216 {
217 return (InsertServiceSelectionBean) Class.forName( getActionBeanString( ) ).newInstance( );
218 }
219 catch( ClassNotFoundException | IllegalAccessException | InstantiationException e )
220 {
221 throw new AppException( "Error instantiating a LinkService Selection Bean : " + e.getMessage( ), e );
222 }
223 }
224
225
226
227
228
229
230
231
232 public String getSelectorUI( HttpServletRequest request )
233 {
234 return getSelectionActionBean( ).getInsertServiceSelectorUI( request );
235 }
236
237
238
239
240
241
242 public boolean isEnabled( )
243 {
244 Plugin plugin = PluginService.getPlugin( _strPluginName );
245
246 return plugin.isInstalled( );
247 }
248
249
250
251
252
253
254
255
256
257 public String getResourceTypeCode( )
258 {
259 return RESOURCE_TYPE;
260 }
261
262
263
264
265
266
267 public String getResourceId( )
268 {
269 return "" + getId( );
270 }
271
272
273
274
275
276
277
278 public void setLocale( Locale locale )
279 {
280 _locale = locale;
281 }
282 }