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
import com.indexdata.mkjsf.pazpar2.data.CommandError;\r
import com.indexdata.mkjsf.utils.Utils;\r
\r
+/**\r
+ * Search client handling straight Pazpar2 requests. \r
+ * \r
+ * <p>Although it is described here as straight Pazpar2, the client itself \r
+ * actually represents a layer between Pazpar2 and the JSF application because it \r
+ * uses the Pazpar2 client from the library masterkey-common.</p>\r
+ * That client, which is the one also used by the Service Proxy, does perform certain \r
+ * types of session handling, bootstraps lost sessions, avoids repeating already \r
+ * executed queries etc, so it is -- in other words -- still a mediated interaction \r
+ * with Pazpar2 that takes place. At least for now.</p> \r
+ * \r
+ * @author Niels Erik\r
+ *\r
+ */\r
public class Pz2Client implements SearchClient {\r
\r
private static final long serialVersionUID = 5414266730169982028L;\r
client.setSearchCommand(clientCommand); \r
}\r
\r
+ /**\r
+ * Runs the give Pazpar2 command and returns a response wrapper with either the received response or \r
+ * with some form of error message. \r
+ * \r
+ * It is intended that this method never throws an exception. All events are supposed to be captured and\r
+ * returned in some form of response. \r
+ */\r
@Override\r
public HttpResponseWrapper executeCommand(Pazpar2Command command) {\r
ClientCommandResponse commandResponse = null;\r
logger.error(e.getMessage());\r
e.printStackTrace();\r
logger.error("Creating error XML");\r
- commandResponse = new ClientCommandResponse(0,CommandError.createErrorXml(command.getCommandName(), "", "Pazpar2Error", e.getMessage(),""),"text/xml");\r
+ commandResponse = new ClientCommandResponse(0,CommandError.createErrorXml(command.getCommandName(), "", "ServiceError", e.getMessage(),""),"text/xml");\r
}\r
long end = System.currentTimeMillis(); \r
- logger.debug("Executed " + command.getCommandName() + " in " + (end-start) + " ms." );\r
+ logger.info("Executed " + command.getCommandName() + " in " + (end-start) + " ms." );\r
return commandResponse;\r
}\r
\r
return clone;\r
}\r
\r
+ /**\r
+ * Returns default configuration parameters for the client.\r
+ */\r
@Override\r
public Map<String, String> getDefaults() {\r
return DEFAULTS;\r
}\r
\r
+ /**\r
+ * Returns the configuration name of the client\r
+ */\r
@Override\r
public String getModuleName() {\r
return MODULENAME;\r
}\r
}\r
\r
+ /**\r
+ * Provides configuration documentation -- mostly for diagnosing problems \r
+ */\r
@Override\r
public List<String> documentConfiguration() {\r
List<String> doc = new ArrayList<String>();\r
return config;\r
}\r
\r
+ /**\r
+ * Returns the currently configured Papzar2 URL.\r
+ */\r
@Override\r
public String getServiceUrl() {\r
return cfg.PAZPAR2_URL; \r
}\r
\r
+ /**\r
+ * Returns true if a Papzar2 URL was defined yet. \r
+ */\r
@Override\r
public boolean hasServiceUrl() {\r
return cfg.PAZPAR2_URL != null && cfg.PAZPAR2_URL.length()>0;\r
}\r
\r
+ /**\r
+ * Sets the Pazpar2 URL to use for requests. \r
+ */\r
@Override \r
public void setServiceUrl (String serviceUrl) { \r
cfg.PAZPAR2_URL = serviceUrl; \r
}\r
\r
+ /**\r
+ * Returns the Pazpar2 Service ID \r
+ */\r
public String getServiceId () {\r
return cfg.PAZPAR2_SERVICE_ID;\r
}\r
\r
+ /**\r
+ * Sets the service ID that Pazpar2 should use when servicing requests\r
+ * @param serviceId\r
+ */\r
public void setServiceId(String serviceId) {\r
cfg.PAZPAR2_SERVICE_ID = serviceId;\r
try {\r