Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.connect.update.impl.task
Class AbstractCommand

java.lang.Object
  extended by org.nuxeo.connect.update.impl.task.AbstractCommand
All Implemented Interfaces:
Command
Direct Known Subclasses:
Copy, Delete, Deploy, DeployConfig, Install, LoadJar, PostInstallCommand, Undeploy, UndeployConfig, Uninstall, UnloadJar

public abstract class AbstractCommand
extends Object
implements Command

All commands have 2 attributes: fail and ignore which are EL expressions.

If ignore is defined and evaluated to true then the command will be ignored (null is returned as the inverse command) If fail is defined and evaluated to true then the validation fails.

Commands extending this class must implement the doRun(org.nuxeo.connect.update.task.Task, java.util.Map) and doValidate(org.nuxeo.connect.update.task.Task, org.nuxeo.connect.update.ValidationStatus) methods instead of the one in the interface. These methods are first testing for ignore and fail guards and then if needed delegated to the doXXX method versions.

Author:
Bogdan Stefanescu

Method Summary
 String getId()
          The command id
 boolean ignore()
           
 void initialize(Element element)
          Initialize a command parameters from a DOM element.
 boolean isPostInstall()
          Test if the command must be run at the end in an installation process.
abstract  void readFrom(Element element)
          Must be implemented to initialize the command arguments from an XML fragment.
 Command run(org.nuxeo.connect.update.task.Task task, Map<String,String> prefs)
          Execute the command and return the inverse command that can be used to rollback.
 void setFail(String fail)
           
 void setIgnore(String ignore)
           
 void validate(org.nuxeo.connect.update.task.Task task, org.nuxeo.connect.update.ValidationStatus status)
          Validate if the command can be safely executed on the running platform.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.nuxeo.connect.update.impl.task.Command
writeTo
 

Method Detail

isPostInstall

public boolean isPostInstall()
Description copied from interface: Command
Test if the command must be run at the end in an installation process. This is useful for flush like commands that reset application cache. These commands musty be executed at the install/uninstall end. By default the uninstall log is generated by using the inverse of the installation commands executed in the inverse order. This is not good for flush like commands that should always be executed at the end. For example if you have a copy and a flush command in the install.xml the generated uninstall.xml will have a flush and a delete command - but he order is not good since flush should be done at the end. By marking your command as post-install it will be put To implement a post-install command simply override PostInstallCommand.

Specified by:
isPostInstall in interface Command
Returns:

validate

public void validate(org.nuxeo.connect.update.task.Task task,
                     org.nuxeo.connect.update.ValidationStatus status)
              throws org.nuxeo.connect.update.PackageException
Description copied from interface: Command
Validate if the command can be safely executed on the running platform. The command should check if the artifacts it needs to copy or replace are consistent with the command configuration. If inconsistency is detected errors or warnings must be added to the status.

Specified by:
validate in interface Command
Throws:
org.nuxeo.connect.update.PackageException

run

public Command run(org.nuxeo.connect.update.task.Task task,
                   Map<String,String> prefs)
            throws org.nuxeo.connect.update.PackageException
Description copied from interface: Command
Execute the command and return the inverse command that can be used to rollback. Can return null if no rollback command is needed.

Specified by:
run in interface Command
Throws:
org.nuxeo.connect.update.PackageException

getId

public String getId()
Description copied from interface: Command
The command id

Specified by:
getId in interface Command
Returns:

setFail

public void setFail(String fail)

setIgnore

public void setIgnore(String ignore)

ignore

public boolean ignore()
               throws org.nuxeo.connect.update.PackageException
Throws:
org.nuxeo.connect.update.PackageException

initialize

public void initialize(Element element)
                throws org.nuxeo.connect.update.PackageException
Description copied from interface: Command
Initialize a command parameters from a DOM element. This method will be called only once by the task when the commands are loaded from an XML file.

Specified by:
initialize in interface Command
Throws:
org.nuxeo.connect.update.PackageException

readFrom

public abstract void readFrom(Element element)
                       throws org.nuxeo.connect.update.PackageException
Must be implemented to initialize the command arguments from an XML fragment.

Throws:
org.nuxeo.connect.update.PackageException

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.