Renames data classes that are no longer pz2 only
[mkjsf-moved-to-github.git] / src / main / java / com / indexdata / mkjsf / errors / ErrorCentral.java
1 package com.indexdata.mkjsf.errors;\r
2 \r
3 import java.io.Serializable;\r
4 import java.util.ArrayList;\r
5 import java.util.List;\r
6 \r
7 import javax.annotation.PostConstruct;\r
8 import javax.enterprise.context.SessionScoped;\r
9 import javax.inject.Inject;\r
10 import javax.inject.Named;\r
11 \r
12 import org.apache.log4j.Logger;\r
13 \r
14 import com.indexdata.mkjsf.config.ConfigurationReader;\r
15 import com.indexdata.mkjsf.pazpar2.data.Responses;\r
16 \r
17 @Named("errors") @SessionScoped\r
18 public class ErrorCentral implements Serializable {\r
19 \r
20   private static final long serialVersionUID = -1658192041068396628L;\r
21   private static Logger logger = Logger.getLogger(ErrorCentral.class);  \r
22   private ErrorHelper errorHelper = null;\r
23   \r
24   @Inject Responses pzresp;\r
25   @Inject ConfigurationReader configurator;\r
26   \r
27   private List<ErrorInterface> configurationErrors = new ArrayList<ErrorInterface>();\r
28 \r
29   public ErrorCentral() {}\r
30   \r
31   @PostConstruct \r
32   public void postConstruct() {\r
33     errorHelper = new ErrorHelper(configurator);\r
34     pzresp.setErrorHelper(errorHelper);    \r
35   }\r
36     \r
37   public void addConfigurationError (ErrorInterface configError) {\r
38     configError.setErrorHelper(errorHelper);\r
39     configurationErrors.add(configError);\r
40   }\r
41   \r
42   public boolean hasConfigurationErrors () {\r
43     return (configurationErrors.size()>0);      \r
44   }\r
45 \r
46   public boolean hasCommandErrors () {\r
47     return pzresp.hasApplicationError();\r
48   }\r
49   \r
50   public ErrorInterface getCommandError () {\r
51     return pzresp.getCommandError();\r
52   }\r
53 \r
54   /**\r
55    * Returns true if application error found in any response data objects \r
56    */\r
57   public boolean hasErrors () {\r
58     logger.debug("Checking for configuration errors or command errors.");\r
59     return hasConfigurationErrors() || hasCommandErrors();\r
60   }\r
61   \r
62   public List<ErrorInterface> getConfigurationErrors() {    \r
63     return configurationErrors;\r
64   }\r
65 \r
66 \r
67 }\r