Class Copy
- java.lang.Object
-
- org.nuxeo.connect.update.task.standalone.commands.AbstractCommand
-
- org.nuxeo.connect.update.task.standalone.commands.Copy
-
- All Implemented Interfaces:
org.nuxeo.connect.update.task.Command
- Direct Known Subclasses:
Append
,ParameterizedCopy
public class Copy extends AbstractCommand
Copy a file to the given target directory or file. If the target is a directory the file name is preserved. If the target file exists it will be replaced if overwrite is true otherwise the command validation fails. If the source file is a directory, then the files it contents will be recursively copied.If md5 is set then the copy command will be validated only if the target file has the same md5 as the one specified in the command.
The Copy command has as inverse either Delete either another Copy command. If the file was copied without overwriting then Delete is the inverse (with a md5 set to the one of the copied file). If the file was overwritten then the inverse of Copy command is another copy command with the md5 to the one of the copied file and the overwrite flag to true. The file to copy will be the backup of the overwritten file.
- Author:
- Bogdan Stefanescu
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
append
protected File
file
The source file.static String
ID
protected static String
LAUNCHER_CHANGED_PROPERTY
protected static String
LAUNCHER_JAR
protected static Log
log
protected String
md5
protected boolean
overwrite
protected boolean
removeOnExit
protected File
tofile
The target file.-
Fields inherited from class org.nuxeo.connect.update.task.standalone.commands.AbstractCommand
fail, guardVars, id, ignore
-
-
Constructor Summary
Constructors Modifier Constructor Description Copy()
Copy(File file, File tofile, String md5, boolean overwrite)
Copy(File file, File tofile, String md5, boolean overwrite, boolean removeOnExit)
protected
Copy(String id)
protected
Copy(String id, File file, File tofile, String md5, boolean overwrite, boolean removeOnExit)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected org.nuxeo.connect.update.task.Command
doCopy(org.nuxeo.connect.update.task.Task task, Map<String,String> prefs, File fileToCopy, File dst, boolean doOverwrite)
protected org.nuxeo.connect.update.task.Command
doRun(org.nuxeo.connect.update.task.Task task, Map<String,String> prefs)
Override to implement command actionsprotected void
doValidate(org.nuxeo.connect.update.task.Task task, org.nuxeo.connect.update.ValidationStatus status)
Override to implement validation.protected String
getContentToCopy(File fileToCopy, Map<String,String> prefs)
Override in subclass to parameterize content.protected String
getContentToCopy(Map<String,String> prefs)
Deprecated.Since 5.5, usegetContentToCopy(File, Map)
.void
readFrom(Element element)
Must be implemented to initialize the command arguments from an XML fragment.void
writeTo(org.nuxeo.connect.update.xml.XmlWriter writer)
-
Methods inherited from class org.nuxeo.connect.update.task.standalone.commands.AbstractCommand
getId, ignore, initialize, isPostInstall, run, setFail, setIgnore, setPackageUpdateService, validate
-
-
-
-
Field Detail
-
log
protected static final Log log
-
ID
public static final String ID
- See Also:
- Constant Field Values
-
LAUNCHER_JAR
protected static final String LAUNCHER_JAR
- See Also:
- Constant Field Values
-
LAUNCHER_CHANGED_PROPERTY
protected static final String LAUNCHER_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
file
protected File file
The source file. It can be a file or a directory.
-
tofile
protected File tofile
The target file. It can be a directory since 5.5
-
overwrite
protected boolean overwrite
-
md5
protected String md5
-
removeOnExit
protected boolean removeOnExit
-
append
protected boolean append
- Since:
- 5.5
-
-
Constructor Detail
-
Copy
protected Copy(String id)
-
Copy
public Copy()
-
-
Method Detail
-
doRun
protected org.nuxeo.connect.update.task.Command doRun(org.nuxeo.connect.update.task.Task task, Map<String,String> prefs) throws org.nuxeo.connect.update.PackageException
Description copied from class:AbstractCommand
Override to implement command actions- Specified by:
doRun
in classAbstractCommand
- Returns:
- Rollback command
- Throws:
org.nuxeo.connect.update.PackageException
-
doCopy
protected org.nuxeo.connect.update.task.Command doCopy(org.nuxeo.connect.update.task.Task task, Map<String,String> prefs, File fileToCopy, File dst, boolean doOverwrite) throws org.nuxeo.connect.update.PackageException
- Throws:
org.nuxeo.connect.update.PackageException
- Since:
- 5.5
-
getContentToCopy
protected String getContentToCopy(File fileToCopy, Map<String,String> prefs) throws org.nuxeo.connect.update.PackageException
Override in subclass to parameterize content.- Returns:
- Content to put in destination file. See
append
parameter to determine if returned content is replacing or appending to destination file. - Throws:
org.nuxeo.connect.update.PackageException
- Since:
- 5.5
-
getContentToCopy
@Deprecated protected String getContentToCopy(Map<String,String> prefs) throws org.nuxeo.connect.update.PackageException
Deprecated.Since 5.5, usegetContentToCopy(File, Map)
. This method is missing the fileToCopy reference. Usingfile
is leading to errors.- Throws:
org.nuxeo.connect.update.PackageException
-
doValidate
protected void doValidate(org.nuxeo.connect.update.task.Task task, org.nuxeo.connect.update.ValidationStatus status) throws org.nuxeo.connect.update.PackageException
Description copied from class:AbstractCommand
Override to implement validation.- Specified by:
doValidate
in classAbstractCommand
- Parameters:
task
- The task being validatedstatus
- UseValidationStatus.addError(String)
orValidationStatus.addWarning(String)
to provide validation error/warning messages- Throws:
org.nuxeo.connect.update.PackageException
-
readFrom
public void readFrom(Element element) throws org.nuxeo.connect.update.PackageException
Description copied from class:AbstractCommand
Must be implemented to initialize the command arguments from an XML fragment.- Specified by:
readFrom
in classAbstractCommand
- Throws:
org.nuxeo.connect.update.PackageException
-
writeTo
public void writeTo(org.nuxeo.connect.update.xml.XmlWriter writer)
-
-