package com.indexdata.pz2utils4jsf.config;\r
\r
import java.io.IOException;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
\r
import javax.enterprise.context.SessionScoped;\r
import javax.enterprise.inject.Alternative;\r
\r
import com.indexdata.masterkey.config.MasterkeyConfiguration;\r
import com.indexdata.masterkey.config.ModuleConfiguration;\r
+import com.indexdata.pz2utils4jsf.utils.Utils;\r
\r
@Named @SessionScoped @Alternative\r
public class Pz2ConfigureByMk2Config implements Pz2Configurator {\r
private Pz2Config pz2config = null;\r
\r
public Pz2ConfigureByMk2Config () throws IOException {\r
- logger.debug("Instantiating Pazpar2 service configuration by MasterKey configuration scheme.");\r
+ logger.info(Utils.objectId(this) + " is instantiating Pazpar2 service configuration by MasterKey configuration scheme.");\r
+ }\r
+ \r
+ @Override\r
+ public Pz2Config getConfig() throws IOException {\r
+ if (pz2config == null) {\r
+ createConfig();\r
+ }\r
+ return pz2config;\r
+ }\r
+ \r
+ private void createConfig () throws IOException {\r
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();\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
+ logger.info(document());\r
}\r
+ \r
+\r
+ public List<String> document() {\r
+ List<String> doc = new ArrayList<String>();\r
\r
- @Override\r
- public Pz2Config getConfig() {\r
- return pz2config;\r
+ doc.add("-- App set to access Pazpar2 at: " +pz2config.get("PAZPAR2_URL"));\r
+ if (pz2config.get("PAZPAR2_SERVICE_XML") != null) {\r
+ doc.add("-- App set to use the service definition contained in " + pz2config.getConfigFilePath() + "/" + pz2config.get("PAZPAR2_SERVICE_XML"));\r
+ if (pz2config.get("PAZPAR2_SETTINGS_XML") != null) {\r
+ doc.add("-- App set to use the target settings contained in " + pz2config.getConfigFilePath() + "/" + pz2config.get("PAZPAR2_SETTINGS_XML"));\r
+ } else {\r
+ doc.add("-- App set to use the server side target settings as defined in the service definition.");\r
+ }\r
+ } else if (pz2config.get("PAZPAR2_SERVICE_ID") != null) {\r
+ doc.add("-- App set to use the server side service definition identified by service id \""+pz2config.get("PAZPAR2_SERVICE_ID") + "\"");\r
+ } else {\r
+ doc.add("Error: Did not find service ID nor service definition XML file to set up pazpar2 service.");\r
+ }\r
+ return doc;\r
}\r
- \r
+ \r
\r
}\r