Improve web services
authorMathieu Baudier <mbaudier@argeo.org>
Sat, 28 Jun 2008 10:09:35 +0000 (10:09 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sat, 28 Jun 2008 10:09:35 +0000 (10:09 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@1305 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

13 files changed:
org.argeo.slc.core/src/main/java/org/argeo/slc/core/process/FileSlcExecutionNotifier.java
org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/DefaultSRegistry.java [deleted file]
org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/StructureRegistry.java
org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/tree/TreeSRegistry.java
org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java
org.argeo.slc.core/src/main/java/org/argeo/slc/dao/test/tree/TreeTestResultCollectionDao.java
org.argeo.slc.core/src/main/java/org/argeo/slc/msg/process/SlcExecutionStepsRequest.java
org.argeo.slc.core/src/main/java/org/argeo/slc/msg/test/tree/CreateTreeTestResultRequest.java
org.argeo.slc.core/src/main/java/org/argeo/slc/msg/test/tree/ResultPartRequest.java
org.argeo.slc.core/src/main/java/org/argeo/slc/runtime/SlcExecutionOutput.java
org.argeo.slc.core/src/main/java/org/argeo/slc/spring/SpringUtils.java
org.argeo.slc.core/src/main/java/org/argeo/slc/unit/AbstractSpringTestCase.java
org.argeo.slc.core/src/main/java/org/argeo/slc/unit/test/tree/TreeTestResultTestUtils.java

index e1fb3e361164af397a14bac634f3d552d234c377..0b9f682b016c8985a8e9ca85a6f340fd5b0b03ec 100644 (file)
@@ -10,12 +10,9 @@ import java.util.Map;
 \r
 import javax.xml.transform.stream.StreamResult;\r
 \r
-import org.springframework.oxm.Marshaller;\r
-\r
 import org.apache.commons.io.IOUtils;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
 import org.argeo.slc.core.SlcException;\r
+import org.springframework.oxm.Marshaller;\r
 \r
 public class FileSlcExecutionNotifier implements SlcExecutionNotifier {\r
        private final static SimpleDateFormat sdf = new SimpleDateFormat(\r
diff --git a/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/DefaultSRegistry.java b/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/DefaultSRegistry.java
deleted file mode 100644 (file)
index 44b4a7a..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.argeo.slc.core.structure;\r
-\r
-import java.util.List;\r
-import java.util.Vector;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-/** Default implementation of a <code>StructureRegistry</code>. */\r
-public class DefaultSRegistry implements StructureRegistry<StructurePath> {\r
-       private static Log log = LogFactory.getLog(DefaultSRegistry.class);\r
-\r
-       private List<StructureElement> elements = new Vector<StructureElement>();\r
-       private List<StructurePath> paths = new Vector<StructurePath>();\r
-       private String mode = StructureRegistry.ALL;\r
-\r
-       private List<StructurePath> activePaths;\r
-\r
-       public List<StructureElement> listElements() {\r
-               return new Vector<StructureElement>(elements);\r
-       }\r
-\r
-       public List<StructurePath> listPaths() {\r
-               return new Vector<StructurePath>(paths);\r
-       }\r
-\r
-       public void register(StructurePath path, StructureElement element) {\r
-               StructureElement treeSElement = element;\r
-               elements.add(treeSElement);\r
-               paths.add(path);\r
-\r
-               if (log.isTraceEnabled())\r
-                       log.trace("Registered " + path + " (label: '"\r
-                                       + treeSElement.getLabel() + "', position: "\r
-                                       + elements.size() + ")");\r
-       }\r
-\r
-       public StructureElement getElement(StructurePath path) {\r
-               int index = paths.indexOf(path);\r
-               if (index >= 0) {\r
-                       return elements.get(index);\r
-               } else {// not found\r
-                       return null;\r
-               }\r
-       }\r
-\r
-       public String getMode() {\r
-               return mode;\r
-       }\r
-\r
-       public void setMode(String mode) {\r
-               this.mode = mode;\r
-       }\r
-\r
-       public List<StructurePath> getActivePaths() {\r
-               return activePaths;\r
-       }\r
-\r
-       public void setActivePaths(List<StructurePath> activePaths) {\r
-               this.activePaths = activePaths;\r
-       }\r
-\r
-}\r
index eac04b2bbf4bf2160165eb2f97af8eaf128709c3..e9091640840f3197141f91b77c874c04844e4845 100644 (file)
@@ -9,7 +9,7 @@ public interface StructureRegistry<P extends StructurePath> {
        /** All mode: everything is executed regardless of the active paths. */\r
        public static String ALL = "ALL";\r
        /** Active mode: only the active paths are executed. */\r
-       public static String ACTIVE = "STATUS_ACTIVE";\r
+       public static String ACTIVE = "ACTIVE";\r
 \r
        /** Adds an element to the registry. */\r
        public void register(P path, StructureElement element);\r
index 7337367dc1de8683f4388e6cc3f75d5e22f46d5f..36c85728fe32c2dcdb75f52acf664a667aef3b23 100644 (file)
@@ -12,11 +12,8 @@ import org.argeo.slc.core.structure.StructureRegistry;
 \r
 /** Tree based implementation of a structure registry. */\r
 public class TreeSRegistry implements StructureRegistry<TreeSPath> {\r
-       public final static String STATUS_ACTIVE = "STATUS_ACTIVE";\r
-\r
        /** For ORM */\r
        private Long tid;\r
-       private String status;\r
        private Map<TreeSPath, SimpleSElement> elements = new TreeMap<TreeSPath, SimpleSElement>();\r
 \r
        private String mode = StructureRegistry.ALL;\r
@@ -36,6 +33,16 @@ public class TreeSRegistry implements StructureRegistry<TreeSPath> {
        }\r
 \r
        public void register(TreeSPath path, StructureElement element) {\r
+               if (path == null)\r
+                       throw new UnsupportedException("Cannot register under a null path.");\r
+               if (element == null)\r
+                       throw new UnsupportedException(\r
+                                       "Cannot register null element for path " + path);\r
+               if (element.getLabel() == null)\r
+                       throw new UnsupportedException(\r
+                                       "Cannot register an element with null label for path "\r
+                                                       + path);\r
+\r
                final SimpleSElement simpleSElement;\r
                if (element instanceof SimpleSElement) {\r
                        simpleSElement = (SimpleSElement) element;\r
@@ -43,11 +50,7 @@ public class TreeSRegistry implements StructureRegistry<TreeSPath> {
                        simpleSElement = new SimpleSElement(element.getLabel());\r
                }\r
 \r
-               if (path == null)\r
-                       throw new UnsupportedException("Path cannot be null.");\r
-\r
                elements.put(path, simpleSElement);\r
-\r
        }\r
 \r
        public String getMode() {\r
@@ -66,14 +69,6 @@ public class TreeSRegistry implements StructureRegistry<TreeSPath> {
                this.activePaths = activePaths;\r
        }\r
 \r
-       public String getStatus() {\r
-               return status;\r
-       }\r
-\r
-       public void setStatus(String status) {\r
-               this.status = status;\r
-       }\r
-\r
        /** Gets the elements. */\r
        public Map<TreeSPath, SimpleSElement> getElements() {\r
                return elements;\r
index f34561a9e3b33881d2bd9c425f2d7990b2795132..ecd6cad52ac1921190d06a36a1f438bc41f59d60 100644 (file)
@@ -9,7 +9,6 @@ import java.util.Vector;
 \r
 import org.apache.commons.logging.Log;\r
 import org.apache.commons.logging.LogFactory;\r
-\r
 import org.argeo.slc.core.SlcException;\r
 import org.argeo.slc.core.structure.SimpleSElement;\r
 import org.argeo.slc.core.structure.StructureAware;\r
@@ -100,7 +99,7 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
                        }\r
                }\r
 \r
-               currentPath = (TreeSPath) path;\r
+               currentPath = path;\r
        }\r
 \r
        /** Gets the current path. */\r
@@ -168,6 +167,11 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
 \r
        public SortedMap<TreeSPath, StructureElement> getRelatedElements(\r
                        TreeSPath path) {\r
+               if (path == null)\r
+                       throw new SlcException(\r
+                                       "Cannot retrieve element for a null path in result #"\r
+                                                       + uuid);\r
+\r
                SortedMap<TreeSPath, StructureElement> relatedElements = new TreeMap<TreeSPath, StructureElement>();\r
                List<TreeSPath> hierarchy = path.getHierarchyAsList();\r
                for (TreeSPath currPath : elements.keySet()) {\r
index f43689df97866938df1cc8a57732764402e0c3b9..730c9d9882d616d77e69c2649b24d3408205104e 100644 (file)
@@ -2,7 +2,6 @@ package org.argeo.slc.dao.test.tree;
 \r
 import java.util.SortedSet;\r
 \r
-import org.argeo.slc.core.test.tree.TreeTestResult;\r
 import org.argeo.slc.core.test.tree.TreeTestResultCollection;\r
 \r
 public interface TreeTestResultCollectionDao {\r
index 9c564aaae22e2e45370b2bf3a5ad5e62ae789e09..7da2b43f55cebb4c1ebb48311e1f969ffe0d2801 100644 (file)
@@ -19,6 +19,14 @@ public class SlcExecutionStepsRequest {
                this.steps = steps;\r
        }\r
 \r
+       public SlcExecutionStepsRequest(String slcExecutionUuid,\r
+                       SlcExecutionStep step) {\r
+               this.slcExecutionUuid = slcExecutionUuid;\r
+               List<SlcExecutionStep> steps = new Vector<SlcExecutionStep>();\r
+               steps.add(step);\r
+               this.steps = steps;\r
+       }\r
+\r
        public String getSlcExecutionUuid() {\r
                return slcExecutionUuid;\r
        }\r
index 281f44d9c2e83acf5df8064617ea0aac82bf0c76..e11ef0407f9772b7b4779c8d5413e340643da8c1 100644 (file)
@@ -20,7 +20,7 @@ public class CreateTreeTestResultRequest {
        public void setTreeTestResult(TreeTestResult treeTestResult) {\r
                this.treeTestResult = treeTestResult;\r
        }\r
-       \r
+\r
        @Override\r
        public String toString() {\r
                return getClass().getSimpleName() + "#" + treeTestResult.getUuid();\r
index 04aa41462d1305b9f0603f61883e0efa969875ed..7e3750ea913b75c68db197cf15d9c7a7329fab32 100644 (file)
@@ -25,8 +25,8 @@ public class ResultPartRequest {
                        SimpleResultPart resultPart) {\r
                resultUuid = ttr.getUuid();\r
                this.resultPart = resultPart;\r
-               this.path = path;\r
-               relatedElements = ttr.getRelatedElements(path);\r
+               this.path = (path != null ? path : ttr.getCurrentPath());\r
+               relatedElements = ttr.getRelatedElements(this.path);\r
                if (ttr.getCurrentTestRun() != null)\r
                        testRunDescriptor = new TestRunDescriptor(ttr.getCurrentTestRun());\r
        }\r
index c6353942df4e08d0e028ea3eb0d577016d5f376f..7db9383996f436a0b85371ee6cdbc1178dc6c60c 100644 (file)
@@ -1,6 +1,6 @@
 package org.argeo.slc.runtime;
 
 public interface SlcExecutionOutput<T extends SlcExecutionContext> {
-       /** Called after the execution, before the resources are freed.*/
+       /** Called after the execution, before the resources are freed. */
        public void postExecution(T executionContext);
 }
index 7e01f3235840dffe9093e027c69e4a6fe86cdc35..2b7569f882891cc29ee7e7ed070b19a3b5a4936a 100644 (file)
@@ -2,13 +2,11 @@ package org.argeo.slc.spring;
 \r
 import java.io.IOException;\r
 import java.net.URI;\r
-import java.net.URL;\r
 import java.util.Map;\r
 \r
 import org.apache.commons.logging.Log;\r
 import org.apache.commons.logging.LogFactory;\r
 import org.argeo.slc.core.SlcException;\r
-import org.springframework.beans.BeanUtils;\r
 import org.springframework.beans.factory.BeanFactoryUtils;\r
 import org.springframework.beans.factory.ListableBeanFactory;\r
 import org.springframework.core.io.DefaultResourceLoader;\r
index 625564fa79ddcebce376a88f502a637b44f2d001..a37c4a7ceb4147cdff4e031d2315cd02ea3d9b16 100644 (file)
@@ -2,15 +2,12 @@ package org.argeo.slc.unit;
 \r
 import junit.framework.TestCase;\r
 \r
-import org.springframework.context.ApplicationContext;\r
-import org.springframework.context.ConfigurableApplicationContext;\r
-import org.springframework.context.support.ClassPathXmlApplicationContext;\r
-\r
 import org.apache.commons.logging.Log;\r
 import org.apache.commons.logging.LogFactory;\r
-\r
 import org.argeo.slc.core.SlcException;\r
 import org.argeo.slc.spring.SpringUtils;\r
+import org.springframework.context.ConfigurableApplicationContext;\r
+import org.springframework.context.support.ClassPathXmlApplicationContext;\r
 \r
 /** Helper for tests using a Spring application co,text. */\r
 public abstract class AbstractSpringTestCase extends TestCase {\r
index a9a2d8e1e692ddb6e0203f46d7880b1dcd78bb9a..92e66bb02286a9752038a724d47e77b461936ee2 100644 (file)
@@ -33,6 +33,16 @@ public abstract class TreeTestResultTestUtils {
                SlcExecutionStep step = new SlcExecutionStep("JUnit step");\r
                slcExecution.getSteps().add(step);\r
 \r
+               TreeTestResult ttr = createMinimalConsistentTreeTestResult(slcExecution);\r
+\r
+               ttr.addResultPart(createSimpleResultPartPassed());\r
+               ttr.addResultPart(createSimpleResultPartFailed());\r
+               ttr.addResultPart(createSimpleResultPartError());\r
+               return ttr;\r
+       }\r
+\r
+       public static TreeTestResult createMinimalConsistentTreeTestResult(\r
+                       SlcExecution slcExecution) {\r
                SimpleTestRun testRun = new SimpleTestRun();\r
                testRun.setUuid(UUID.randomUUID().toString());\r
 \r
@@ -71,10 +81,6 @@ public abstract class TreeTestResultTestUtils {
 \r
                });\r
                testRun.notifySlcExecution(slcExecution);\r
-\r
-               ttr.addResultPart(createSimpleResultPartPassed());\r
-               ttr.addResultPart(createSimpleResultPartFailed());\r
-               ttr.addResultPart(createSimpleResultPartError());\r
                return ttr;\r
        }\r
 \r