Revision 60586
Added by Konstantinos Triantafyllou about 3 years ago
RegistryCalls.java | ||
---|---|---|
284 | 284 |
} |
285 | 285 |
|
286 | 286 |
/** |
287 |
* 14. Assign a member role to a User
|
|
287 |
* 14. Get Users' identifiers of a Cou
|
|
288 | 288 |
*/ |
289 |
public JsonArray getUserIdByCouId(Integer couId, boolean admin) { |
|
290 |
Map<String, String> params = new HashMap<>(); |
|
291 |
params.put("couid", couId.toString()); |
|
292 |
if (admin) { |
|
293 |
params.put("admin", "true"); |
|
294 |
} |
|
295 |
JsonElement response = httpUtils.get("identifiers.json", params); |
|
296 |
JsonArray infos = (response != null) ? response.getAsJsonObject().get("Identifiers").getAsJsonArray() : new JsonArray(); |
|
297 |
JsonArray emails = new JsonArray(); |
|
298 |
infos.forEach(info -> { |
|
299 |
JsonObject user = new JsonObject(); |
|
300 |
user.addProperty("id", info.getAsJsonObject().get("Identifier").getAsString()); |
|
301 |
user.addProperty("memberSince", info.getAsJsonObject().get("Created").getAsString()); |
|
302 |
emails.add(user); |
|
303 |
}); |
|
304 |
return emails; |
|
305 |
} |
|
306 |
|
|
307 |
/** |
|
308 |
* 15. Assign a member role to a User |
|
309 |
*/ |
|
289 | 310 |
public void assignMemberRole(Integer coPersonId, Integer couId, Integer id) { |
290 | 311 |
if (id != null) { |
291 | 312 |
httpUtils.put("co_person_roles/" + id.toString() + ".json", jsonUtils.coPersonRoles(coPersonId, couId, "Active")); |
... | ... | |
295 | 316 |
} |
296 | 317 |
|
297 | 318 |
/** |
298 |
* 15. Remove a member role from a User
|
|
319 |
* 16. Remove a member role from a User
|
|
299 | 320 |
*/ |
300 | 321 |
public void removeMemberRole(Integer coPersonId, Integer couId, Integer id) { |
301 | 322 |
httpUtils.put("co_person_roles/" + id.toString() + ".json", jsonUtils.coPersonRoles(coPersonId, couId, "Deleted")); |
302 | 323 |
} |
303 | 324 |
|
304 | 325 |
/** |
305 |
* 16. Create a new role
|
|
326 |
* 17. Create a new role
|
|
306 | 327 |
*/ |
307 | 328 |
public void createRole(Role role) { |
308 | 329 |
httpUtils.post("cous.json", jsonUtils.createNewCou(role)); |
309 | 330 |
} |
310 | 331 |
|
311 | 332 |
/** |
312 |
* 17. Get User's email
|
|
333 |
* 18. Get User's email
|
|
313 | 334 |
*/ |
314 | 335 |
public String getUserEmail(Integer coPersonId) { |
315 | 336 |
Map<String, String> params = new HashMap<>(); |
... | ... | |
320 | 341 |
} |
321 | 342 |
|
322 | 343 |
/** |
323 |
* 18. Get User's names
|
|
344 |
* 19. Get User's names
|
|
324 | 345 |
*/ |
325 | 346 |
public String getUserNames(Integer coPersonId) { |
326 | 347 |
Map<String, String> params = new HashMap<>(); |
... | ... | |
331 | 352 |
} |
332 | 353 |
|
333 | 354 |
/** |
334 |
* 14. Assign an admin role to a User
|
|
355 |
* 20. Get User's identifier
|
|
335 | 356 |
*/ |
357 |
public String getUserId(Integer coPersonId) { |
|
358 |
Map<String, String> params = new HashMap<>(); |
|
359 |
params.put("copersonid", coPersonId.toString()); |
|
360 |
JsonElement response = httpUtils.get("identifiers.json", params); |
|
361 |
JsonObject info = (response != null) ? response.getAsJsonObject().get("Identifiers").getAsJsonArray().get(0).getAsJsonObject() : null; |
|
362 |
return (info != null) ? info.getAsJsonObject().get("Identifier").getAsString() : null; |
|
363 |
} |
|
364 |
|
|
365 |
/** |
|
366 |
* 21. Assign an admin role to a User |
|
367 |
*/ |
|
336 | 368 |
public void assignAdminRole(Integer coPersonId, Integer couId) { |
337 | 369 |
JsonObject group = getCouAdminGroup(couId); |
338 | 370 |
if (group != null) { |
... | ... | |
341 | 373 |
} |
342 | 374 |
|
343 | 375 |
/** |
344 |
* 15. Remove an admin role from a User
|
|
376 |
* 22. Remove an admin role from a User
|
|
345 | 377 |
*/ |
346 | 378 |
public void removeAdminRole(Integer coPersonId, Integer couId) { |
347 | 379 |
JsonObject adminGroup = this.getCouAdminGroup(couId); |
Also available in: Unified diff
[User | Trunk]: Add methods to get ids of managers and members for an entity.