Resource r = registry.get(path);
if (!(r instanceof Collection)) {
String msg = path + " is not a collection. Topics should be collections.";
log.error(msg);
throw new TopicException(msg);
}
Collection topic = (Collection) r;
List<MapEntry> endpointList = new ArrayList<MapEntry> ();
List<MapEntry> subtopicList = new ArrayList<MapEntry> ();
String[] children = (String[]) topic.getContent();
for(String childPath: children) {
processTopicChild(childPath, endpointList, subtopicList, registry);
}
r.discard();
TopicBean topicBean = new TopicBean();
topicBean.setEndpoints(endpointList.toArray(new MapEntry[endpointList.size()]));
topicBean.setSubtopics(subtopicList.toArray(new MapEntry[subtopicList.size()]));
return topicBean;
} catch (Exception e) {
String msg = "Failed to get topic details. " + e.getMessage();
log.error(msg, e);
throw new TopicException(msg, e);
}
}