X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.core%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Fprocess%2FFileSlcExecutionNotifier.java;fp=org.argeo.slc.core%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Fprocess%2FFileSlcExecutionNotifier.java;h=0000000000000000000000000000000000000000;hb=cdb5a9f10678f41914d6eeebd6620c0a84dbd208;hp=0b9f682b016c8985a8e9ca85a6f340fd5b0b03ec;hpb=7a8f034133c1112e187e2a2bfd2c56a8d2452345;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc.core/src/main/java/org/argeo/slc/core/process/FileSlcExecutionNotifier.java b/org.argeo.slc.core/src/main/java/org/argeo/slc/core/process/FileSlcExecutionNotifier.java deleted file mode 100644 index 0b9f682b0..000000000 --- a/org.argeo.slc.core/src/main/java/org/argeo/slc/core/process/FileSlcExecutionNotifier.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.argeo.slc.core.process; - -import java.io.File; -import java.io.FileWriter; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.transform.stream.StreamResult; - -import org.apache.commons.io.IOUtils; -import org.argeo.slc.core.SlcException; -import org.springframework.oxm.Marshaller; - -public class FileSlcExecutionNotifier implements SlcExecutionNotifier { - private final static SimpleDateFormat sdf = new SimpleDateFormat( - "yyyyMMdd-HHmmss"); - - private String basePath; - private Marshaller marshaller; - - private Map uuidToDir = new HashMap(); - - public void addSteps(SlcExecution slcExecution, - List additionalSteps) { - writeSlcExecution(slcExecution); - } - - public void newExecution(SlcExecution slcExecution) { - String dirPath = basePath + File.separator + sdf.format(new Date()) - + '-' + slcExecution.getUuid(); - File dir = new File(dirPath); - dir.mkdirs(); - - uuidToDir.put(slcExecution.getUuid(), dirPath); - - writeSlcExecution(slcExecution); - } - - public void updateExecution(SlcExecution slcExecution) { - writeSlcExecution(slcExecution); - } - - public void updateStatus(SlcExecution slcExecution, String oldStatus, - String newStatus) { - writeSlcExecution(slcExecution); - } - - protected void writeSlcExecution(SlcExecution slcExecution) { - FileWriter out = null; - try { - out = new FileWriter(getFilePath(slcExecution)); - marshaller.marshal(slcExecution, new StreamResult(out)); - } catch (Exception e) { - throw new SlcException("Cannot marshall SlcExecution to " - + getFilePath(slcExecution), e); - } finally { - IOUtils.closeQuietly(out); - } - } - - protected String getFileName(SlcExecution slcExecution) { - return "SlcExecution-" + slcExecution.getUuid() + ".xml"; - } - - protected String getFilePath(SlcExecution slcExecution) { - String dirPath = uuidToDir.get(slcExecution.getUuid()); - return dirPath + File.separator + "SlcExecution-" - + slcExecution.getUuid() + ".xml"; - } - - public void setBasePath(String basePath) { - this.basePath = basePath; - } - - public void setMarshaller(Marshaller marshaller) { - this.marshaller = marshaller; - } - -}