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.enterprise.context.SessionScoped;
\r
8 import javax.inject.Inject;
\r
9 import javax.inject.Named;
\r
11 import org.apache.log4j.Logger;
\r
13 import com.indexdata.mkjsf.config.ConfigurationReader;
\r
14 import com.indexdata.mkjsf.pazpar2.Pz2Service;
\r
16 @SessionScoped @Named
\r
17 public class ErrorCentral implements Serializable {
\r
19 private static final long serialVersionUID = -1658192041068396628L;
\r
20 private static Logger logger = Logger.getLogger(ErrorCentral.class);
\r
21 private ErrorHelper errorHelper = null;
\r
23 @Inject ConfigurationReader configurator;
\r
25 private List<ErrorInterface> configurationErrors = new ArrayList<ErrorInterface>();
\r
27 public ErrorCentral() {
\r
28 logger.info("Instantiating ErrorCentral "+this);
\r
29 errorHelper = new ErrorHelper(configurator);
\r
32 public void addConfigurationError (ErrorInterface configError) {
\r
33 configError.setErrorHelper(errorHelper);
\r
34 configurationErrors.add(configError);
\r
37 public boolean hasConfigurationErrors () {
\r
38 return (configurationErrors.size()>0);
\r
41 public boolean hasCommandErrors () {
\r
42 return Pz2Service.get().getPzresp().hasApplicationError();
\r
45 public ErrorInterface getCommandError () {
\r
46 return Pz2Service.get().getPzresp().getCommandError();
\r
50 * Returns true if application error found in any response data objects
\r
52 public boolean hasErrors () {
\r
53 logger.debug("Checking for configuration errors or command errors.");
\r
54 return hasConfigurationErrors() || hasCommandErrors();
\r
57 public List<ErrorInterface> getConfigurationErrors() {
\r
58 return configurationErrors;
\r
61 public ErrorHelper getHelper () {
\r