*/
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;
*
*/
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);
+ }
}