import com.indexdata.masterkey.config.MasterkeyConfiguration;\r
import com.indexdata.masterkey.config.ModuleConfiguration;\r
import com.indexdata.pz2utils4jsf.utils.Utils;\r
+import static com.indexdata.pz2utils4jsf.utils.Utils.nl;\r
\r
@Named @SessionScoped @Alternative\r
public class Pz2ConfigureByMk2Config implements Pz2Configurator {\r
private static final long serialVersionUID = 8865086878660568870L;\r
private static Logger logger = Logger.getLogger(Pz2ConfigureByMk2Config.class);\r
private Pz2Config pz2config = null;\r
+ private String configFilePathAndName = "none";\r
\r
public Pz2ConfigureByMk2Config () throws IOException {\r
logger.info(Utils.objectId(this) + " is instantiating Pazpar2 service configuration by MasterKey configuration scheme.");\r
\r
private void createConfig () throws IOException {\r
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();\r
- ServletContext servletContext = (ServletContext) externalContext.getContext(); \r
+ ServletContext servletContext = (ServletContext) externalContext.getContext(); \r
MasterkeyConfiguration mkConfigContext =\r
MasterkeyConfiguration.getInstance(servletContext,\r
"pazpar-application-jsf", ((HttpServletRequest) externalContext.getRequest()).getServerName());\r
+ configFilePathAndName = mkConfigContext.getConfigFileLocation().getConfigFilePath();\r
ModuleConfiguration moduleConfig = mkConfigContext.getModuleConfiguration("pz2client");\r
pz2config = new Pz2Config(moduleConfig);\r
logger.info(document());\r
\r
public List<String> document() {\r
List<String> doc = new ArrayList<String>();\r
- \r
- doc.add("-- App set to access Pazpar2 at: " +pz2config.get("PAZPAR2_URL"));\r
+ doc.add("Attempted to configure service using the file " + configFilePathAndName);\r
+ doc.add(nl+"-- Configured 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
+ doc.add(nl+"-- Configured 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
+ doc.add(nl+"-- Configured 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
+ doc.add(nl+"-- Configured 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
+ doc.add(nl+"-- Configured 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
+ doc.add(nl+"Error: Did not find service ID nor service definition XML file for setting up a pazpar2 service.");\r
}\r
return doc;\r
}\r
LOCAL_SETTINGS_FILE_NOT_FOUND,\r
MASTERKEY_CONFIG_FILE_NOT_FOUND,\r
MISSING_MANDATORY_PARAMETER,\r
+ MISSING_MK2_CONFIG_INIT_PARAMETER,\r
NOT_RESOLVED,\r
SKIP_SUGGESTIONS};\r
\r
return ErrorCode.SKIP_SUGGESTIONS;\r
} else if (appError.getMessage().contains("Missing mandatory parameter")) {\r
return ErrorCode.MISSING_MANDATORY_PARAMETER;\r
+ } else if (appError.getMessage().contains("Init parameter")\r
+ && appError.getMessage().contains("MASTERKEY")\r
+ && appError.getMessage().contains("missing in deployment descriptor")) {\r
+ return ErrorCode.MISSING_MK2_CONFIG_INIT_PARAMETER;\r
}\r
return ErrorCode.NOT_RESOLVED;\r
}\r
" file used. Please check the property file for the parameter given in the error message ");\r
addConfigurationDocumentation(suggestions);\r
break;\r
+ case MISSING_MK2_CONFIG_INIT_PARAMETER:\r
+ suggestions.add("A mandatory init parameter was not found in the deployment descriptor (web.xml)." +\r
+ " Following init parameters must be present in web.xml when using the Masterkey (MK2) configuration scheme:" +\r
+ " MASTERKEY_ROOT_CONFIG_DIR (i.e. '/etc/masterkey'), MASTERKEY_COMPONENT_CONFIG_DIR (i.e. '/myapp'), " +\r
+ "MASTERKEY_CONFIG_FILE_NAME (i.e. 'myapp.properties'"); \r
+ break;\r
case NOT_RESOLVED:\r
suggestions.add("Unforeseen error situation. No suggestions prepared.");\r
break;\r