From: yossarian Date: Sat, 11 Nov 2006 16:16:36 +0000 (+0000) Subject: DirCopyingProducerNode is now alerting the ChangeTracker when a directory gets copied. X-Git-Tag: LATEST_MERGED_1_1~31 X-Git-Url: http://erislabs.net/gitweb/?p=mir.git;a=commitdiff_plain;h=e098d83481bff4603cdfeb8e1f6eee2a20daeb72 DirCopyingProducerNode is now alerting the ChangeTracker when a directory gets copied. --- diff --git a/source/mir/producer/DirCopyingProducerNode.java b/source/mir/producer/DirCopyingProducerNode.java index e9caa58e..7682b560 100755 --- a/source/mir/producer/DirCopyingProducerNode.java +++ b/source/mir/producer/DirCopyingProducerNode.java @@ -27,9 +27,12 @@ */ package mir.producer; +import mir.changetracker.ChangeTracker; +import mir.changetracker.ChangeType; import mir.log.LoggerWrapper; import mir.util.FileRoutines; import mir.util.ParameterExpander; +import mircoders.global.MirGlobal; import java.io.File; import java.util.Map; @@ -38,32 +41,40 @@ import java.util.Map; * */ public class DirCopyingProducerNode extends AbstractProducerNode { - private String sourceExpression; - private String destinationExpression; - private File sourceBasePath; - private File destinationBasePath; - public DirCopyingProducerNode(File aSourceBasePath, File aDestinationBasePath, String aSource, String aDestination) { - sourceBasePath = aSourceBasePath; - destinationBasePath = aDestinationBasePath; - sourceExpression = aSource; - destinationExpression = aDestination; - } + private String sourceExpression; + private String destinationExpression; + private File sourceBasePath; + private File destinationBasePath; - public void produce(Map aValueMap, String aVerb, LoggerWrapper aLogger) throws ProducerFailure { - String source = ""; - String destination = ""; + public DirCopyingProducerNode(File aSourceBasePath, File aDestinationBasePath, String aSource, String aDestination) { + sourceBasePath = aSourceBasePath; + destinationBasePath = aDestinationBasePath; + sourceExpression = aSource; + destinationExpression = aDestination; + } - try { - source = ParameterExpander.expandExpression( aValueMap, sourceExpression ); - destination = ParameterExpander.expandExpression( aValueMap, destinationExpression ); - FileRoutines.copy( - new File(sourceBasePath, source), - new File(destinationBasePath, destination)); - aLogger.info(source + " copied into " + destination); - } - catch (Throwable e) { - aLogger.error("Copying " + source + " into " + destination + " failed: " + e.getMessage()); - } - } + public void produce(Map aValueMap, String aVerb, LoggerWrapper aLogger) throws ProducerFailure { + String source = ""; + String destination = ""; + + try { + source = ParameterExpander.expandExpression( aValueMap, sourceExpression ); + destination = ParameterExpander.expandExpression( aValueMap, destinationExpression ); + FileRoutines.copy( + new File(sourceBasePath, source), + new File(destinationBasePath, destination)); + aLogger.info(source + " copied into " + destination); + // YOSS TODO: changed this puppy, is it correct? + reportChange(destinationBasePath + destination); + } + catch (Throwable e) { + aLogger.error("Copying " + source + " into " + destination + " failed: " + e.getMessage()); + } + } + + private void reportChange(String destination) { + ChangeTracker changeTracker = MirGlobal.getChangeEngine().getTracker(); + changeTracker.addChange(destination, ChangeType.MODIFICATION); + } }