Work on error handling
[mkjsf-moved-to-github.git] / src / main / java / com / indexdata / pz2utils4jsf / errors / ErrorHelper.java
index 0abad05..4f05b77 100644 (file)
@@ -10,7 +10,6 @@ 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
@@ -24,6 +23,7 @@ public class ErrorHelper implements Serializable {
                          REMOTE_SERVICE_DEF_NOT_FOUND,\r
                          LOCAL_SETTINGS_FILE_NOT_FOUND,\r
                          MASTERKEY_CONFIG_FILE_NOT_FOUND,\r
+                         MISSING_MANDATORY_PARAMETER,\r
                          NOT_RESOLVED,\r
                          SKIP_SUGGESTIONS};\r
 \r
@@ -38,7 +38,7 @@ public class ErrorHelper implements Serializable {
     this.configurator = configurator;\r
   }\r
   \r
-  public ErrorHelper.ErrorCode getErrorCode(ApplicationError appError) {\r
+  public ErrorHelper.ErrorCode getErrorCode(ErrorInterface appError) {\r
     if (appError.hasPazpar2Error()) {\r
       Pazpar2Error pz2err = appError.getPazpar2Error();\r
       String pz2errcode = pz2err.getCode();\r
@@ -70,11 +70,13 @@ public class ErrorHelper implements Serializable {
       return ErrorCode.LOCAL_SERVICE_DEF_FILE_NOT_FOUND;    \r
     } else if (appError.getMessage().contains("Cannot query Pazpar2 while there are configuration errors")) {\r
       return ErrorCode.SKIP_SUGGESTIONS;\r
+    } else if (appError.getMessage().contains("Missing mandatory parameter")) {\r
+      return ErrorCode.MISSING_MANDATORY_PARAMETER;\r
     }\r
     return ErrorCode.NOT_RESOLVED;\r
   }\r
     \r
-  public ArrayList<String> getSuggestions(ApplicationError error) {\r
+  public ArrayList<String> getSuggestions(ErrorInterface error) {\r
     ArrayList<String> suggestions = new ArrayList<String>();\r
     ErrorCode code = getErrorCode(error);\r
     switch (code) {\r
@@ -106,6 +108,11 @@ public class ErrorHelper implements Serializable {
                " the file itself could not be found. Please check the configuration.");\r
       addConfigurationDocumentation(suggestions);\r
       break;\r
+    case MISSING_MANDATORY_PARAMETER:\r
+      suggestions.add("A mandatory configuration parameter was not found in the MK2 config properties" +\r
+               " file used. Please check the property file for the parameter given in the error message ");\r
+      addConfigurationDocumentation(suggestions);\r
+      break;\r
     case NOT_RESOLVED:\r
       suggestions.add("Unforeseen error situation. No suggestions prepared.");\r
       break;\r