X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.specs%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fprocess%2FSlcExecutionStep.java;h=235b617e500f75cd6d95ae1265a86b4325eb1c68;hb=1fdb1b4e7b1d2b0cabb6483238301b857a6392fa;hp=59cf231d834cdee6299e0008d0ed493f1189f36a;hpb=2f57b9abf7e5110603e8cf952259509c76c9a162;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/process/SlcExecutionStep.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/process/SlcExecutionStep.java index 59cf231d8..235b617e5 100644 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/process/SlcExecutionStep.java +++ b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/process/SlcExecutionStep.java @@ -1,31 +1,51 @@ +/* + * Copyright (C) 2010 Mathieu Baudier + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.argeo.slc.process; -import java.io.IOException; -import java.io.StringReader; -import java.io.StringWriter; +import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.StringTokenizer; import java.util.UUID; -import java.util.Vector; - -import org.apache.commons.io.IOUtils; public class SlcExecutionStep { + public final static String TYPE_START = "START"; + public final static String TYPE_END = "END"; + public final static String TYPE_PHASE_START = "PHASE_START"; + public final static String TYPE_PHASE_END = "PHASE_END"; public final static String TYPE_LOG = "LOG"; - private String uuid; + private String uuid = UUID.randomUUID().toString(); private String type; - private Date begin; - private List logLines = new Vector(); + private Date begin = new Date(); + private List logLines = new ArrayList(); /** Empty constructor */ public SlcExecutionStep() { } + /** Creates a step of type LOG. */ public SlcExecutionStep(String log) { - this.type = TYPE_LOG; - this.begin = new Date(); - this.uuid = UUID.randomUUID().toString(); + this(TYPE_LOG, log); + } + + /** Creates a step of the given type. */ + public SlcExecutionStep(String type, String log) { + this.type = type; addLog(log); } @@ -61,23 +81,13 @@ public class SlcExecutionStep { this.logLines = logLines; } - public String logAsString() { - StringWriter writer = new StringWriter(); - String log = writer.toString(); - IOUtils.closeQuietly(writer); - return log; - } - public void addLog(String log) { if (log == null) return; - try { - List lines = IOUtils.readLines(new StringReader(log)); - logLines.addAll(lines); - } catch (IOException e) { - throw new RuntimeException("Cannot add log", e); - } + StringTokenizer st = new StringTokenizer(log, "\n"); + while (st.hasMoreTokens()) + logLines.add(st.nextToken()); } @Override