01: /*
02: * $Id: LogCommand.java 674 2006-10-06 12:15:59Z hengels $
03: * (c) Copyright 2004 con:cern development team.
04: *
05: * This file is part of con:cern (http://concern.sf.net).
06: *
07: * con:cern is free software; you can redistribute it and/or modify
08: * it under the terms of the GNU Lesser General Public License
09: * as published by the Free Software Foundation; either version 2.1
10: * of the License, or (at your option) any later version.
11: *
12: * Please see COPYING for the complete licence.
13: */
14: package org.concern.client.commandline;
15:
16: import org.concern.Log;
17:
18: import java.util.*;
19:
20: /**
21: * <b>Example</b>: log of project 99<br>
22: * <pre>
23: * concern.sh Project log 99
24: * </pre>
25: *
26: * @author hengels
27: */
28: public class LogCommand extends Command {
29: private String[] subjects;
30:
31: public LogCommand() {
32: usage = "SUBJECT...\n Print the log of a subject that is still in the process.";
33: }
34:
35: public String[] getSubjects() {
36: return subjects;
37: }
38:
39: public void setSubjects(String[] subjects) {
40: this .subjects = subjects;
41: }
42:
43: public void setArguments(String[] args) {
44: subjects = new String[args.length];
45: for (int i = 0; i < args.length; i++) {
46: String subject = args[i];
47: subjects[i] = subject;
48: }
49: }
50:
51: public void run() {
52: for (int i = 0; i < subjects.length; i++) {
53: String subject = subjects[i];
54: try {
55: System.out.println("log " + subject + ":");
56: StringBuffer buffer = new StringBuffer();
57:
58: List list = controller.getLog(subject);
59: for (Iterator iterator = list.iterator(); iterator
60: .hasNext();) {
61: Log log = (Log) iterator.next();
62: buffer.setLength(0);
63: buffer.append(log.getTimestamp());
64: buffer.append(" [");
65: buffer.append(log.getActivity());
66: buffer.append("] ");
67: if (!log.isSuccess()) {
68: buffer.append("FAILED - ");
69: buffer.append(log.getMessage());
70: }
71: System.out.println(buffer.toString());
72: }
73: } catch (Exception e) {
74: System.out.println("log " + subject + ": ERROR");
75: e.printStackTrace();
76: }
77: }
78: }
79: }
|