Author: rareddy
Date: 2012-06-14 13:20:06 -0400 (Thu, 14 Jun 2012)
New Revision: 4178
Modified:
trunk/admin/src/main/java/org/teiid/adminapi/VDB.java
trunk/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
Log:
TEIID-2057: weeding out the runtime errors from the validation errors to avoid any
ephemeral errors that could be introduced for vdb persistent state.
Modified: trunk/admin/src/main/java/org/teiid/adminapi/VDB.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/VDB.java 2012-06-13 13:57:08 UTC (rev
4177)
+++ trunk/admin/src/main/java/org/teiid/adminapi/VDB.java 2012-06-14 17:20:06 UTC (rev
4178)
@@ -92,6 +92,12 @@
public List<String> getValidityErrors();
/**
+ * Shows any validity errors present in the VDB
+ * @return
+ */
+ public List<String> getRuntimeErrors();
+
+ /**
* Shows if VDB is a valid entity
* @return
*/
Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2012-06-13
13:57:08 UTC (rev 4177)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2012-06-14
17:20:06 UTC (rev 4178)
@@ -51,7 +51,8 @@
protected String description;
protected String path;
protected Boolean visible = true;
- protected List<ValidationError> errors;
+ protected List<ValidationError> validationErrors;
+ protected transient List<ValidationError> runtimeErrors;
protected String schemaSourceType;
protected String schemaText;
@@ -185,16 +186,12 @@
return getValidationErrors(Severity.ERROR);
}
- public void setErrors(List<ValidationError> errors){
- this.errors = errors;
- }
-
public synchronized List<ValidationError>
getValidationErrors(ValidationError.Severity severity){
- if (this.errors == null) {
+ if (this.validationErrors == null) {
return Collections.emptyList();
}
List<ValidationError> list = new ArrayList<ValidationError>();
- for (ValidationError ve: this.errors) {
+ for (ValidationError ve: this.validationErrors) {
if (Severity.valueOf(ve.severity) == severity) {
list.add(ve);
}
@@ -203,39 +200,60 @@
}
public synchronized ValidationError addError(String severity, String message) {
- if (this.errors == null) {
- this.errors = new LinkedList<ValidationError>();
+ if (this.validationErrors == null) {
+ this.validationErrors = new LinkedList<ValidationError>();
}
ValidationError ve = new ValidationError(severity, message);
- this.errors.add(ve);
- if (this.errors.size() > DEFAULT_ERROR_HISTORY) {
- this.errors.remove(0);
+ this.validationErrors.add(ve);
+ if (this.validationErrors.size() > DEFAULT_ERROR_HISTORY) {
+ this.validationErrors.remove(0);
}
return ve;
}
+ public List<ValidationError> getRuntimeErrors(){
+ if (this.runtimeErrors == null) {
+ return Collections.emptyList();
+ }
+ List<ValidationError> list = new ArrayList<ValidationError>();
+ for (ValidationError ve: this.runtimeErrors) {
+ if (Severity.valueOf(ve.severity) == Severity.ERROR) {
+ list.add(ve);
+ }
+ }
+ return list;
+ }
+
+ public synchronized ValidationError addRuntimeError(String severity, String message)
{
+ if (this.runtimeErrors == null) {
+ this.runtimeErrors = new LinkedList<ValidationError>();
+ }
+ ValidationError ve = new ValidationError(severity, message);
+ this.runtimeErrors.add(ve);
+ if (this.runtimeErrors.size() > DEFAULT_ERROR_HISTORY) {
+ this.runtimeErrors.remove(0);
+ }
+ return ve;
+ }
+
public synchronized ValidationError addError(ValidationError ve) {
- if (this.errors == null) {
- this.errors = new LinkedList<ValidationError>();
+ if (this.validationErrors == null) {
+ this.validationErrors = new LinkedList<ValidationError>();
}
- this.errors.add(ve);
- if (this.errors.size() > DEFAULT_ERROR_HISTORY) {
- this.errors.remove(0);
+ this.validationErrors.add(ve);
+ if (this.validationErrors.size() > DEFAULT_ERROR_HISTORY) {
+ this.validationErrors.remove(0);
}
return ve;
}
-
- public synchronized boolean removeError(ValidationError remove) {
- if (this.errors == null) {
- return false;
- }
- return this.errors.remove(remove);
+ public synchronized void clearErrors() {
+ this.validationErrors.clear();
}
- public synchronized void clearErrors() {
- this.errors.clear();
- }
+ public synchronized void clearRuntimeErrors() {
+ this.runtimeErrors.clear();
+ }
public static class ValidationError implements Serializable{
private static final long serialVersionUID = 2044197069467559527L;
Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2012-06-13 13:57:08
UTC (rev 4177)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2012-06-14 17:20:06
UTC (rev 4178)
@@ -198,12 +198,31 @@
}
return allErrors;
}
+
+ @Override
+ public List<String> getRuntimeErrors(){
+ List<String> allErrors = new ArrayList<String>();
+ for (ModelMetaData model:this.models.getMap().values()) {
+ List<ValidationError> errors = model.getRuntimeErrors();
+ if (errors != null && !errors.isEmpty()) {
+ for (ValidationError m:errors) {
+ if
(ValidationError.Severity.valueOf(m.getSeverity()).equals(ValidationError.Severity.ERROR))
{
+ allErrors.add(m.getValue());
+ }
+ }
+ }
+ }
+ return allErrors;
+ }
@Override
public boolean isValid() {
if (!getValidityErrors().isEmpty()) {
return false;
}
+ if (!getRuntimeErrors().isEmpty()) {
+ return false;
+ }
if (getModels().isEmpty()) {
return false;
}
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2012-06-13 13:57:08
UTC (rev 4177)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2012-06-14 17:20:06
UTC (rev 4178)
@@ -314,7 +314,7 @@
if (cm != null) {
String msg = cm.getStausMessage();
if (msg != null && msg.length() > 0) {
- model.addError(ModelMetaData.ValidationError.Severity.ERROR.name(),
cm.getStausMessage());
+ model.addRuntimeError(ModelMetaData.ValidationError.Severity.ERROR.name(),
cm.getStausMessage());
LogManager.logInfo(LogConstants.CTX_RUNTIME, cm.getStausMessage());
}
}
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java 2012-06-13
13:57:08 UTC (rev 4177)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java 2012-06-14
17:20:06 UTC (rev 4178)
@@ -86,7 +86,7 @@
if (!cm.getConnectionName().equals(dsName)){
markInvalid(vdb);
String msg = RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40076, vdb.getName(),
vdb.getVersion(), model.getSourceTranslatorName(sourceName), dsName);
- model.addError(ModelMetaData.ValidationError.Severity.ERROR.name(), msg);
+ model.addRuntimeError(ModelMetaData.ValidationError.Severity.ERROR.name(), msg);
cm = new ConnectorManager(translatorName, dsName);
cm.setExecutionFactory(ef);
cmr.addConnectorManager(sourceName, cm);
@@ -137,7 +137,7 @@
ConnectorManagerRepository cmr =
vdb.getAttachment(ConnectorManagerRepository.class);
for (ModelMetaData model:vdb.getModelMetaDatas().values()) {
- if (model.getErrors().isEmpty()) {
+ if (model.getRuntimeErrors().isEmpty()) {
continue;
}
@@ -149,7 +149,7 @@
ConnectorManager cm = cmr.getConnectorManager(sourceName);
String status = cm.getStausMessage();
if (status != null && status.length() > 0) {
- model.addError(ModelMetaData.ValidationError.Severity.ERROR.name(), status);
+ model.addRuntimeError(ModelMetaData.ValidationError.Severity.ERROR.name(),
status);
LogManager.logInfo(LogConstants.CTX_RUNTIME, status);
} else {
//get the pending metadata load
@@ -157,14 +157,14 @@
if (r != null) {
runnables.add(r);
} else {
- model.clearErrors();
+ model.clearRuntimeErrors();
}
}
}
boolean valid = true;
for (ModelMetaData model:vdb.getModelMetaDatas().values()) {
- if (!model.getErrors().isEmpty()) {
+ if (!model.getRuntimeErrors().isEmpty()) {
valid = false;
break;
}
@@ -203,7 +203,7 @@
else {
msg = RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40012, vdb.getName(),
vdb.getVersion(), resourceName);
}
- model.addError(ModelMetaData.ValidationError.Severity.ERROR.name(), msg);
+ model.addRuntimeError(ModelMetaData.ValidationError.Severity.ERROR.name(), msg);
LogManager.logInfo(LogConstants.CTX_RUNTIME, msg);
LogManager.logInfo(LogConstants.CTX_RUNTIME,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40003,vdb.getName(), vdb.getVersion(),
vdb.getStatus()));
}