1 25 package org.ofbiz.service; 26 27 import java.util.List ; 28 import java.util.ArrayList ; 29 import java.util.Iterator ; 30 31 38 public class ServiceValidationException extends GenericServiceException { 39 40 protected List messages = new ArrayList (); 41 protected List missingFields = new ArrayList (); 42 protected List extraFields = new ArrayList (); 43 protected String errorMode = null; 44 protected ModelService service = null; 45 46 public ServiceValidationException(ModelService service, List missingFields, List extraFields, String errorMode) { 47 super(); 48 this.service = service; 49 this.errorMode = errorMode; 50 if (missingFields != null) { 51 this.missingFields = missingFields; 52 } 53 if (extraFields != null) { 54 this.extraFields = extraFields; 55 } 56 } 57 58 public ServiceValidationException(String str, ModelService service) { 59 super(str); 60 this.service = service; 61 } 62 63 public ServiceValidationException(String str, ModelService service, List missingFields, List extraFields, String errorMode) { 64 super(str); 65 this.service = service; 66 this.errorMode = errorMode; 67 if (missingFields != null) { 68 this.missingFields = missingFields; 69 } 70 if (extraFields != null) { 71 this.extraFields = extraFields; 72 } 73 } 74 75 public ServiceValidationException(String str, Throwable nested, ModelService service) { 76 super(str, nested); 77 this.service = service; 78 } 79 80 public ServiceValidationException(String str, Throwable nested, ModelService service, List missingFields, List extraFields, String errorMode) { 81 super(str, nested); 82 this.service = service; 83 this.errorMode = errorMode; 84 if (missingFields != null) { 85 this.missingFields = missingFields; 86 } 87 if (extraFields != null) { 88 this.extraFields = extraFields; 89 } 90 } 91 92 public ServiceValidationException(List messages, ModelService service, List missingFields, List extraFields, String errorMode) { 93 super(); 94 this.messages = messages; 95 this.service = service; 96 this.errorMode = errorMode; 97 if (missingFields != null) { 98 this.missingFields = missingFields; 99 } 100 if (extraFields != null) { 101 this.extraFields = extraFields; 102 } 103 } 104 105 public ServiceValidationException(List messages, ModelService service, String errorMode) { 106 this(messages, service, null, null, errorMode); 107 } 108 109 public List getExtraFields() { 110 return extraFields; 111 } 112 113 public List getMissingFields() { 114 return missingFields; 115 } 116 117 public List getMessageList() { 118 if (this.messages == null || this.messages.size() == 0) { 119 return null; 120 } 121 return this.messages; 122 } 123 124 public ModelService getModelService() { 125 return service; 126 } 127 128 public String getMode() { 129 return errorMode; 130 } 131 132 public String getServiceName() { 133 if (service != null) { 134 return service.name; 135 } else { 136 return null; 137 } 138 } 139 140 public String getMessage() { 141 String msg = super.getMessage(); 142 if (this.messages != null && this.messages.size() > 0) { 143 if (msg != null) { 144 msg += "\n"; 145 } else { 146 msg = ""; 147 } 148 Iterator i = this.messages.iterator(); 149 while (i.hasNext()) { 150 msg += i.next(); 151 } 152 } 153 return msg; 154 } 155 } 156 157 | Popular Tags |