org.rhq.enterprise.agent.update
Class CopyWithBackup

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.rhq.enterprise.agent.update.CopyWithBackup
All Implemented Interfaces:
Cloneable

public class CopyWithBackup
extends org.apache.tools.ant.Task

Compares two files, an old one and a new one and if they differ, one will win and be kept as-is in the new file's parent directory while the other one will get copied under a new name in the new file's parent directory as a backup copy. If the two files are identical, this task is a no-op and does nothing. If backupextension is not specified, the file that is not to be kept will not be backed up. That will compare old/file to new/file and if they are different, the new one will be kept as is in directory new and the old one will be copied into directory 'new' but with a name of "file" appended with the backup extension ".default". The "old" file is always copied to the directory where the "new" file is located; the "keep" attribute determines which file gets renamed with the backup extension and which keeps its file name intact. This allows us to tell which customized files from an old install should override the new install's default files and which of the new default files should override any previous customizations made to an old install. This loads in the content of both files to generate the MD5 - do not use this task on large binary files. If we need to do this kind of task on files other than small text files, we need to refactor the way the MD5's are calculated.

Author:
John Mazzitelli

Field Summary
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
CopyWithBackup()
           
 
Method Summary
 void execute()
           
 void setBackupextension(String ext)
           
 void setFailonerror(Boolean flag)
           
 void setFilename(String filename)
           
 void setKeep(String keep)
           
 void setNewdir(File dir)
           
 void setOlddir(File dir)
           
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CopyWithBackup

public CopyWithBackup()
Method Detail

setOlddir

public void setOlddir(File dir)

setNewdir

public void setNewdir(File dir)

setFilename

public void setFilename(String filename)

setKeep

public void setKeep(String keep)

setBackupextension

public void setBackupextension(String ext)

setFailonerror

public void setFailonerror(Boolean flag)

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Overrides:
execute in class org.apache.tools.ant.Task
Throws:
org.apache.tools.ant.BuildException
See Also:
Task.execute()


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.