@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
SolrCore core = req.getCore();
NamedList cats = new NamedList();
rsp.add("solr-mbeans", cats);
String[] requestedCats = req.getParams().getParams("cat");
if (null == requestedCats || 0 == requestedCats.length) {
for (SolrInfoMBean.Category cat : SolrInfoMBean.Category.values()) {
cats.add(cat.name(), new SimpleOrderedMap());
}
} else {
for (String catName : requestedCats) {
cats.add(catName,new SimpleOrderedMap());
}
}
Set<String> requestedKeys = arrayToSet(req.getParams().getParams("key"));
Map<String, SolrInfoMBean> reg = core.getInfoRegistry();
for (Map.Entry<String, SolrInfoMBean> entry : reg.entrySet()) {
String key = entry.getKey();
SolrInfoMBean m = entry.getValue();
if ( ! ( requestedKeys.isEmpty() || requestedKeys.contains(key) ) ) continue;
NamedList catInfo = (NamedList) cats.get(m.getCategory().name());
if ( null == catInfo ) continue;
NamedList mBeanInfo = new SimpleOrderedMap();
mBeanInfo.add("class", m.getName());
mBeanInfo.add("version", m.getVersion());
mBeanInfo.add("description", m.getDescription());
mBeanInfo.add("srcId", m.getSourceId());
mBeanInfo.add("src", m.getSource());
mBeanInfo.add("docs", m.getDocs());
if (req.getParams().getFieldBool(key, "stats", false))
mBeanInfo.add("stats", m.getStatistics());
catInfo.add(key, mBeanInfo);
}
rsp.setHttpCaching(false); // never cache, no matter what init config looks like
}