1 package com.indexdata.mkjsf.errors;
\r
3 import java.io.Serializable;
\r
4 import java.util.ArrayList;
\r
5 import java.util.List;
\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
12 import org.apache.log4j.Logger;
\r
14 import com.indexdata.mkjsf.config.ConfigurationReader;
\r
15 import com.indexdata.mkjsf.pazpar2.data.Responses;
\r
17 @Named("errors") @SessionScoped
\r
18 public class ErrorCentral implements Serializable {
\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
24 @Inject Responses pzresp;
\r
25 @Inject ConfigurationReader configurator;
\r
27 private List<ErrorInterface> configurationErrors = new ArrayList<ErrorInterface>();
\r
29 public ErrorCentral() {}
\r
32 public void postConstruct() {
\r
33 errorHelper = new ErrorHelper(configurator);
\r
34 pzresp.setErrorHelper(errorHelper);
\r
37 public void addConfigurationError (ErrorInterface configError) {
\r
38 configError.setErrorHelper(errorHelper);
\r
39 configurationErrors.add(configError);
\r
42 public boolean hasConfigurationErrors () {
\r
43 return (configurationErrors.size()>0);
\r
46 public boolean hasCommandErrors () {
\r
47 return pzresp.hasApplicationError();
\r
50 public ErrorInterface getCommandError () {
\r
51 return pzresp.getCommandError();
\r
55 * Returns true if application error found in any response data objects
\r
57 public boolean hasErrors () {
\r
58 logger.debug("Checking for configuration errors or command errors.");
\r
59 return hasConfigurationErrors() || hasCommandErrors();
\r
62 public List<ErrorInterface> getConfigurationErrors() {
\r
63 return configurationErrors;
\r