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();
}
Aggregations