1 13 14 package org.ejbca.core.model.log; 15 16 import java.io.Serializable ; 17 import java.util.HashMap ; 18 19 20 26 public class LogConfiguration implements Serializable { 27 28 37 private static final long serialVersionUID = -6349974447455748715L; 38 39 public LogConfiguration() { 42 this.useexternaldevices = true; 43 this.uselogdb = true; 44 this.configurationdata = new HashMap (); 45 46 for (int i = 0; i < LogEntry.EVENTNAMES_INFO.length; i++) { 48 configurationdata.put(new Integer (i), Boolean.TRUE); 49 } 50 51 for (int i = 0; i < LogEntry.EVENTNAMES_ERROR.length; i++) { 52 configurationdata.put(new Integer (i + LogEntry.EVENT_ERROR_BOUNDRARY), Boolean.TRUE); 53 } 54 } 55 58 public LogConfiguration(boolean usedb, boolean useext, HashMap data) { 59 this.configurationdata = data; 60 this.uselogdb = usedb; 61 this.useexternaldevices = useext; 62 } 63 64 public boolean logEvent(int event) { 66 Boolean log = (Boolean ) configurationdata.get(new Integer (event)); 67 68 if (log == null) { 69 return true; } 71 return log.booleanValue(); 72 } 73 74 81 public Boolean getLogEvent(int event) { 82 return (Boolean ) configurationdata.get(new Integer (event)); 83 } 84 85 91 public void setLogEvent(int event, boolean log) { 92 configurationdata.put(new Integer (event), Boolean.valueOf(log)); 93 } 94 95 100 public boolean useLogDB() { 101 return uselogdb; 102 } 103 104 109 public void setUseLogDB(boolean use) { 110 this.uselogdb = use; 111 } 112 113 118 public boolean useExternalLogDevices() { 119 return this.useexternaldevices; 120 } 121 122 127 public void setUseExternalLogDevices(boolean use) { 128 this.useexternaldevices = use; 129 } 130 131 public String getStringRepresentationOfEventId(int event) { 133 if (event >= LogEntry.EVENT_ERROR_BOUNDRARY) { 134 return LogEntry.EVENTNAMES_ERROR[event]; 135 } 136 return LogEntry.EVENTNAMES_INFO[event]; 137 } 138 139 private HashMap configurationdata; 141 private boolean uselogdb; 142 private boolean useexternaldevices; 143 } 144 | Popular Tags |