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
52 public class InsertService implements RBACResource, Localizable
53 {
54 public static final String RESOURCE_TYPE = "INSERT_SERVICE";
55
56
57 private String _strId;
58
59
60 private String _strNameKey;
61
62
63 private String _strLabelKey;
64
65
66 private String _strActionBean;
67
68
69 private String _strPluginName;
70 private Locale _locale;
71
72
73
74
75
76
77 public String getId( )
78 {
79 return _strId;
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 public void setNameKey( String strNameKey )
118 {
119 _strNameKey = strNameKey;
120 }
121
122
123
124
125
126
127 public String getLabelKey( )
128 {
129 return _strLabelKey;
130 }
131
132
133
134
135
136
137 public String getLabel( )
138 {
139 return I18nService.getLocalizedString( _strLabelKey, _locale );
140 }
141
142
143
144
145
146
147 public void setLabelKey( String strLabelKey )
148 {
149 _strLabelKey = strLabelKey;
150 }
151
152
153
154
155
156
157 public String getActionBeanString( )
158 {
159 return _strActionBean;
160 }
161
162
163
164
165
166
167 public void setActionBeanString( String strActionBean )
168 {
169 _strActionBean = strActionBean;
170 }
171
172
173
174
175
176
177 public void setActionBeanClassName( String strSelectionBean )
178 {
179 _strActionBean = strSelectionBean;
180 }
181
182
183
184
185
186
187 public String getPluginName( )
188 {
189 return _strPluginName;
190 }
191
192
193
194
195
196
197 public void setPluginName( String strPluginName )
198 {
199 _strPluginName = strPluginName;
200 }
201
202
203
204
205
206
207
208 public InsertServiceSelectionBean getSelectionActionBean( )
209 {
210 try
211 {
212 return (InsertServiceSelectionBean) Class.forName( getActionBeanString( ) ).newInstance( );
213 }
214 catch ( InstantiationException e )
215 {
216 throw new AppException( "Error instantiating a LinkService Selection Bean : " + e.getMessage( ), e );
217 }
218 catch ( IllegalAccessException e )
219 {
220 throw new AppException( "Error instantiating a LinkService Selection Bean : " + e.getMessage( ), e );
221 }
222 catch ( ClassNotFoundException e )
223 {
224 throw new AppException( "Error instantiating a LinkService Selection Bean : " + e.getMessage( ), e );
225 }
226 }
227
228
229
230
231
232
233
234 public String getSelectorUI( HttpServletRequest request )
235 {
236 return getSelectionActionBean( ).getInsertServiceSelectorUI( request );
237 }
238
239
240
241
242
243 public boolean isEnabled( )
244 {
245 Plugin plugin = PluginService.getPlugin( _strPluginName );
246
247 return plugin.isInstalled( );
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 public String getResourceId( )
267 {
268 return "" + getId( );
269 }
270
271
272
273
274
275 public void setLocale( Locale locale )
276 {
277 _locale = locale;
278 }
279 }