+++ /dev/null
-package com.indexdata.pz2utils4jsf.config;\r
-\r
-import java.io.IOException;\r
-import java.io.Serializable;\r
-\r
-import javax.faces.context.ExternalContext;\r
-import javax.faces.context.FacesContext;\r
-import javax.servlet.ServletContext;\r
-import javax.servlet.http.HttpServletRequest;\r
-\r
-import com.indexdata.masterkey.config.MasterkeyConfiguration;\r
-import com.indexdata.masterkey.config.ModuleConfiguration;\r
-import com.indexdata.masterkey.config.ModuleConfigurationGetter;\r
-\r
-public abstract class FacesModuleConfiguration implements ModuleConfigurationGetter, Serializable {\r
-\r
- private static final long serialVersionUID = -7225977088088592928L;\r
- private ModuleConfiguration config;\r
-\r
- public FacesModuleConfiguration() {\r
- if (FacesContext.getCurrentInstance() != null) {\r
- ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();\r
- HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();\r
- ServletContext servletContext = (ServletContext) externalContext.getContext();\r
- String host = request.getServerName();\r
- try {\r
- config = MasterkeyConfiguration.getModuleConfiguration(servletContext, host, getComponentName(), getModuleName());\r
- } catch (IOException ioe) {\r
- ioe.printStackTrace();\r
- }\r
- }\r
- }\r
-\r
- public String get(String name) {\r
- return config.get(name);\r
- }\r
-\r
- public String get(String name, String defaultValue) {\r
- return config.get(name, defaultValue);\r
- }\r
- \r
- public ModuleConfiguration getModuleConfiguration () {\r
- return config;\r
- }\r
- \r
- public abstract String getModuleName();\r
- \r
- public abstract String getComponentName();\r
-\r
-}\r
+++ /dev/null
-package com.indexdata.pz2utils4jsf.config;\r
-\r
-import com.indexdata.pz2utils4jsf.config.FacesModuleConfiguration;\r
-\r
-public abstract class JsfdemoModuleConfiguration extends FacesModuleConfiguration {\r
-\r
- private static final long serialVersionUID = -2936339728016978922L;\r
-\r
- @Override\r
- public abstract String getModuleName();\r
-\r
- @Override\r
- public String getComponentName() {\r
- return "jsfdemo";\r
- }\r
-\r
-}\r
+++ /dev/null
-package com.indexdata.pz2utils4jsf.config;\r
-\r
-import javax.enterprise.context.SessionScoped;\r
-import javax.inject.Named;\r
-\r
-import com.indexdata.pz2utils4jsf.config.JsfdemoModuleConfiguration;\r
-\r
-@Named("pz2clientConfig")\r
-@SessionScoped\r
-public class JsfdemoPazpar2ClientConfiguration extends JsfdemoModuleConfiguration {\r
-\r
- private static final long serialVersionUID = 8865086878660568870L;\r
- \r
- @Override\r
- public String getModuleName() {\r
- return "pz2client";\r
- }\r
-\r
-}\r
--- /dev/null
+package com.indexdata.pz2utils4jsf.config;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import com.indexdata.masterkey.config.MissingMandatoryParameterException;\r
+import com.indexdata.masterkey.config.ModuleConfigurationGetter;\r
+\r
+public class Pz2Config implements ModuleConfigurationGetter {\r
+\r
+ Map<String,String> properties = new HashMap<String,String>();\r
+ \r
+ public Pz2Config () {\r
+ setStatics();\r
+ }\r
+ \r
+ public Pz2Config (String pazpar2Url, String pazpar2ServiceId) {\r
+ setStatics();\r
+ setPazpar2Url(pazpar2Url);\r
+ setPazpar2ServiceId(pazpar2ServiceId);\r
+ }\r
+ \r
+ private void setStatics () {\r
+ properties.put("PROXY_MODE","1");\r
+ properties.put("SERIALIZE_REQUESTS", "false");\r
+ properties.put("STREAMBUFF_SIZE", "4096");\r
+ properties.put("PARSE_RESPONSES", "true"); \r
+ }\r
+ \r
+ @Override\r
+ public String get(String key) {\r
+ return properties.get(key); \r
+ }\r
+ \r
+ public void set(String key, String value) {\r
+ properties.put(key, value);\r
+ }\r
+ \r
+ public void setPazpar2Url (String value) {\r
+ properties.put("PAZPAR2_URL", value);\r
+ }\r
+ \r
+ public void setPazpar2ServiceId (String value) {\r
+ properties.put("PAZPAR2_SERVICE_ID",value);\r
+ }\r
+\r
+ @Override\r
+ public String get(String key, String defaultValue) {\r
+ if (properties.containsKey(key)) {\r
+ return properties.get(key);\r
+ } else {\r
+ return defaultValue;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public String getMandatory(String key) throws MissingMandatoryParameterException {\r
+ if (properties.containsKey(key)) {\r
+ return properties.get(key);\r
+ } \r
+ throw new Error("Missing mandatory parameter: " + key); \r
+ }\r
+\r
+ @Override\r
+ public String getConfigFilePath() {\r
+ return null;\r
+ }\r
+ \r
+ \r
+\r
+}\r
--- /dev/null
+package com.indexdata.pz2utils4jsf.config;\r
+\r
+import java.io.Serializable;\r
+\r
+public interface Pz2Configurator extends Serializable {\r
+ public Pz2Config getConfig();\r
+}\r
--- /dev/null
+package com.indexdata.pz2utils4jsf.config;\r
+\r
+import javax.enterprise.context.SessionScoped;\r
+import javax.faces.context.ExternalContext;\r
+import javax.faces.context.FacesContext;\r
+import javax.inject.Named;\r
+import javax.servlet.ServletContext;\r
+\r
+import org.apache.log4j.Logger;\r
+\r
+@Named("pz2configwebxml")\r
+@SessionScoped\r
+public class Pz2ConfigureByWebXml implements Pz2Configurator {\r
+\r
+ private static final long serialVersionUID = 144390224959311772L;\r
+ private static Logger logger = Logger.getLogger(Pz2ConfigureByWebXml.class);\r
+ private Pz2Config config = null;\r
+ \r
+ public Pz2ConfigureByWebXml () {\r
+ logger.debug("Instantiating Pazpar2 service configuration by web.xml parameters");\r
+ ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();\r
+ ServletContext servletContext = (ServletContext) externalContext.getContext();\r
+ String pazpar2Url = servletContext.getInitParameter("PAZPAR2_URL");\r
+ String pazpar2ServiceId = servletContext.getInitParameter("PAZPAR2_SERVICE_id");\r
+ config = new Pz2Config(pazpar2Url,pazpar2ServiceId);\r
+ }\r
+ \r
+ @Override\r
+ public Pz2Config getConfig() {\r
+ return config;\r
+ }\r
+}\r
import java.util.List;\r
\r
import javax.enterprise.context.SessionScoped;\r
+import javax.inject.Inject;\r
import javax.inject.Named;\r
\r
+import com.indexdata.pz2utils4jsf.config.Pz2ConfigureByWebXml;\r
import com.indexdata.pz2utils4jsf.controls.ResultsPager;\r
import com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface;\r
import com.indexdata.pz2utils4jsf.pazpar2.Pz2Session;\r
\r
private static final long serialVersionUID = 3440277287081557861L;\r
Pz2Session pz2;\r
- \r
+\r
+ @Inject \r
+ private Pz2ConfigureByWebXml pz2conf;\r
+\r
public Pz2Bean () {\r
- pz2 = new Pz2Session(); \r
+ pz2 = new Pz2Session(pz2conf); \r
}\r
/* (non-Javadoc)\r
* @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#doSearch(java.lang.String)\r
\r
import org.apache.log4j.Logger;\r
\r
-import com.indexdata.pz2utils4jsf.controls.ResultsPager;\r
-import com.indexdata.pz2utils4jsf.pazpar2.CommandParameter;\r
-import com.indexdata.pz2utils4jsf.pazpar2.CommandThread;\r
-import com.indexdata.pz2utils4jsf.pazpar2.Expression;\r
-import com.indexdata.pz2utils4jsf.pazpar2.Pazpar2Command;\r
-import com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface;\r
-import com.indexdata.pz2utils4jsf.pazpar2.Pz2Session;\r
-import com.indexdata.pz2utils4jsf.pazpar2.TargetFilter;\r
-import com.indexdata.masterkey.pazpar2.client.Pazpar2Client;\r
-import com.indexdata.masterkey.pazpar2.client.Pazpar2ClientConfiguration;\r
-import com.indexdata.masterkey.pazpar2.client.Pazpar2ClientGeneric;\r
import com.indexdata.masterkey.pazpar2.client.exceptions.ProxyErrorException;\r
-import com.indexdata.pz2utils4jsf.config.JsfdemoPazpar2ClientConfiguration;\r
+import com.indexdata.pz2utils4jsf.config.Pz2Configurator;\r
+import com.indexdata.pz2utils4jsf.controls.ResultsPager;\r
import com.indexdata.pz2utils4jsf.pazpar2.data.ByTarget;\r
import com.indexdata.pz2utils4jsf.pazpar2.data.Pazpar2ResponseData;\r
import com.indexdata.pz2utils4jsf.pazpar2.data.Pazpar2ResponseParser;\r
private QueryStates queryStates = new QueryStates();\r
\r
private static final long serialVersionUID = 3947514708343320514L; \r
- private Pazpar2ClientConfiguration cfg = null;\r
- private Pazpar2Client client = null; \r
+ private com.indexdata.masterkey.pazpar2.client.Pazpar2ClientConfiguration cfg = null;\r
+ private com.indexdata.masterkey.pazpar2.client.Pazpar2Client client = null; \r
private TargetFilter targetFilter = null; \r
private ResultsPager pager = null; \r
-\r
- public Pz2Session () {\r
- logger.debug("Instantiating pz2"); \r
+ \r
+ public Pz2Session (Pz2Configurator pz2conf) {\r
+ logger.debug("Instantiating pz2"); \r
+ if (pz2conf == null) {logger.error("conf is null!!!!!!!!!!!!!!!"); }\r
try {\r
- cfg = new Pazpar2ClientConfiguration(new JsfdemoPazpar2ClientConfiguration().getModuleConfiguration());\r
- client = new Pazpar2ClientGeneric(cfg);\r
+ cfg = new com.indexdata.masterkey.pazpar2.client.Pazpar2ClientConfiguration(pz2conf.getConfig());\r
+ client = new com.indexdata.masterkey.pazpar2.client.Pazpar2ClientGeneric(cfg);\r
resetDataObjects();\r
} catch (ProxyErrorException e) {\r
e.printStackTrace();\r