package com.indexdata.pz2utils4jsf.config;\r
\r
+import java.io.IOException;\r
import java.io.Serializable;\r
import java.util.HashMap;\r
import java.util.Map;\r
import org.apache.log4j.Logger;\r
\r
import com.indexdata.masterkey.config.MissingMandatoryParameterException;\r
+import com.indexdata.masterkey.config.ModuleConfiguration;\r
import com.indexdata.masterkey.config.ModuleConfigurationGetter;\r
\r
public class Pz2Config implements ModuleConfigurationGetter, Serializable {\r
private static final long serialVersionUID = -6801241975338182197L;\r
private static Logger logger = Logger.getLogger(Pz2Config.class);\r
Map<String,String> properties = new HashMap<String,String>();\r
+ ModuleConfiguration moduleConfig = null;\r
\r
public Pz2Config () {\r
- setStatics();\r
+ setDefaults();\r
}\r
\r
- public Pz2Config (String pazpar2Url, String pazpar2ServiceId) {\r
- setStatics();\r
- setPazpar2Url(pazpar2Url);\r
- setPazpar2ServiceId(pazpar2ServiceId);\r
- logger.debug("Creating pazpar2 configuration with "+ get("PAZPAR2_URL") + " and " + get("PAZPAR2_SERVICE_ID"));\r
+ public Pz2Config (Map<String,String> parameters) {\r
+ setDefaults();\r
+ for (String key : parameters.keySet()) {\r
+ properties.put(key, parameters.get(key));\r
+ }\r
+ }\r
+ \r
+ public Pz2Config (ModuleConfiguration moduleConfig) throws IOException {\r
+ this.moduleConfig = moduleConfig;\r
+ for (String key : moduleConfig.getConfigMap().keySet()) {\r
+ properties.put(key, moduleConfig.getConfigParameter(key));\r
+ }\r
}\r
\r
- private void setStatics () {\r
+ private void setDefaults () {\r
properties.put("PROXY_MODE","1");\r
properties.put("SERIALIZE_REQUESTS", "false");\r
properties.put("STREAMBUFF_SIZE", "4096");\r
\r
@Override\r
public String getConfigFilePath() {\r
- return null;\r
+ return moduleConfig.getConfigFilePath();\r
}\r
\r
\r
ServletContext servletContext = (ServletContext) externalContext.getContext(); \r
MasterkeyConfiguration mkConfigContext =\r
MasterkeyConfiguration.getInstance(servletContext,\r
- "faces-component", ((HttpServletRequest) externalContext.getRequest()).getServerName());\r
- ModuleConfiguration moduleConfig = mkConfigContext.getModuleConfiguration("pz2client"); \r
- String pazpar2Url = moduleConfig.get("PAZPAR2_URL");\r
- String pazpar2ServiceId = moduleConfig.get("PAZPAR2_SERVICE_ID");\r
- pz2config = new Pz2Config(pazpar2Url,pazpar2ServiceId);\r
+ "pazpar-application-jsf", ((HttpServletRequest) externalContext.getRequest()).getServerName());\r
+ ModuleConfiguration moduleConfig = mkConfigContext.getModuleConfiguration("pz2client");\r
+ pz2config = new Pz2Config(moduleConfig);\r
}\r
\r
@Override\r
package com.indexdata.pz2utils4jsf.config;\r
\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
import javax.enterprise.context.SessionScoped;\r
import javax.enterprise.inject.Alternative;\r
import javax.faces.context.ExternalContext;\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
+ Map<String,String> parameters = new HashMap<String,String>();\r
+ parameters.put("PAZPAR2_URL", servletContext.getInitParameter("PAZPAR2_URL"));\r
+ parameters.put("PAZPAR2_SERVICE_ID", servletContext.getInitParameter("PAZPAR2_SERVICE_ID"));\r
+ config = new Pz2Config(parameters);\r
}\r
\r
@Override\r