@Override
@Transactional
public void updateActionDefinition(String actionName, ActionType actionType, String description,
TargetHostType targetType, Short defaultTimeout)
throws AmbariException {
ActionEntity entity = actionDefinitionDAO.findByPK(actionName);
if (entity != null) {
if (actionType != null) {
if (actionType == ActionType.SYSTEM_DISABLED) {
throw new AmbariException("Action type cannot be " + actionType);
}
entity.setActionType(actionType);
}
if (description != null) {
if (description.isEmpty()) {
throw new AmbariException("Action description cannot be empty");
}
entity.setDescription(description);
}
if (targetType != null) {
entity.setTargetType(targetType);
}
if (defaultTimeout != null) {
if (defaultTimeout < MIN_TIMEOUT || defaultTimeout > MAX_TIMEOUT) {
throw new AmbariException("Default timeout should be between " + MIN_TIMEOUT + " and " + MAX_TIMEOUT);
}
entity.setDefaultTimeout(defaultTimeout);
}
actionDefinitionDAO.merge(entity);
} else {
throw new AmbariException("Action definition " + actionName + " does not exist");
}