Revision 50969
Added by Argiro Kokogiannaki about 6 years ago
HelloWorldService.java | ||
---|---|---|
63 | 63 |
@DefaultValue("") @QueryParam("keyword") String keyword, |
64 | 64 |
@DefaultValue("") @QueryParam("sortby") String orderby, |
65 | 65 |
@DefaultValue("true") @QueryParam("descending") boolean descending, |
66 |
@DefaultValue("") @QueryParam("types") String types,
|
|
66 |
@DefaultValue("") @QueryParam("types") List<String> types,
|
|
67 | 67 |
@HeaderParam("X-XSRF-TOKEN") String token, |
68 | 68 |
@CookieParam("AccessToken") String cookie, |
69 | 69 |
@Context HttpServletRequest request) { |
... | ... | |
85 | 85 |
} |
86 | 86 |
|
87 | 87 |
List<Claim> claims = null; |
88 |
List<String> listTypes = new ArrayList<String>(); |
|
89 |
String[] types_array = types.split(","); |
|
90 |
for (int i = 0; i < types_array.length; i++) { |
|
91 |
if (types_array[i].length() > 0) { |
|
92 |
listTypes.add(types_array[i]); |
|
93 |
} |
|
94 |
} |
|
95 | 88 |
try { |
96 |
claims = fetchClaimHandler.fetchClaimsByProject(projectId, limit, offset, keyword, orderby, descending, listTypes,false);
|
|
97 |
total = fetchClaimHandler.countClaimsByProject(projectId, keyword, listTypes);
|
|
89 |
claims = fetchClaimHandler.fetchClaimsByProject(projectId, limit, offset, keyword, orderby, descending, types,false);
|
|
90 |
total = fetchClaimHandler.countClaimsByProject(projectId, keyword, types);
|
|
98 | 91 |
|
99 | 92 |
} catch (SQLStoreException|Exception e) { //TODO check this with exception |
100 | 93 |
logger.error("Could not fetch claims for project with id " + projectId, e); |
... | ... | |
120 | 113 |
@DefaultValue("") @QueryParam("keyword") String keyword, |
121 | 114 |
@DefaultValue("") @QueryParam("sortby") String orderby, |
122 | 115 |
@DefaultValue("true") @QueryParam("descending") boolean descending, |
123 |
@DefaultValue("") @QueryParam("types") String types,
|
|
116 |
@DefaultValue("") @QueryParam("types") List<String> types,
|
|
124 | 117 |
@HeaderParam("X-XSRF-TOKEN") String token, |
125 | 118 |
@CookieParam("AccessToken") String cookie, |
126 | 119 |
@Context HttpServletRequest request) { |
... | ... | |
145 | 138 |
} |
146 | 139 |
|
147 | 140 |
List<Claim> claims = null; |
148 |
List<String> listTypes = new ArrayList<String>(); |
|
149 |
String[] types_array = types.split(","); |
|
150 |
for (int i = 0; i < types_array.length; i++) { |
|
151 |
if (types_array[i].length() > 0) { |
|
152 |
listTypes.add(types_array[i]); |
|
153 |
} |
|
154 |
} |
|
155 | 141 |
try { |
156 | 142 |
String projectId = fetchProjectHandler.fetchProjectIdByToken(projectToken,userMail); |
157 | 143 |
if(projectId == null){ |
... | ... | |
161 | 147 |
}else{ |
162 | 148 |
if(offset == -1 && limit == -1) { |
163 | 149 |
// when offset and limit are -1 fetch claims with null values, to ignore paging and limit clause |
164 |
claims = fetchClaimHandler.fetchClaimsByProject(projectId, null, null, keyword, orderby, descending, listTypes, true);
|
|
150 |
claims = fetchClaimHandler.fetchClaimsByProject(projectId, null, null, keyword, orderby, descending, types, true);
|
|
165 | 151 |
} else { |
166 |
claims = fetchClaimHandler.fetchClaimsByProject(projectId, limit, offset, keyword, orderby, descending, listTypes, true);
|
|
152 |
claims = fetchClaimHandler.fetchClaimsByProject(projectId, limit, offset, keyword, orderby, descending, types, true);
|
|
167 | 153 |
} |
168 |
total = fetchClaimHandler.countClaimsByProject(projectId, keyword, listTypes);
|
|
154 |
total = fetchClaimHandler.countClaimsByProject(projectId, keyword, types);
|
|
169 | 155 |
|
170 | 156 |
return Response.status(200).entity(composeDataResponse(request, claims, total, offset, limit)).build(); |
171 | 157 |
} |
... | ... | |
190 | 176 |
@DefaultValue("") @QueryParam("keyword") String keyword, |
191 | 177 |
@DefaultValue("") @QueryParam("sortby") String orderby, |
192 | 178 |
@DefaultValue("true") @QueryParam("descending") boolean descending, |
193 |
@DefaultValue("") @QueryParam("types") String types,
|
|
179 |
@DefaultValue("") @QueryParam("types") List<String> types,
|
|
194 | 180 |
@HeaderParam("X-XSRF-TOKEN") String token, |
195 | 181 |
@CookieParam("AccessToken") String cookie, |
196 | 182 |
@Context HttpServletRequest request) { |
197 |
|
|
183 |
// @RequestParam(value="includeStates[]", defaultValue="1,2,3") String[] includeStates |
|
198 | 184 |
|
199 | 185 |
if(token == null || token.isEmpty() || cookie == null || cookie.isEmpty() || !cookie.equals(token)){ |
200 | 186 |
authorization.logStatus(token,cookie); |
... | ... | |
202 | 188 |
.type(MediaType.APPLICATION_JSON) |
203 | 189 |
.build(); |
204 | 190 |
} |
205 |
logger.debug("Calling API for context with token " + token); |
|
191 |
// logger.debug("Calling API for context with token " + token);
|
|
206 | 192 |
|
207 | 193 |
if(authorization.isAdmin(token)) { |
208 | 194 |
|
... | ... | |
211 | 197 |
return Response.status(Response.Status.BAD_REQUEST).entity(compose400Message("Context id cannot be empty.")) |
212 | 198 |
.type(MediaType.APPLICATION_JSON).build(); |
213 | 199 |
} |
200 |
logger.debug("Types are " + types); |
|
201 |
List<Claim> claims = null; |
|
214 | 202 |
|
215 |
List<Claim> claims = null; |
|
216 |
List<String> listTypes = new ArrayList<String>(); |
|
217 |
String[] types_array = types.split(","); |
|
218 |
for (int i = 0; i < types_array.length; i++) { |
|
219 |
if (types_array[i].length() > 0) { |
|
220 |
listTypes.add(types_array[i]); |
|
221 |
} |
|
222 |
} |
|
223 | 203 |
try { |
224 |
claims = fetchClaimHandler.fetchClaimsByContext(contextId, limit, offset, keyword, orderby, descending, listTypes,false);
|
|
225 |
total = fetchClaimHandler.countClaimsByContext(contextId, keyword, listTypes);
|
|
204 |
claims = fetchClaimHandler.fetchClaimsByContext(contextId, limit, offset, keyword, orderby, descending, types,false);
|
|
205 |
total = fetchClaimHandler.countClaimsByContext(contextId, keyword, types);
|
|
226 | 206 |
|
227 | 207 |
} catch (SQLStoreException|Exception e) { |
228 | 208 |
logger.error("Could not fetch claims for context with id " + contextId, e); |
... | ... | |
248 | 228 |
@DefaultValue("") @QueryParam("keyword") String keyword, |
249 | 229 |
@DefaultValue("") @QueryParam("sortby") String orderby, |
250 | 230 |
@DefaultValue("true") @QueryParam("descending") boolean descending, |
251 |
@DefaultValue("") @QueryParam("types") String types,
|
|
231 |
@DefaultValue("") @QueryParam("types") List<String> types,
|
|
252 | 232 |
@HeaderParam("X-XSRF-TOKEN") String token, |
253 | 233 |
@CookieParam("AccessToken") String cookie, |
254 | 234 |
@Context HttpServletRequest request) { |
... | ... | |
270 | 250 |
} |
271 | 251 |
|
272 | 252 |
List<Claim> claims = null; |
273 |
List<String> listTypes = new ArrayList<String>(); |
|
274 |
String[] types_array = types.split(","); |
|
275 |
for (int i = 0; i < types_array.length; i++) { |
|
276 |
if (types_array[i].length() > 0) { |
|
277 |
listTypes.add(types_array[i]); |
|
278 |
} |
|
279 |
} |
|
280 |
|
|
281 | 253 |
try { |
282 |
claims = fetchClaimHandler.fetchClaimsByResult(resultId, limit, offset, keyword, orderby, descending, listTypes,false);
|
|
283 |
total = fetchClaimHandler.countClaimsByResult(resultId, keyword, listTypes);
|
|
254 |
claims = fetchClaimHandler.fetchClaimsByResult(resultId, limit, offset, keyword, orderby, descending, types,false);
|
|
255 |
total = fetchClaimHandler.countClaimsByResult(resultId, keyword, types);
|
|
284 | 256 |
|
285 | 257 |
} catch (SQLStoreException|Exception e) { |
286 | 258 |
logger.error("Could not fetch claims for result with id " + resultId, e); |
... | ... | |
305 | 277 |
@DefaultValue("") @QueryParam("keyword") String keyword, |
306 | 278 |
@DefaultValue("") @QueryParam("sortby") String orderby, |
307 | 279 |
@DefaultValue("true") @QueryParam("descending") boolean descending, |
308 |
@DefaultValue("") @QueryParam("types") String types,
|
|
280 |
@DefaultValue("") @QueryParam("types") List<String> types,
|
|
309 | 281 |
@HeaderParam("X-XSRF-TOKEN") String token, |
310 | 282 |
@CookieParam("AccessToken") String cookie, |
311 | 283 |
@Context HttpServletRequest request) { |
... | ... | |
335 | 307 |
} |
336 | 308 |
|
337 | 309 |
List<Claim> claims = null; |
338 |
List<String> listTypes = new ArrayList<String>(); |
|
339 |
String[] types_array = types.split(","); |
|
340 |
for (int i = 0; i < types_array.length; i++) { |
|
341 |
if (types_array[i].length() > 0) { |
|
342 |
listTypes.add(types_array[i]); |
|
343 |
} |
|
344 |
} |
|
345 | 310 |
try { |
346 | 311 |
logger.debug("About to fetch claims" ); |
347 |
claims = fetchClaimHandler.fetchClaimsByUser(userMail, limit, offset, keyword, orderby, descending, listTypes,false);
|
|
348 |
total = fetchClaimHandler.countClaimsByUser(userMail, keyword, listTypes);
|
|
312 |
claims = fetchClaimHandler.fetchClaimsByUser(userMail, limit, offset, keyword, orderby, descending, types,false);
|
|
313 |
total = fetchClaimHandler.countClaimsByUser(userMail, keyword, types);
|
|
349 | 314 |
|
350 | 315 |
} catch (SQLStoreException|Exception e) { |
351 | 316 |
logger.error("Could not fetch claims for user with mail " + userMail, e); |
... | ... | |
424 | 389 |
@DefaultValue("") @QueryParam("keyword") String keyword, |
425 | 390 |
@DefaultValue("date") @QueryParam("sortby") String orderby, |
426 | 391 |
@DefaultValue("true") @QueryParam("descending") boolean descending, |
427 |
@DefaultValue("") @QueryParam("types") String types,
|
|
392 |
@DefaultValue("") @QueryParam("types") List<String> types,
|
|
428 | 393 |
@HeaderParam("X-XSRF-TOKEN") String token, |
429 | 394 |
@HeaderParam("Origin") String origin, |
430 | 395 |
@CookieParam("AccessToken") String cookie, |
... | ... | |
446 | 411 |
if(authorization.isAdmin(token)) { |
447 | 412 |
logger.debug("User is authorized ! !"); |
448 | 413 |
List<Claim> claims = null; |
449 |
List<String> listTypes = new ArrayList<String>(); |
|
450 |
String[] types_array = types.split(","); |
|
451 |
for (int i = 0; i < types_array.length; i++) { |
|
452 |
if (types_array[i].length() > 0) { |
|
453 |
listTypes.add(types_array[i]); |
|
454 |
} |
|
455 |
} |
|
456 |
logger.debug("Types: " + listTypes.toString()); |
|
457 |
|
|
414 |
|
|
458 | 415 |
int total = -1; |
459 | 416 |
try { |
460 |
claims = fetchClaimHandler.fetchAllClaims(limit, offset, keyword, orderby, descending, listTypes,false);
|
|
461 |
total = fetchClaimHandler.countAllClaims(keyword, listTypes);
|
|
417 |
claims = fetchClaimHandler.fetchAllClaims(limit, offset, keyword, orderby, descending, types,false);
|
|
418 |
total = fetchClaimHandler.countAllClaims(keyword, types);
|
|
462 | 419 |
|
463 | 420 |
return Response.status(200).entity(composeDataResponse(request, claims, total, offset, limit)).build(); |
464 | 421 |
|
Also available in: Unified diff
fixing issues with types filter - change the parameter for types