]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.support.castor/src/main/java/org/argeo/slc/xml/process/FileSlcExecutionNotifier.java
Improve logging
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.castor / src / main / java / org / argeo / slc / xml / process / FileSlcExecutionNotifier.java
index f16b4e7894cf06a2c0a1fccfde78e28fe0db658d..8b110ecd2032f4302f38806929d3dd731c6c0369 100644 (file)
@@ -1,9 +1,23 @@
+/*\r
+ * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>\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
+\r
 package org.argeo.slc.xml.process;\r
 \r
 import java.io.File;\r
 import java.io.FileWriter;\r
-import java.text.SimpleDateFormat;\r
-import java.util.Date;\r
 import java.util.HashMap;\r
 import java.util.List;\r
 import java.util.Map;\r
@@ -12,46 +26,38 @@ import javax.xml.transform.stream.StreamResult;
 \r
 import org.apache.commons.io.IOUtils;\r
 import org.argeo.slc.SlcException;\r
+import org.argeo.slc.execution.ExecutionProcess;\r
 import org.argeo.slc.process.SlcExecution;\r
 import org.argeo.slc.process.SlcExecutionNotifier;\r
+import org.argeo.slc.execution.ExecutionStep;\r
 import org.argeo.slc.process.SlcExecutionStep;\r
 import org.springframework.oxm.Marshaller;\r
 \r
+/** @deprecated Probably not even working anymore */\r
 public class FileSlcExecutionNotifier implements SlcExecutionNotifier {\r
-       private final static SimpleDateFormat sdf = new SimpleDateFormat(\r
-                       "yyyyMMdd-HHmmss");\r
-\r
-       private String basePath;\r
+       // private final static SimpleDateFormat sdf = new SimpleDateFormat(\r
+       // "yyyyMMdd-HHmmss");\r
+       //\r
+       // private String basePath;\r
        private Marshaller marshaller;\r
 \r
        private Map<String, String> uuidToDir = new HashMap<String, String>();\r
 \r
-       public void addSteps(SlcExecution slcExecution,\r
-                       List<SlcExecutionStep> additionalSteps) {\r
-               writeSlcExecution(slcExecution);\r
-       }\r
-\r
-       public void newExecution(SlcExecution slcExecution) {\r
-               String dirPath = basePath + File.separator + sdf.format(new Date())\r
-                               + '-' + slcExecution.getUuid();\r
-               File dir = new File(dirPath);\r
-               dir.mkdirs();\r
-\r
-               uuidToDir.put(slcExecution.getUuid(), dirPath);\r
-\r
-               writeSlcExecution(slcExecution);\r
-       }\r
-\r
-       public void updateExecution(SlcExecution slcExecution) {\r
+       public void addSteps(ExecutionProcess slcExecution,\r
+                       List<ExecutionStep> additionalSteps) {\r
                writeSlcExecution(slcExecution);\r
        }\r
 \r
-       public void updateStatus(SlcExecution slcExecution, String oldStatus,\r
+       public void updateStatus(ExecutionProcess slcExecution, String oldStatus,\r
                        String newStatus) {\r
                writeSlcExecution(slcExecution);\r
        }\r
 \r
-       protected void writeSlcExecution(SlcExecution slcExecution) {\r
+       protected void writeSlcExecution(ExecutionProcess process) {\r
+               if (!(process instanceof SlcExecution))\r
+                       throw new SlcException("Unsupported process type "\r
+                                       + process.getClass());\r
+               SlcExecution slcExecution = (SlcExecution) process;\r
                FileWriter out = null;\r
                try {\r
                        out = new FileWriter(getFilePath(slcExecution));\r
@@ -75,7 +81,7 @@ public class FileSlcExecutionNotifier implements SlcExecutionNotifier {
        }\r
 \r
        public void setBasePath(String basePath) {\r
-               this.basePath = basePath;\r
+               // this.basePath = basePath;\r
        }\r
 \r
        public void setMarshaller(Marshaller marshaller) {\r