Search in sources :

Example 21 with UIConstants

use of org.ovirt.engine.ui.uicompat.UIConstants in project ovirt-engine by oVirt.

the class RunOnceModel method validate.

public boolean validate() {
    getIsoImage().setIsValid(true);
    if (getAttachIso().getEntity()) {
        getIsoImage().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    }
    getFloppyImage().setIsValid(true);
    if (getAttachFloppy().getEntity()) {
        getFloppyImage().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    }
    boolean customPropertyValidation = getCustomPropertySheet().validate();
    if (getIsLinuxOS()) {
        getKernelImage().validateSelectedItem(new IValidation[] { new NoTrimmingWhitespacesValidation() });
        getInitrdImage().validateSelectedItem(new IValidation[] { new NoTrimmingWhitespacesValidation() });
        getKernelParameters().validateEntity(new IValidation[] { new NoTrimmingWhitespacesValidation() });
        // initrd path and kernel params require kernel path to be filled
        if (StringHelper.isNullOrEmpty(getKernelImage().getSelectedItem())) {
            final UIConstants constants = ConstantsManager.getInstance().getConstants();
            if (!StringHelper.isNullOrEmpty(getInitrdImage().getSelectedItem())) {
                getInitrdImage().getInvalidityReasons().add(constants.initrdPathInvalid());
                getInitrdImage().setIsValid(false);
                getKernelImage().getInvalidityReasons().add(constants.initrdPathInvalid());
                getKernelImage().setIsValid(false);
            }
            if (!StringHelper.isNullOrEmpty(getKernelParameters().getEntity())) {
                getKernelParameters().getInvalidityReasons().add(constants.kernelParamsInvalid());
                getKernelParameters().setIsValid(false);
                getKernelImage().getInvalidityReasons().add(constants.kernelParamsInvalid());
                getKernelImage().setIsValid(false);
            }
        }
    }
    if (getIsAutoAssign().getEntity() != null && !getIsAutoAssign().getEntity()) {
        getDefaultHost().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    } else {
        getDefaultHost().setIsValid(true);
    }
    getSysPrepPassword().setIsValid(true);
    getSysPrepPasswordVerification().setIsValid(true);
    if (getIsWindowsOS() && getIsSysprepEnabled().getEntity()) {
        getSysPrepPassword().validateEntity(new IValidation[] { new NotEmptyValidation(), new MatchFieldsValidator(getSysPrepPassword().getEntity(), getSysPrepPasswordVerification().getEntity()) });
    }
    boolean cloudInitIsValid = getVmInitModel().validate();
    getEmulatedMachine().validateSelectedItem(new IValidation[] { new I18NExtraNameOrNoneValidation(), new LengthValidation(BusinessEntitiesDefinitions.VM_EMULATED_MACHINE_SIZE) });
    getCustomCpu().validateSelectedItem(new IValidation[] { new I18NExtraNameOrNoneValidation(), new LengthValidation(BusinessEntitiesDefinitions.VM_CPU_NAME_SIZE) });
    return getIsoImage().getIsValid() && getFloppyImage().getIsValid() && getKernelImage().getIsValid() && getInitrdImage().getIsValid() && getKernelParameters().getIsValid() && getDefaultHost().getIsValid() && customPropertyValidation && cloudInitIsValid && getSysPrepPassword().getIsValid() && getEmulatedMachine().getIsValid() && getCustomCpu().getIsValid();
}
Also used : NoTrimmingWhitespacesValidation(org.ovirt.engine.ui.uicommonweb.validation.NoTrimmingWhitespacesValidation) MatchFieldsValidator(org.ovirt.engine.ui.uicommonweb.validation.MatchFieldsValidator) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) I18NExtraNameOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.I18NExtraNameOrNoneValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation)

Aggregations

UIConstants (org.ovirt.engine.ui.uicompat.UIConstants)21 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)11 ArrayList (java.util.ArrayList)10 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)7 List (java.util.List)6 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)6 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)4 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)4 ActionType (org.ovirt.engine.core.common.action.ActionType)4 GlusterVolumeParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeParameters)4 GlusterStatus (org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus)4 SearchParameters (org.ovirt.engine.core.common.queries.SearchParameters)4 Guid (org.ovirt.engine.core.compat.Guid)4 Frontend (org.ovirt.engine.ui.frontend.Frontend)4 Inject (com.google.inject.Inject)3 Arrays (java.util.Arrays)3 CreateGlusterVolumeParameters (org.ovirt.engine.core.common.action.gluster.CreateGlusterVolumeParameters)3 GlusterVolumeActionParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeActionParameters)3 GlusterVolumeOptionParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeOptionParameters)3 GlusterVolumeRebalanceParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeRebalanceParameters)3