Start SLC 2 refactoring.
authorMathieu Baudier <mbaudier@argeo.org>
Sat, 15 Feb 2020 09:55:52 +0000 (10:55 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Sat, 15 Feb 2020 09:55:52 +0000 (10:55 +0100)
76 files changed:
dep/org.argeo.slc.dep.backend/pom.xml
dep/org.argeo.slc.dep.e4.rap/pom.xml
dep/org.argeo.slc.dep.minimal/pom.xml
dep/org.argeo.slc.dep.spring/pom.xml
legacy/argeo-commons/dep/org.argeo.dep.cms.platform/pom.xml
org.argeo.slc.api/src/org/argeo/slc/attachment/Attachment.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/attachment/AttachmentsEnabled.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/attachment/AttachmentsStorage.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/AbstractExecutionValue.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/AbstractSpecAttribute.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/RefSpecAttribute.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/RefValue.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/RefValueChoice.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveAccessor.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveSpecAttribute.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveUtils.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveValue.java [new file with mode: 0644]
org.argeo.slc.client.ui/pom.xml
org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java
org.argeo.slc.e4/pom.xml
org.argeo.slc.jcr/.classpath [new file with mode: 0644]
org.argeo.slc.jcr/.gitignore [new file with mode: 0644]
org.argeo.slc.jcr/.project [new file with mode: 0644]
org.argeo.slc.jcr/META-INF/.gitignore [new file with mode: 0644]
org.argeo.slc.jcr/bnd.bnd [new file with mode: 0644]
org.argeo.slc.jcr/build.properties [new file with mode: 0644]
org.argeo.slc.jcr/pom.xml [new file with mode: 0644]
org.argeo.slc.jcr/src/org/argeo/slc/jcr/JcrMetadataWriter.java [new file with mode: 0644]
org.argeo.slc.jcr/src/org/argeo/slc/jcr/JcrTestResult.java [new file with mode: 0644]
org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrConstants.java [new file with mode: 0644]
org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrResultUtils.java [new file with mode: 0644]
org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrUtils.java [new file with mode: 0644]
org.argeo.slc.repo/pom.xml
org.argeo.slc.spring/bnd.bnd
org.argeo.slc.spring/pom.xml
org.argeo.slc.spring/src/org/argeo/slc/core/attachment/Attachment.java [deleted file]
org.argeo.slc.spring/src/org/argeo/slc/core/attachment/AttachmentUploader.java
org.argeo.slc.spring/src/org/argeo/slc/core/attachment/AttachmentsEnabled.java [deleted file]
org.argeo.slc.spring/src/org/argeo/slc/core/attachment/AttachmentsStorage.java [deleted file]
org.argeo.slc.spring/src/org/argeo/slc/core/attachment/FileAttachmentsStorage.java
org.argeo.slc.spring/src/org/argeo/slc/core/attachment/SimpleAttachment.java
org.argeo.slc.spring/src/org/argeo/slc/core/execution/AbstractExecutionValue.java [deleted file]
org.argeo.slc.spring/src/org/argeo/slc/core/execution/AbstractSpecAttribute.java [deleted file]
org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionFlowDescriptorConverter.java
org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionSpec.java
org.argeo.slc.spring/src/org/argeo/slc/core/execution/InstantiationManager.java
org.argeo.slc.spring/src/org/argeo/slc/core/execution/PrimitiveAccessor.java [deleted file]
org.argeo.slc.spring/src/org/argeo/slc/core/execution/PrimitiveSpecAttribute.java [deleted file]
org.argeo.slc.spring/src/org/argeo/slc/core/execution/PrimitiveUtils.java [deleted file]
org.argeo.slc.spring/src/org/argeo/slc/core/execution/PrimitiveValue.java [deleted file]
org.argeo.slc.spring/src/org/argeo/slc/core/execution/RefSpecAttribute.java [deleted file]
org.argeo.slc.spring/src/org/argeo/slc/core/execution/RefValue.java [deleted file]
org.argeo.slc.spring/src/org/argeo/slc/core/execution/RefValueChoice.java [deleted file]
org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/UploadAttachments.java
org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/SpecBeanDefinitionParser.java
org.argeo.slc.spring/src/org/argeo/slc/jcr/JcrMetadataWriter.java [deleted file]
org.argeo.slc.spring/src/org/argeo/slc/jcr/JcrTestResult.java [deleted file]
org.argeo.slc.spring/src/org/argeo/slc/jcr/SlcJcrConstants.java [deleted file]
org.argeo.slc.spring/src/org/argeo/slc/jcr/SlcJcrResultUtils.java [deleted file]
org.argeo.slc.spring/src/org/argeo/slc/jcr/SlcJcrUtils.java [deleted file]
org.argeo.slc.spring/src/org/argeo/slc/jcr/execution/JcrAttachmentUploader.java
org.argeo.slc.spring/src/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java
org.argeo.slc.spring/src/org/argeo/slc/jcr/execution/JcrRealizedFlow.java
org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractExecutionFlowTestcase.java [new file with mode: 0644]
org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractOsgiRuntimeTestCase.java [new file with mode: 0644]
org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractSpringTestCase.java [new file with mode: 0644]
org.argeo.slc.spring/src/org/argeo/slc/spring/unit/ExecutionFlowDescriptorTestUtils.java [new file with mode: 0644]
org.argeo.slc.spring/src/org/argeo/slc/spring/unit/UnitUtils.java [new file with mode: 0644]
org.argeo.slc.support/pom.xml
org.argeo.slc.unit/pom.xml
org.argeo.slc.unit/src/org/argeo/slc/equinox/unit/AbstractOsgiRuntimeTestCase.java [deleted file]
org.argeo.slc.unit/src/org/argeo/slc/unit/AbstractSpringTestCase.java [deleted file]
org.argeo.slc.unit/src/org/argeo/slc/unit/UnitUtils.java [deleted file]
org.argeo.slc.unit/src/org/argeo/slc/unit/execution/AbstractExecutionFlowTestcase.java [deleted file]
org.argeo.slc.unit/src/org/argeo/slc/unit/execution/ExecutionFlowDescriptorTestUtils.java [deleted file]
pom.xml

index e0210c753c7734ca3a09ede16a0d498936fa91ec..4bbe5394d634564ebbcc2fa444ef7f269091ed13 100644 (file)
                        <groupId>org.argeo.tp.misc</groupId>
                        <artifactId>org.eclipse.jgit</artifactId>
                </dependency>
-
-
-               <!-- For target platform generation -->
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.unit</artifactId>
-                       <version>2.1.17-SNAPSHOT</version>
-                       <scope>test</scope>
-               </dependency>
        </dependencies>
        <profiles>
                <profile>
index 30bd59c9ee8bee32fdd482e4c6861249ff2a8c61..63cfd3403242c3621cf4252e907cd54211955a96 100644 (file)
                        <version>2.1.17-SNAPSHOT</version>
                </dependency>
 
+               <!-- OSGi Boot for platform generation only, as it could be used by regular 
+                       Java applications to launch an OSGi runtime. -->
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.osgi.boot</artifactId>
+                       <version>2.1.86-SNAPSHOT</version>
+                       <scope>test</scope>
+               </dependency>
+
                <!-- ALM Third Parties -->
                <!-- <dependency> -->
                <!-- <groupId>org.argeo.tp.apache.ant</groupId> -->
                <!-- <artifactId>org.apache.ant.launch</artifactId> -->
                <!-- </dependency> -->
 
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.sdk</groupId> -->
-<!--                   <artifactId>biz.aQute.bndlib</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.sdk</groupId> -->
-<!--                   <artifactId>org.junit</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.sdk</groupId> -->
-<!--                   <artifactId>org.redline-rpm</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.misc</groupId> -->
-<!--                   <artifactId>com.googlecode.javaewah.JavaEWAH</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.misc</groupId> -->
-<!--                   <artifactId>org.eclipse.jgit</artifactId> -->
-<!--           </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.sdk</groupId> -->
+               <!-- <artifactId>biz.aQute.bndlib</artifactId> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.sdk</groupId> -->
+               <!-- <artifactId>org.junit</artifactId> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.sdk</groupId> -->
+               <!-- <artifactId>org.redline-rpm</artifactId> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.misc</groupId> -->
+               <!-- <artifactId>com.googlecode.javaewah.JavaEWAH</artifactId> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.misc</groupId> -->
+               <!-- <artifactId>org.eclipse.jgit</artifactId> -->
+               <!-- </dependency> -->
        </dependencies>
        <profiles>
                <profile>
index e32a59a8229cb5a0e3b2a8e207fa0a123d20ced1..e518262485128a882eb6f80bed0db8dec5e02ba8 100644 (file)
                        <artifactId>org.argeo.slc.api</artifactId>
                        <version>2.1.17-SNAPSHOT</version>
                </dependency>
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.support</artifactId>
-                       <version>2.1.17-SNAPSHOT</version>
-               </dependency>
 
                <!-- CLI Agent -->
                <!-- <dependency> -->
index faada3bb65b9dad2034a68b611351d6f0a33a20f..835345eea935249970495f765aaf5bae567e488a 100644 (file)
                <!-- Spring-based Agent -->
                <dependency>
                        <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.core</artifactId>
+                       <artifactId>org.argeo.slc.spring</artifactId>
+                       <version>2.1.17-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.support</artifactId>
                        <version>2.1.17-SNAPSHOT</version>
                </dependency>
                <dependency>
                        <version>2.1.17-SNAPSHOT</version>
                </dependency>
 
+               <!-- Not strictly Spring dependencies but used by the old approach -->
+               <dependency>
+                       <groupId>org.argeo.tp.apache.ant</groupId>
+                       <artifactId>org.apache.ant</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.apache.ant</groupId>
+                       <artifactId>org.apache.ant.launch</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.javax</groupId>
+                       <artifactId>javax.mail</artifactId>
+               </dependency>
+
                <!-- Base Spring dependency -->
                <dependency>
                        <groupId>org.argeo.tp.spring</groupId>
index 047a269fbaf299a9c85861cc37ccfb347c8ec06a..f2edc68c325b6180ec47288dde14f9a03511b830 100644 (file)
                <!-- <groupId>org.argeo.tp.apache</groupId> -->
                <!-- <artifactId>org.apache.tika.parser</artifactId> -->
                <!-- </dependency> -->
-               <dependency>
-                       <groupId>org.argeo.tp.bouncycastle</groupId>
-                       <artifactId>bcmail</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.bouncycastle</groupId>
-                       <artifactId>bcpg</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.apache.ant</groupId>
-                       <artifactId>org.apache.ant</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.apache.ant</groupId>
-                       <artifactId>org.apache.ant.launch</artifactId>
-               </dependency>
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.bouncycastle</groupId> -->
+               <!-- <artifactId>bcmail</artifactId> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.bouncycastle</groupId> -->
+               <!-- <artifactId>bcpg</artifactId> -->
+               <!-- </dependency> -->
                <!-- <dependency> -->
                <!-- <groupId>org.argeo.tp.misc</groupId> -->
                <!-- <artifactId>org.quartz-scheduler.quartz</artifactId> -->
                <!-- <groupId>org.argeo.tp.misc</groupId> -->
                <!-- <artifactId>org.quartz-scheduler.quartz.jobs</artifactId> -->
                <!-- </dependency> -->
-               <dependency>
-                       <groupId>org.argeo.tp.javax</groupId>
-                       <artifactId>javax.mail</artifactId>
-               </dependency>
 
                <!-- Base Spring dependency -->
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.beans</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.core</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.javax</groupId>
-                       <artifactId>javax.el</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.gemini</groupId>
-                       <artifactId>org.eclipse.gemini.blueprint.core</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.gemini</groupId>
-                       <artifactId>org.eclipse.gemini.blueprint.extender</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.gemini</groupId>
-                       <artifactId>org.eclipse.gemini.blueprint.io</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.misc</groupId>
-                       <artifactId>org.aspectj.weaver</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.misc</groupId>
-                       <artifactId>org.aopalliance</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.aop</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.context</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.expression</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.instrument</artifactId>
-               </dependency>
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.spring</groupId> -->
+               <!-- <artifactId>org.springframework.beans</artifactId> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.spring</groupId> -->
+               <!-- <artifactId>org.springframework.core</artifactId> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.javax</groupId> -->
+               <!-- <artifactId>javax.el</artifactId> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.gemini</groupId> -->
+               <!-- <artifactId>org.eclipse.gemini.blueprint.core</artifactId> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.gemini</groupId> -->
+               <!-- <artifactId>org.eclipse.gemini.blueprint.extender</artifactId> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.gemini</groupId> -->
+               <!-- <artifactId>org.eclipse.gemini.blueprint.io</artifactId> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.misc</groupId> -->
+               <!-- <artifactId>org.aspectj.weaver</artifactId> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.misc</groupId> -->
+               <!-- <artifactId>org.aopalliance</artifactId> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.spring</groupId> -->
+               <!-- <artifactId>org.springframework.aop</artifactId> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.spring</groupId> -->
+               <!-- <artifactId>org.springframework.context</artifactId> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.spring</groupId> -->
+               <!-- <artifactId>org.springframework.expression</artifactId> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.spring</groupId> -->
+               <!-- <artifactId>org.springframework.instrument</artifactId> -->
+               <!-- </dependency> -->
 
                <!-- Spring -->
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.aspects</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.context.support</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.jdbc</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.tx</artifactId>
-               </dependency>
+
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.spring</groupId> -->
+               <!-- <artifactId>org.springframework.aspects</artifactId> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.spring</groupId> -->
+               <!-- <artifactId>org.springframework.context.support</artifactId> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.spring</groupId> -->
+               <!-- <artifactId>org.springframework.jdbc</artifactId> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.tp.spring</groupId> -->
+               <!-- <artifactId>org.springframework.tx</artifactId> -->
+               <!-- </dependency> -->
                <!-- <dependency> -->
                <!-- <groupId>org.argeo.tp.spring</groupId> -->
                <!-- <artifactId>org.springframework.web</artifactId> -->
diff --git a/org.argeo.slc.api/src/org/argeo/slc/attachment/Attachment.java b/org.argeo.slc.api/src/org/argeo/slc/attachment/Attachment.java
new file mode 100644 (file)
index 0000000..9ad9613
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.attachment;
+
+public interface Attachment {
+       public String getUuid();
+
+       public void setUuid(String uuid);
+
+       public String getName();
+
+       public String getContentType();
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/attachment/AttachmentsEnabled.java b/org.argeo.slc.api/src/org/argeo/slc/attachment/AttachmentsEnabled.java
new file mode 100644 (file)
index 0000000..53c8cdf
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.attachment;
+
+public interface AttachmentsEnabled {
+       public void addAttachment(Attachment attachment);
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/attachment/AttachmentsStorage.java b/org.argeo.slc.api/src/org/argeo/slc/attachment/AttachmentsStorage.java
new file mode 100644 (file)
index 0000000..94a845c
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.attachment;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public interface AttachmentsStorage {
+       public void retrieveAttachment(Attachment attachment,
+                       OutputStream outputStream);
+
+       /** Does NOT close the provided input stream. */
+       public void storeAttachment(Attachment attachment, InputStream inputStream);
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/AbstractExecutionValue.java b/org.argeo.slc.api/src/org/argeo/slc/execution/AbstractExecutionValue.java
new file mode 100644 (file)
index 0000000..23ab55e
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.execution;
+
+import java.io.Serializable;
+
+/** Value to be used by an execution */
+public abstract class AbstractExecutionValue implements Serializable {
+       private static final long serialVersionUID = 1558444746120706961L;
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/AbstractSpecAttribute.java b/org.argeo.slc.api/src/org/argeo/slc/execution/AbstractSpecAttribute.java
new file mode 100644 (file)
index 0000000..5b1438a
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.execution;
+
+import java.io.Serializable;
+
+/** Canonical implementation of the execution spec attribute booleans. */
+public abstract class AbstractSpecAttribute implements ExecutionSpecAttribute,
+               Serializable {
+       private static final long serialVersionUID = 6494963738891709440L;
+       private Boolean isImmutable = false;
+       private Boolean isConstant = false;
+       private Boolean isHidden = false;
+
+       private String description;
+
+       /** Has to be set at instantiation */
+       public Boolean getIsImmutable() {
+               return isImmutable;
+       }
+
+       public void setIsImmutable(Boolean isImmutable) {
+               this.isImmutable = isImmutable;
+       }
+
+       /** Cannot be overridden at runtime */
+       public Boolean getIsConstant() {
+               return isConstant;
+       }
+
+       public void setIsConstant(Boolean isConstant) {
+               this.isConstant = isConstant;
+       }
+
+       /** Should not be shown to the end user */
+       public Boolean getIsHidden() {
+               return isHidden;
+       }
+
+       public void setIsHidden(Boolean isHidden) {
+               this.isHidden = isHidden;
+       }
+
+       /*
+        * DEPRECATED
+        */
+       /** @deprecated use {@link #getIsImmutable()} instead */
+       public Boolean getIsParameter() {
+               return isImmutable;
+       }
+
+       /** @deprecated use {@link #getIsConstant()} instead */
+       public Boolean getIsFrozen() {
+               return isConstant;
+       }
+
+       /** @deprecated use {@link #setIsImmutable(Boolean)} instead */
+       public void setIsParameter(Boolean isParameter) {
+               this.isImmutable = isParameter;
+       }
+
+       /** @deprecated use {@link #setIsConstant(Boolean)} instead */
+       public void setIsFrozen(Boolean isFrozen) {
+               this.isConstant = isFrozen;
+       }
+
+       public void setDescription(String description) {
+               this.description = description;
+       }
+
+       public String getDescription() {
+               return description;
+       }
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/RefSpecAttribute.java b/org.argeo.slc.api/src/org/argeo/slc/execution/RefSpecAttribute.java
new file mode 100644 (file)
index 0000000..ccfebaf
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.execution;
+
+import java.util.List;
+
+/** A spec attribute whose value is a reference to a full fledged object. */
+public class RefSpecAttribute extends AbstractSpecAttribute implements
+               Cloneable {
+       private static final long serialVersionUID = -3427797452955753574L;
+       private transient Class<?> targetClass = String.class;
+       /** Read only. */
+       private String targetClassName;
+       private transient Object value = null;
+
+       /** List to be chosen from */
+       private List<RefValueChoice> choices = null;
+
+       public Object getValue() {
+               return value;
+       }
+
+       public void setValue(Object value) {
+               this.value = value;
+       }
+
+       /** Default is {@link String} */
+       public Class<?> getTargetClass() {
+               return targetClass;
+       }
+
+       public void setTargetClass(Class<?> targetClass) {
+               this.targetClass = targetClass;
+               this.targetClassName = targetClass.getName();
+       }
+
+       public String getTargetClassName() {
+               return targetClassName;
+       }
+
+       /** @return can be null */
+       public List<RefValueChoice> getChoices() {
+               return choices;
+       }
+
+       public void setChoices(List<RefValueChoice> choices) {
+               this.choices = choices;
+       }
+
+       @Override
+       protected Object clone() throws CloneNotSupportedException {
+               RefSpecAttribute rsa = new RefSpecAttribute();
+               rsa.setTargetClass(targetClass);
+               rsa.setChoices(choices);
+               return rsa;
+       }
+
+       @Override
+       public String toString() {
+               return "Ref spec attribute [" + targetClass + "]"
+                               + (value != null ? "=" + value : "");
+       }
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/RefValue.java b/org.argeo.slc.api/src/org/argeo/slc/execution/RefValue.java
new file mode 100644 (file)
index 0000000..b66f2c4
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.execution;
+
+/** Reference value to be used by an execution */
+public class RefValue extends AbstractExecutionValue {
+       private static final long serialVersionUID = -8951231456757181687L;
+       private String ref;
+       private String type;
+
+       public RefValue() {
+       }
+
+       public RefValue(String ref) {
+               super();
+               this.ref = ref;
+       }
+
+       public String getRef() {
+               return ref;
+       }
+
+       public void setRef(String ref) {
+               this.ref = ref;
+       }
+
+       public String getType() {
+               return type;
+       }
+
+       public void setType(String type) {
+               this.type = type;
+       }
+
+       @Override
+       public String toString() {
+               return "Ref Value [" + type + "=" + ref + "]";
+       }
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/RefValueChoice.java b/org.argeo.slc.api/src/org/argeo/slc/execution/RefValueChoice.java
new file mode 100644 (file)
index 0000000..83c880a
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.execution;
+
+import java.io.Serializable;
+
+/** A choice of ref value to be shown to the end user. */
+public class RefValueChoice implements Serializable {
+       private static final long serialVersionUID = -1133645722307507774L;
+       private String name;
+       private String description;
+
+       public RefValueChoice() {
+       }
+
+       public RefValueChoice(String name, String description) {
+               this.name = name;
+               this.description = description;
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       public String getDescription() {
+               return description;
+       }
+
+       public void setDescription(String description) {
+               this.description = description;
+       }
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveAccessor.java b/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveAccessor.java
new file mode 100644 (file)
index 0000000..ce71429
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.primitive;
+
+/** Abstraction of access to primitive values */
+public interface PrimitiveAccessor {
+       public final static String TYPE_STRING = "string";
+       /**
+        * As of Argeo 1, passwords are NOT stored encrypted, just hidden in the UI,
+        * but stored in plain text in JCR. Use keyring instead.
+        */
+       public final static String TYPE_PASSWORD = "password";
+       public final static String TYPE_INTEGER = "integer";
+       public final static String TYPE_LONG = "long";
+       public final static String TYPE_FLOAT = "float";
+       public final static String TYPE_DOUBLE = "double";
+       public final static String TYPE_BOOLEAN = "boolean";
+
+       public String getType();
+
+       public Object getValue();
+
+       public void setValue(Object value);
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveSpecAttribute.java b/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveSpecAttribute.java
new file mode 100644 (file)
index 0000000..eb9ff2a
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.primitive;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.execution.AbstractSpecAttribute;
+
+/**
+ * A spec attribute wrapping a primitive value.
+ * 
+ * @see PrimitiveAccessor
+ */
+public class PrimitiveSpecAttribute extends AbstractSpecAttribute implements
+               PrimitiveAccessor {
+       private static final long serialVersionUID = -566676381839825483L;
+       private String type = "string";
+       private Object value = null;
+
+       public PrimitiveSpecAttribute() {
+       }
+
+       public PrimitiveSpecAttribute(String type, Object value) {
+               this.type = type;
+               this.value = value;
+       }
+
+       public Object getValue() {
+               return value;
+       }
+
+       public void setValue(Object value) {
+               this.value = value;
+       }
+
+       public String getType() {
+               return type;
+       }
+
+       public void setType(String type) {
+               // check whether type is recognized.
+               if (PrimitiveUtils.typeAsClass(type) == null)
+                       throw new SlcException("Unrecognized type " + type);
+               this.type = type;
+
+       }
+
+       @Override
+       public String toString() {
+               return "Primitive spec attribute [" + type + "]"
+                               + (value != null ? "=" + value : "");
+       }
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveUtils.java b/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveUtils.java
new file mode 100644 (file)
index 0000000..d7284cf
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.primitive;
+
+/** Converts to and from primitive types. */
+public class PrimitiveUtils {
+       /**
+        * @deprecated Use {@link PrimitiveAccessor#TYPE_STRING} instead
+        */
+       public final static String TYPE_STRING = PrimitiveAccessor.TYPE_STRING;
+       /**
+        * @deprecated Use {@link PrimitiveAccessor#TYPE_INTEGER} instead
+        */
+       public final static String TYPE_INTEGER = PrimitiveAccessor.TYPE_INTEGER;
+       /**
+        * @deprecated Use {@link PrimitiveAccessor#TYPE_LONG} instead
+        */
+       public final static String TYPE_LONG = PrimitiveAccessor.TYPE_LONG;
+       /**
+        * @deprecated Use {@link PrimitiveAccessor#TYPE_FLOAT} instead
+        */
+       public final static String TYPE_FLOAT = PrimitiveAccessor.TYPE_FLOAT;
+       /**
+        * @deprecated Use {@link PrimitiveAccessor#TYPE_DOUBLE} instead
+        */
+       public final static String TYPE_DOUBLE = PrimitiveAccessor.TYPE_DOUBLE;
+       /**
+        * @deprecated Use {@link PrimitiveAccessor#TYPE_BOOLEAN} instead
+        */
+       public final static String TYPE_BOOLEAN = PrimitiveAccessor.TYPE_BOOLEAN;
+
+       private PrimitiveUtils() {
+
+       }
+
+       /** @return the class or null if the provided type is not a primitive */
+       public static Class<?> typeAsClass(String type) {
+               if (PrimitiveAccessor.TYPE_STRING.equals(type))
+                       return String.class;
+               else if (PrimitiveAccessor.TYPE_PASSWORD.equals(type))
+                       return char[].class;
+               else if (PrimitiveAccessor.TYPE_INTEGER.equals(type))
+                       return Integer.class;
+               else if (PrimitiveAccessor.TYPE_LONG.equals(type))
+                       return Long.class;
+               else if (PrimitiveAccessor.TYPE_FLOAT.equals(type))
+                       return Float.class;
+               else if (PrimitiveAccessor.TYPE_DOUBLE.equals(type))
+                       return Double.class;
+               else if (PrimitiveAccessor.TYPE_BOOLEAN.equals(type))
+                       return Boolean.class;
+               else
+                       return null;
+       }
+
+       /** @return the type or null if the provided class is not a primitive */
+       public static String classAsType(Class<?> clss) {
+               if (String.class.isAssignableFrom(clss))
+                       return PrimitiveAccessor.TYPE_STRING;
+               else if (char[].class.isAssignableFrom(clss))
+                       return PrimitiveAccessor.TYPE_PASSWORD;
+               else if (Integer.class.isAssignableFrom(clss))
+                       return PrimitiveAccessor.TYPE_INTEGER;
+               else if (Long.class.isAssignableFrom(clss))
+                       return PrimitiveAccessor.TYPE_LONG;
+               else if (Float.class.isAssignableFrom(clss))
+                       return PrimitiveAccessor.TYPE_FLOAT;
+               else if (Double.class.isAssignableFrom(clss))
+                       return PrimitiveAccessor.TYPE_DOUBLE;
+               else if (Boolean.class.isAssignableFrom(clss))
+                       return PrimitiveAccessor.TYPE_BOOLEAN;
+               else
+                       return null;
+       }
+
+       /** Parse string as an object. Passwords are returned as String.*/
+       public static Object convert(String type, String str) {
+               if (PrimitiveAccessor.TYPE_STRING.equals(type)) {
+                       return str;
+               } else if (PrimitiveAccessor.TYPE_PASSWORD.equals(type)) {
+                       return str;
+               } else if (PrimitiveAccessor.TYPE_INTEGER.equals(type)) {
+                       return (Integer.parseInt(str));
+               } else if (PrimitiveAccessor.TYPE_LONG.equals(type)) {
+                       return (Long.parseLong(str));
+               } else if (PrimitiveAccessor.TYPE_FLOAT.equals(type)) {
+                       return (Float.parseFloat(str));
+               } else if (PrimitiveAccessor.TYPE_DOUBLE.equals(type)) {
+                       return (Double.parseDouble(str));
+               } else if (PrimitiveAccessor.TYPE_BOOLEAN.equals(type)) {
+                       return (Boolean.parseBoolean(str));
+               } else {
+                       return str;
+               }
+       }
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveValue.java b/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveValue.java
new file mode 100644 (file)
index 0000000..b3ade50
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.primitive;
+
+import org.argeo.slc.execution.AbstractExecutionValue;
+
+/** Primitive value to be used by an execution. */
+public class PrimitiveValue extends AbstractExecutionValue implements
+               PrimitiveAccessor {
+       private static final long serialVersionUID = 533414290998374166L;
+
+       private String type;
+
+       private Object value;
+
+       public PrimitiveValue() {
+       }
+
+       public PrimitiveValue(String type, Object value) {
+               super();
+               this.type = type;
+               this.value = value;
+       }
+
+       public String getType() {
+               return type;
+       }
+
+       public void setType(String type) {
+               this.type = type;
+       }
+
+       public Object getValue() {
+               return value;
+       }
+
+       public void setValue(Object value) {
+               this.value = value;
+       }
+
+}
index c2ff564df1b414ab1388805172a9bddf9fd6e7db..f4571db4c4ae926a32385cb8b2955eebe0eb65d7 100644 (file)
@@ -15,7 +15,7 @@
                <!-- SLC -->
                <dependency>
                        <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.core</artifactId>
+                       <artifactId>org.argeo.slc.spring</artifactId>
                        <version>2.1.17-SNAPSHOT</version>
                </dependency>
 
index 758d761c6cb381a8165212d6fe3fb811c95c11e1..638d3a2d238280e704dab5a7305d4ebd67208b0c 100644 (file)
@@ -38,8 +38,8 @@ import org.argeo.slc.SlcException;
 import org.argeo.slc.SlcNames;
 import org.argeo.slc.SlcTypes;
 import org.argeo.slc.client.ui.SlcImages;
-import org.argeo.slc.core.execution.PrimitiveAccessor;
-import org.argeo.slc.core.execution.PrimitiveUtils;
+import org.argeo.slc.primitive.PrimitiveAccessor;
+import org.argeo.slc.primitive.PrimitiveUtils;
 import org.argeo.slc.execution.ExecutionProcess;
 import org.argeo.slc.jcr.SlcJcrUtils;
 import org.eclipse.jface.viewers.CellEditor;
index e638a99b5a7a74f4f47e16a9df2005f5bbd3bfbe..8585843b7f85bb7b82b3ced796faf477dcb81c62 100644 (file)
@@ -13,7 +13,7 @@
                <!-- SLC -->
                <dependency>
                        <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.core</artifactId>
+                       <artifactId>org.argeo.slc.jcr</artifactId>
                        <version>2.1.17-SNAPSHOT</version>
                </dependency>
 
diff --git a/org.argeo.slc.jcr/.classpath b/org.argeo.slc.jcr/.classpath
new file mode 100644 (file)
index 0000000..e801ebf
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.argeo.slc.jcr/.gitignore b/org.argeo.slc.jcr/.gitignore
new file mode 100644 (file)
index 0000000..09e3bc9
--- /dev/null
@@ -0,0 +1,2 @@
+/bin/
+/target/
diff --git a/org.argeo.slc.jcr/.project b/org.argeo.slc.jcr/.project
new file mode 100644 (file)
index 0000000..a4cd874
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.jcr</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.argeo.slc.jcr/META-INF/.gitignore b/org.argeo.slc.jcr/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/org.argeo.slc.jcr/bnd.bnd b/org.argeo.slc.jcr/bnd.bnd
new file mode 100644 (file)
index 0000000..b632c5a
--- /dev/null
@@ -0,0 +1,2 @@
+Import-Package: javax.jcr.nodetype,\
+*
\ No newline at end of file
diff --git a/org.argeo.slc.jcr/build.properties b/org.argeo.slc.jcr/build.properties
new file mode 100644 (file)
index 0000000..34d2e4d
--- /dev/null
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .
diff --git a/org.argeo.slc.jcr/pom.xml b/org.argeo.slc.jcr/pom.xml
new file mode 100644 (file)
index 0000000..8f34b61
--- /dev/null
@@ -0,0 +1,59 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>argeo-slc</artifactId>
+               <version>2.1.17-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.jcr</artifactId>
+       <name>SLC JCR implementations</name>
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-surefire-plugin</artifactId>
+                               <configuration>
+                                       <skipTests>true</skipTests>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+       <dependencies>
+               <!-- Commons -->
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.enterprise</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.node.api</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.cms</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.jcr</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.util</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+
+               <!-- SLC -->
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.api</artifactId>
+                       <version>2.1.17-SNAPSHOT</version>
+               </dependency>
+       </dependencies>
+</project>
\ No newline at end of file
diff --git a/org.argeo.slc.jcr/src/org/argeo/slc/jcr/JcrMetadataWriter.java b/org.argeo.slc.jcr/src/org/argeo/slc/jcr/JcrMetadataWriter.java
new file mode 100644 (file)
index 0000000..c4922d3
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.jcr;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+
+/**
+ * Writes arbitrary metadata into a child node of a given node (or the node
+ * itself if metadata node name is set to null)
+ */
+public class JcrMetadataWriter implements Runnable {
+       private final static Log log = LogFactory.getLog(JcrMetadataWriter.class);
+
+       private Node baseNode;
+       private String metadataNodeName = SlcNames.SLC_METADATA;
+
+       private Map<String, String> metadata = new HashMap<String, String>();
+
+       public void run() {
+               try {
+                       Node metadataNode;
+                       if (metadataNodeName != null)
+                               metadataNode = baseNode.hasNode(metadataNodeName) ? baseNode
+                                               .getNode(metadataNodeName) : baseNode
+                                               .addNode(metadataNodeName);
+                       else
+                               metadataNode = baseNode;
+
+                       for (String key : metadata.keySet())
+                               metadataNode.setProperty(key, metadata.get(key));
+
+                       baseNode.getSession().save();
+
+                       if (log.isDebugEnabled())
+                               log.debug("Wrote " + metadata.size() + " metadata entries to "
+                                               + metadataNode);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot write metadata to " + baseNode, e);
+               } finally {
+                       JcrUtils.discardUnderlyingSessionQuietly(baseNode);
+               }
+
+       }
+
+       public void setBaseNode(Node baseNode) {
+               this.baseNode = baseNode;
+       }
+
+       public void setMetadataNodeName(String metadataNodeName) {
+               this.metadataNodeName = metadataNodeName;
+       }
+
+       public void setMetadata(Map<String, String> metadata) {
+               this.metadata = metadata;
+       }
+
+}
diff --git a/org.argeo.slc.jcr/src/org/argeo/slc/jcr/JcrTestResult.java b/org.argeo.slc.jcr/src/org/argeo/slc/jcr/JcrTestResult.java
new file mode 100644 (file)
index 0000000..3f94b8b
--- /dev/null
@@ -0,0 +1,291 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.jcr;
+
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.jcr.Credentials;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.Repository;
+import javax.jcr.Session;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.attachment.Attachment;
+import org.argeo.slc.attachment.AttachmentsEnabled;
+import org.argeo.slc.test.TestResult;
+import org.argeo.slc.test.TestResultPart;
+import org.argeo.slc.test.TestRun;
+import org.argeo.slc.test.TestStatus;
+
+/**
+ * {@link TestResult} wrapping a JCR node of type
+ * {@link SlcTypes#SLC_TEST_RESULT}.
+ */
+public class JcrTestResult implements TestResult, SlcNames, AttachmentsEnabled {
+       private final static Log log = LogFactory.getLog(JcrTestResult.class);
+
+       /** Should only be set for an already existing result. */
+       private String uuid;
+       private Repository repository;
+       private Session session;
+       /**
+        * For testing purposes, best practice is to not set them explicitely but
+        * via other mechanisms such as JAAS or SPring Security.
+        */
+       private Credentials credentials = null;
+       private String resultType = SlcTypes.SLC_TEST_RESULT;
+
+       /** cached for performance purposes */
+       private String nodeIdentifier = null;
+
+       private Map<String, String> attributes = new HashMap<String, String>();
+
+       public void init() {
+               try {
+                       session = repository.login(credentials);
+                       if (uuid == null) {
+                               // create new result
+                               uuid = UUID.randomUUID().toString();
+                               String path = SlcJcrUtils.createResultPath(session, uuid);
+                               Node resultNode = JcrUtils.mkdirs(session, path, resultType);
+                               resultNode.setProperty(SLC_UUID, uuid);
+                               for (String attr : attributes.keySet()) {
+                                       String property = attr;
+                                       // compatibility with legacy applications
+                                       if ("testCase".equals(attr))
+                                               property = SLC_TEST_CASE;
+                                       else if ("testCaseType".equals(attr))
+                                               property = SLC_TEST_CASE_TYPE;
+                                       resultNode.setProperty(property, attributes.get(attr));
+                               }
+                               session.save();
+                               if (log.isDebugEnabled())
+                                       log.debug("Created test result " + uuid);
+                       }
+               } catch (Exception e) {
+                       JcrUtils.discardQuietly(session);
+                       throw new SlcException("Cannot initialize JCR result", e);
+               }
+       }
+
+       public void destroy() {
+               JcrUtils.logoutQuietly(session);
+               if (log.isTraceEnabled())
+                       log.trace("Logged out session for result " + uuid);
+       }
+
+       public Node getNode() {
+               try {
+                       Node resultNode;
+                       if (nodeIdentifier != null) {
+                               return session.getNodeByIdentifier(nodeIdentifier);
+                       } else {
+                               QueryManager qm = session.getWorkspace().getQueryManager();
+                               Query q = qm.createQuery("select * from ["
+                                               + SlcTypes.SLC_TEST_RESULT + "] where [slc:uuid]='"
+                                               + uuid + "'", Query.JCR_SQL2);
+                               resultNode = JcrUtils.querySingleNode(q);
+                               if (resultNode != null)
+                                       nodeIdentifier = resultNode.getIdentifier();
+                       }
+                       return resultNode;
+               } catch (Exception e) {
+                       throw new SlcException("Cannot get result node", e);
+               }
+       }
+
+       public void notifyTestRun(TestRun testRun) {
+               // TODO store meta data about the test running
+               // if (log.isDebugEnabled())
+               // log.debug("Running test "
+               // + testRun.getTestDefinition().getClass().getName() + "...");
+       }
+
+       public void addResultPart(TestResultPart testResultPart) {
+               Node node = getNode();
+
+               try {
+                       // error : revert all unsaved changes on the resultNode to be sure
+                       // it is in a consistant state
+                       if (testResultPart.getExceptionMessage() != null)
+                               JcrUtils.discardQuietly(node.getSession());
+                       node.getSession().save();
+
+                       // add the new result part, retrieving status information
+                       Node resultPartNode = node.addNode(SlcNames.SLC_RESULT_PART,
+                                       SlcTypes.SLC_CHECK);
+                       resultPartNode.setProperty(SLC_SUCCESS, testResultPart.getStatus()
+                                       .equals(TestStatus.PASSED));
+                       if (testResultPart.getMessage() != null)
+                               resultPartNode.setProperty(SLC_MESSAGE,
+                                               testResultPart.getMessage());
+                       if (testResultPart.getStatus().equals(TestStatus.ERROR)) {
+                               resultPartNode.setProperty(SLC_ERROR_MESSAGE,
+                                               (testResultPart.getExceptionMessage() == null) ? ""
+                                                               : testResultPart.getExceptionMessage());
+                       }
+
+                       // helper update aggregate status node
+                       Node mainStatus;
+                       if (!node.hasNode(SLC_AGGREGATED_STATUS)) {
+
+                               mainStatus = node.addNode(SLC_AGGREGATED_STATUS,
+                                               SlcTypes.SLC_CHECK);
+                               mainStatus.setProperty(SLC_SUCCESS,
+                                               resultPartNode.getProperty(SLC_SUCCESS).getBoolean());
+                               if (resultPartNode.hasProperty(SLC_MESSAGE))
+                                       mainStatus.setProperty(SLC_MESSAGE, resultPartNode
+                                                       .getProperty(SLC_MESSAGE).getString());
+                               if (resultPartNode.hasProperty(SLC_ERROR_MESSAGE))
+                                       mainStatus.setProperty(SLC_ERROR_MESSAGE, resultPartNode
+                                                       .getProperty(SLC_ERROR_MESSAGE).getString());
+                       } else {
+                               mainStatus = node.getNode(SLC_AGGREGATED_STATUS);
+                               if (mainStatus.hasProperty(SLC_ERROR_MESSAGE)) {
+                                       // main status already in error we do nothing
+                               } else if (resultPartNode.hasProperty(SLC_ERROR_MESSAGE)) {
+                                       // main status was not in error and new result part is in
+                                       // error; we update main status
+                                       mainStatus.setProperty(SLC_SUCCESS, false);
+                                       mainStatus.setProperty(SLC_ERROR_MESSAGE, resultPartNode
+                                                       .getProperty(SLC_ERROR_MESSAGE).getString());
+                                       if (resultPartNode.hasProperty(SLC_MESSAGE))
+                                               mainStatus.setProperty(SLC_MESSAGE, resultPartNode
+                                                               .getProperty(SLC_MESSAGE).getString());
+                                       else
+                                               // remove old message to remain consistent
+                                               mainStatus.setProperty(SLC_MESSAGE, "");
+                               } else if (!mainStatus.getProperty(SLC_SUCCESS).getBoolean()) {
+                                       // main status was already failed and new result part is not
+                                       // in error, we do nothing
+                               } else if (!resultPartNode.getProperty(SLC_SUCCESS)
+                                               .getBoolean()) {
+                                       // new resultPart that is failed
+                                       mainStatus.setProperty(SLC_SUCCESS, false);
+                                       if (resultPartNode.hasProperty(SLC_MESSAGE))
+                                               mainStatus.setProperty(SLC_MESSAGE, resultPartNode
+                                                               .getProperty(SLC_MESSAGE).getString());
+                                       else
+                                               // remove old message to remain consistent
+                                               mainStatus.setProperty(SLC_MESSAGE, "");
+                               } else if (resultPartNode.hasProperty(SLC_MESSAGE)
+                                               && (!mainStatus.hasProperty(SLC_MESSAGE) || (""
+                                                               .equals(mainStatus.getProperty(SLC_MESSAGE)
+                                                                               .getString().trim())))) {
+                                       mainStatus.setProperty(SLC_MESSAGE, resultPartNode
+                                                       .getProperty(SLC_MESSAGE).getString());
+                               }
+                       }
+                       JcrUtils.updateLastModified(node);
+                       node.getSession().save();
+               } catch (Exception e) {
+                       JcrUtils.discardUnderlyingSessionQuietly(node);
+                       throw new SlcException("Cannot add ResultPart to node " + node, e);
+               }
+       }
+
+       public String getUuid() {
+               Node node = getNode();
+               try {
+                       return node.getProperty(SLC_UUID).getString();
+               } catch (Exception e) {
+                       throw new SlcException("Cannot get UUID from " + node, e);
+               }
+       }
+
+       /** JCR session is NOT logged out */
+       public void close() {
+               Node node = getNode();
+               try {
+                       if (node.hasNode(SLC_COMPLETED))
+                               return;
+                       node.setProperty(SLC_COMPLETED, new GregorianCalendar());
+                       JcrUtils.updateLastModified(node);
+                       node.getSession().save();
+               } catch (Exception e) {
+                       JcrUtils.discardUnderlyingSessionQuietly(node);
+                       throw new SlcException("Cannot get close date from " + node, e);
+               }
+       }
+
+       public Date getCloseDate() {
+               Node node = getNode();
+               try {
+                       if (!node.hasNode(SLC_COMPLETED))
+                               return null;
+                       return node.getProperty(SLC_COMPLETED).getDate().getTime();
+               } catch (Exception e) {
+                       throw new SlcException("Cannot get close date from " + node, e);
+               }
+       }
+
+       public Map<String, String> getAttributes() {
+               Node node = getNode();
+               try {
+                       Map<String, String> map = new HashMap<String, String>();
+                       PropertyIterator pit = node.getProperties();
+                       while (pit.hasNext()) {
+                               Property p = pit.nextProperty();
+                               if (!p.isMultiple())
+                                       map.put(p.getName(), p.getValue().getString());
+                       }
+                       return map;
+               } catch (Exception e) {
+                       throw new SlcException("Cannot get close date from " + node, e);
+               }
+       }
+
+       public void addAttachment(Attachment attachment) {
+               // TODO implement it
+       }
+
+       public void setUuid(String uuid) {
+               this.uuid = uuid;
+       }
+
+       public void setRepository(Repository repository) {
+               this.repository = repository;
+       }
+
+       public void setResultType(String resultType) {
+               this.resultType = resultType;
+       }
+
+       public void setAttributes(Map<String, String> attributes) {
+               if (uuid != null)
+                       throw new SlcException(
+                                       "Attributes cannot be set on an already initialized test result."
+                                                       + " Update the related JCR node directly instead.");
+               this.attributes = attributes;
+       }
+
+       public void setCredentials(Credentials credentials) {
+               this.credentials = credentials;
+       }
+}
diff --git a/org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrConstants.java b/org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrConstants.java
new file mode 100644 (file)
index 0000000..3190c85
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.jcr;
+
+import org.argeo.slc.SlcNames;
+
+/** JCR related constants used across SLC */
+public interface SlcJcrConstants {
+       public final static String PROPERTY_PATH = "argeo.slc.jcr.path";
+
+       public final static String SLC_BASE_PATH = "/" + SlcNames.SLC_SYSTEM;
+       public final static String AGENTS_BASE_PATH = SLC_BASE_PATH + "/"
+                       + SlcNames.SLC_AGENTS;
+       public final static String VM_AGENT_FACTORY_PATH = AGENTS_BASE_PATH + "/"
+                       + SlcNames.SLC_VM;
+}
diff --git a/org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrResultUtils.java b/org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrResultUtils.java
new file mode 100644 (file)
index 0000000..6353804
--- /dev/null
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.jcr;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+
+import org.argeo.jcr.JcrUtils;
+import org.argeo.node.NodeUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+
+/**
+ * Utilities around the SLC JCR Result model. Note that it relies on fixed base
+ * paths (convention over configuration) for optimization purposes.
+ */
+public class SlcJcrResultUtils {
+
+       /**
+        * Returns the path to the current slc:result node
+        */
+       public static String getSlcResultsBasePath(Session session) {
+               try {
+                       Node userHome = NodeUtils.getUserHome(session);
+                       if (userHome == null)
+                               throw new SlcException("No user home available for "
+                                               + session.getUserID());
+                       return userHome.getPath() + '/' + SlcNames.SLC_SYSTEM + '/'
+                                       + SlcNames.SLC_RESULTS;
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while getting Slc Results Base Path.", re);
+               }
+       }
+
+       /**
+        * Returns the base node to store SlcResults. If it does not exists, it is
+        * created. If a node already exists at the given path with the wrong type,
+        * it throws an exception.
+        * 
+        * @param session
+        * @return
+        */
+       public static Node getSlcResultsParentNode(Session session) {
+               try {
+                       String absPath = getSlcResultsBasePath(session);
+                       if (session.nodeExists(absPath)) {
+                               Node currNode = session.getNode(absPath);
+                               if (currNode.isNodeType(NodeType.NT_UNSTRUCTURED))
+                                       return currNode;
+                               else
+                                       throw new SlcException(
+                                                       "A node already exists at this path : " + absPath
+                                                                       + " that has the wrong type. ");
+                       } else {
+                               Node slcResParNode = JcrUtils.mkdirs(session, absPath);
+                               slcResParNode.setPrimaryType(NodeType.NT_UNSTRUCTURED);
+                               session.save();
+                               return slcResParNode;
+                       }
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while creating slcResult root parent node.",
+                                       re);
+               }
+       }
+
+       /**
+        * Returns the path to the current Result UI specific node, depending the
+        * current user
+        */
+       public static String getMyResultsBasePath(Session session) {
+               try {
+                       Node userHome = NodeUtils.getUserHome(session);
+                       if (userHome == null)
+                               throw new SlcException("No user home available for "
+                                               + session.getUserID());
+                       return userHome.getPath() + '/' + SlcNames.SLC_SYSTEM + '/'
+                                       + SlcNames.SLC_MY_RESULTS;
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while getting Slc Results Base Path.", re);
+               }
+       }
+
+       /**
+        * Creates a new node with type SlcTypes.SLC_MY_RESULT_ROOT_FOLDER at the
+        * given absolute path. If a node already exists at the given path, returns
+        * that node if it has the correct type and throws an exception otherwise.
+        * 
+        * @param session
+        * @return
+        */
+       public static Node getMyResultParentNode(Session session) {
+               try {
+                       String absPath = getMyResultsBasePath(session);
+                       if (session.nodeExists(absPath)) {
+                               Node currNode = session.getNode(absPath);
+                               if (currNode.isNodeType(SlcTypes.SLC_MY_RESULT_ROOT_FOLDER))
+                                       return currNode;
+                               else
+                                       throw new SlcException(
+                                                       "A node already exists at this path : " + absPath
+                                                                       + " that has the wrong type. ");
+                       } else {
+                               Node myResParNode = JcrUtils.mkdirs(session, absPath);
+                               myResParNode.setPrimaryType(SlcTypes.SLC_MY_RESULT_ROOT_FOLDER);
+                               session.save();
+                               return myResParNode;
+                       }
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while creating user MyResult base node.",
+                                       re);
+               }
+       }
+
+       /**
+        * Creates a new node with type SlcTypes.SLC_RESULT_FOLDER at the given
+        * absolute path. If a node already exists at the given path, returns that
+        * node if it has the correct type and throws an exception otherwise.
+        * 
+        * @param session
+        * @param absPath
+        * @return
+        */
+       public static synchronized Node createResultFolderNode(Session session,
+                       String absPath) {
+               try {
+                       if (session.nodeExists(absPath)) {
+                               // Sanity check
+                               Node currNode = session.getNode(absPath);
+                               if (currNode.isNodeType(SlcTypes.SLC_RESULT_FOLDER))
+                                       return currNode;
+                               else
+                                       throw new SlcException(
+                                                       "A node already exists at this path : " + absPath
+                                                                       + " that has the wrong type. ");
+                       }
+                       Node rfNode = JcrUtils.mkdirs(session, absPath);
+                       rfNode.setPrimaryType(SlcTypes.SLC_RESULT_FOLDER);
+                       Node statusNode = rfNode.addNode(SlcNames.SLC_AGGREGATED_STATUS,
+                                       SlcTypes.SLC_CHECK);
+                       statusNode.setProperty(SlcNames.SLC_SUCCESS, true);
+                       session.save();
+                       return rfNode;
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while creating Result Folder node.", re);
+               }
+       }
+}
\ No newline at end of file
diff --git a/org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrUtils.java b/org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrUtils.java
new file mode 100644 (file)
index 0000000..fcf2e71
--- /dev/null
@@ -0,0 +1,268 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.jcr;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+
+import org.argeo.jcr.JcrUtils;
+import org.argeo.node.NodeUtils;
+import org.argeo.slc.DefaultNameVersion;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.deploy.ModuleDescriptor;
+import org.argeo.slc.primitive.PrimitiveAccessor;
+import org.argeo.slc.primitive.PrimitiveUtils;
+import org.argeo.slc.test.TestStatus;
+
+/**
+ * Utilities around the SLC JCR model. Note that it relies on fixed base paths
+ * (convention over configuration) for optimization purposes.
+ */
+public class SlcJcrUtils implements SlcNames {
+       public final static Integer AGENT_FACTORY_DEPTH = 3;
+
+       /** Extracts the path of a flow relative to its execution module */
+       public static String flowRelativePath(String fullFlowPath) {
+               String[] tokens = fullFlowPath.split("/");
+               StringBuffer buf = new StringBuffer(fullFlowPath.length());
+               for (int i = AGENT_FACTORY_DEPTH + 3; i < tokens.length; i++) {
+                       buf.append('/').append(tokens[i]);
+               }
+               return buf.toString();
+       }
+
+       /** Extracts the path to the related execution module */
+       public static String modulePath(String fullFlowPath) {
+               String[] tokens = fullFlowPath.split("/");
+               StringBuffer buf = new StringBuffer(fullFlowPath.length());
+               for (int i = 0; i < AGENT_FACTORY_DEPTH + 3; i++) {
+                       if (!tokens[i].equals(""))
+                               buf.append('/').append(tokens[i]);
+               }
+               return buf.toString();
+       }
+
+       /** Extracts the module name from a flow path */
+       public static String moduleName(String fullFlowPath) {
+               String[] tokens = fullFlowPath.split("/");
+               String moduleName = tokens[AGENT_FACTORY_DEPTH + 2];
+               moduleName = moduleName.substring(0, moduleName.indexOf('_'));
+               return moduleName;
+       }
+
+       /** Extracts the module name and version from a flow path */
+       public static NameVersion moduleNameVersion(String fullFlowPath) {
+               String[] tokens = fullFlowPath.split("/");
+               String module = tokens[AGENT_FACTORY_DEPTH + 2];
+               String moduleName = module.substring(0, module.indexOf('_'));
+               String moduleVersion = module.substring(module.indexOf('_') + 1);
+               return new DefaultNameVersion(moduleName, moduleVersion);
+       }
+
+       /** Module node name based on module name and version */
+       public static String getModuleNodeName(ModuleDescriptor moduleDescriptor) {
+               return moduleDescriptor.getName() + "_" + moduleDescriptor.getVersion();
+       }
+
+       /** Extracts the agent factory of a flow */
+       public static String flowAgentFactoryPath(String fullFlowPath) {
+               String[] tokens = fullFlowPath.split("/");
+               StringBuffer buf = new StringBuffer(fullFlowPath.length());
+               // first token is always empty
+               for (int i = 1; i < AGENT_FACTORY_DEPTH + 1; i++) {
+                       buf.append('/').append(tokens[i]);
+               }
+               return buf.toString();
+       }
+
+       /** Create a new execution process path based on the current time */
+       public static String createExecutionProcessPath(Session session, String uuid) {
+               Calendar now = new GregorianCalendar();
+               return getSlcProcessesBasePath(session) + '/'
+                               + JcrUtils.dateAsPath(now, true) + uuid;
+       }
+
+       /** Get the base for the user processi. */
+       public static String getSlcProcessesBasePath(Session session) {
+               try {
+                       Node userHome = NodeUtils.getUserHome(session);
+                       if (userHome == null)
+                               throw new SlcException("No user home available for "
+                                               + session.getUserID());
+                       return userHome.getPath() + '/' + SlcNames.SLC_SYSTEM + '/'
+                                       + SlcNames.SLC_PROCESSES;
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while getting Slc Results Base Path.", re);
+               }
+       }
+
+       /**
+        * Create a new execution result path in the user home based on the current
+        * time
+        */
+       public static String createResultPath(Session session, String uuid)
+                       throws RepositoryException {
+               Calendar now = new GregorianCalendar();
+               StringBuffer absPath = new StringBuffer(
+                               SlcJcrResultUtils.getSlcResultsBasePath(session) + '/');
+               // Remove hours and add title property to the result process path on
+               // request of O. Capillon
+               // return getSlcProcessesBasePath(session) + '/'
+               // + JcrUtils.dateAsPath(now, true) + uuid;
+               String relPath = JcrUtils.dateAsPath(now, false);
+               List<String> names = JcrUtils.tokenize(relPath);
+               for (String name : names) {
+                       absPath.append(name + "/");
+                       Node node = JcrUtils.mkdirs(session, absPath.toString());
+                       try {
+                               node.addMixin(NodeType.MIX_TITLE);
+                               node.setProperty(Property.JCR_TITLE, name.substring(1));
+                       } catch (RepositoryException e) {
+                               throw new SlcException(
+                                               "unable to create execution process path", e);
+                       }
+               }
+               return absPath.toString() + uuid;
+       }
+
+       /**
+        * Set the value of the primitive accessor as a JCR property. Does nothing
+        * if the value is null.
+        */
+       public static void setPrimitiveAsProperty(Node node, String propertyName,
+                       PrimitiveAccessor primitiveAccessor) {
+               String type = primitiveAccessor.getType();
+               Object value = primitiveAccessor.getValue();
+               setPrimitiveAsProperty(node, propertyName, type, value);
+       }
+
+       /** Map a primitive value to JCR property value. */
+       public static void setPrimitiveAsProperty(Node node, String propertyName,
+                       String type, Object value) {
+               if (value == null)
+                       return;
+               if (value instanceof CharSequence)
+                       value = PrimitiveUtils.convert(type,
+                                       ((CharSequence) value).toString());
+               if (value instanceof char[])
+                       value = new String((char[]) value);
+
+               try {
+                       if (type.equals(PrimitiveAccessor.TYPE_STRING))
+                               node.setProperty(propertyName, value.toString());
+                       else if (type.equals(PrimitiveAccessor.TYPE_PASSWORD))
+                               node.setProperty(propertyName, value.toString());
+                       else if (type.equals(PrimitiveAccessor.TYPE_INTEGER))
+                               node.setProperty(propertyName, (long) ((Integer) value));
+                       else if (type.equals(PrimitiveAccessor.TYPE_LONG))
+                               node.setProperty(propertyName, ((Long) value));
+                       else if (type.equals(PrimitiveAccessor.TYPE_FLOAT))
+                               node.setProperty(propertyName, (double) ((Float) value));
+                       else if (type.equals(PrimitiveAccessor.TYPE_DOUBLE))
+                               node.setProperty(propertyName, ((Double) value));
+                       else if (type.equals(PrimitiveAccessor.TYPE_BOOLEAN))
+                               node.setProperty(propertyName, ((Boolean) value));
+                       else
+                               throw new SlcException("Unsupported type " + type);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot set primitive of " + type
+                                       + " as property " + propertyName + " on " + node, e);
+               }
+       }
+
+       /** Aggregates the {@link TestStatus} of this sub-tree. */
+       public static Integer aggregateTestStatus(Node node) {
+               try {
+                       Integer status = TestStatus.PASSED;
+                       if (node.isNodeType(SlcTypes.SLC_CHECK))
+                               if (node.getProperty(SLC_SUCCESS).getBoolean())
+                                       status = TestStatus.PASSED;
+                               else if (node.hasProperty(SLC_ERROR_MESSAGE))
+                                       status = TestStatus.ERROR;
+                               else
+                                       status = TestStatus.FAILED;
+
+                       NodeIterator it = node.getNodes();
+                       while (it.hasNext()) {
+                               Node curr = it.nextNode();
+
+                               // Manually skip aggregated status
+                               if (!SlcNames.SLC_AGGREGATED_STATUS.equals(curr.getName())) {
+                                       Integer childStatus = aggregateTestStatus(curr);
+                                       if (childStatus > status)
+                                               status = childStatus;
+                               }
+                       }
+                       return status;
+               } catch (Exception e) {
+                       throw new SlcException("Could not aggregate test status from "
+                                       + node, e);
+               }
+       }
+
+       /**
+        * Aggregates the {@link TestStatus} of this sub-tree.
+        * 
+        * @return the same {@link StringBuffer}, for convenience (typically calling
+        *         toString() on it)
+        */
+       public static StringBuffer aggregateTestMessages(Node node,
+                       StringBuffer messages) {
+               try {
+                       if (node.isNodeType(SlcTypes.SLC_CHECK)) {
+                               if (node.hasProperty(SLC_MESSAGE)) {
+                                       if (messages.length() > 0)
+                                               messages.append('\n');
+                                       messages.append(node.getProperty(SLC_MESSAGE).getString());
+                               }
+                               if (node.hasProperty(SLC_ERROR_MESSAGE)) {
+                                       if (messages.length() > 0)
+                                               messages.append('\n');
+                                       messages.append(node.getProperty(SLC_ERROR_MESSAGE)
+                                                       .getString());
+                               }
+                       }
+                       NodeIterator it = node.getNodes();
+                       while (it.hasNext()) {
+                               Node child = it.nextNode();
+                               // Manually skip aggregated status
+                               if (!SlcNames.SLC_AGGREGATED_STATUS.equals(child.getName())) {
+                                       aggregateTestMessages(child, messages);
+                               }
+                       }
+                       return messages;
+               } catch (Exception e) {
+                       throw new SlcException("Could not aggregate test messages from "
+                                       + node, e);
+               }
+       }
+
+       /** Prevents instantiation */
+       private SlcJcrUtils() {
+       }
+}
\ No newline at end of file
index ab207def92462476597e0db80d61771801006abe..759c6118991fddc84f9096aebd0877c61cd71519 100644 (file)
        <artifactId>org.argeo.slc.repo</artifactId>
        <name>SLC Repo</name>
        <dependencies>
-               <!-- SLC Runtime -->
+               <!-- SLC API -->
                <dependency>
                        <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.support</artifactId>
+                       <artifactId>org.argeo.slc.api</artifactId>
                        <version>2.1.17-SNAPSHOT</version>
                </dependency>
                <dependency>
                        <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.core</artifactId>
+                       <artifactId>org.argeo.slc.spring</artifactId>
                        <version>2.1.17-SNAPSHOT</version>
                </dependency>
 
index fb76254e2b98a12d44abefa44459123ca495616d..2b27e378d6b745dae1051d629706dfd9d2c4ccdf 100644 (file)
@@ -1,5 +1,6 @@
 Import-Package: javax.jcr.nodetype,\
 javax.jcr.security,\
+org.argeo.node,\
 org.apache.tools.ant.*;resolution:="optional",\
 junit.framework;resolution:="optional",\
 org.osgi.*;version=0.0.0,\
index 29ba3cf979ea5e73cc79ea5774153d18cb5f6a8d..5462d544609d1a31a49723421b23de4566865957 100644 (file)
                        <version>${version.argeo-commons}</version>
                </dependency>
 
+               <!-- Commons -->
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.osgi.boot</artifactId>
+                       <version>${version.argeo-commons}</version>
+                       <scope>provided</scope>
+               </dependency>
+
                <!-- SLC -->
                <dependency>
                        <groupId>org.argeo.slc</groupId>
                        <artifactId>org.argeo.slc.api</artifactId>
                        <version>2.1.17-SNAPSHOT</version>
                </dependency>
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.jcr</artifactId>
+                       <version>2.1.17-SNAPSHOT</version>
+               </dependency>
 
                <!-- Spring -->
                <dependency>
                        <groupId>org.argeo.tp.apache.ant</groupId>
                        <artifactId>org.apache.ant</artifactId>
                </dependency>
-
        </dependencies>
 </project>
\ No newline at end of file
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/Attachment.java b/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/Attachment.java
deleted file mode 100644 (file)
index ecde0b9..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.core.attachment;
-
-public interface Attachment {
-       public String getUuid();
-
-       public void setUuid(String uuid);
-
-       public String getName();
-
-       public String getContentType();
-}
index eb484c92c36ed113b20af77613ddb163e8e616d7..9b91207b33cbaf2af729147d5d3014ffd7996d5e 100644 (file)
@@ -15,6 +15,7 @@
  */
 package org.argeo.slc.core.attachment;
 
+import org.argeo.slc.attachment.Attachment;
 import org.springframework.core.io.Resource;
 
 public interface AttachmentUploader {
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/AttachmentsEnabled.java b/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/AttachmentsEnabled.java
deleted file mode 100644 (file)
index 780a6a4..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.core.attachment;
-
-public interface AttachmentsEnabled {
-       public void addAttachment(Attachment attachment);
-}
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/AttachmentsStorage.java b/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/AttachmentsStorage.java
deleted file mode 100644 (file)
index 2214afa..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.core.attachment;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-
-public interface AttachmentsStorage {
-       public void retrieveAttachment(Attachment attachment,
-                       OutputStream outputStream);
-
-       /** Does NOT close the provided input stream. */
-       public void storeAttachment(Attachment attachment, InputStream inputStream);
-}
index 3b7e62dac1ebb1ed2c986cea87153803b2dabc89..e6bd8e776256e36dba1f5d2ccf0aeca7393393ca 100644 (file)
@@ -30,6 +30,8 @@ import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.slc.SlcException;
+import org.argeo.slc.attachment.Attachment;
+import org.argeo.slc.attachment.AttachmentsStorage;
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.core.io.Resource;
 
index 6248dd71e5425628c498575e090dd29b9deaafcb..e9a44c959474e504cf4243f815b9a9d06ee32b8f 100644 (file)
@@ -18,6 +18,8 @@ package org.argeo.slc.core.attachment;
 import java.io.Serializable;
 import java.util.UUID;
 
+import org.argeo.slc.attachment.Attachment;
+
 public class SimpleAttachment implements Attachment, Serializable {
        private static final long serialVersionUID = 6615155908800610606L;
        private String uuid = UUID.randomUUID().toString();
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/core/execution/AbstractExecutionValue.java b/org.argeo.slc.spring/src/org/argeo/slc/core/execution/AbstractExecutionValue.java
deleted file mode 100644 (file)
index 131ffec..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.core.execution;
-
-import java.io.Serializable;
-
-/** Value to be used by an execution */
-public abstract class AbstractExecutionValue implements Serializable {
-       private static final long serialVersionUID = 1558444746120706961L;
-}
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/core/execution/AbstractSpecAttribute.java b/org.argeo.slc.spring/src/org/argeo/slc/core/execution/AbstractSpecAttribute.java
deleted file mode 100644 (file)
index 109c033..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.core.execution;
-
-import java.io.Serializable;
-
-import org.argeo.slc.execution.ExecutionSpecAttribute;
-
-/** Canonical implementation of the execution spec attribute booleans. */
-public abstract class AbstractSpecAttribute implements ExecutionSpecAttribute,
-               Serializable {
-       private static final long serialVersionUID = 6494963738891709440L;
-       private Boolean isImmutable = false;
-       private Boolean isConstant = false;
-       private Boolean isHidden = false;
-
-       private String description;
-
-       /** Has to be set at instantiation */
-       public Boolean getIsImmutable() {
-               return isImmutable;
-       }
-
-       public void setIsImmutable(Boolean isImmutable) {
-               this.isImmutable = isImmutable;
-       }
-
-       /** Cannot be overridden at runtime */
-       public Boolean getIsConstant() {
-               return isConstant;
-       }
-
-       public void setIsConstant(Boolean isConstant) {
-               this.isConstant = isConstant;
-       }
-
-       /** Should not be shown to the end user */
-       public Boolean getIsHidden() {
-               return isHidden;
-       }
-
-       public void setIsHidden(Boolean isHidden) {
-               this.isHidden = isHidden;
-       }
-
-       /*
-        * DEPRECATED
-        */
-       /** @deprecated use {@link #getIsImmutable()} instead */
-       public Boolean getIsParameter() {
-               return isImmutable;
-       }
-
-       /** @deprecated use {@link #getIsConstant()} instead */
-       public Boolean getIsFrozen() {
-               return isConstant;
-       }
-
-       /** @deprecated use {@link #setIsImmutable(Boolean)} instead */
-       public void setIsParameter(Boolean isParameter) {
-               this.isImmutable = isParameter;
-       }
-
-       /** @deprecated use {@link #setIsConstant(Boolean)} instead */
-       public void setIsFrozen(Boolean isFrozen) {
-               this.isConstant = isFrozen;
-       }
-
-       public void setDescription(String description) {
-               this.description = description;
-       }
-
-       public String getDescription() {
-               return description;
-       }
-
-}
index beac9175a19e2876c027b718ebb87b71370d330b..41a2f27e980f867556617ba3c1a41696b7dd9d83 100644 (file)
@@ -30,6 +30,11 @@ import org.argeo.slc.execution.ExecutionFlowDescriptorConverter;
 import org.argeo.slc.execution.ExecutionModuleDescriptor;
 import org.argeo.slc.execution.ExecutionSpec;
 import org.argeo.slc.execution.ExecutionSpecAttribute;
+import org.argeo.slc.execution.RefSpecAttribute;
+import org.argeo.slc.execution.RefValue;
+import org.argeo.slc.primitive.PrimitiveSpecAttribute;
+import org.argeo.slc.primitive.PrimitiveUtils;
+import org.argeo.slc.primitive.PrimitiveValue;
 import org.springframework.aop.scope.ScopedObject;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.BeanFactory;
index 2bce125772818ffb1fa48f7e7bc340bb65c33869..f36a71f738cf0b2b9591322043c561a5f6d5d76c 100644 (file)
@@ -25,6 +25,8 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.slc.execution.ExecutionSpec;
 import org.argeo.slc.execution.ExecutionSpecAttribute;
+import org.argeo.slc.execution.RefSpecAttribute;
+import org.argeo.slc.execution.RefValueChoice;
 import org.springframework.beans.factory.BeanNameAware;
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.beans.factory.NoSuchBeanDefinitionException;
index 60e93ec15c08b40d24882f7ffa431f7e8d56da8b..211fc4cf9fa8db366f743ffa3c4675f09a10a716 100644 (file)
@@ -22,6 +22,9 @@ import org.apache.commons.logging.LogFactory;
 import org.argeo.slc.SlcException;\r
 import org.argeo.slc.execution.ExecutionFlow;\r
 import org.argeo.slc.execution.ExecutionSpecAttribute;\r
+import org.argeo.slc.execution.RefSpecAttribute;\r
+import org.argeo.slc.primitive.PrimitiveSpecAttribute;\r
+import org.argeo.slc.primitive.PrimitiveUtils;\r
 \r
 /** Manage parameters that need to be set during the instantiation of a flow */\r
 public class InstantiationManager {\r
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/core/execution/PrimitiveAccessor.java b/org.argeo.slc.spring/src/org/argeo/slc/core/execution/PrimitiveAccessor.java
deleted file mode 100644 (file)
index 18d1b98..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.core.execution;
-
-/** Abstraction of access to primitive values */
-public interface PrimitiveAccessor {
-       public final static String TYPE_STRING = "string";
-       /**
-        * As of Argeo 1, passwords are NOT stored encrypted, just hidden in the UI,
-        * but stored in plain text in JCR. Use keyring instead.
-        */
-       public final static String TYPE_PASSWORD = "password";
-       public final static String TYPE_INTEGER = "integer";
-       public final static String TYPE_LONG = "long";
-       public final static String TYPE_FLOAT = "float";
-       public final static String TYPE_DOUBLE = "double";
-       public final static String TYPE_BOOLEAN = "boolean";
-
-       public String getType();
-
-       public Object getValue();
-
-       public void setValue(Object value);
-}
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/core/execution/PrimitiveSpecAttribute.java b/org.argeo.slc.spring/src/org/argeo/slc/core/execution/PrimitiveSpecAttribute.java
deleted file mode 100644 (file)
index fe8412c..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.core.execution;
-
-import org.argeo.slc.SlcException;
-
-/**
- * A spec attribute wrapping a primitive value.
- * 
- * @see PrimitiveAccessor
- */
-public class PrimitiveSpecAttribute extends AbstractSpecAttribute implements
-               PrimitiveAccessor {
-       private static final long serialVersionUID = -566676381839825483L;
-       private String type = "string";
-       private Object value = null;
-
-       public PrimitiveSpecAttribute() {
-       }
-
-       public PrimitiveSpecAttribute(String type, Object value) {
-               this.type = type;
-               this.value = value;
-       }
-
-       public Object getValue() {
-               return value;
-       }
-
-       public void setValue(Object value) {
-               this.value = value;
-       }
-
-       public String getType() {
-               return type;
-       }
-
-       public void setType(String type) {
-               // check whether type is recognized.
-               if (PrimitiveUtils.typeAsClass(type) == null)
-                       throw new SlcException("Unrecognized type " + type);
-               this.type = type;
-
-       }
-
-       @Override
-       public String toString() {
-               return "Primitive spec attribute [" + type + "]"
-                               + (value != null ? "=" + value : "");
-       }
-
-}
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/core/execution/PrimitiveUtils.java b/org.argeo.slc.spring/src/org/argeo/slc/core/execution/PrimitiveUtils.java
deleted file mode 100644 (file)
index 4268b8b..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.core.execution;
-
-/** Converts to and from primitive types. */
-public class PrimitiveUtils {
-       /**
-        * @deprecated Use {@link PrimitiveAccessor#TYPE_STRING} instead
-        */
-       public final static String TYPE_STRING = PrimitiveAccessor.TYPE_STRING;
-       /**
-        * @deprecated Use {@link PrimitiveAccessor#TYPE_INTEGER} instead
-        */
-       public final static String TYPE_INTEGER = PrimitiveAccessor.TYPE_INTEGER;
-       /**
-        * @deprecated Use {@link PrimitiveAccessor#TYPE_LONG} instead
-        */
-       public final static String TYPE_LONG = PrimitiveAccessor.TYPE_LONG;
-       /**
-        * @deprecated Use {@link PrimitiveAccessor#TYPE_FLOAT} instead
-        */
-       public final static String TYPE_FLOAT = PrimitiveAccessor.TYPE_FLOAT;
-       /**
-        * @deprecated Use {@link PrimitiveAccessor#TYPE_DOUBLE} instead
-        */
-       public final static String TYPE_DOUBLE = PrimitiveAccessor.TYPE_DOUBLE;
-       /**
-        * @deprecated Use {@link PrimitiveAccessor#TYPE_BOOLEAN} instead
-        */
-       public final static String TYPE_BOOLEAN = PrimitiveAccessor.TYPE_BOOLEAN;
-
-       private PrimitiveUtils() {
-
-       }
-
-       /** @return the class or null if the provided type is not a primitive */
-       public static Class<?> typeAsClass(String type) {
-               if (PrimitiveAccessor.TYPE_STRING.equals(type))
-                       return String.class;
-               else if (PrimitiveAccessor.TYPE_PASSWORD.equals(type))
-                       return char[].class;
-               else if (PrimitiveAccessor.TYPE_INTEGER.equals(type))
-                       return Integer.class;
-               else if (PrimitiveAccessor.TYPE_LONG.equals(type))
-                       return Long.class;
-               else if (PrimitiveAccessor.TYPE_FLOAT.equals(type))
-                       return Float.class;
-               else if (PrimitiveAccessor.TYPE_DOUBLE.equals(type))
-                       return Double.class;
-               else if (PrimitiveAccessor.TYPE_BOOLEAN.equals(type))
-                       return Boolean.class;
-               else
-                       return null;
-       }
-
-       /** @return the type or null if the provided class is not a primitive */
-       public static String classAsType(Class<?> clss) {
-               if (String.class.isAssignableFrom(clss))
-                       return PrimitiveAccessor.TYPE_STRING;
-               else if (char[].class.isAssignableFrom(clss))
-                       return PrimitiveAccessor.TYPE_PASSWORD;
-               else if (Integer.class.isAssignableFrom(clss))
-                       return PrimitiveAccessor.TYPE_INTEGER;
-               else if (Long.class.isAssignableFrom(clss))
-                       return PrimitiveAccessor.TYPE_LONG;
-               else if (Float.class.isAssignableFrom(clss))
-                       return PrimitiveAccessor.TYPE_FLOAT;
-               else if (Double.class.isAssignableFrom(clss))
-                       return PrimitiveAccessor.TYPE_DOUBLE;
-               else if (Boolean.class.isAssignableFrom(clss))
-                       return PrimitiveAccessor.TYPE_BOOLEAN;
-               else
-                       return null;
-       }
-
-       /** Parse string as an object. Passwords are returned as String.*/
-       public static Object convert(String type, String str) {
-               if (PrimitiveAccessor.TYPE_STRING.equals(type)) {
-                       return str;
-               } else if (PrimitiveAccessor.TYPE_PASSWORD.equals(type)) {
-                       return str;
-               } else if (PrimitiveAccessor.TYPE_INTEGER.equals(type)) {
-                       return (Integer.parseInt(str));
-               } else if (PrimitiveAccessor.TYPE_LONG.equals(type)) {
-                       return (Long.parseLong(str));
-               } else if (PrimitiveAccessor.TYPE_FLOAT.equals(type)) {
-                       return (Float.parseFloat(str));
-               } else if (PrimitiveAccessor.TYPE_DOUBLE.equals(type)) {
-                       return (Double.parseDouble(str));
-               } else if (PrimitiveAccessor.TYPE_BOOLEAN.equals(type)) {
-                       return (Boolean.parseBoolean(str));
-               } else {
-                       return str;
-               }
-       }
-
-}
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/core/execution/PrimitiveValue.java b/org.argeo.slc.spring/src/org/argeo/slc/core/execution/PrimitiveValue.java
deleted file mode 100644 (file)
index 3dedb9c..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.core.execution;
-
-/** Primitive value to be used by an execution. */
-public class PrimitiveValue extends AbstractExecutionValue implements
-               PrimitiveAccessor {
-       private static final long serialVersionUID = 533414290998374166L;
-
-       private String type;
-
-       private Object value;
-
-       public PrimitiveValue() {
-       }
-
-       public PrimitiveValue(String type, Object value) {
-               super();
-               this.type = type;
-               this.value = value;
-       }
-
-       public String getType() {
-               return type;
-       }
-
-       public void setType(String type) {
-               this.type = type;
-       }
-
-       public Object getValue() {
-               return value;
-       }
-
-       public void setValue(Object value) {
-               this.value = value;
-       }
-
-}
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/core/execution/RefSpecAttribute.java b/org.argeo.slc.spring/src/org/argeo/slc/core/execution/RefSpecAttribute.java
deleted file mode 100644 (file)
index 8e4f617..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.core.execution;
-
-import java.util.List;
-
-/** A spec attribute whose value is a reference to a full fledged object. */
-public class RefSpecAttribute extends AbstractSpecAttribute implements
-               Cloneable {
-       private static final long serialVersionUID = -3427797452955753574L;
-       private transient Class<?> targetClass = String.class;
-       /** Read only. */
-       private String targetClassName;
-       private transient Object value = null;
-
-       /** List to be chosen from */
-       private List<RefValueChoice> choices = null;
-
-       public Object getValue() {
-               return value;
-       }
-
-       public void setValue(Object value) {
-               this.value = value;
-       }
-
-       /** Default is {@link String} */
-       public Class<?> getTargetClass() {
-               return targetClass;
-       }
-
-       public void setTargetClass(Class<?> targetClass) {
-               this.targetClass = targetClass;
-               this.targetClassName = targetClass.getName();
-       }
-
-       public String getTargetClassName() {
-               return targetClassName;
-       }
-
-       /** @return can be null */
-       public List<RefValueChoice> getChoices() {
-               return choices;
-       }
-
-       public void setChoices(List<RefValueChoice> choices) {
-               this.choices = choices;
-       }
-
-       @Override
-       protected Object clone() throws CloneNotSupportedException {
-               RefSpecAttribute rsa = new RefSpecAttribute();
-               rsa.setTargetClass(targetClass);
-               rsa.setChoices(choices);
-               return rsa;
-       }
-
-       @Override
-       public String toString() {
-               return "Ref spec attribute [" + targetClass + "]"
-                               + (value != null ? "=" + value : "");
-       }
-
-}
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/core/execution/RefValue.java b/org.argeo.slc.spring/src/org/argeo/slc/core/execution/RefValue.java
deleted file mode 100644 (file)
index 0a24bc4..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.core.execution;
-
-/** Reference value to be used by an execution */
-public class RefValue extends AbstractExecutionValue {
-       private static final long serialVersionUID = -8951231456757181687L;
-       private String ref;
-       private String type;
-
-       public RefValue() {
-       }
-
-       public RefValue(String ref) {
-               super();
-               this.ref = ref;
-       }
-
-       public String getRef() {
-               return ref;
-       }
-
-       public void setRef(String ref) {
-               this.ref = ref;
-       }
-
-       public String getType() {
-               return type;
-       }
-
-       public void setType(String type) {
-               this.type = type;
-       }
-
-       @Override
-       public String toString() {
-               return "Ref Value [" + type + "=" + ref + "]";
-       }
-
-}
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/core/execution/RefValueChoice.java b/org.argeo.slc.spring/src/org/argeo/slc/core/execution/RefValueChoice.java
deleted file mode 100644 (file)
index 5e1f9c2..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.core.execution;
-
-import java.io.Serializable;
-
-/** A choice of ref value to be shown to the end user. */
-public class RefValueChoice implements Serializable {
-       private static final long serialVersionUID = -1133645722307507774L;
-       private String name;
-       private String description;
-
-       public RefValueChoice() {
-       }
-
-       public RefValueChoice(String name, String description) {
-               this.name = name;
-               this.description = description;
-       }
-
-       public String getName() {
-               return name;
-       }
-
-       public void setName(String name) {
-               this.name = name;
-       }
-
-       public String getDescription() {
-               return description;
-       }
-
-       public void setDescription(String description) {
-               this.description = description;
-       }
-
-}
index 13cc519184888de33786e01285551d0ee8938c80..93f27b281f28a58d1005ae5c9a4eaad8ac6029c3 100644 (file)
@@ -22,9 +22,9 @@ import java.util.Map;
 import java.util.UUID;
 
 import org.argeo.slc.SlcException;
-import org.argeo.slc.core.attachment.Attachment;
+import org.argeo.slc.attachment.Attachment;
+import org.argeo.slc.attachment.AttachmentsEnabled;
 import org.argeo.slc.core.attachment.AttachmentUploader;
-import org.argeo.slc.core.attachment.AttachmentsEnabled;
 import org.springframework.core.io.Resource;
 
 public class UploadAttachments implements Runnable {
index 761e26dd1e24a308258358422f9d52dc817a0dec..bb2d24516f548c5b12a07f346015ff26e0551497 100644 (file)
@@ -20,9 +20,9 @@ import java.util.List;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.slc.core.execution.DefaultExecutionSpec;
-import org.argeo.slc.core.execution.PrimitiveSpecAttribute;
-import org.argeo.slc.core.execution.RefSpecAttribute;
-import org.argeo.slc.core.execution.RefValueChoice;
+import org.argeo.slc.execution.RefSpecAttribute;
+import org.argeo.slc.execution.RefValueChoice;
+import org.argeo.slc.primitive.PrimitiveSpecAttribute;
 import org.springframework.beans.factory.config.BeanDefinition;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 import org.springframework.beans.factory.support.ManagedList;
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/jcr/JcrMetadataWriter.java b/org.argeo.slc.spring/src/org/argeo/slc/jcr/JcrMetadataWriter.java
deleted file mode 100644 (file)
index c4922d3..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.jcr;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-
-/**
- * Writes arbitrary metadata into a child node of a given node (or the node
- * itself if metadata node name is set to null)
- */
-public class JcrMetadataWriter implements Runnable {
-       private final static Log log = LogFactory.getLog(JcrMetadataWriter.class);
-
-       private Node baseNode;
-       private String metadataNodeName = SlcNames.SLC_METADATA;
-
-       private Map<String, String> metadata = new HashMap<String, String>();
-
-       public void run() {
-               try {
-                       Node metadataNode;
-                       if (metadataNodeName != null)
-                               metadataNode = baseNode.hasNode(metadataNodeName) ? baseNode
-                                               .getNode(metadataNodeName) : baseNode
-                                               .addNode(metadataNodeName);
-                       else
-                               metadataNode = baseNode;
-
-                       for (String key : metadata.keySet())
-                               metadataNode.setProperty(key, metadata.get(key));
-
-                       baseNode.getSession().save();
-
-                       if (log.isDebugEnabled())
-                               log.debug("Wrote " + metadata.size() + " metadata entries to "
-                                               + metadataNode);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot write metadata to " + baseNode, e);
-               } finally {
-                       JcrUtils.discardUnderlyingSessionQuietly(baseNode);
-               }
-
-       }
-
-       public void setBaseNode(Node baseNode) {
-               this.baseNode = baseNode;
-       }
-
-       public void setMetadataNodeName(String metadataNodeName) {
-               this.metadataNodeName = metadataNodeName;
-       }
-
-       public void setMetadata(Map<String, String> metadata) {
-               this.metadata = metadata;
-       }
-
-}
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/jcr/JcrTestResult.java b/org.argeo.slc.spring/src/org/argeo/slc/jcr/JcrTestResult.java
deleted file mode 100644 (file)
index c9ec874..0000000
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.jcr;
-
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.PropertyIterator;
-import javax.jcr.Repository;
-import javax.jcr.Session;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryManager;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.core.attachment.Attachment;
-import org.argeo.slc.core.attachment.AttachmentsEnabled;
-import org.argeo.slc.test.TestResult;
-import org.argeo.slc.test.TestResultPart;
-import org.argeo.slc.test.TestRun;
-import org.argeo.slc.test.TestStatus;
-
-/**
- * {@link TestResult} wrapping a JCR node of type
- * {@link SlcTypes#SLC_TEST_RESULT}.
- */
-public class JcrTestResult implements TestResult, SlcNames, AttachmentsEnabled {
-       private final static Log log = LogFactory.getLog(JcrTestResult.class);
-
-       /** Should only be set for an already existing result. */
-       private String uuid;
-       private Repository repository;
-       private Session session;
-       /**
-        * For testing purposes, best practice is to not set them explicitely but
-        * via other mechanisms such as JAAS or SPring Security.
-        */
-       private Credentials credentials = null;
-       private String resultType = SlcTypes.SLC_TEST_RESULT;
-
-       /** cached for performance purposes */
-       private String nodeIdentifier = null;
-
-       private Map<String, String> attributes = new HashMap<String, String>();
-
-       public void init() {
-               try {
-                       session = repository.login(credentials);
-                       if (uuid == null) {
-                               // create new result
-                               uuid = UUID.randomUUID().toString();
-                               String path = SlcJcrUtils.createResultPath(session, uuid);
-                               Node resultNode = JcrUtils.mkdirs(session, path, resultType);
-                               resultNode.setProperty(SLC_UUID, uuid);
-                               for (String attr : attributes.keySet()) {
-                                       String property = attr;
-                                       // compatibility with legacy applications
-                                       if ("testCase".equals(attr))
-                                               property = SLC_TEST_CASE;
-                                       else if ("testCaseType".equals(attr))
-                                               property = SLC_TEST_CASE_TYPE;
-                                       resultNode.setProperty(property, attributes.get(attr));
-                               }
-                               session.save();
-                               if (log.isDebugEnabled())
-                                       log.debug("Created test result " + uuid);
-                       }
-               } catch (Exception e) {
-                       JcrUtils.discardQuietly(session);
-                       throw new SlcException("Cannot initialize JCR result", e);
-               }
-       }
-
-       public void destroy() {
-               JcrUtils.logoutQuietly(session);
-               if (log.isTraceEnabled())
-                       log.trace("Logged out session for result " + uuid);
-       }
-
-       public Node getNode() {
-               try {
-                       Node resultNode;
-                       if (nodeIdentifier != null) {
-                               return session.getNodeByIdentifier(nodeIdentifier);
-                       } else {
-                               QueryManager qm = session.getWorkspace().getQueryManager();
-                               Query q = qm.createQuery("select * from ["
-                                               + SlcTypes.SLC_TEST_RESULT + "] where [slc:uuid]='"
-                                               + uuid + "'", Query.JCR_SQL2);
-                               resultNode = JcrUtils.querySingleNode(q);
-                               if (resultNode != null)
-                                       nodeIdentifier = resultNode.getIdentifier();
-                       }
-                       return resultNode;
-               } catch (Exception e) {
-                       throw new SlcException("Cannot get result node", e);
-               }
-       }
-
-       public void notifyTestRun(TestRun testRun) {
-               // TODO store meta data about the test running
-               // if (log.isDebugEnabled())
-               // log.debug("Running test "
-               // + testRun.getTestDefinition().getClass().getName() + "...");
-       }
-
-       public void addResultPart(TestResultPart testResultPart) {
-               Node node = getNode();
-
-               try {
-                       // error : revert all unsaved changes on the resultNode to be sure
-                       // it is in a consistant state
-                       if (testResultPart.getExceptionMessage() != null)
-                               JcrUtils.discardQuietly(node.getSession());
-                       node.getSession().save();
-
-                       // add the new result part, retrieving status information
-                       Node resultPartNode = node.addNode(SlcNames.SLC_RESULT_PART,
-                                       SlcTypes.SLC_CHECK);
-                       resultPartNode.setProperty(SLC_SUCCESS, testResultPart.getStatus()
-                                       .equals(TestStatus.PASSED));
-                       if (testResultPart.getMessage() != null)
-                               resultPartNode.setProperty(SLC_MESSAGE,
-                                               testResultPart.getMessage());
-                       if (testResultPart.getStatus().equals(TestStatus.ERROR)) {
-                               resultPartNode.setProperty(SLC_ERROR_MESSAGE,
-                                               (testResultPart.getExceptionMessage() == null) ? ""
-                                                               : testResultPart.getExceptionMessage());
-                       }
-
-                       // helper update aggregate status node
-                       Node mainStatus;
-                       if (!node.hasNode(SLC_AGGREGATED_STATUS)) {
-
-                               mainStatus = node.addNode(SLC_AGGREGATED_STATUS,
-                                               SlcTypes.SLC_CHECK);
-                               mainStatus.setProperty(SLC_SUCCESS,
-                                               resultPartNode.getProperty(SLC_SUCCESS).getBoolean());
-                               if (resultPartNode.hasProperty(SLC_MESSAGE))
-                                       mainStatus.setProperty(SLC_MESSAGE, resultPartNode
-                                                       .getProperty(SLC_MESSAGE).getString());
-                               if (resultPartNode.hasProperty(SLC_ERROR_MESSAGE))
-                                       mainStatus.setProperty(SLC_ERROR_MESSAGE, resultPartNode
-                                                       .getProperty(SLC_ERROR_MESSAGE).getString());
-                       } else {
-                               mainStatus = node.getNode(SLC_AGGREGATED_STATUS);
-                               if (mainStatus.hasProperty(SLC_ERROR_MESSAGE)) {
-                                       // main status already in error we do nothing
-                               } else if (resultPartNode.hasProperty(SLC_ERROR_MESSAGE)) {
-                                       // main status was not in error and new result part is in
-                                       // error; we update main status
-                                       mainStatus.setProperty(SLC_SUCCESS, false);
-                                       mainStatus.setProperty(SLC_ERROR_MESSAGE, resultPartNode
-                                                       .getProperty(SLC_ERROR_MESSAGE).getString());
-                                       if (resultPartNode.hasProperty(SLC_MESSAGE))
-                                               mainStatus.setProperty(SLC_MESSAGE, resultPartNode
-                                                               .getProperty(SLC_MESSAGE).getString());
-                                       else
-                                               // remove old message to remain consistent
-                                               mainStatus.setProperty(SLC_MESSAGE, "");
-                               } else if (!mainStatus.getProperty(SLC_SUCCESS).getBoolean()) {
-                                       // main status was already failed and new result part is not
-                                       // in error, we do nothing
-                               } else if (!resultPartNode.getProperty(SLC_SUCCESS)
-                                               .getBoolean()) {
-                                       // new resultPart that is failed
-                                       mainStatus.setProperty(SLC_SUCCESS, false);
-                                       if (resultPartNode.hasProperty(SLC_MESSAGE))
-                                               mainStatus.setProperty(SLC_MESSAGE, resultPartNode
-                                                               .getProperty(SLC_MESSAGE).getString());
-                                       else
-                                               // remove old message to remain consistent
-                                               mainStatus.setProperty(SLC_MESSAGE, "");
-                               } else if (resultPartNode.hasProperty(SLC_MESSAGE)
-                                               && (!mainStatus.hasProperty(SLC_MESSAGE) || (""
-                                                               .equals(mainStatus.getProperty(SLC_MESSAGE)
-                                                                               .getString().trim())))) {
-                                       mainStatus.setProperty(SLC_MESSAGE, resultPartNode
-                                                       .getProperty(SLC_MESSAGE).getString());
-                               }
-                       }
-                       JcrUtils.updateLastModified(node);
-                       node.getSession().save();
-               } catch (Exception e) {
-                       JcrUtils.discardUnderlyingSessionQuietly(node);
-                       throw new SlcException("Cannot add ResultPart to node " + node, e);
-               }
-       }
-
-       public String getUuid() {
-               Node node = getNode();
-               try {
-                       return node.getProperty(SLC_UUID).getString();
-               } catch (Exception e) {
-                       throw new SlcException("Cannot get UUID from " + node, e);
-               }
-       }
-
-       /** JCR session is NOT logged out */
-       public void close() {
-               Node node = getNode();
-               try {
-                       if (node.hasNode(SLC_COMPLETED))
-                               return;
-                       node.setProperty(SLC_COMPLETED, new GregorianCalendar());
-                       JcrUtils.updateLastModified(node);
-                       node.getSession().save();
-               } catch (Exception e) {
-                       JcrUtils.discardUnderlyingSessionQuietly(node);
-                       throw new SlcException("Cannot get close date from " + node, e);
-               }
-       }
-
-       public Date getCloseDate() {
-               Node node = getNode();
-               try {
-                       if (!node.hasNode(SLC_COMPLETED))
-                               return null;
-                       return node.getProperty(SLC_COMPLETED).getDate().getTime();
-               } catch (Exception e) {
-                       throw new SlcException("Cannot get close date from " + node, e);
-               }
-       }
-
-       public Map<String, String> getAttributes() {
-               Node node = getNode();
-               try {
-                       Map<String, String> map = new HashMap<String, String>();
-                       PropertyIterator pit = node.getProperties();
-                       while (pit.hasNext()) {
-                               Property p = pit.nextProperty();
-                               if (!p.isMultiple())
-                                       map.put(p.getName(), p.getValue().getString());
-                       }
-                       return map;
-               } catch (Exception e) {
-                       throw new SlcException("Cannot get close date from " + node, e);
-               }
-       }
-
-       public void addAttachment(Attachment attachment) {
-               // TODO implement it
-       }
-
-       public void setUuid(String uuid) {
-               this.uuid = uuid;
-       }
-
-       public void setRepository(Repository repository) {
-               this.repository = repository;
-       }
-
-       public void setResultType(String resultType) {
-               this.resultType = resultType;
-       }
-
-       public void setAttributes(Map<String, String> attributes) {
-               if (uuid != null)
-                       throw new SlcException(
-                                       "Attributes cannot be set on an already initialized test result."
-                                                       + " Update the related JCR node directly instead.");
-               this.attributes = attributes;
-       }
-
-       public void setCredentials(Credentials credentials) {
-               this.credentials = credentials;
-       }
-}
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/jcr/SlcJcrConstants.java b/org.argeo.slc.spring/src/org/argeo/slc/jcr/SlcJcrConstants.java
deleted file mode 100644 (file)
index 3190c85..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.jcr;
-
-import org.argeo.slc.SlcNames;
-
-/** JCR related constants used across SLC */
-public interface SlcJcrConstants {
-       public final static String PROPERTY_PATH = "argeo.slc.jcr.path";
-
-       public final static String SLC_BASE_PATH = "/" + SlcNames.SLC_SYSTEM;
-       public final static String AGENTS_BASE_PATH = SLC_BASE_PATH + "/"
-                       + SlcNames.SLC_AGENTS;
-       public final static String VM_AGENT_FACTORY_PATH = AGENTS_BASE_PATH + "/"
-                       + SlcNames.SLC_VM;
-}
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/jcr/SlcJcrResultUtils.java b/org.argeo.slc.spring/src/org/argeo/slc/jcr/SlcJcrResultUtils.java
deleted file mode 100644 (file)
index 6353804..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.jcr;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.node.NodeUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-
-/**
- * Utilities around the SLC JCR Result model. Note that it relies on fixed base
- * paths (convention over configuration) for optimization purposes.
- */
-public class SlcJcrResultUtils {
-
-       /**
-        * Returns the path to the current slc:result node
-        */
-       public static String getSlcResultsBasePath(Session session) {
-               try {
-                       Node userHome = NodeUtils.getUserHome(session);
-                       if (userHome == null)
-                               throw new SlcException("No user home available for "
-                                               + session.getUserID());
-                       return userHome.getPath() + '/' + SlcNames.SLC_SYSTEM + '/'
-                                       + SlcNames.SLC_RESULTS;
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while getting Slc Results Base Path.", re);
-               }
-       }
-
-       /**
-        * Returns the base node to store SlcResults. If it does not exists, it is
-        * created. If a node already exists at the given path with the wrong type,
-        * it throws an exception.
-        * 
-        * @param session
-        * @return
-        */
-       public static Node getSlcResultsParentNode(Session session) {
-               try {
-                       String absPath = getSlcResultsBasePath(session);
-                       if (session.nodeExists(absPath)) {
-                               Node currNode = session.getNode(absPath);
-                               if (currNode.isNodeType(NodeType.NT_UNSTRUCTURED))
-                                       return currNode;
-                               else
-                                       throw new SlcException(
-                                                       "A node already exists at this path : " + absPath
-                                                                       + " that has the wrong type. ");
-                       } else {
-                               Node slcResParNode = JcrUtils.mkdirs(session, absPath);
-                               slcResParNode.setPrimaryType(NodeType.NT_UNSTRUCTURED);
-                               session.save();
-                               return slcResParNode;
-                       }
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while creating slcResult root parent node.",
-                                       re);
-               }
-       }
-
-       /**
-        * Returns the path to the current Result UI specific node, depending the
-        * current user
-        */
-       public static String getMyResultsBasePath(Session session) {
-               try {
-                       Node userHome = NodeUtils.getUserHome(session);
-                       if (userHome == null)
-                               throw new SlcException("No user home available for "
-                                               + session.getUserID());
-                       return userHome.getPath() + '/' + SlcNames.SLC_SYSTEM + '/'
-                                       + SlcNames.SLC_MY_RESULTS;
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while getting Slc Results Base Path.", re);
-               }
-       }
-
-       /**
-        * Creates a new node with type SlcTypes.SLC_MY_RESULT_ROOT_FOLDER at the
-        * given absolute path. If a node already exists at the given path, returns
-        * that node if it has the correct type and throws an exception otherwise.
-        * 
-        * @param session
-        * @return
-        */
-       public static Node getMyResultParentNode(Session session) {
-               try {
-                       String absPath = getMyResultsBasePath(session);
-                       if (session.nodeExists(absPath)) {
-                               Node currNode = session.getNode(absPath);
-                               if (currNode.isNodeType(SlcTypes.SLC_MY_RESULT_ROOT_FOLDER))
-                                       return currNode;
-                               else
-                                       throw new SlcException(
-                                                       "A node already exists at this path : " + absPath
-                                                                       + " that has the wrong type. ");
-                       } else {
-                               Node myResParNode = JcrUtils.mkdirs(session, absPath);
-                               myResParNode.setPrimaryType(SlcTypes.SLC_MY_RESULT_ROOT_FOLDER);
-                               session.save();
-                               return myResParNode;
-                       }
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while creating user MyResult base node.",
-                                       re);
-               }
-       }
-
-       /**
-        * Creates a new node with type SlcTypes.SLC_RESULT_FOLDER at the given
-        * absolute path. If a node already exists at the given path, returns that
-        * node if it has the correct type and throws an exception otherwise.
-        * 
-        * @param session
-        * @param absPath
-        * @return
-        */
-       public static synchronized Node createResultFolderNode(Session session,
-                       String absPath) {
-               try {
-                       if (session.nodeExists(absPath)) {
-                               // Sanity check
-                               Node currNode = session.getNode(absPath);
-                               if (currNode.isNodeType(SlcTypes.SLC_RESULT_FOLDER))
-                                       return currNode;
-                               else
-                                       throw new SlcException(
-                                                       "A node already exists at this path : " + absPath
-                                                                       + " that has the wrong type. ");
-                       }
-                       Node rfNode = JcrUtils.mkdirs(session, absPath);
-                       rfNode.setPrimaryType(SlcTypes.SLC_RESULT_FOLDER);
-                       Node statusNode = rfNode.addNode(SlcNames.SLC_AGGREGATED_STATUS,
-                                       SlcTypes.SLC_CHECK);
-                       statusNode.setProperty(SlcNames.SLC_SUCCESS, true);
-                       session.save();
-                       return rfNode;
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while creating Result Folder node.", re);
-               }
-       }
-}
\ No newline at end of file
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/jcr/SlcJcrUtils.java b/org.argeo.slc.spring/src/org/argeo/slc/jcr/SlcJcrUtils.java
deleted file mode 100644 (file)
index 137e298..0000000
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.jcr;
-
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.node.NodeUtils;
-import org.argeo.slc.DefaultNameVersion;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.core.execution.PrimitiveAccessor;
-import org.argeo.slc.core.execution.PrimitiveUtils;
-import org.argeo.slc.deploy.ModuleDescriptor;
-import org.argeo.slc.test.TestStatus;
-
-/**
- * Utilities around the SLC JCR model. Note that it relies on fixed base paths
- * (convention over configuration) for optimization purposes.
- */
-public class SlcJcrUtils implements SlcNames {
-       public final static Integer AGENT_FACTORY_DEPTH = 3;
-
-       /** Extracts the path of a flow relative to its execution module */
-       public static String flowRelativePath(String fullFlowPath) {
-               String[] tokens = fullFlowPath.split("/");
-               StringBuffer buf = new StringBuffer(fullFlowPath.length());
-               for (int i = AGENT_FACTORY_DEPTH + 3; i < tokens.length; i++) {
-                       buf.append('/').append(tokens[i]);
-               }
-               return buf.toString();
-       }
-
-       /** Extracts the path to the related execution module */
-       public static String modulePath(String fullFlowPath) {
-               String[] tokens = fullFlowPath.split("/");
-               StringBuffer buf = new StringBuffer(fullFlowPath.length());
-               for (int i = 0; i < AGENT_FACTORY_DEPTH + 3; i++) {
-                       if (!tokens[i].equals(""))
-                               buf.append('/').append(tokens[i]);
-               }
-               return buf.toString();
-       }
-
-       /** Extracts the module name from a flow path */
-       public static String moduleName(String fullFlowPath) {
-               String[] tokens = fullFlowPath.split("/");
-               String moduleName = tokens[AGENT_FACTORY_DEPTH + 2];
-               moduleName = moduleName.substring(0, moduleName.indexOf('_'));
-               return moduleName;
-       }
-
-       /** Extracts the module name and version from a flow path */
-       public static NameVersion moduleNameVersion(String fullFlowPath) {
-               String[] tokens = fullFlowPath.split("/");
-               String module = tokens[AGENT_FACTORY_DEPTH + 2];
-               String moduleName = module.substring(0, module.indexOf('_'));
-               String moduleVersion = module.substring(module.indexOf('_') + 1);
-               return new DefaultNameVersion(moduleName, moduleVersion);
-       }
-
-       /** Module node name based on module name and version */
-       public static String getModuleNodeName(ModuleDescriptor moduleDescriptor) {
-               return moduleDescriptor.getName() + "_" + moduleDescriptor.getVersion();
-       }
-
-       /** Extracts the agent factory of a flow */
-       public static String flowAgentFactoryPath(String fullFlowPath) {
-               String[] tokens = fullFlowPath.split("/");
-               StringBuffer buf = new StringBuffer(fullFlowPath.length());
-               // first token is always empty
-               for (int i = 1; i < AGENT_FACTORY_DEPTH + 1; i++) {
-                       buf.append('/').append(tokens[i]);
-               }
-               return buf.toString();
-       }
-
-       /** Create a new execution process path based on the current time */
-       public static String createExecutionProcessPath(Session session, String uuid) {
-               Calendar now = new GregorianCalendar();
-               return getSlcProcessesBasePath(session) + '/'
-                               + JcrUtils.dateAsPath(now, true) + uuid;
-       }
-
-       /** Get the base for the user processi. */
-       public static String getSlcProcessesBasePath(Session session) {
-               try {
-                       Node userHome = NodeUtils.getUserHome(session);
-                       if (userHome == null)
-                               throw new SlcException("No user home available for "
-                                               + session.getUserID());
-                       return userHome.getPath() + '/' + SlcNames.SLC_SYSTEM + '/'
-                                       + SlcNames.SLC_PROCESSES;
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while getting Slc Results Base Path.", re);
-               }
-       }
-
-       /**
-        * Create a new execution result path in the user home based on the current
-        * time
-        */
-       public static String createResultPath(Session session, String uuid)
-                       throws RepositoryException {
-               Calendar now = new GregorianCalendar();
-               StringBuffer absPath = new StringBuffer(
-                               SlcJcrResultUtils.getSlcResultsBasePath(session) + '/');
-               // Remove hours and add title property to the result process path on
-               // request of O. Capillon
-               // return getSlcProcessesBasePath(session) + '/'
-               // + JcrUtils.dateAsPath(now, true) + uuid;
-               String relPath = JcrUtils.dateAsPath(now, false);
-               List<String> names = JcrUtils.tokenize(relPath);
-               for (String name : names) {
-                       absPath.append(name + "/");
-                       Node node = JcrUtils.mkdirs(session, absPath.toString());
-                       try {
-                               node.addMixin(NodeType.MIX_TITLE);
-                               node.setProperty(Property.JCR_TITLE, name.substring(1));
-                       } catch (RepositoryException e) {
-                               throw new SlcException(
-                                               "unable to create execution process path", e);
-                       }
-               }
-               return absPath.toString() + uuid;
-       }
-
-       /**
-        * Set the value of the primitive accessor as a JCR property. Does nothing
-        * if the value is null.
-        */
-       public static void setPrimitiveAsProperty(Node node, String propertyName,
-                       PrimitiveAccessor primitiveAccessor) {
-               String type = primitiveAccessor.getType();
-               Object value = primitiveAccessor.getValue();
-               setPrimitiveAsProperty(node, propertyName, type, value);
-       }
-
-       /** Map a primitive value to JCR property value. */
-       public static void setPrimitiveAsProperty(Node node, String propertyName,
-                       String type, Object value) {
-               if (value == null)
-                       return;
-               if (value instanceof CharSequence)
-                       value = PrimitiveUtils.convert(type,
-                                       ((CharSequence) value).toString());
-               if (value instanceof char[])
-                       value = new String((char[]) value);
-
-               try {
-                       if (type.equals(PrimitiveAccessor.TYPE_STRING))
-                               node.setProperty(propertyName, value.toString());
-                       else if (type.equals(PrimitiveAccessor.TYPE_PASSWORD))
-                               node.setProperty(propertyName, value.toString());
-                       else if (type.equals(PrimitiveAccessor.TYPE_INTEGER))
-                               node.setProperty(propertyName, (long) ((Integer) value));
-                       else if (type.equals(PrimitiveAccessor.TYPE_LONG))
-                               node.setProperty(propertyName, ((Long) value));
-                       else if (type.equals(PrimitiveAccessor.TYPE_FLOAT))
-                               node.setProperty(propertyName, (double) ((Float) value));
-                       else if (type.equals(PrimitiveAccessor.TYPE_DOUBLE))
-                               node.setProperty(propertyName, ((Double) value));
-                       else if (type.equals(PrimitiveAccessor.TYPE_BOOLEAN))
-                               node.setProperty(propertyName, ((Boolean) value));
-                       else
-                               throw new SlcException("Unsupported type " + type);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot set primitive of " + type
-                                       + " as property " + propertyName + " on " + node, e);
-               }
-       }
-
-       /** Aggregates the {@link TestStatus} of this sub-tree. */
-       public static Integer aggregateTestStatus(Node node) {
-               try {
-                       Integer status = TestStatus.PASSED;
-                       if (node.isNodeType(SlcTypes.SLC_CHECK))
-                               if (node.getProperty(SLC_SUCCESS).getBoolean())
-                                       status = TestStatus.PASSED;
-                               else if (node.hasProperty(SLC_ERROR_MESSAGE))
-                                       status = TestStatus.ERROR;
-                               else
-                                       status = TestStatus.FAILED;
-
-                       NodeIterator it = node.getNodes();
-                       while (it.hasNext()) {
-                               Node curr = it.nextNode();
-
-                               // Manually skip aggregated status
-                               if (!SlcNames.SLC_AGGREGATED_STATUS.equals(curr.getName())) {
-                                       Integer childStatus = aggregateTestStatus(curr);
-                                       if (childStatus > status)
-                                               status = childStatus;
-                               }
-                       }
-                       return status;
-               } catch (Exception e) {
-                       throw new SlcException("Could not aggregate test status from "
-                                       + node, e);
-               }
-       }
-
-       /**
-        * Aggregates the {@link TestStatus} of this sub-tree.
-        * 
-        * @return the same {@link StringBuffer}, for convenience (typically calling
-        *         toString() on it)
-        */
-       public static StringBuffer aggregateTestMessages(Node node,
-                       StringBuffer messages) {
-               try {
-                       if (node.isNodeType(SlcTypes.SLC_CHECK)) {
-                               if (node.hasProperty(SLC_MESSAGE)) {
-                                       if (messages.length() > 0)
-                                               messages.append('\n');
-                                       messages.append(node.getProperty(SLC_MESSAGE).getString());
-                               }
-                               if (node.hasProperty(SLC_ERROR_MESSAGE)) {
-                                       if (messages.length() > 0)
-                                               messages.append('\n');
-                                       messages.append(node.getProperty(SLC_ERROR_MESSAGE)
-                                                       .getString());
-                               }
-                       }
-                       NodeIterator it = node.getNodes();
-                       while (it.hasNext()) {
-                               Node child = it.nextNode();
-                               // Manually skip aggregated status
-                               if (!SlcNames.SLC_AGGREGATED_STATUS.equals(child.getName())) {
-                                       aggregateTestMessages(child, messages);
-                               }
-                       }
-                       return messages;
-               } catch (Exception e) {
-                       throw new SlcException("Could not aggregate test messages from "
-                                       + node, e);
-               }
-       }
-
-       /** Prevents instantiation */
-       private SlcJcrUtils() {
-       }
-}
\ No newline at end of file
index 105d549cd22ce07a5bb53e79547d7cf1e88f0911..52ea2801a93fb37bd68ec7b055fbe1239affdb2e 100644 (file)
@@ -17,7 +17,7 @@ package org.argeo.slc.jcr.execution;
 
 import javax.jcr.Session;
 
-import org.argeo.slc.core.attachment.Attachment;
+import org.argeo.slc.attachment.Attachment;
 import org.argeo.slc.core.attachment.AttachmentUploader;
 import org.springframework.core.io.Resource;
 
index 1a2576e069baf0bb8e1d7cd1e6656c2d61e73048..022dd872156b9b7d105a1e153ac17ea1df545c58 100644 (file)
@@ -33,10 +33,6 @@ import org.argeo.jcr.JcrUtils;
 import org.argeo.slc.SlcException;
 import org.argeo.slc.SlcNames;
 import org.argeo.slc.SlcTypes;
-import org.argeo.slc.core.execution.PrimitiveSpecAttribute;
-import org.argeo.slc.core.execution.PrimitiveValue;
-import org.argeo.slc.core.execution.RefSpecAttribute;
-import org.argeo.slc.core.execution.RefValueChoice;
 import org.argeo.slc.deploy.ModuleDescriptor;
 import org.argeo.slc.execution.ExecutionFlowDescriptor;
 import org.argeo.slc.execution.ExecutionModuleDescriptor;
@@ -44,7 +40,11 @@ import org.argeo.slc.execution.ExecutionModulesListener;
 import org.argeo.slc.execution.ExecutionModulesManager;
 import org.argeo.slc.execution.ExecutionSpec;
 import org.argeo.slc.execution.ExecutionSpecAttribute;
+import org.argeo.slc.execution.RefSpecAttribute;
+import org.argeo.slc.execution.RefValueChoice;
 import org.argeo.slc.jcr.SlcJcrUtils;
+import org.argeo.slc.primitive.PrimitiveSpecAttribute;
+import org.argeo.slc.primitive.PrimitiveValue;
 
 /**
  * Synchronizes the local execution runtime with a JCR repository. For the time
index c371b1114531c7544423a6f8849fdbea9f0ef60b..5c8738b3f2381a18c9cb99a2d833d82edcbd44c0 100644 (file)
@@ -12,13 +12,13 @@ import org.argeo.slc.SlcException;
 import org.argeo.slc.SlcNames;
 import org.argeo.slc.SlcTypes;
 import org.argeo.slc.core.execution.DefaultExecutionSpec;
-import org.argeo.slc.core.execution.PrimitiveSpecAttribute;
-import org.argeo.slc.core.execution.PrimitiveUtils;
-import org.argeo.slc.core.execution.RefSpecAttribute;
 import org.argeo.slc.execution.ExecutionFlowDescriptor;
 import org.argeo.slc.execution.ExecutionSpecAttribute;
 import org.argeo.slc.execution.RealizedFlow;
+import org.argeo.slc.execution.RefSpecAttribute;
 import org.argeo.slc.jcr.SlcJcrUtils;
+import org.argeo.slc.primitive.PrimitiveSpecAttribute;
+import org.argeo.slc.primitive.PrimitiveUtils;
 
 public class JcrRealizedFlow extends RealizedFlow implements SlcNames {
        private static final long serialVersionUID = -3709453850260712001L;
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractExecutionFlowTestcase.java b/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractExecutionFlowTestcase.java
new file mode 100644 (file)
index 0000000..3018463
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.spring.unit;
+
+import org.argeo.slc.execution.ExecutionFlow;
+
+public class AbstractExecutionFlowTestcase extends AbstractSpringTestCase {
+       @SuppressWarnings(value = { "unchecked" })
+       protected <T extends ExecutionFlow> T executeFlow(String flowName) {
+               ExecutionFlow flow = getBean(flowName);
+               flow.run();
+               return (T) flow;
+       }
+}
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractOsgiRuntimeTestCase.java b/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractOsgiRuntimeTestCase.java
new file mode 100644 (file)
index 0000000..7cd1473
--- /dev/null
@@ -0,0 +1,246 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.spring.unit;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.osgi.boot.OsgiBoot;
+import org.argeo.slc.SlcException;
+import org.eclipse.core.runtime.adaptor.EclipseStarter;
+import org.eclipse.gemini.blueprint.util.OsgiStringUtils;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.springframework.context.ApplicationContext;
+
+import junit.framework.TestCase;
+
+@SuppressWarnings("restriction")
+public abstract class AbstractOsgiRuntimeTestCase extends TestCase {
+       private final static Log log = LogFactory
+                       .getLog(AbstractOsgiRuntimeTestCase.class);
+
+       protected OsgiBoot osgiBoot = null;
+
+       protected void installBundles() throws Exception {
+
+       }
+
+       public void setUp() throws Exception {
+               // To avoid xerces from the classpath being detected as the provider
+               System
+                               .setProperty("javax.xml.parsers.DocumentBuilderFactory",
+                                               "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
+               System.setProperty("javax.xml.parsers.SAXParserFactory",
+                               "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
+
+               BundleContext bundleContext = startRuntime();
+               osgiBoot = new OsgiBoot(bundleContext);
+               log.info("OSGi runtime started.");
+
+               installBundles();
+
+               List<String> bundlesToStart = getBundlesToStart();
+               osgiBoot.startBundles(bundlesToStart);
+               waitAllBundlesOk(bundlesToStart);
+               if (log.isTraceEnabled())
+                       listInstalledBundles();
+       }
+
+       public void tearDown() throws Exception {
+               osgiBoot = null;
+               stopRuntime();
+               log.info("OSGi runtime stopped.");
+       }
+
+       protected BundleContext startRuntime() throws Exception {
+               String[] args = { "-console", "-clean" };
+               BundleContext bundleContext = EclipseStarter.startup(args, null);
+               return bundleContext;
+       }
+
+       protected void stopRuntime() throws Exception {
+               EclipseStarter.shutdown();
+       }
+
+       protected List<String> getBundlesToStart() {
+               return new ArrayList<String>();
+       }
+
+       protected void listInstalledBundles() {
+               BundleContext bundleContext = osgiBoot.getBundleContext();
+               Bundle[] bundles = bundleContext.getBundles();
+               for (int i = 0; i < bundles.length; i++) {
+                       System.out.println(OsgiStringUtils.nullSafeSymbolicName(bundles[i])
+                                       + " [" + OsgiStringUtils.bundleStateAsString(bundles[i])
+                                       + "] " + bundles[i].getLocation());
+               }
+
+       }
+
+       protected Map<Bundle, ApplicationContext> getOsgiApplicationContexts()
+                       throws Exception {
+               Map<Bundle, ApplicationContext> map = new HashMap<Bundle, ApplicationContext>();
+               BundleContext bundleContext = osgiBoot.getBundleContext();
+               ServiceReference[] srs = bundleContext.getServiceReferences(
+                               ApplicationContext.class.getName(), null);
+               for (ServiceReference sr : srs) {
+                       ApplicationContext context = (ApplicationContext) bundleContext
+                                       .getService(sr);
+                       map.put(sr.getBundle(), context);
+               }
+               return map;
+       }
+
+       /** Wait for all bundles to be either RESOLVED or ACTIVE. */
+       protected void waitAllBundlesOk(List<String> bundlesToStart) {
+               BundleContext bundleContext = osgiBoot.getBundleContext();
+               long begin = System.currentTimeMillis();
+               long duration = 0;
+               boolean allBundlesOk = true;
+               StringBuffer badBundles = null;
+               while (duration < getResolvedTimeout()) {
+                       badBundles = new StringBuffer();
+                       for (Bundle bundle : bundleContext.getBundles()) {
+                               if (bundle.getSymbolicName() != null
+                                               && bundle.getSymbolicName().startsWith(
+                                                               "org.eclipse.jdt")) {
+                                       // don't check Eclipse SDK bundles
+                                       continue;
+                               }
+
+                               if (bundle.getState() == Bundle.INSTALLED) {
+                                       allBundlesOk = false;
+                                       badBundles
+                                                       .append(OsgiStringUtils
+                                                                       .nullSafeSymbolicName(bundle)
+                                                                       + " ["
+                                                                       + OsgiStringUtils
+                                                                                       .bundleStateAsString(bundle) + "]");
+                               }
+
+                               if (bundlesToStart.contains(bundle.getSymbolicName())
+                                               && bundle.getState() != Bundle.ACTIVE) {
+                                       allBundlesOk = false;
+                                       badBundles.append(OsgiStringUtils
+                                                       .nullSafeSymbolicName(bundle)
+                                                       + " ["
+                                                       + OsgiStringUtils.bundleStateAsString(bundle)
+                                                       + "]\n");
+                               }
+                       }
+
+                       if (allBundlesOk)
+                               break;// while
+
+                       sleep(1000);
+
+                       duration = System.currentTimeMillis() - begin;
+               }
+
+               if (!allBundlesOk) {
+                       listInstalledBundles();
+                       throw new SlcException(
+                                       "Some bundles are not at the proper status:\n" + badBundles);
+               }
+       }
+
+       /**
+        * Make sure that the application context of the started bundles starting
+        * with this prefix are properly initialized
+        */
+       protected void assertStartedBundlesApplicationContext(
+                       String bundleSymbolicNamesPrefix) {
+               List<String> bundlesToStart = getBundlesToStart();
+               for (String bundleSName : bundlesToStart) {
+                       if (bundleSName.startsWith(bundleSymbolicNamesPrefix))
+                               assertBundleApplicationContext(bundleSName);
+               }
+       }
+
+       /**
+        * Make sure that the application context of this bundle is properly
+        * initialized
+        */
+       protected void assertBundleApplicationContext(String bundleSymbolicName) {
+               String filter = "(Bundle-SymbolicName=" + bundleSymbolicName + ")";
+               // Wait for application context to be ready
+               try {
+                       ServiceReference[] srs = getServiceRefSynchronous(
+                                       ApplicationContext.class.getName(), filter);
+                       if (srs == null)
+                               throw new SlcException("No application context for "
+                                               + bundleSymbolicName);
+               } catch (InvalidSyntaxException e) {
+                       throw new SlcException(
+                                       "Unexpected exception when looking for application context for bundle "
+                                                       + bundleSymbolicName, e);
+               }
+               log.info("Application context of bundle " + bundleSymbolicName
+                               + " is initalized.");
+       }
+
+       protected ServiceReference[] getServiceRefSynchronous(String clss,
+                       String filter) throws InvalidSyntaxException {
+               // FIXME: factorize
+               if (log.isTraceEnabled())
+                       log.debug("Filter: '" + filter + "'");
+               ServiceReference[] sfs = null;
+               boolean waiting = true;
+               long begin = System.currentTimeMillis();
+               do {
+                       sfs = getBundleContext().getServiceReferences(clss, filter);
+
+                       if (sfs != null)
+                               waiting = false;
+
+                       sleep(100);
+                       if (System.currentTimeMillis() - begin > getDefaultTimeout())
+                               throw new SlcException("Search of services " + clss
+                                               + " with filter " + filter + " timed out.");
+               } while (waiting);
+
+               return sfs;
+       }
+
+       protected BundleContext getBundleContext() {
+               return osgiBoot.getBundleContext();
+       }
+
+       /** Default is 30s */
+       protected long getResolvedTimeout() {
+               return 30 * 1000l;
+       }
+
+       /** Default is 10s */
+       protected long getDefaultTimeout() {
+               return 10 * 1000l;
+       }
+
+       final protected void sleep(long duration) {
+               try {
+                       Thread.sleep(1000);
+               } catch (InterruptedException e) {
+                       // silent
+               }
+       }
+}
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractSpringTestCase.java b/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractSpringTestCase.java
new file mode 100644 (file)
index 0000000..b6e48fe
--- /dev/null
@@ -0,0 +1,115 @@
+/*\r
+ * Copyright (C) 2007-2012 Argeo GmbH\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *         http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.argeo.slc.spring.unit;\r
+\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.SlcException;\r
+import org.springframework.beans.factory.BeanFactoryUtils;\r
+import org.springframework.beans.factory.ListableBeanFactory;\r
+import org.springframework.context.ConfigurableApplicationContext;\r
+import org.springframework.context.support.ClassPathXmlApplicationContext;\r
+\r
+import junit.framework.TestCase;\r
+\r
+/** Helper for tests using a Spring application co,text. */\r
+public abstract class AbstractSpringTestCase extends TestCase {\r
+       protected final Log log = LogFactory.getLog(getClass());\r
+       private ConfigurableApplicationContext context;\r
+\r
+       /**\r
+        * Gets (and create if necessary) the application context to use. Default\r
+        * implementation uses a class path xml application context and calls\r
+        * {@link #getApplicationContextLocation()}.\r
+        */\r
+       protected ConfigurableApplicationContext getContext() {\r
+               if (context == null) {\r
+                       context = new ClassPathXmlApplicationContext(\r
+                                       getApplicationContextLocation());\r
+                       if (getIsStartContext())\r
+                               context.start();\r
+               }\r
+               return context;\r
+       }\r
+\r
+       @Override\r
+       protected void tearDown() throws Exception {\r
+               if (context != null && context.isActive())\r
+                       context.close();\r
+               super.tearDown();\r
+       }\r
+\r
+       /** Whether the context should be started after being created. */\r
+       protected Boolean getIsStartContext() {\r
+               return false;\r
+       }\r
+\r
+       /** Returns a bean from the underlying context */\r
+       @SuppressWarnings(value = { "unchecked" })\r
+       protected <T> T getBean(String beanId) {\r
+               return (T) getContext().getBean(beanId);\r
+       }\r
+\r
+       protected <T> T getBean(Class<? extends T> clss) {\r
+               T bean = loadSingleFromContext(getContext(), clss);\r
+               if (bean == null) {\r
+                       throw new SlcException("Cannot retrieve a unique bean of type "\r
+                                       + clss);\r
+               } else {\r
+                       return bean;\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Th location of the application to load. The default implementation\r
+        * returns <i>applicationContext.xml</i> found in the same package as the\r
+        * test.\r
+        */\r
+       protected String getApplicationContextLocation() {\r
+               return inPackage("applicationContext.xml");\r
+       }\r
+\r
+       /**\r
+        * Prefixes the package of the class after converting the '.' to '/' in\r
+        * order to have a resource path.\r
+        */\r
+       protected String inPackage(String suffix) {\r
+               String prefix = getClass().getPackage().getName().replace('.', '/');\r
+               return prefix + '/' + suffix;\r
+       }\r
+\r
+       @SuppressWarnings(value = { "unchecked" })\r
+       protected <T> T loadSingleFromContext(ListableBeanFactory context,\r
+                       Class<T> clss) {\r
+               Map<String, T> beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(\r
+                               context, clss, false, false);\r
+               if (beans.size() == 1) {\r
+                       return beans.values().iterator().next();\r
+               } else if (beans.size() > 1) {\r
+                       if (log.isDebugEnabled()) {\r
+                               log\r
+                                               .debug(("Found more that on bean for type " + clss\r
+                                                               + ": " + beans.keySet()));\r
+                       }\r
+                       return null;\r
+               } else {\r
+                       return null;\r
+               }\r
+       }\r
+\r
+}\r
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/ExecutionFlowDescriptorTestUtils.java b/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/ExecutionFlowDescriptorTestUtils.java
new file mode 100644 (file)
index 0000000..a78662f
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.spring.unit;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.argeo.slc.core.execution.DefaultExecutionSpec;
+import org.argeo.slc.core.test.BasicTestData;
+import org.argeo.slc.execution.ExecutionFlowDescriptor;
+import org.argeo.slc.execution.ExecutionSpecAttribute;
+import org.argeo.slc.execution.RefSpecAttribute;
+import org.argeo.slc.execution.RefValue;
+import org.argeo.slc.execution.RefValueChoice;
+import org.argeo.slc.primitive.PrimitiveAccessor;
+import org.argeo.slc.primitive.PrimitiveSpecAttribute;
+import org.argeo.slc.primitive.PrimitiveValue;
+
+public class ExecutionFlowDescriptorTestUtils {
+       public static ExecutionFlowDescriptor createSimpleExecutionFlowDescriptor() {
+               ExecutionFlowDescriptor flowDescriptor = new ExecutionFlowDescriptor();
+               flowDescriptor.setName("simpleFlow");
+               flowDescriptor.setDescription("my description");
+
+               Map<String, Object> values = new HashMap<String, Object>();
+               values.put("primitiveInteger", new PrimitiveValue(
+                               PrimitiveAccessor.TYPE_INTEGER, 100));
+
+               RefValue refValue = new RefValue("002");
+               values.put("ref1", refValue);
+               flowDescriptor.setValues(values);
+
+               flowDescriptor.setExecutionSpec(createRelatedSimpleSpec());
+               return flowDescriptor;
+       }
+
+       protected static DefaultExecutionSpec createRelatedSimpleSpec() {
+               DefaultExecutionSpec spec = new DefaultExecutionSpec();
+               spec.setBeanName("simpleSpec");
+               Map<String, ExecutionSpecAttribute> attributes = new HashMap<String, ExecutionSpecAttribute>();
+
+               PrimitiveSpecAttribute primitiveInteger = new PrimitiveSpecAttribute();
+               primitiveInteger.setType(PrimitiveAccessor.TYPE_INTEGER);
+               primitiveInteger.setValue(50);
+               attributes.put("primitiveInteger", primitiveInteger);
+
+               RefSpecAttribute ref1 = new RefSpecAttribute();
+               ref1.setTargetClass(BasicTestData.class);
+               ref1.setChoices(new ArrayList<RefValueChoice>());
+               ref1.getChoices().add(new RefValueChoice("001", "desc"));
+               ref1.getChoices().add(new RefValueChoice("002", null));
+               ref1.getChoices().add(new RefValueChoice("003", null));
+               attributes.put("ref1", ref1);
+
+               spec.setAttributes(attributes);
+
+               return spec;
+       }
+}
diff --git a/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/UnitUtils.java b/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/UnitUtils.java
new file mode 100644 (file)
index 0000000..1eeca05
--- /dev/null
@@ -0,0 +1,57 @@
+/*\r
+ * Copyright (C) 2007-2012 Argeo GmbH\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *         http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.argeo.slc.spring.unit;\r
+\r
+import static junit.framework.Assert.assertEquals;\r
+import static junit.framework.Assert.assertNotNull;\r
+import static junit.framework.Assert.assertNull;\r
+\r
+import java.util.Calendar;\r
+import java.util.Date;\r
+import java.util.GregorianCalendar;\r
+\r
+public abstract class UnitUtils {\r
+       public static void assertDateSec(Date expected, Date reached) {\r
+               if (expected == null) {\r
+                       assertNull(reached);\r
+                       return;\r
+               } else {\r
+                       assertNotNull(reached);\r
+               }\r
+\r
+               Calendar expectedCal = new GregorianCalendar();\r
+               expectedCal.setTime(expected);\r
+               Calendar reachedCal = new GregorianCalendar();\r
+               reachedCal.setTime(reached);\r
+               assertEquals(expectedCal.get(Calendar.YEAR), reachedCal\r
+                               .get(Calendar.YEAR));\r
+               assertEquals(expectedCal.get(Calendar.MONTH), reachedCal\r
+                               .get(Calendar.MONTH));\r
+               assertEquals(expectedCal.get(Calendar.DATE), reachedCal\r
+                               .get(Calendar.DATE));\r
+               assertEquals(expectedCal.get(Calendar.HOUR_OF_DAY), reachedCal\r
+                               .get(Calendar.HOUR_OF_DAY));\r
+               assertEquals(expectedCal.get(Calendar.MINUTE), reachedCal\r
+                               .get(Calendar.MINUTE));\r
+               assertEquals(expectedCal.get(Calendar.SECOND), reachedCal\r
+                               .get(Calendar.SECOND));\r
+       }\r
+\r
+       private UnitUtils() {\r
+\r
+       }\r
+\r
+}\r
index b4d091d3ffbe1b721385c9336fa7ba042caea65d..d9082295de32c43cea64fcec61270b7076e2d723 100644 (file)
@@ -12,7 +12,7 @@
                <!-- SLC Runtime -->
                <dependency>
                        <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.core</artifactId>
+                       <artifactId>org.argeo.slc.spring</artifactId>
                        <version>2.1.17-SNAPSHOT</version>
                </dependency>
        </dependencies>
index ef9c0e4bc4f1951b17a71d4b92cd074b2a524ae5..76563e3d134a831e060aa75040d87d3dc161f48a 100644 (file)
                <!-- SLC -->
                <dependency>
                        <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.core</artifactId>
-                       <version>2.1.17-SNAPSHOT</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.support</artifactId>
+                       <artifactId>org.argeo.slc.api</artifactId>
                        <version>2.1.17-SNAPSHOT</version>
                </dependency>
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.slc</groupId> -->
+<!--                   <artifactId>org.argeo.slc.support</artifactId> -->
+<!--                   <version>2.1.17-SNAPSHOT</version> -->
+<!--           </dependency> -->
        </dependencies>
 </project>
\ No newline at end of file
diff --git a/org.argeo.slc.unit/src/org/argeo/slc/equinox/unit/AbstractOsgiRuntimeTestCase.java b/org.argeo.slc.unit/src/org/argeo/slc/equinox/unit/AbstractOsgiRuntimeTestCase.java
deleted file mode 100644 (file)
index 2bcf960..0000000
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.equinox.unit;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.osgi.boot.OsgiBoot;
-import org.argeo.slc.SlcException;
-import org.eclipse.core.runtime.adaptor.EclipseStarter;
-import org.eclipse.gemini.blueprint.util.OsgiStringUtils;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.springframework.context.ApplicationContext;
-
-@SuppressWarnings("restriction")
-public abstract class AbstractOsgiRuntimeTestCase extends TestCase {
-       private final static Log log = LogFactory
-                       .getLog(AbstractOsgiRuntimeTestCase.class);
-
-       protected OsgiBoot osgiBoot = null;
-
-       protected void installBundles() throws Exception {
-
-       }
-
-       public void setUp() throws Exception {
-               // To avoid xerces from the classpath being detected as the provider
-               System
-                               .setProperty("javax.xml.parsers.DocumentBuilderFactory",
-                                               "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
-               System.setProperty("javax.xml.parsers.SAXParserFactory",
-                               "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
-
-               BundleContext bundleContext = startRuntime();
-               osgiBoot = new OsgiBoot(bundleContext);
-               log.info("OSGi runtime started.");
-
-               installBundles();
-
-               List<String> bundlesToStart = getBundlesToStart();
-               osgiBoot.startBundles(bundlesToStart);
-               waitAllBundlesOk(bundlesToStart);
-               if (log.isTraceEnabled())
-                       listInstalledBundles();
-       }
-
-       public void tearDown() throws Exception {
-               osgiBoot = null;
-               stopRuntime();
-               log.info("OSGi runtime stopped.");
-       }
-
-       protected BundleContext startRuntime() throws Exception {
-               String[] args = { "-console", "-clean" };
-               BundleContext bundleContext = EclipseStarter.startup(args, null);
-               return bundleContext;
-       }
-
-       protected void stopRuntime() throws Exception {
-               EclipseStarter.shutdown();
-       }
-
-       protected List<String> getBundlesToStart() {
-               return new ArrayList<String>();
-       }
-
-       protected void listInstalledBundles() {
-               BundleContext bundleContext = osgiBoot.getBundleContext();
-               Bundle[] bundles = bundleContext.getBundles();
-               for (int i = 0; i < bundles.length; i++) {
-                       System.out.println(OsgiStringUtils.nullSafeSymbolicName(bundles[i])
-                                       + " [" + OsgiStringUtils.bundleStateAsString(bundles[i])
-                                       + "] " + bundles[i].getLocation());
-               }
-
-       }
-
-       protected Map<Bundle, ApplicationContext> getOsgiApplicationContexts()
-                       throws Exception {
-               Map<Bundle, ApplicationContext> map = new HashMap<Bundle, ApplicationContext>();
-               BundleContext bundleContext = osgiBoot.getBundleContext();
-               ServiceReference[] srs = bundleContext.getServiceReferences(
-                               ApplicationContext.class.getName(), null);
-               for (ServiceReference sr : srs) {
-                       ApplicationContext context = (ApplicationContext) bundleContext
-                                       .getService(sr);
-                       map.put(sr.getBundle(), context);
-               }
-               return map;
-       }
-
-       /** Wait for all bundles to be either RESOLVED or ACTIVE. */
-       protected void waitAllBundlesOk(List<String> bundlesToStart) {
-               BundleContext bundleContext = osgiBoot.getBundleContext();
-               long begin = System.currentTimeMillis();
-               long duration = 0;
-               boolean allBundlesOk = true;
-               StringBuffer badBundles = null;
-               while (duration < getResolvedTimeout()) {
-                       badBundles = new StringBuffer();
-                       for (Bundle bundle : bundleContext.getBundles()) {
-                               if (bundle.getSymbolicName() != null
-                                               && bundle.getSymbolicName().startsWith(
-                                                               "org.eclipse.jdt")) {
-                                       // don't check Eclipse SDK bundles
-                                       continue;
-                               }
-
-                               if (bundle.getState() == Bundle.INSTALLED) {
-                                       allBundlesOk = false;
-                                       badBundles
-                                                       .append(OsgiStringUtils
-                                                                       .nullSafeSymbolicName(bundle)
-                                                                       + " ["
-                                                                       + OsgiStringUtils
-                                                                                       .bundleStateAsString(bundle) + "]");
-                               }
-
-                               if (bundlesToStart.contains(bundle.getSymbolicName())
-                                               && bundle.getState() != Bundle.ACTIVE) {
-                                       allBundlesOk = false;
-                                       badBundles.append(OsgiStringUtils
-                                                       .nullSafeSymbolicName(bundle)
-                                                       + " ["
-                                                       + OsgiStringUtils.bundleStateAsString(bundle)
-                                                       + "]\n");
-                               }
-                       }
-
-                       if (allBundlesOk)
-                               break;// while
-
-                       sleep(1000);
-
-                       duration = System.currentTimeMillis() - begin;
-               }
-
-               if (!allBundlesOk) {
-                       listInstalledBundles();
-                       throw new SlcException(
-                                       "Some bundles are not at the proper status:\n" + badBundles);
-               }
-       }
-
-       /**
-        * Make sure that the application context of the started bundles starting
-        * with this prefix are properly initialized
-        */
-       protected void assertStartedBundlesApplicationContext(
-                       String bundleSymbolicNamesPrefix) {
-               List<String> bundlesToStart = getBundlesToStart();
-               for (String bundleSName : bundlesToStart) {
-                       if (bundleSName.startsWith(bundleSymbolicNamesPrefix))
-                               assertBundleApplicationContext(bundleSName);
-               }
-       }
-
-       /**
-        * Make sure that the application context of this bundle is properly
-        * initialized
-        */
-       protected void assertBundleApplicationContext(String bundleSymbolicName) {
-               String filter = "(Bundle-SymbolicName=" + bundleSymbolicName + ")";
-               // Wait for application context to be ready
-               try {
-                       ServiceReference[] srs = getServiceRefSynchronous(
-                                       ApplicationContext.class.getName(), filter);
-                       if (srs == null)
-                               throw new SlcException("No application context for "
-                                               + bundleSymbolicName);
-               } catch (InvalidSyntaxException e) {
-                       throw new SlcException(
-                                       "Unexpected exception when looking for application context for bundle "
-                                                       + bundleSymbolicName, e);
-               }
-               log.info("Application context of bundle " + bundleSymbolicName
-                               + " is initalized.");
-       }
-
-       protected ServiceReference[] getServiceRefSynchronous(String clss,
-                       String filter) throws InvalidSyntaxException {
-               // FIXME: factorize
-               if (log.isTraceEnabled())
-                       log.debug("Filter: '" + filter + "'");
-               ServiceReference[] sfs = null;
-               boolean waiting = true;
-               long begin = System.currentTimeMillis();
-               do {
-                       sfs = getBundleContext().getServiceReferences(clss, filter);
-
-                       if (sfs != null)
-                               waiting = false;
-
-                       sleep(100);
-                       if (System.currentTimeMillis() - begin > getDefaultTimeout())
-                               throw new SlcException("Search of services " + clss
-                                               + " with filter " + filter + " timed out.");
-               } while (waiting);
-
-               return sfs;
-       }
-
-       protected BundleContext getBundleContext() {
-               return osgiBoot.getBundleContext();
-       }
-
-       /** Default is 30s */
-       protected long getResolvedTimeout() {
-               return 30 * 1000l;
-       }
-
-       /** Default is 10s */
-       protected long getDefaultTimeout() {
-               return 10 * 1000l;
-       }
-
-       final protected void sleep(long duration) {
-               try {
-                       Thread.sleep(1000);
-               } catch (InterruptedException e) {
-                       // silent
-               }
-       }
-}
diff --git a/org.argeo.slc.unit/src/org/argeo/slc/unit/AbstractSpringTestCase.java b/org.argeo.slc.unit/src/org/argeo/slc/unit/AbstractSpringTestCase.java
deleted file mode 100644 (file)
index 76b7fb6..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/*\r
- * Copyright (C) 2007-2012 Argeo GmbH\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *         http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.argeo.slc.unit;\r
-\r
-import java.util.Map;\r
-\r
-import junit.framework.TestCase;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-import org.argeo.slc.SlcException;\r
-import org.springframework.beans.factory.BeanFactoryUtils;\r
-import org.springframework.beans.factory.ListableBeanFactory;\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
-       protected final Log log = LogFactory.getLog(getClass());\r
-       private ConfigurableApplicationContext context;\r
-\r
-       /**\r
-        * Gets (and create if necessary) the application context to use. Default\r
-        * implementation uses a class path xml application context and calls\r
-        * {@link #getApplicationContextLocation()}.\r
-        */\r
-       protected ConfigurableApplicationContext getContext() {\r
-               if (context == null) {\r
-                       context = new ClassPathXmlApplicationContext(\r
-                                       getApplicationContextLocation());\r
-                       if (getIsStartContext())\r
-                               context.start();\r
-               }\r
-               return context;\r
-       }\r
-\r
-       @Override\r
-       protected void tearDown() throws Exception {\r
-               if (context != null && context.isActive())\r
-                       context.close();\r
-               super.tearDown();\r
-       }\r
-\r
-       /** Whether the context should be started after being created. */\r
-       protected Boolean getIsStartContext() {\r
-               return false;\r
-       }\r
-\r
-       /** Returns a bean from the underlying context */\r
-       @SuppressWarnings(value = { "unchecked" })\r
-       protected <T> T getBean(String beanId) {\r
-               return (T) getContext().getBean(beanId);\r
-       }\r
-\r
-       protected <T> T getBean(Class<? extends T> clss) {\r
-               T bean = loadSingleFromContext(getContext(), clss);\r
-               if (bean == null) {\r
-                       throw new SlcException("Cannot retrieve a unique bean of type "\r
-                                       + clss);\r
-               } else {\r
-                       return bean;\r
-               }\r
-       }\r
-\r
-       /**\r
-        * Th location of the application to load. The default implementation\r
-        * returns <i>applicationContext.xml</i> found in the same package as the\r
-        * test.\r
-        */\r
-       protected String getApplicationContextLocation() {\r
-               return inPackage("applicationContext.xml");\r
-       }\r
-\r
-       /**\r
-        * Prefixes the package of the class after converting the '.' to '/' in\r
-        * order to have a resource path.\r
-        */\r
-       protected String inPackage(String suffix) {\r
-               String prefix = getClass().getPackage().getName().replace('.', '/');\r
-               return prefix + '/' + suffix;\r
-       }\r
-\r
-       @SuppressWarnings(value = { "unchecked" })\r
-       protected <T> T loadSingleFromContext(ListableBeanFactory context,\r
-                       Class<T> clss) {\r
-               Map<String, T> beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(\r
-                               context, clss, false, false);\r
-               if (beans.size() == 1) {\r
-                       return beans.values().iterator().next();\r
-               } else if (beans.size() > 1) {\r
-                       if (log.isDebugEnabled()) {\r
-                               log\r
-                                               .debug(("Found more that on bean for type " + clss\r
-                                                               + ": " + beans.keySet()));\r
-                       }\r
-                       return null;\r
-               } else {\r
-                       return null;\r
-               }\r
-       }\r
-\r
-}\r
diff --git a/org.argeo.slc.unit/src/org/argeo/slc/unit/UnitUtils.java b/org.argeo.slc.unit/src/org/argeo/slc/unit/UnitUtils.java
deleted file mode 100644 (file)
index 75cc578..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*\r
- * Copyright (C) 2007-2012 Argeo GmbH\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *         http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.argeo.slc.unit;\r
-\r
-import static junit.framework.Assert.assertEquals;\r
-import static junit.framework.Assert.assertNotNull;\r
-import static junit.framework.Assert.assertNull;\r
-\r
-import java.util.Calendar;\r
-import java.util.Date;\r
-import java.util.GregorianCalendar;\r
-\r
-public abstract class UnitUtils {\r
-       public static void assertDateSec(Date expected, Date reached) {\r
-               if (expected == null) {\r
-                       assertNull(reached);\r
-                       return;\r
-               } else {\r
-                       assertNotNull(reached);\r
-               }\r
-\r
-               Calendar expectedCal = new GregorianCalendar();\r
-               expectedCal.setTime(expected);\r
-               Calendar reachedCal = new GregorianCalendar();\r
-               reachedCal.setTime(reached);\r
-               assertEquals(expectedCal.get(Calendar.YEAR), reachedCal\r
-                               .get(Calendar.YEAR));\r
-               assertEquals(expectedCal.get(Calendar.MONTH), reachedCal\r
-                               .get(Calendar.MONTH));\r
-               assertEquals(expectedCal.get(Calendar.DATE), reachedCal\r
-                               .get(Calendar.DATE));\r
-               assertEquals(expectedCal.get(Calendar.HOUR_OF_DAY), reachedCal\r
-                               .get(Calendar.HOUR_OF_DAY));\r
-               assertEquals(expectedCal.get(Calendar.MINUTE), reachedCal\r
-                               .get(Calendar.MINUTE));\r
-               assertEquals(expectedCal.get(Calendar.SECOND), reachedCal\r
-                               .get(Calendar.SECOND));\r
-       }\r
-\r
-       private UnitUtils() {\r
-\r
-       }\r
-\r
-}\r
diff --git a/org.argeo.slc.unit/src/org/argeo/slc/unit/execution/AbstractExecutionFlowTestcase.java b/org.argeo.slc.unit/src/org/argeo/slc/unit/execution/AbstractExecutionFlowTestcase.java
deleted file mode 100644 (file)
index 774ce25..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.unit.execution;
-
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.unit.AbstractSpringTestCase;
-
-public class AbstractExecutionFlowTestcase extends AbstractSpringTestCase {
-       @SuppressWarnings(value = { "unchecked" })
-       protected <T extends ExecutionFlow> T executeFlow(String flowName) {
-               ExecutionFlow flow = getBean(flowName);
-               flow.run();
-               return (T) flow;
-       }
-}
diff --git a/org.argeo.slc.unit/src/org/argeo/slc/unit/execution/ExecutionFlowDescriptorTestUtils.java b/org.argeo.slc.unit/src/org/argeo/slc/unit/execution/ExecutionFlowDescriptorTestUtils.java
deleted file mode 100644 (file)
index b8619f4..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.unit.execution;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.argeo.slc.core.execution.DefaultExecutionSpec;
-import org.argeo.slc.core.execution.PrimitiveAccessor;
-import org.argeo.slc.core.execution.PrimitiveSpecAttribute;
-import org.argeo.slc.core.execution.PrimitiveValue;
-import org.argeo.slc.core.execution.RefSpecAttribute;
-import org.argeo.slc.core.execution.RefValue;
-import org.argeo.slc.core.execution.RefValueChoice;
-import org.argeo.slc.core.test.BasicTestData;
-import org.argeo.slc.execution.ExecutionFlowDescriptor;
-import org.argeo.slc.execution.ExecutionSpecAttribute;
-
-public class ExecutionFlowDescriptorTestUtils {
-       public static ExecutionFlowDescriptor createSimpleExecutionFlowDescriptor() {
-               ExecutionFlowDescriptor flowDescriptor = new ExecutionFlowDescriptor();
-               flowDescriptor.setName("simpleFlow");
-               flowDescriptor.setDescription("my description");
-
-               Map<String, Object> values = new HashMap<String, Object>();
-               values.put("primitiveInteger", new PrimitiveValue(
-                               PrimitiveAccessor.TYPE_INTEGER, 100));
-
-               RefValue refValue = new RefValue("002");
-               values.put("ref1", refValue);
-               flowDescriptor.setValues(values);
-
-               flowDescriptor.setExecutionSpec(createRelatedSimpleSpec());
-               return flowDescriptor;
-       }
-
-       protected static DefaultExecutionSpec createRelatedSimpleSpec() {
-               DefaultExecutionSpec spec = new DefaultExecutionSpec();
-               spec.setBeanName("simpleSpec");
-               Map<String, ExecutionSpecAttribute> attributes = new HashMap<String, ExecutionSpecAttribute>();
-
-               PrimitiveSpecAttribute primitiveInteger = new PrimitiveSpecAttribute();
-               primitiveInteger.setType(PrimitiveAccessor.TYPE_INTEGER);
-               primitiveInteger.setValue(50);
-               attributes.put("primitiveInteger", primitiveInteger);
-
-               RefSpecAttribute ref1 = new RefSpecAttribute();
-               ref1.setTargetClass(BasicTestData.class);
-               ref1.setChoices(new ArrayList<RefValueChoice>());
-               ref1.getChoices().add(new RefValueChoice("001", "desc"));
-               ref1.getChoices().add(new RefValueChoice("002", null));
-               ref1.getChoices().add(new RefValueChoice("003", null));
-               attributes.put("ref1", ref1);
-
-               spec.setAttributes(attributes);
-
-               return spec;
-       }
-}
diff --git a/pom.xml b/pom.xml
index 6cee4d3e1dc12587da01f794fb1a2a0b147bd5f8..98a5e915ef463ca8f2207817603fa8e31d573035 100644 (file)
--- a/pom.xml
+++ b/pom.xml
        </properties>
        <modules>
                <module>org.argeo.slc.api</module>
+               <module>org.argeo.slc.jcr</module>
 
                <!-- Runtime -->
                <module>org.argeo.slc.spring</module>
-               <module>org.argeo.slc.unit</module>
                <module>org.argeo.slc.support</module>
                <module>org.argeo.slc.repo</module>
                <module>org.argeo.slc.factory</module>