X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fcom%2Findexdata%2Fmkjsf%2Fpazpar2%2FPz2Client.java;h=6dfe77f7f570914465083725ddef3a47222333b8;hb=3cc9707fdd556a222b5d8e6bba61c84a320eb357;hp=7ab5ec5ad1a15877841491d9be02655b0dbcc6b3;hpb=6da388f43fedda3e61e630f826244608d2da6301;p=mkjsf-moved-to-github.git diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2Client.java b/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2Client.java index 7ab5ec5..6dfe77f 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2Client.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2Client.java @@ -59,7 +59,7 @@ public class Pz2Client implements SearchClient { } if (cfg != null) { try { - client = new Pazpar2ClientGeneric(cfg); + client = new Pazpar2ClientGeneric(cfg); } catch (ProxyErrorException pe) { logger.error("Could not configure Pazpar2 client: " + pe.getMessage()); throw new ConfigurationException("Could not configure Pz2Client: "+ pe.getMessage(),pe); @@ -99,6 +99,9 @@ public class Pz2Client implements SearchClient { pz2HttpResponse = client.executeCommand(clientCommand, baos); if (pz2HttpResponse.getStatusCode()==200 && pz2HttpResponse.getContentType().contains("xml")) { commandResponse = new ClientCommandResponse(pz2HttpResponse,baos); + } else if (pz2HttpResponse.getStatusCode()==200 && pz2HttpResponse.getContentType().contains("octet-stream")) { + commandResponse = new ClientCommandResponse(pz2HttpResponse,baos); + logger.info("Content type: " + commandResponse.getContentType() + ". isBinary?: " + commandResponse.isBinary()); } else if (pz2HttpResponse.getStatusCode()==417) { logger.error("Pazpar2 status code 417: " + baos.toString("UTF-8")); commandResponse = new ClientCommandResponse(pz2HttpResponse.getStatusCode(),CommandError.insertErrorXml(command.getCommandName(), String.valueOf(pz2HttpResponse.getStatusCode()) ,"Pazpar2: Expectation failed (417)", baos.toString("UTF-8")),"text/xml"); @@ -126,7 +129,7 @@ public class Pz2Client implements SearchClient { logger.error(e.getMessage()); e.printStackTrace(); logger.error("Creating error XML"); - commandResponse = new ClientCommandResponse(500,CommandError.createErrorXml(command.getCommandName(), "", "Pazpar2Error", e.getMessage(),""),"text/xml"); + commandResponse = new ClientCommandResponse(0,CommandError.createErrorXml(command.getCommandName(), "", "ServiceError", e.getMessage(),""),"text/xml"); } long end = System.currentTimeMillis(); logger.debug("Executed " + command.getCommandName() + " in " + (end-start) + " ms." ); @@ -198,8 +201,20 @@ public class Pz2Client implements SearchClient { @Override public void setServiceUrl (String serviceUrl) { - cfg.PAZPAR2_URL = serviceUrl; - + cfg.PAZPAR2_URL = serviceUrl; + } + + public String getServiceId () { + return cfg.PAZPAR2_SERVICE_ID; + } + + public void setServiceId(String serviceId) { + cfg.PAZPAR2_SERVICE_ID = serviceId; + try { + client = new Pazpar2ClientGeneric(cfg); + } catch (ProxyErrorException pe) { + logger.error("Could not configure Pazpar2 client: " + pe.getMessage()); + } } }