private JSONObj storeDetails(JSONObj json, StoreInfo store, HttpServletRequest req)
      throws IOException {
    store(json, store);

    JSONObj connection = new JSONObj();
    Map<String, Serializable> params = store.getConnectionParameters();
    for (Entry<String, Serializable> param : params.entrySet()) {
      String key = param.getKey();
      Object value = param.getValue();
      String text = value == null ? null : value.toString();

      connection.put(key, text);
    }
    if (store instanceof CoverageStoreInfo) {
      CoverageStoreInfo info = (CoverageStoreInfo) store;
      connection.put("raster", info.getURL());
    }
    if (store instanceof WMSStoreInfo) {
      WMSStoreInfo info = (WMSStoreInfo) store;
      json.put("wms", info.getCapabilitiesURL());
    }
    json.put("connection", connection);
    json.put("error", IO.error(new JSONObj(), store.getError()));

    if (store.isEnabled()) {
      resources(store, json.putArray("resources"), req);
    }
    json.put("layer-count", layerCount(store));

    return json;
  }