{
String json = "";
MetsObjectController controller = null;
try {
controller = new MetsObjectController(getConfig(coll));
MetsObject metsObj = controller.getMetsObject(oid);
JSONObject ret = new JSONObject();
ret.put("item", getJSONAtomicItem(metsObj, inum));
JSONObject mo = new JSONObject();
mo.put("size", metsObj.getPhysicalStruct().size());
mo.put("id", oid);
mo.put("objid", metsObj.getObjId());
mo.put("linkbackUrl", metsObj.getLinkBackUrl());
mo.put("label", metsObj.getDescription());
JSONObject dataStream = new JSONObject();
for (Map.Entry<String, Map<String, String>> entry: metsObj.getDataStreamsMap().entrySet()) {
JSONObject stream = new JSONObject();
for (Map.Entry<String, String> streamEntry: entry.getValue().entrySet()) {
stream.put(streamEntry.getKey(), streamEntry.getValue());
}
if (stream.entrySet().size() > 0) {
dataStream.put(entry.getKey(), stream);
}
}
if (dataStream.size() > 0) {
mo.put("dataStream", dataStream);
}
Map<String, Related> rmap = metsObj.getRelatedMap();
if (rmap != null) {
Related titleMets = rmap.get("title");
if (titleMets != null) {
mo.put("titleLevelMets", titleMets.getPurl());
}