import com.indexdata.mkjsf.pazpar2.commands.CommandParameter;\r
import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command;\r
import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Commands;\r
-import com.indexdata.mkjsf.pazpar2.commands.sp.ServiceProxyCommand;\r
import com.indexdata.mkjsf.pazpar2.data.RecordResponse;\r
import com.indexdata.mkjsf.pazpar2.data.ResponseDataObject;\r
import com.indexdata.mkjsf.pazpar2.data.ResponseParser;\r
errors.addConfigurationError(new ConfigurationError("Search Client","Configuration",e.getMessage())); \r
} \r
logger.info(configReader.document());\r
- pzresp.resetAllSessionData(); \r
+ pzresp.getSp().resetAuthAndBeyond(true); \r
}\r
\r
public void resetSearchAndRecordCommands () {\r
errors.addConfigurationError(new ConfigurationError("No client defined","Client is null","No search client defined. A client must be pre-configured or selected runtime, prior to searching."));\r
} else {\r
stateMgr.hasPendingStateChange("search",false);\r
- pzresp.resetSearchResponses();\r
- // resets some record and show command parameters without \r
- // changing state or creating state change feedback\r
+ pzresp.resetSearchAndBeyond();\r
pzreq.getRecord().removeParametersInState(); \r
pzreq.getShow().setParameterInState(new CommandParameter("start","=",0)); \r
logger.debug(Utils.objectId(this) + " is searching using "+pzreq.getCommand("search").getUrlEncodedParameterValue("query"));\r
if (url!=null && searchClient != null && !url.equals(searchClient.getServiceUrl())) {\r
pzreq.getRecord().removeParametersInState();\r
pzreq.getSearch().removeParametersInState();\r
- pzresp.resetAllSessionData();\r
+ pzresp.getSp().resetAuthAndBeyond(true);\r
user.clear();\r
searchClient.setServiceUrl(url);\r
} \r
public void setServiceId () {\r
pzreq.getRecord().removeParametersInState();\r
pzreq.getSearch().removeParametersInState();\r
- pzresp.resetSearchResponses();\r
+ pzresp.resetSearchAndBeyond();\r
pz2Client.setServiceId(pzreq.getInit().getService());\r
}\r
\r
if (!serviceType.equals(type) &&\r
!serviceType.equals(SERVICE_TYPE_TBD)) {\r
resetSearchAndRecordCommands();\r
- pzresp.resetAllSessionData();\r
+ pzresp.getSp().resetAuthAndBeyond(true);\r
}\r
serviceType = type;\r
if (serviceType.equals(SERVICE_TYPE_PZ2)) {\r
import java.util.List;\r
import java.util.Map;\r
\r
-import javax.faces.context.ExternalContext;\r
-import javax.faces.context.FacesContext;\r
-\r
import org.apache.log4j.Logger;\r
\r
import com.indexdata.masterkey.config.MissingMandatoryParameterException;\r
public String login(String navigateTo) {\r
logger.info("doing login by " + user + " using " + pz2 + " and client " + pz2.getSpClient());\r
pz2.resetSearchAndRecordCommands();\r
- pzresp.resetAllSessionData();\r
+ pzresp.getSp().resetAuthAndBeyond(true);\r
AuthCommand auth = pzreq.getSp().getAuth(); \r
auth.setParametersInState(new CommandParameter("action","=","login"),\r
new CommandParameter("username","=",user.getName()),\r
user.clear();\r
}\r
pz2.resetSearchAndRecordCommands();\r
- pzresp.resetAllSessionData();\r
+ pzresp.getSp().resetAuthAndBeyond(true);\r
AuthCommand auth = pzreq.getSp().getAuth(); \r
auth.setParameterInState(new CommandParameter("action","=","ipAuth"));\r
ClientCommandResponse commandResponse = pz2.getSpClient().send(auth); \r
public ClientCommandResponse postInit() throws UnsupportedEncodingException, IOException { \r
String initDocPath = pz2.getSpClient().getInitDocPaths().get(0);\r
logger.info("Paths: " + pz2.getSpClient().getInitDocPaths());\r
- logger.info("Path: " + initDocPath);\r
+ logger.info("Path: " + initDocPath); \r
pz2.resetSearchAndRecordCommands();\r
- pzresp.resetAllSessionData();\r
+ pzresp.getSp().resetAuthAndBeyond(true);\r
ClientCommandResponse response = pz2.getSpClient().postInitDoc(initDocPath + getInitFileName()); \r
return response;\r
}\r
@Override\r
public HttpResponseWrapper postInit(byte[] initDoc, boolean includeDebug) throws UnsupportedEncodingException, IOException { \r
pz2.resetSearchAndRecordCommands();\r
- pzresp.resetAllSessionData();\r
+ pzresp.getSp().resetAuthAndBeyond(true);\r
HttpResponseWrapper response = pz2.getSpClient().postInitDoc(initDoc,includeDebug); \r
return response;\r
}\r
\r
import com.indexdata.mkjsf.errors.ErrorHelper;\r
import com.indexdata.mkjsf.errors.ErrorInterface;\r
-import com.indexdata.mkjsf.pazpar2.data.sp.AuthResponse;\r
-import com.indexdata.mkjsf.pazpar2.data.sp.CategoriesResponse;\r
+import com.indexdata.mkjsf.pazpar2.data.sp.SpResponses;\r
import com.indexdata.mkjsf.utils.Utils;\r
\r
@Named("pzresp") @SessionScoped\r
protected Map<String,ResponseDataObject> dataObjects = new ConcurrentHashMap<String,ResponseDataObject>();\r
private static Logger logger = Logger.getLogger(Responses.class);\r
private ErrorHelper errorHelper = null;\r
+ private SpResponses sp = null;\r
\r
public Responses() { \r
}\r
return error; \r
}\r
\r
- public void resetSearchResponses() {\r
+ public void resetSearchAndBeyond() {\r
logger.debug("Resetting show,stat,termlist,bytarget,record,search response objects.");\r
dataObjects.put("show", new ShowResponse());\r
dataObjects.put("stat", new StatResponse());\r
dataObjects.put("termlist", new TermListsResponse());\r
dataObjects.put("bytarget", new ByTarget());\r
dataObjects.put("record", new RecordResponse());\r
- dataObjects.put("search", new SearchResponse()); \r
+ dataObjects.put("search", new SearchResponse());\r
+ getSp().resetSearchAndBeyond(false);\r
}\r
\r
- public void resetAllSessionData () {\r
- logger.debug("Resetting all response objects");\r
- dataObjects = new ConcurrentHashMap<String,ResponseDataObject>(); \r
- resetSearchResponses();\r
- dataObjects.put("init", new InitResponse());\r
- dataObjects.put("auth", new AuthResponse());\r
- dataObjects.put("categories", new CategoriesResponse());\r
+ public void resetInitAndBeyond () {\r
+ dataObjects.put("init", new InitResponse()); \r
+ resetSearchAndBeyond();\r
+ getSp().resetInitAndBeyond(false);\r
}\r
- \r
+ \r
public InitResponse getInit () { \r
return ((InitResponse) dataObjects.get("init"));\r
}\r
return ((ByTarget) dataObjects.get("bytarget"));\r
}\r
\r
- // Service Proxy extras \r
- public AuthResponse getAuth () {\r
- return ((AuthResponse) dataObjects.get("auth"));\r
- }\r
-\r
- public CategoriesResponse getCategories() {\r
- return ((CategoriesResponse) dataObjects.get("categories"));\r
- }\r
- // Service Proxy extras\r
- \r
-\r
public ResponseDataObject getResponseObject (String name) {\r
return dataObjects.get(name);\r
}\r
facesContext.responseComplete();\r
}\r
\r
+ public SpResponses getSp() {\r
+ return (sp == null ? new SpResponses(this) : sp);\r
+ }\r
+ \r
}
\ No newline at end of file
package com.indexdata.mkjsf.pazpar2.data.sp;\r
\r
-public class SpResponses {\r
+import java.io.Serializable;\r
\r
- public SpResponses() {\r
- // TODO Auto-generated constructor stub\r
+import com.indexdata.mkjsf.pazpar2.data.Responses;\r
+\r
+public class SpResponses implements Serializable {\r
+ \r
+ private static final long serialVersionUID = -3831357590639961167L;\r
+ private Responses responses = null; \r
+\r
+ public SpResponses(Responses responses) {\r
+ this.responses = responses; \r
+ }\r
+ \r
+ /**\r
+ * Resets all responses from the search request to any request \r
+ * that can follow search (i.e. show and bytarget but not init or auth) \r
+ * @param includePazpar2Responses Set to true if the invocation should\r
+ * reset Pazpar2 responses \r
+ * (non-SP-specific responses) as well. \r
+ */\r
+ public void resetSearchAndBeyond(boolean includePazpar2Responses) {\r
+ if (includePazpar2Responses) {\r
+ responses.resetSearchAndBeyond();\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Resets all responses from the init request to any request \r
+ * that can follow init (i.e. search and show but not auth) \r
+ * @param includePazpar2Responses Set to true if the invocation should\r
+ * reset Pazpar2 responses \r
+ * (non-SP-specific responses) as well. \r
+ */\r
+ public void resetInitAndBeyond (boolean includePazpar2Responses) {\r
+ responses.put("categories", new CategoriesResponse());\r
+ if (includePazpar2Responses) {\r
+ responses.resetInitAndBeyond();\r
+ }\r
+ resetSearchAndBeyond(includePazpar2Responses); \r
+ }\r
+ \r
+ /**\r
+ * Resets all responses from the authentication request to any request \r
+ * that can follow authentication. \r
+ * @param includePazpar2Responses Set to true if the invocation should\r
+ * reset Pazpar2 responses \r
+ * (non-SP-specific responses) as well. \r
+ */\r
+ public void resetAuthAndBeyond (boolean includePazpar2Responses) {\r
+ responses.put("auth", new AuthResponse());\r
+ resetInitAndBeyond(includePazpar2Responses); \r
+ }\r
+ \r
+ public AuthResponse getAuth () {\r
+ return ((AuthResponse) responses.getResponseObject("auth"));\r
+ }\r
+\r
+ public CategoriesResponse getCategories() {\r
+ return ((CategoriesResponse) responses.getResponseObject("categories"));\r
}\r
\r
}\r