|
[HepData-svn] r1847 - trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pagesblackhole at projects.hepforge.org blackhole at projects.hepforge.orgFri Mar 27 15:07:53 GMT 2015
Author: whalley Date: Fri Mar 27 15:07:53 2015 New Revision: 1847 Log: addition of JSON formatter - first attempt Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/View.java Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/View.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/View.java Mon Mar 2 16:53:27 2015 (r1846) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/View.java Fri Mar 27 15:07:53 2015 (r1847) @@ -42,7 +42,7 @@ parseBaseViewContext(context); // Handle pattern parsing separately - Pattern patt = Pattern.compile("\\A" + "(short|long|full|plain.txt|yoda|aida|pyroot.py|root|mpl|bdms|hepml|scavis.py|input|marcxml)" + "\\Z", + Pattern patt = Pattern.compile("\\A" + "(short|long|full|plain.txt|yoda|aida|pyroot.py|root|mpl|bdms|hepml|scavis.py|input|marcxml|json)" + "\\Z", Pattern.CASE_INSENSITIVE); Pattern patt2 = Pattern.compile("\\A" + "(irn\\d+)" + "\\Z",Pattern.CASE_INSENSITIVE); String stype = "i"; @@ -66,6 +66,7 @@ if (fmt.equals("scavis.py")) return asJhepwork(); if (fmt.equals("hepml")) return asHepML(); if (fmt.equals("marcxml")) return asMarcXML(); + if (fmt.equals("json")) return asJSON(); if (fmt.equals("bdms")) return asBDMS(); if (fmt.equals("input")) return asINPUT(context); if (fmt.equals("plain.txt")) return asPlain(); @@ -132,6 +133,17 @@ } return new TextStreamResponse("text/xml", asMarcXML); } + public Object getJsonContext() { + return formatContext("json"); + } + public StreamResponse asJSON() { + Paper p = getPaper(); + String asJSON = JsonFormatter.format(p); + if (asJSON == null) { + asJSON = "No valid paper specified"; + } + return new TextStreamResponse("text/plain", asJSON); + } public Object getBdmsContext() { return formatContext("bdms");
More information about the HepData-svn mailing list |