01: package fr.aliacom.dbmjui;
02:
03: import java.text.ParseException;
04: import java.text.SimpleDateFormat;
05: import java.util.ArrayList;
06:
07: import org.apache.log4j.Logger;
08:
09: /**
10: * @author tom
11: *
12: * (C) 2001, 2002 Thomas Cataldo
13: */
14: public final class BackupHistory extends ArrayList {
15:
16: private SimpleDateFormat dParser;
17: private Logger log;
18:
19: public BackupHistory() {
20: super ();
21: dParser = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
22: log = Logger.getLogger(BackupHistory.class);
23: }
24:
25: /**
26: * Adds a back to history
27: * @param historyLine a line comming from the dbm server output
28: */
29: public void addBackup(String historyLine) {
30: String[] items = historyLine.split("\\|");
31: log.debug("hline is '" + historyLine + "'");
32: for (int i = items.length - 1; i >= 0; i--) {
33: items[i] = items[i].trim();
34: log.debug("Item[" + i + "]=" + items[i]);
35: }
36: HistoryLine hl = new HistoryLine();
37:
38: hl.setKey(items[0]);
39: hl.setLabel(items[1]);
40: hl.setAction(items[2]);
41: if (!items[2].equals("HISTLOST")) {
42: try {
43: hl.setStamp1(dParser.parse(items[3]));
44: } catch (ParseException pe) {
45: log
46: .debug("stamp1 (" + items[3] + ")"
47: + pe.getMessage());
48: }
49: try {
50: hl.setStamp2(dParser.parse(items[4]));
51: } catch (ParseException pe) {
52: log
53: .debug("stamp2 (" + items[4] + ")"
54: + pe.getMessage());
55: }
56: try {
57: hl.setStart(dParser.parse(items[5]));
58: } catch (ParseException pe) {
59: log.debug("start (" + items[5] + ")" + pe.getMessage());
60: }
61: try {
62: hl.setStop(dParser.parse(items[6]));
63: } catch (ParseException pe) {
64: log.debug("stop (" + items[6] + ")" + pe.getMessage());
65: }
66:
67: if (items[7].length() > 0) {
68: hl.setFirstLog(new Integer(Integer.parseInt(items[7])));
69: }
70: if (items[8].length() > 0) {
71: hl.setLastLog(new Integer(Integer.parseInt(items[8])));
72: }
73: hl.setLog(items[9].equals("NO") ? Boolean.FALSE
74: : Boolean.TRUE);
75: hl.setMedia(items[10]);
76: hl.setPages(new Integer(8 * Integer.parseInt(items[11])));
77: hl.setVolumes(new Integer(Integer.parseInt(items[12])));
78: hl.setRc(new Integer(Integer.parseInt(items[13])));
79: hl.setError(items[14]);
80: }
81:
82: log.debug("Backup line added to history");
83: add(hl);
84: }
85:
86: }
|