From: Niels Erik G. Nielsen Date: Fri, 18 Apr 2014 19:56:29 +0000 (-0400) Subject: Adds support for pazpar2 info command X-Git-Tag: v0.0.7~10 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=1ab622be3bcde018e6b7816d4af8b79f80159630;p=mkjsf-moved-to-github.git Adds support for pazpar2 info command --- diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/InfoCommand.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/InfoCommand.java new file mode 100644 index 0000000..7c8e578 --- /dev/null +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/InfoCommand.java @@ -0,0 +1,51 @@ +/** + * + */ +package com.indexdata.mkjsf.pazpar2.commands; + +import com.indexdata.mkjsf.pazpar2.commands.sp.ServiceProxyCommand; + +/** + * @author Niels Erik + * + */ +public class InfoCommand extends Pazpar2Command implements ServiceProxyCommand { + + /** + * + */ + private static final long serialVersionUID = -180974027395677475L; + + public InfoCommand () { + super("info"); + } + + /* (non-Javadoc) + * @see com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command#copy() + */ + @Override + public Pazpar2Command copy() { + InfoCommand newCommand = new InfoCommand(); + for (String parameterName : parameters.keySet()) { + newCommand.setParameterInState(parameters.get(parameterName).copy()); + } + return newCommand; + } + + /* (non-Javadoc) + * @see com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command#getSp() + */ + @Override + public ServiceProxyCommand getSp() { + return this; + } + + /* (non-Javadoc) + * @see com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command#spOnly() + */ + @Override + public boolean spOnly() { + return false; + } + +} diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/data/InfoResponse.java b/src/main/java/com/indexdata/mkjsf/pazpar2/data/InfoResponse.java new file mode 100644 index 0000000..82f31dc --- /dev/null +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/data/InfoResponse.java @@ -0,0 +1,19 @@ +package com.indexdata.mkjsf.pazpar2.data; + +public class InfoResponse extends ResponseDataObject { + + /** + * + */ + private static final long serialVersionUID = 3084509436017631123L; + + public String getPazpar2Version () { + return getOneElement("version").getOneValue("pazpar2"); + } + + public String getYazVersion() { + return getOneElement("version").getOneValue("yaz"); + } + + +} diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/data/Pazpar2VersionResponse.java b/src/main/java/com/indexdata/mkjsf/pazpar2/data/Pazpar2VersionResponse.java new file mode 100644 index 0000000..6b4fff3 --- /dev/null +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/data/Pazpar2VersionResponse.java @@ -0,0 +1,17 @@ +package com.indexdata.mkjsf.pazpar2.data; + +public class Pazpar2VersionResponse extends ResponseDataObject { + + /** + * + */ + private static final long serialVersionUID = 8565086923105413965L; + + public String getPazpar2 () { + return getOneValue("pazpar2"); + } + + public String getYaz() { + return getOneValue("yaz"); + } +} diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/data/ResponseParser.java b/src/main/java/com/indexdata/mkjsf/pazpar2/data/ResponseParser.java index 56e4218..8036a29 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/data/ResponseParser.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/data/ResponseParser.java @@ -38,7 +38,7 @@ public class ResponseParser extends DefaultHandler { private String xml = null; private static Logger logger = Logger.getLogger(ResponseParser.class); - public static List docTypes = Arrays.asList( "bytarget","termlist","show","stat","record","search","init", + public static List docTypes = Arrays.asList( "bytarget","termlist","show","stat","record","search","init","info", /* SP extras */ "auth", "categories" ); public ResponseParser() { @@ -123,6 +123,10 @@ public class ResponseParser extends DefaultHandler { currentElement = new TermResponse(); } ((TermListResponse)dataElements.peek()).addTerm((TermResponse)currentElement); + } else if (localName.equals("info")) { + currentElement = new InfoResponse(); + } else if (localName.equals("version") && dataElements.peek().getType().equals("info")) { + currentElement = new Pazpar2VersionResponse(); } else if (localName.equals("applicationerror")) { currentElement = new CommandError(); } else if (localName.equals("error") && dataElements.peek().getType().equals("applicationerror")) {