Mark ref as internal when they are not found
authorMathieu Baudier <mbaudier@argeo.org>
Thu, 30 Jul 2009 15:58:56 +0000 (15:58 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Thu, 30 Jul 2009 15:58:56 +0000 (15:58 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@2839 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultExecutionFlowDescriptorConverter.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/ExecutionThread.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/ProcessThread.java

index 0e51cfeaa9b959b624f9c6e815e73c3334d9d7b2..e10b4bc76632e15c0d3a2e891ef58268d8f50060 100644 (file)
@@ -28,7 +28,7 @@ public class DefaultExecutionFlowDescriptorConverter implements
        public final static String REF_VALUE_TYPE_BEAN_NAME = "beanName";
 
        /** Workaround for https://www.spartadn.com/bugzilla/show_bug.cgi?id=206 */
-       private final static String REF_VALUE_IS_FROZEN = "[internal]";
+       private final static String REF_VALUE_INTERNAL = "[internal]";
 
        private final static Log log = LogFactory
                        .getLog(DefaultExecutionFlowDescriptorConverter.class);
@@ -61,17 +61,19 @@ public class DefaultExecutionFlowDescriptorConverter implements
                                } else if (value instanceof RefValue) {
                                        RefValue refValue = (RefValue) value;
 
-                                       if (REF_VALUE_TYPE_BEAN_NAME.equals(refValue.getType()))
-                                               if (refValue.getRef() != null) {
+                                       if (REF_VALUE_TYPE_BEAN_NAME.equals(refValue.getType())) {
+                                               String ref = refValue.getRef();
+                                               if (ref != null && !ref.equals(REF_VALUE_INTERNAL)) {
                                                        Object obj = applicationContext.getBean(refValue
                                                                        .getRef());
                                                        convertedValues.put(key, obj);
                                                } else {
                                                        log.warn("Cannot interpret " + refValue);
                                                }
-                                       else
+                                       } else {
                                                throw new UnsupportedException("Ref value type",
                                                                refValue.getType());
+                                       }
                                }
                        }
                }
@@ -110,7 +112,7 @@ public class DefaultExecutionFlowDescriptorConverter implements
                                        }
                                } else if (attribute instanceof RefSpecAttribute) {
                                        if (attribute.getIsFrozen()) {
-                                               values.put(key, new RefValue(REF_VALUE_IS_FROZEN));
+                                               values.put(key, new RefValue(REF_VALUE_INTERNAL));
                                        } else
                                                values.put(key, buildRefValue(
                                                                (RefSpecAttribute) attribute, executionFlow,
@@ -180,6 +182,7 @@ public class DefaultExecutionFlowDescriptorConverter implements
                                log.warn("Cannot define reference for ref spec attribute "
                                                + key + " in " + executionFlow + " (" + rsa + ")."
                                                + " If it is an inner bean consider put it frozen.");
+                               ref = REF_VALUE_INTERNAL;
                        } else {
                                if (log.isDebugEnabled())
                                        log.debug(ref + " is the reference for ref spec attribute "
index 08dfca28b7df73eea616c779e07caa436bce7734..1450ab98a065f5dbe614d7c8c52b8bfb125c7dfc 100644 (file)
@@ -43,6 +43,7 @@ public class ExecutionThread extends Thread {
                        log.error(msg, e);
                        dispatchAddStep(processThread.getSlcProcess(),
                                        new SlcExecutionStep(msg + " " + e.getMessage()));
+                       processThread.notifyError();
                } finally {
                        processThread.flowCompleted();
                        dispatchAddStep(processThread.getSlcProcess(),
index 678e6f679ae809322e81125b79fece1074489a50..ec600cb5776deeaa6a9020cba225f2c284d59ea0 100644 (file)
@@ -19,6 +19,8 @@ public class ProcessThread extends Thread {
        private final ThreadGroup processThreadGroup;
        private final List<RealizedFlow> flowsToProcess = new ArrayList<RealizedFlow>();
 
+       private Boolean hadAnError = false;
+
        public ProcessThread(
                        AbstractExecutionModulesManager executionModulesManager,
                        SlcExecution slcExecution) {
@@ -53,9 +55,12 @@ public class ProcessThread extends Thread {
                        }
                }
 
-               slcProcess.setStatus(SlcExecution.STATUS_FINISHED);
+               if (hadAnError)
+                       slcProcess.setStatus(SlcExecution.STATUS_ERROR);
+               else
+                       slcProcess.setStatus(SlcExecution.STATUS_FINISHED);
                dispatchUpdateStatus(slcProcess, SlcExecution.STATUS_RUNNING,
-                               SlcExecution.STATUS_FINISHED);
+                               slcProcess.getStatus());
        }
 
        protected void dispatchUpdateStatus(SlcExecution slcExecution,
@@ -66,6 +71,10 @@ public class ProcessThread extends Thread {
                }
        }
 
+       public void notifyError() {
+               hadAnError = true;
+       }
+
        public synchronized void flowCompleted() {
                notifyAll();
        }