Avoids npe in case of main config file missing
[mkjsf-moved-to-github.git] / src / main / java / com / indexdata / pz2utils4jsf / errors / ErrorHelper.java
index f74407d..0abad05 100644 (file)
@@ -10,6 +10,7 @@ import java.util.regex.Pattern;
 import org.apache.log4j.Logger;\r
 \r
 import com.indexdata.pz2utils4jsf.config.Pz2Configurator;\r
+import com.indexdata.pz2utils4jsf.config.Pz2ConfigureByMk2Config;\r
 import com.indexdata.pz2utils4jsf.pazpar2.data.Pazpar2Error;\r
 import com.indexdata.pz2utils4jsf.utils.Utils;\r
 \r
@@ -22,6 +23,7 @@ public class ErrorHelper implements Serializable {
                          LOCAL_SERVICE_DEF_FILE_NOT_FOUND,\r
                          REMOTE_SERVICE_DEF_NOT_FOUND,\r
                          LOCAL_SETTINGS_FILE_NOT_FOUND,\r
+                         MASTERKEY_CONFIG_FILE_NOT_FOUND,\r
                          NOT_RESOLVED,\r
                          SKIP_SUGGESTIONS};\r
 \r
@@ -62,6 +64,8 @@ public class ErrorHelper implements Serializable {
           return ErrorCode.PAZPAR2_UNEXPECTED_RESPONSE;\r
         }\r
       }       \r
+    } else if (appError.getMessage().contains("Configuration file") & appError.getMessage().contains("properties")) {\r
+      return ErrorCode.MASTERKEY_CONFIG_FILE_NOT_FOUND; \r
     } else if (appError.getMessage().contains("Error reading service definition XML")) {\r
       return ErrorCode.LOCAL_SERVICE_DEF_FILE_NOT_FOUND;    \r
     } else if (appError.getMessage().contains("Cannot query Pazpar2 while there are configuration errors")) {\r
@@ -84,6 +88,11 @@ public class ErrorHelper implements Serializable {
       suggestions.add("Unexpected response code from Pazpar2. " + nl\r
           + "Please check the PAZPAR2_URL configuration and verify "\r
           + "that a pazpar2 service is running at the given address." + nl);\r
+      break;     \r
+    case MASTERKEY_CONFIG_FILE_NOT_FOUND: \r
+      suggestions.add("The main configuration file that is looked up using parameters" +\r
+               " in web.xml (MASTERKEY_ROOT_CONFIG_DIR,MASTERKEY_COMPONENT_CONFIG_DIR,MASTERKEY_CONFIG_FILE_NAME)" +\r
+               " could not be found. Please check the web.xml parameters and the expected file system location. ");      \r
       break;\r
     case LOCAL_SERVICE_DEF_FILE_NOT_FOUND:\r
       suggestions.add("The service definition file could not be loaded.");\r