import java.io.IOException;\r
import java.io.Serializable;\r
import java.io.UnsupportedEncodingException;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
\r
import javax.enterprise.context.SessionScoped;\r
import javax.inject.Inject;\r
@Inject Pz2Bean pz2;\r
@Inject Pazpar2Commands pzreq;\r
@Inject Responses pzresp;\r
-\r
- \r
+ \r
public ServiceProxyExtensions() {\r
this.initDocUpload = new InitDocUpload(this);\r
// TODO: \r
//stateMgr.addStateListener(this);\r
}\r
- \r
+ \r
public void authenticate() {\r
+ String command = "auth";\r
+ if (pzresp.getSp().getAuth().unsupportedCommand()) {\r
+ logger.warn("Running seemingly unsupported command [auth] against SP.");\r
+ }\r
pz2.resetSearchAndRecordCommands();\r
pzresp.getSp().resetAuthAndBeyond(true);\r
AuthCommand auth = pzreq.getSp().getAuth(); \r
ClientCommandResponse commandResponse = pz2.getSpClient().send(auth); \r
- String renamedResponse = renameResponseElement(commandResponse.getResponseString(), "auth");\r
+ String renamedResponse = renameResponseElement(commandResponse.getResponseString(), "auth"); \r
commandResponse.setResponseToParse(renamedResponse);\r
- ResponseDataObject responseObject = ResponseParser.getParser().getDataObject(commandResponse);\r
+ SpResponseDataObject responseObject = (SpResponseDataObject) ResponseParser.getParser().getDataObject(commandResponse); \r
if (ResponseParser.docTypes.contains(responseObject.getType())) {\r
pzresp.put(auth.getCommandName(), responseObject);\r
}\r
+ if (responseObject.unsupportedCommand()) {\r
+ logger.error("auth command does not seem to be supported by this Service Proxy");\r
+ }\r
String responseStr = commandResponse.getResponseString();\r
logger.info(responseStr); \r
}\r
return initDocUpload;\r
}\r
\r
- public CategoriesResponse getCategories () {\r
+ public CategoriesResponse getCategories () { \r
+ String command="categories";\r
if (pz2.isServiceProxyService()) {\r
- SpResponseDataObject response = (SpResponseDataObject) pz2.doCommand("categories");\r
- if (response.unsupportedCommand()) {\r
- logger.warn("Command 'categories' not supported by this Service Proxy"); \r
+ if (pzresp.getSp().getCategories().unsupportedCommand()) {\r
+ logger.info("Skipping seemingly unsupported command: " + command); \r
return new CategoriesResponse();\r
} else {\r
- if (response.hasApplicationError()) {\r
- logger.debug(response.getXml());\r
- return new CategoriesResponse();\r
- } else {\r
- try {\r
+ SpResponseDataObject response = (SpResponseDataObject) pz2.doCommand(command);\r
+ if (response.unsupportedCommand()) {\r
+ logger.warn("Command 'categories' not supported by this Service Proxy"); \r
+ } else if (response.hasApplicationError()) {\r
+ logger.error(response.getXml()); \r
+ } \r
+ try {\r
return (CategoriesResponse) response;\r
- } catch (Exception e) {\r
+ } catch (Exception e) {\r
e.printStackTrace();\r
logger.debug(response.getXml());\r
return new CategoriesResponse();\r
- }\r
}\r
}\r
} else {\r
package com.indexdata.mkjsf.pazpar2.data.sp;\r
\r
-import org.apache.log4j.Logger;\r
-\r
import com.indexdata.mkjsf.pazpar2.data.ResponseDataObject;\r
\r
public class SpResponseDataObject extends ResponseDataObject {\r
\r
- private static final long serialVersionUID = -3098556883153269199L;\r
- private static Logger logger = Logger.getLogger(SpResponseDataObject.class);\r
+ private static final long serialVersionUID = -3098556883153269199L; \r
\r
public boolean unsupportedCommand() {\r
- if (hasServiceError() && getServiceError().getCode().equalsIgnoreCase("3")) {\r
- logger.warn("The " + getType() + " command not supported by this Service Proxy (request fell through SP to Pazpar2).");\r
+ if (hasServiceError() \r
+ && getServiceError().getCode().equals("3")\r
+ && getServiceError().getValue().equals("command")) { \r
return true;\r
}\r
return false;\r