use of org.ovirt.engine.ui.uicommonweb.validation.LengthValidation in project ovirt-engine by oVirt.
the class StorageModel method validate.
public boolean validate() {
validateListItems(getHost());
validateListItems(getAvailableStorageDomainTypeItems());
validateListItems(getAvailableStorageTypeItems());
getDescription().validateEntity(new IValidation[] { new LengthValidation(BusinessEntitiesDefinitions.GENERAL_MAX_SIZE), new SpecialAsciiI18NOrNoneValidation() });
getComment().validateEntity(new IValidation[] { new SpecialAsciiI18NOrNoneValidation() });
getWarningLowSpaceIndicator().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(0, StorageConstants.LOW_SPACE_THRESHOLD) });
getCriticalSpaceActionBlocker().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(0, Integer.MAX_VALUE) });
validateDiscardAfterDelete();
return getName().getIsValid() && getHost().getIsValid() && getIsValid() && getCurrentStorageItem().validate() && getDescription().getIsValid() && getComment().getIsValid() && getWarningLowSpaceIndicator().getIsValid() && getCriticalSpaceActionBlocker().getIsValid() && getDiscardAfterDelete().getIsValid() && getBackup().getIsValid();
}
use of org.ovirt.engine.ui.uicommonweb.validation.LengthValidation in project ovirt-engine by oVirt.
the class NetworkModel method validate.
private boolean validate() {
LengthValidation tempVar = new LengthValidation();
tempVar.setMaxLength(BusinessEntitiesDefinitions.NETWORK_NAME_SIZE);
RegexValidation tempVar2 = new RegexValidation();
tempVar2.setIsNegate(true);
// $NON-NLS-1$
tempVar2.setExpression("^(bond)");
tempVar2.setMessage(ConstantsManager.getInstance().getConstants().networkNameStartMsg());
getName().validateEntity(new IValidation[] { new NotEmptyValidation(), tempVar, tempVar2 });
LengthValidation tempVar3 = new LengthValidation();
tempVar3.setMaxLength(40);
getDescription().validateEntity(new IValidation[] { tempVar3 });
getComment().validateEntity(new IValidation[] { new SpecialAsciiI18NOrNoneValidation() });
getVLanTag().setIsValid(true);
if (getHasVLanTag().getEntity()) {
IntegerValidation tempVar4 = new IntegerValidation();
tempVar4.setMinimum(0);
tempVar4.setMaximum(4094);
getVLanTag().validateEntity(new IValidation[] { new NotEmptyValidation(), tempVar4 });
}
IntegerValidation tempVar5 = new IntegerValidation();
tempVar5.setMinimum(68);
getMtu().validateEntity(new IValidation[] { new NotEmptyValidation(), tempVar5 });
getDnsConfigurationModel().validate();
getExternalProviders().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
boolean subnetValid = true;
if (getExternal().getEntity() && getCreateSubnet().getEntity()) {
subnetValid = getSubnetModel().validate();
}
boolean profilesValid = true;
Iterable<VnicProfileModel> profiles = getProfiles().getItems();
for (VnicProfileModel profileModel : profiles) {
if (!profileModel.validate()) {
profilesValid = false;
}
}
getNetworkLabel().validateSelectedItem(new IValidation[] { new AsciiNameValidation() });
setValidTab(TabName.GENERAL_TAB, isGeneralTabValid());
setValidTab(TabName.SUBNET_TAB, subnetValid);
setValidTab(TabName.PROFILES_TAB, profilesValid);
ValidationCompleteEvent.fire(getEventBus(), this);
return allTabsValid();
}
use of org.ovirt.engine.ui.uicommonweb.validation.LengthValidation 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.LengthValidation in project ovirt-engine by oVirt.
the class PoolModelBehaviorBase method validate.
@Override
public boolean validate() {
boolean isNew = getModel().getIsNew();
int maxAllowedVms = getMaxVmsInPool();
int assignedVms = getModel().getAssignedVms().asConvertible().integer();
int futureNumOfDesktops = (isNew ? 0 : assignedVms) + getModel().getNumOfDesktops().getEntity();
getModel().getNumOfDesktops().validateEntity(new IValidation[] { new NotEmptyValidation(), new LengthValidation(4), new IntegerValidation(isNew ? 1 : 0, isNew ? maxAllowedVms : maxAllowedVms - assignedVms) });
getModel().getPrestartedVms().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(0, futureNumOfDesktops) });
getModel().getMaxAssignedVmsPerUser().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(1, futureNumOfDesktops) });
getModel().setValidTab(TabName.GENERAL_TAB, getModel().isValidTab(TabName.GENERAL_TAB) && getModel().getName().getIsValid() && getModel().getNumOfDesktops().getIsValid() && getModel().getPrestartedVms().getIsValid() && getModel().getMaxAssignedVmsPerUser().getIsValid());
getModel().setValidTab(TabName.POOL_TAB, true);
if (getModel().getSpiceProxyEnabled().getEntity()) {
getModel().getSpiceProxy().validateEntity(new IValidation[] { new HostWithProtocolAndPortAddressValidation() });
} else {
getModel().getSpiceProxy().setIsValid(true);
}
return super.validate() && getModel().getName().getIsValid() && getModel().getNumOfDesktops().getIsValid() && getModel().getPrestartedVms().getIsValid() && getModel().getMaxAssignedVmsPerUser().getIsValid() && getModel().getSpiceProxy().getIsValid();
}
use of org.ovirt.engine.ui.uicommonweb.validation.LengthValidation in project ovirt-engine by oVirt.
the class FenceAgentModel method validatePmModels.
/**
* Validate the Power Management related Entity Models.
*/
public void validatePmModels() {
EntityModel<String> ip = getManagementIp();
EntityModel<String> userName = getPmUserName();
EntityModel<String> password = getPmPassword();
ListModel<String> type = getPmType();
EntityModel<Integer> port = getPmPort();
ip.validateEntity(new IValidation[] { new NotEmptyValidation(), new HostAddressValidation() });
userName.validateEntity(new IValidation[] { new NotEmptyValidation() });
password.validateEntity(new IValidation[] { new NotEmptyValidation(), new LengthValidation(50) });
type.validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
port.validateEntity(new IValidation[] { new IntegerValidation(1, 65535) });
}
Aggregations