use of org.ovirt.engine.ui.uicommonweb.validation.NoTrimmingWhitespacesValidation in project ovirt-engine by oVirt.
the class UnitVmModel method validate.
public boolean validate(boolean templateWithVersionRequired) {
resetTabsValidity();
getInstanceTypes().setIsValid(true);
getInstanceTypes().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
getDataCenterWithClustersList().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
getOSType().validateSelectedItem(new NotEmptyValidation[] { new NotEmptyValidation() });
DataCenterWithCluster dataCenterWithCluster = getDataCenterWithClustersList().getSelectedItem();
StoragePool dataCenter = dataCenterWithCluster == null ? null : dataCenterWithCluster.getDataCenter();
if (dataCenter != null && dataCenter.getQuotaEnforcementType() == QuotaEnforcementTypeEnum.HARD_ENFORCEMENT) {
getQuota().validateSelectedItem(new IValidation[] { new NotEmptyQuotaValidation() });
}
if (getOSType().getIsValid()) {
validateNaming();
getVmId().setIsValid(true);
if (getVmId().getIsAvailable() && !StringHelper.isNullOrEmpty(getVmId().getEntity())) {
getVmId().validateEntity(new IValidation[] { new GuidValidation() });
}
getComment().validateEntity(new IValidation[] { new SpecialAsciiI18NOrNoneValidation() });
setValidTab(TabName.GENERAL_TAB, isValidTab(TabName.GENERAL_TAB) && getVmId().getIsValid() && getComment().getIsValid());
}
if (templateWithVersionRequired) {
getTemplateWithVersion().validateSelectedItem(new IValidation[] { new NotEmptyValidation(), createEachDiskAHasStorageDomainValidation() });
}
getDisksAllocationModel().validateEntity(new IValidation[] {});
getCdImage().setIsValid(true);
if (getCdImage().getIsChangable()) {
getCdImage().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
}
if (getIsLinuxOS()) {
getKernel_path().validateEntity(new IValidation[] { new NoTrimmingWhitespacesValidation() });
getInitrd_path().validateEntity(new IValidation[] { new NoTrimmingWhitespacesValidation() });
getKernel_parameters().validateEntity(new IValidation[] { new NoTrimmingWhitespacesValidation() });
// initrd path and kernel params require kernel path to be filled
if (StringHelper.isNullOrEmpty(getKernel_path().getEntity())) {
if (!StringHelper.isNullOrEmpty(getInitrd_path().getEntity())) {
getInitrd_path().getInvalidityReasons().add(constants.initrdPathInvalid());
getInitrd_path().setIsValid(false);
getKernel_path().getInvalidityReasons().add(constants.initrdPathInvalid());
getKernel_path().setIsValid(false);
}
if (!StringHelper.isNullOrEmpty(getKernel_parameters().getEntity())) {
getKernel_parameters().getInvalidityReasons().add(constants.kernelParamsInvalid());
getKernel_parameters().setIsValid(false);
getKernel_path().getInvalidityReasons().add(constants.kernelParamsInvalid());
getKernel_path().setIsValid(false);
}
}
}
if (!getBehavior().isBlankTemplateBehavior()) {
setValidTab(TabName.GENERAL_TAB, isValidTab(TabName.GENERAL_TAB) && getDataCenterWithClustersList().getIsValid() && getTemplateWithVersion().getIsValid());
}
setValidTab(TabName.HOST_TAB, isValidTab(TabName.HOST_TAB) && getMigrationDowntime().getIsValid());
boolean diskAliasesValid = getDisksAllocationModel().getIsValid();
setValidTab(TabName.RESOURCE_ALLOCATION_TAB, isValidTab(TabName.RESOURCE_ALLOCATION_TAB) && getCpuSharesAmount().getIsValid() && diskAliasesValid);
setValidTab(TabName.BOOT_OPTIONS_TAB, getCdImage().getIsValid() && getKernel_path().getIsValid());
boolean vmInitIsValid = getVmInitModel().validate();
setValidTab(TabName.INITIAL_RUN_TAB, vmInitIsValid);
getIcon().validateEntity(new IValidation[] { new IconWithOsDefaultValidation() });
setValidTab(TabName.ICON_TAB, getIcon().getIsValid());
boolean hwPartValid = validateHwPart();
boolean isValid = hwPartValid && vmInitIsValid && allTabsValid();
getValid().setEntity(isValid);
fireValidationCompleteEvent();
return isValid;
}
use of org.ovirt.engine.ui.uicommonweb.validation.NoTrimmingWhitespacesValidation 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();
}
Aggregations