public abstract class CommandBase<T extends VdcActionParametersBase> extends AuditLogableBase implements RollbackHandler, TransactionMethod<Object>
Modifier and Type | Field and Description |
---|---|
protected static long |
BYTES_IN_GB
Multiplier used to convert GB to bytes or vice versa.
|
protected LogCompat |
log |
Modifier | Constructor and Description |
---|---|
protected |
CommandBase() |
protected |
CommandBase(Guid commandId)
Constructor for command creation when compensation is applied on startup
|
protected |
CommandBase(T parameters) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
acquireLock() |
protected void |
addCanDoActionMessage(String message)
Add a message to the
canDoAction() 's return value. |
protected void |
addCanDoActionMessage(VdcBllMessages message)
Add a message to the
canDoAction() 's return value. |
protected List<Class<?>> |
addValidationGroup(Class<?>... validationGroup) |
protected boolean |
canDoAction() |
VdcReturnValueBase |
CanDoActionOnly() |
protected void |
compensate()
Run the default compensation logic (inside a new transaction):
Get all the entity snapshots that this command has created. For each snapshot: Deserialize the entity. Using the entity DAO: If the entity was added by the command, remove it. Otherwise, If the entity is not in DB anymore, restore it. Otherwise, update it. Remove all the snapshots for this command, since we handled them. |
protected Guid |
ConcreteCreateTask(AsyncTaskCreationInfo asyncTaskCreationInfo,
VdcActionType parentCommand) |
protected VdcReturnValueBase |
CreateReturnValue()
Factory to determine the type of the ReturnValue field
|
protected Guid |
CreateTask(AsyncTaskCreationInfo asyncTaskCreationInfo,
VdcActionType parentCommand)
Use this method in order to create task in the AsyncTaskManager in a safe
way.
|
VdcReturnValueBase |
EndAction() |
void |
endActionInTransactionScope() |
protected void |
EndSuccessfully() |
protected void |
EndWithFailure() |
VdcReturnValueBase |
ExecuteAction() |
protected abstract void |
executeCommand() |
protected void |
freeLock() |
protected Object |
getActionReturnValue() |
protected CommandActionState |
getActionState() |
protected VdcActionType |
getActionType() |
protected BusinessEntitySnapshotDAO |
getBusinessEntitySnapshotDAO() |
boolean |
getCommandShouldBeLogged() |
protected CompensationContext |
getCompensationContext() |
protected String |
getDescription() |
protected static Date |
getNow() |
protected Guid |
getObjectLockingId() |
protected T |
getParameters() |
protected VdcActionParametersBase |
getParametersForTask(VdcActionType parentCommandType,
VdcActionParametersBase parameters)
Calculates the proper parameters for the task
|
abstract Map<Guid,VdcObjectType> |
getPermissionCheckSubjects()
Permissions are attached to object so every command must declare its
object target type and its GUID
|
VdcReturnValueBase |
getReturnValue() |
protected boolean |
getSucceeded() |
protected List<tags> |
GetTagsAttachedToObject() |
protected ArrayList<Guid> |
getTaskIdList() |
protected TransactionScopeOption |
getTransactionScopeOption() |
TimeSpan |
getTransactionTimeout() |
protected List<Class<?>> |
getValidationGroups() |
protected boolean |
IsBackwardsCompatible() |
protected boolean |
isInternalExecution() |
protected boolean |
IsUserAutorizedToRunAction()
Check if current user is authorized to run current action.
|
protected void |
RevertTasks() |
void |
Rollback() |
Object |
runInTransaction() |
protected VDSReturnValue |
runVdsCommand(VDSCommandType commandType,
VDSParametersBase parameters)
Run the given command in the VDS and return the VDS's response.
|
protected void |
setActionMessageParameters()
Set the parameters for bll messages (such as type and action).
|
protected void |
setActionReturnValue(Object value) |
void |
setCommandShouldBeLogged(boolean value) |
void |
setCompensationContext(CompensationContext compensationContext) |
protected void |
setDescription(String value) |
void |
setInternalExecution(boolean isInternalExecution) |
protected void |
setSucceeded(boolean value) |
protected void |
UpdateTasksWithActionParameters() |
protected boolean |
validateInputs() |
AddCustomValue, AppendCustomValue, DefaultLog, getAuditLogTypeValue, getCurrentUser, GetCustomValue, getCustomValues, getKey, getSnapshotName, getStorageDomain, getStorageDomainDAO, getStorageDomainId, getStorageDomainName, getStoragePool, getStoragePoolDAO, getStoragePoolId, getStoragePoolName, getUserId, getUserName, getVds, getVdsDAO, getVdsGroup, getVdsGroupDAO, getVdsGroupId, getVdsGroupName, getVdsId, getVdsIdRef, getVdsName, getVm, getVmDAO, getVmId, getVmIdRef, getVmName, getVmStaticDAO, getVmStatisticsDAO, getVmTemplate, getVmTemplateDAO, getVmTemplateId, getVmTemplateIdRef, getVmTemplateName, log, setCurrentUser, setSnapshotName, setStorageDomain, setStorageDomainId, setStoragePool, setStoragePoolId, setUserId, setUserName, setVds, setVdsGroup, setVdsGroupId, setVdsId, setVdsIdRef, setVdsName, setVm, setVmId, setVmName, setVmTemplate, setVmTemplateId, setVmTemplateName
getEndTime, getLegal, getTimeoutObjectId, getUseTimout, setEndTime, setTimeoutObjectId, setUseTimout
protected static final long BYTES_IN_GB
protected LogCompat log
protected CommandBase()
protected CommandBase(T parameters)
protected CommandBase(Guid commandId)
commandId
- protected CommandActionState getActionState()
protected BusinessEntitySnapshotDAO getBusinessEntitySnapshotDAO()
protected CompensationContext getCompensationContext()
public void setCompensationContext(CompensationContext compensationContext)
compensationContext
- the compensationContext to setpublic VdcReturnValueBase CanDoActionOnly()
public VdcReturnValueBase ExecuteAction()
protected void compensate()
public VdcReturnValueBase EndAction()
public void endActionInTransactionScope()
protected void EndSuccessfully()
protected void EndWithFailure()
protected boolean validateInputs()
protected void setActionMessageParameters()
protected boolean IsBackwardsCompatible()
protected boolean IsUserAutorizedToRunAction()
protected boolean canDoAction()
protected VdcReturnValueBase CreateReturnValue()
protected boolean getSucceeded()
protected void setSucceeded(boolean value)
public boolean getCommandShouldBeLogged()
public void setCommandShouldBeLogged(boolean value)
protected void setActionReturnValue(Object value)
protected Object getActionReturnValue()
public TimeSpan getTransactionTimeout()
protected VdcActionParametersBase getParametersForTask(VdcActionType parentCommandType, VdcActionParametersBase parameters)
parentCommandType
- parent command type for which the task is createdparameters
- parameter of the creating commandprotected TransactionScopeOption getTransactionScopeOption()
protected abstract void executeCommand()
protected static Date getNow()
protected T getParameters()
public VdcReturnValueBase getReturnValue()
protected VdcActionType getActionType()
protected String getDescription()
protected void setDescription(String value)
protected Guid CreateTask(AsyncTaskCreationInfo asyncTaskCreationInfo, VdcActionType parentCommand)
asyncTaskCreationInfo
- info to send to AsyncTaskManager when creating the task.parentCommand
- VdcActionType of the command that its EndAction we want to
invoke when tasks are finished.protected Guid ConcreteCreateTask(AsyncTaskCreationInfo asyncTaskCreationInfo, VdcActionType parentCommand)
protected void UpdateTasksWithActionParameters()
public void Rollback()
Rollback
in interface RollbackHandler
protected void RevertTasks()
protected Guid getObjectLockingId()
protected boolean acquireLock()
protected void freeLock()
public Object runInTransaction()
runInTransaction
in interface TransactionMethod<Object>
protected boolean isInternalExecution()
public void setInternalExecution(boolean isInternalExecution)
protected void addCanDoActionMessage(VdcBllMessages message)
canDoAction()
's return value.
This return value will be sent to the client for the detailed information
of why the action can't be performed.message
- The message to add.protected void addCanDoActionMessage(String message)
canDoAction()
's return value.
This return value will be sent to the client for the detailed information of why the action can't be performed.message
- The message to add.protected VDSReturnValue runVdsCommand(VDSCommandType commandType, VDSParametersBase parameters) throws VdcBLLException
commandType
- The command to run.parameters
- The corresponding parameters for the command.VdcBLLException
- In case of an unhandled exception (Usually more severe than failure of the command, because we don't
know why).public abstract Map<Guid,VdcObjectType> getPermissionCheckSubjects()
Copyright © 2012. All Rights Reserved.