if (params.containsKey("relatedEventIds[]")) {
Set<String> visitedIds = new HashSet<String>();
String[] relatedEventIds = getStrings("relatedEventIds[]");
List<String> eventIds = new ArrayList<String>();
ArrayNode array = new ArrayNode(JsonNodeFactory.instance);
for (String relatedEventId : relatedEventIds) {
if (!Util.isUUID(relatedEventId))
continue;
if (eventId.equals(relatedEventId))
continue;
if (visitedIds.contains(relatedEventId))
continue;
visitedIds.add(relatedEventId);
Event relatedEvent = daos.getEventAccess().find(con, relatedEventId);
if (relatedEvent == null)
continue;
eventIds.add(relatedEventId);
ObjectNode obj = new ObjectNode(JsonNodeFactory.instance);
obj.put("id", relatedEvent.getId());
obj.put("title", relatedEvent.getTitle());
array.add(obj);
}
event.setRelatedEventIds(eventIds);
// OK. We want to return event.id and event.title.
json.put("relatedEvents", array);
}
if (params.containsKey("editorIds[]")) {
ArrayNode array = new ArrayNode(JsonNodeFactory.instance);
List<String> editorIds = new ArrayList<String>();
Set<String> visitedIds = new HashSet<String>();
for (String editorId : getStrings("editorIds[]")) {
// Skips invalid users here.
if (!Util.isUUID(editorId))
continue;
if (visitedIds.contains(editorId))
continue;
visitedIds.add(editorId);
UserEx editor = UserDAOFacade.getUserEx(con, daos, editorId);
if (editor == null)
continue;
// OK.
editorIds.add(editor.getId());
array.add(editor.toSafeJSON());
}
event.setEditorIds(editorIds);
json.put("editors", array);
}