use of org.ovirt.engine.ui.uicommonweb.validation.I18NExtraNameOrNoneValidation in project ovirt-engine by oVirt.
the class UnitVmModel method validateHwPart.
public boolean validateHwPart() {
getMigrationDowntime().validateEntity(new IValidation[] { new NotNullIntegerValidation(0, Integer.MAX_VALUE) });
getTotalCPUCores().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(1, behavior.maxCpus), new TotalCpuCoresComposableValidation() });
if (getIsAutoAssign().getEntity() != null && !getIsAutoAssign().getEntity()) {
getDefaultHost().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
} else {
getDefaultHost().setIsValid(true);
}
if (getCpuSharesAmount().getIsAvailable()) {
getCpuSharesAmount().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(0, 262144) });
}
boolean customPropertySheetValid = getCustomPropertySheet().validate();
setValidTab(TabName.CUSTOM_PROPERTIES_TAB, customPropertySheetValid);
if (getSerialNumberPolicy().getSelectedSerialNumberPolicy() == SerialNumberPolicy.CUSTOM) {
getSerialNumberPolicy().getCustomSerialNumber().validateEntity(new IValidation[] { new NotEmptyValidation() });
} else {
getSerialNumberPolicy().getCustomSerialNumber().setIsValid(true);
}
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) });
setValidTab(TabName.CONSOLE_TAB, getUsbPolicy().getIsValid() && getNumOfMonitors().getIsValid() && getSpiceProxy().getIsValid());
setValidTab(TabName.HOST_TAB, getMigrationDowntime().getIsValid());
getRngBytes().validateEntity(new IValidation[] { new IntegerValidation(0, Integer.MAX_VALUE), new RngDevValidation() });
getRngPeriod().validateEntity(new IValidation[] { new IntegerValidation(0, Integer.MAX_VALUE) });
setValidTab(TabName.TAB_RNG, getRngBytes().getIsValid() && getRngPeriod().getIsValid());
// Minimum 'Physical Memory Guaranteed' is 1MB
validateMemorySize(getMemSize(), Integer.MAX_VALUE, 1);
if (getMemSize().getIsValid()) {
validateMemorySize(getMinAllocatedMemory(), getMemSize().getEntity(), 1);
}
validateMaxMemorySize();
validateMemoryAlignment(getMemSize());
setValidTab(TabName.RESOURCE_ALLOCATION_TAB, getMinAllocatedMemory().getIsValid());
setValidTab(TabName.SYSTEM_TAB, getMemSize().getIsValid() && getMaxMemorySize().getIsValid() && getTotalCPUCores().getIsValid() && getSerialNumberPolicy().getCustomSerialNumber().getIsValid() && getEmulatedMachine().getIsValid() && getCustomCpu().getIsValid());
/*
* This should be run at very end of the validation process otherwise general validation can override more
* strict checks in behaviors
*/
boolean behaviorValid = behavior.validate();
boolean isValid = behaviorValid && allTabsValid();
return isValid;
}
use of org.ovirt.engine.ui.uicommonweb.validation.I18NExtraNameOrNoneValidation 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