DirCopyingProducerNode is now alerting the ChangeTracker when a directory gets copied.
authoryossarian <yossarian>
Sat, 11 Nov 2006 16:16:36 +0000 (16:16 +0000)
committeryossarian <yossarian>
Sat, 11 Nov 2006 16:16:36 +0000 (16:16 +0000)
source/mir/producer/DirCopyingProducerNode.java

index e9caa58..7682b56 100755 (executable)
  */
 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);
+       }
 }