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.workgroup;
35
36 import fr.paris.lutece.portal.service.util.AppLogService;
37 import fr.paris.lutece.portal.service.util.AppPropertiesService;
38 import fr.paris.lutece.util.url.UrlItem;
39
40 import java.io.UnsupportedEncodingException;
41
42 import java.net.URLEncoder;
43
44 import javax.servlet.http.HttpServletRequest;
45
46
47
48
49 public class AdminWorkgroupFilter
50 {
51
52 private static final String CONSTANT_EQUAL = "=";
53 private static final String CONSTANT_ESPERLUETTE = "&";
54
55
56 private static final String PARAMETER_SEARCH_IS_SEARCH = "search_is_search";
57 private static final String PARAMETER_SEARCH_KEY = "search_key";
58 private static final String PARAMETER_SEARCH_DESCRIPTION = "search_description";
59
60
61 private static final String PROPERTY_ENCODING_URL = "lutece.encoding.url";
62 private String _strKey;
63 private String _strDescription;
64
65
66
67
68 public AdminWorkgroupFilter( )
69 {
70
71 }
72
73
74
75
76 public void init( )
77 {
78 _strKey = "";
79 _strDescription = "";
80 }
81
82
83
84
85
86
87 public String getKey( )
88 {
89 return _strKey;
90 }
91
92
93
94
95
96
97
98 public void setKey( String strKey )
99 {
100 _strKey = strKey;
101 }
102
103
104
105
106
107
108 public String getDescription( )
109 {
110 return _strDescription;
111 }
112
113
114
115
116
117
118
119 public void setDescription( String strDescription )
120 {
121 _strDescription = strDescription;
122 }
123
124
125
126
127
128
129 public String getWorkgroup( )
130 {
131 return getKey( );
132 }
133
134
135
136
137
138
139
140
141 public boolean setAdminWorkgroupFilter( HttpServletRequest request )
142 {
143 boolean bIsSearch = false;
144 String strIsSearch = request.getParameter( PARAMETER_SEARCH_IS_SEARCH );
145
146 if ( strIsSearch != null )
147 {
148 bIsSearch = true;
149 _strKey = request.getParameter( PARAMETER_SEARCH_KEY );
150 _strDescription = request.getParameter( PARAMETER_SEARCH_DESCRIPTION );
151 }
152 else
153 {
154 init( );
155 }
156
157 return bIsSearch;
158 }
159
160
161
162
163
164
165
166 public void setUrlAttributes( UrlItem url )
167 {
168 url.addParameter( PARAMETER_SEARCH_IS_SEARCH, Boolean.TRUE.toString( ) );
169
170 try
171 {
172 url.addParameter( PARAMETER_SEARCH_KEY, URLEncoder.encode( _strKey, AppPropertiesService.getProperty( PROPERTY_ENCODING_URL ) ) );
173 url.addParameter( PARAMETER_SEARCH_DESCRIPTION, URLEncoder.encode( _strDescription, AppPropertiesService.getProperty( PROPERTY_ENCODING_URL ) ) );
174 }
175 catch( UnsupportedEncodingException e )
176 {
177 AppLogService.error( e.getMessage( ), e );
178 }
179 }
180
181
182
183
184
185
186 public String getUrlAttributes( )
187 {
188 StringBuilder sbUrlAttributes = new StringBuilder( );
189 sbUrlAttributes.append( PARAMETER_SEARCH_IS_SEARCH + CONSTANT_EQUAL + Boolean.TRUE );
190
191 try
192 {
193 sbUrlAttributes.append( CONSTANT_ESPERLUETTE + PARAMETER_SEARCH_KEY + CONSTANT_EQUAL
194 + URLEncoder.encode( _strKey, AppPropertiesService.getProperty( PROPERTY_ENCODING_URL ) ) );
195 sbUrlAttributes.append( CONSTANT_ESPERLUETTE + PARAMETER_SEARCH_DESCRIPTION + CONSTANT_EQUAL
196 + URLEncoder.encode( _strDescription, AppPropertiesService.getProperty( PROPERTY_ENCODING_URL ) ) );
197 }
198 catch( UnsupportedEncodingException e )
199 {
200 AppLogService.error( e.getMessage( ), e );
201 }
202
203 return sbUrlAttributes.toString( );
204 }
205 }