X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fcom%2Findexdata%2Fpz2utils4jsf%2Fpazpar2%2FPz2Client.java;h=39adf03123cff48f031f49ff7cba968bf8cd7c02;hb=7b71381e71db35eed511606e80c0d3e18cab4d2b;hp=bc10fab4b6967a12236715b8d4581a19108d4354;hpb=aa4634e1a3c9eec2103b299dda20d916dcba8b20;p=mkjsf-moved-to-github.git diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Client.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Client.java index bc10fab..39adf03 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Client.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Client.java @@ -9,9 +9,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.enterprise.context.SessionScoped; -import javax.inject.Named; - import org.apache.log4j.Logger; import com.indexdata.masterkey.config.MissingMandatoryParameterException; @@ -26,9 +23,9 @@ import com.indexdata.masterkey.pazpar2.client.exceptions.ProxyErrorException; import com.indexdata.pz2utils4jsf.config.Configuration; import com.indexdata.pz2utils4jsf.config.ConfigurationReader; import com.indexdata.pz2utils4jsf.errors.ConfigurationException; +import com.indexdata.pz2utils4jsf.pazpar2.commands.CommandReadOnly; import com.indexdata.pz2utils4jsf.utils.Utils; -@Named @SessionScoped public class Pz2Client implements SearchClient { private static final long serialVersionUID = 5414266730169982028L; @@ -37,6 +34,7 @@ public class Pz2Client implements SearchClient { private Pazpar2ClientConfiguration cfg = null; public static final String MODULENAME = "pz2client"; public static Map DEFAULTS = new HashMap(); + Configuration config = null; static { DEFAULTS.put("PROXY_MODE","1"); @@ -51,7 +49,7 @@ public class Pz2Client implements SearchClient { public void configure(ConfigurationReader configReader) throws ConfigurationException { logger.info(Utils.objectId(this) + " is configuring using the provided " + Utils.objectId(configReader)); try { - Configuration config = configReader.getConfiguration(this); + config = configReader.getConfiguration(this); cfg = new Pazpar2ClientConfiguration(new ConfigurationGetter(config)); } catch (ProxyErrorException pe) { logger.error("Could not configure Pazpar2 client: " + pe.getMessage()); @@ -83,13 +81,13 @@ public class Pz2Client implements SearchClient { } @Override - public void setSearchCommand(Pazpar2Command command) { + public void setSearchCommand(CommandReadOnly command) { ClientCommand clientCommand = new ClientCommand(command.getName(), command.getEncodedQueryString()); client.setSearchCommand(clientCommand); } @Override - public CommandResponse executeCommand(Pazpar2Command command, ByteArrayOutputStream baos) + public CommandResponse executeCommand(CommandReadOnly command, ByteArrayOutputStream baos) throws Pazpar2ErrorException, IOException { ClientCommand clientCommand = new ClientCommand(command.getName(), command.getEncodedQueryString()); Pazpar2HttpResponse pz2HttpResponse = client.executeCommand(clientCommand, baos); @@ -144,5 +142,9 @@ public class Pz2Client implements SearchClient { doc.add(nl+ MODULENAME + " was configured to access Pazpar2 at : " + cfg.PAZPAR2_URL); return new ArrayList(); } + + public Configuration getConfiguration () { + return config; + } }