001: package edu.iu.uis.eden;
002:
003: import java.io.Serializable;
004: import java.util.ArrayList;
005: import java.util.Collection;
006: import java.util.Iterator;
007: import java.util.List;
008:
009: import edu.iu.uis.eden.services.ServiceErrorConstants;
010:
011: /**
012: * <p>Title: DocElementError </p>
013: * <p>Description: A simple object holding any error(s) generated by
014: * an IDocElement and it's children IDocElements. See IDocElement
015: * documentation for further explanation.</p>
016: * <p>Copyright: Copyright (c) 2002</p>
017: * <p>Company: Indiana University</p>
018: * @author Ryan Kirkendall
019: * @version 1.0
020: */
021: public class WorkflowServiceErrorImpl implements Serializable,
022: WorkflowServiceError {
023:
024: static final long serialVersionUID = 6900090941686297017L;
025: private Collection children;
026: private String type;
027: private String message;
028: private String arg1;
029: private String arg2;
030:
031: private WorkflowServiceErrorImpl() {
032: }
033:
034: public WorkflowServiceErrorImpl(String message, String type) {
035: children = new ArrayList();
036: this .message = message;
037: this .type = type;
038: }
039:
040: public WorkflowServiceErrorImpl(String message, String type,
041: String arg1) {
042: children = new ArrayList();
043: this .message = message;
044: this .type = type;
045: this .arg1 = arg1;
046: }
047:
048: public WorkflowServiceErrorImpl(String message, String type,
049: String arg1, String arg2) {
050: children = new ArrayList();
051: this .message = message;
052: this .type = type;
053: this .arg1 = arg1;
054: this .arg2 = arg2;
055: }
056:
057: public Collection getChildren() {
058: return this .children;
059: }
060:
061: public String getMessage() {
062: return this .message;
063: }
064:
065: public String getKey() {
066: return this .type;
067: }
068:
069: public String getArg1() {
070: return arg1;
071: }
072:
073: public String getArg2() {
074: return arg2;
075: }
076:
077: public void addChild(WorkflowServiceError busError) {
078: if (busError != null) {
079: children.add(busError);
080: }
081: }
082:
083: public void addChildren(Collection children) {
084: this .children.addAll(children);
085: }
086:
087: public Collection getFlatChildrenList() {
088: return buildFlatChildrenList(this , null);
089: }
090:
091: private static Collection buildFlatChildrenList(
092: WorkflowServiceError error, List flatList) {
093: if (flatList == null) {
094: flatList = new ArrayList();
095: }
096:
097: if (error.getKey() != ServiceErrorConstants.CHILDREN_IN_ERROR) {
098: flatList.add(error);
099: }
100:
101: Iterator iter = error.getChildren().iterator();
102:
103: while (iter.hasNext()) {
104: WorkflowServiceError childError = (WorkflowServiceError) iter
105: .next();
106: buildFlatChildrenList(childError, flatList);
107: }
108:
109: return flatList;
110: }
111:
112: public String toString() {
113: String s = "[WorkflowServiceErrorImpl: type=" + type
114: + ", message=" + message + ", arg1=" + arg1 + ", arg2="
115: + arg2 + ", children=";
116: if (children == null) {
117: s += "null";
118: } else {
119: s += children;
120: }
121: s += "]";
122: return s;
123: }
124: }
|