use of org.ovirt.engine.ui.uicommonweb.validation.IValidation in project ovirt-engine by oVirt.
the class ClusterModel method validate.
public boolean validate() {
validateName();
getDataCenter().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
getCustomPropertySheet().setIsValid(getCustomPropertySheet().validate());
setValidTab(TabName.CLUSTER_POLICY_TAB, getCustomPropertySheet().getIsValid());
final IValidation[] versionValidations = new IValidation[] { new NotEmptyValidation() };
getVersion().validateSelectedItem(versionValidations);
getManagementNetwork().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
getRngHwrngSourceRequired().setIsValid(true);
boolean validService = true;
if (getEnableOvirtService().getIsAvailable() && getEnableGlusterService().getIsAvailable()) {
validService = getEnableOvirtService().getEntity() || getEnableGlusterService().getEntity();
}
getGlusterHostAddress().validateEntity(new IValidation[] { new NotEmptyValidation() });
getGlusterHostPassword().validateEntity(new IValidation[] { new NotEmptyValidation() });
if (!validService) {
setMessage(ConstantsManager.getInstance().getConstants().clusterServiceValidationMsg());
} else if (getIsImportGlusterConfiguration().getEntity() && getGlusterHostAddress().getIsValid() && getGlusterHostPassword().getIsValid() && !isFingerprintVerified()) {
setMessage(ConstantsManager.getInstance().getConstants().fingerprintNotVerified());
} else {
setMessage(null);
}
if (getSpiceProxyEnabled().getEntity()) {
getSpiceProxy().validateEntity(new IValidation[] { new HostWithProtocolAndPortAddressValidation() });
} else {
getSpiceProxy().setIsValid(true);
}
setValidTab(TabName.CONSOLE_TAB, getSpiceProxy().getIsValid());
if (getSerialNumberPolicy().getSelectedSerialNumberPolicy() == SerialNumberPolicy.CUSTOM) {
getSerialNumberPolicy().getCustomSerialNumber().validateEntity(new IValidation[] { new NotEmptyValidation() });
} else {
getSerialNumberPolicy().getCustomSerialNumber().setIsValid(true);
}
getMacPoolModel().validate();
boolean generalTabValid = getName().getIsValid() && getDataCenter().getIsValid() && getCPU().getIsValid() && getManagementNetwork().getIsValid() && getVersion().getIsValid() && validService && getGlusterHostAddress().getIsValid() && getRngHwrngSourceRequired().getIsValid() && getGlusterHostPassword().getIsValid() && (!getIsImportGlusterConfiguration().getEntity() || (getGlusterHostAddress().getIsValid() && getGlusterHostPassword().getIsValid() && getSerialNumberPolicy().getCustomSerialNumber().getIsValid() && isFingerprintVerified()));
setValidTab(TabName.GENERAL_TAB, generalTabValid);
if (getVersion().getSelectedItem() != null) {
if (AsyncDataProvider.getInstance().isMigrationPoliciesSupported(getVersion().getSelectedItem()) && MigrationBandwidthLimitType.CUSTOM.equals(getMigrationBandwidthLimitType().getSelectedItem())) {
getCustomMigrationNetworkBandwidth().validateEntity(new IValidation[] { new NotNullIntegerValidation(0, Integer.MAX_VALUE) });
} else {
getCustomMigrationNetworkBandwidth().setIsValid(true);
}
}
final boolean migrationTabValid = getMigrationBandwidthLimitType().getIsValid() && getCustomMigrationNetworkBandwidth().getIsValid();
setValidTab(TabName.MIGRATION_TAB, migrationTabValid);
boolean macPoolTabValid = getMacPoolModel().getIsValid();
setValidTab(TabName.MAC_POOL_TAB, macPoolTabValid);
ValidationCompleteEvent.fire(getEventBus(), this);
return generalTabValid && macPoolTabValid && getCustomPropertySheet().getIsValid() && getSpiceProxy().getIsValid() && migrationTabValid;
}
use of org.ovirt.engine.ui.uicommonweb.validation.IValidation in project ovirt-engine by oVirt.
the class VmInitModel method validate.
public boolean validate() {
getHostname().setIsValid(true);
getWindowsHostname().setIsValid(true);
getSysprepAdminPassword().setIsValid(true);
getSysprepAdminPasswordVerification().setIsValid(true);
getCloudInitRootPassword().setIsValid(true);
getCloudInitRootPasswordVerification().setIsValid(true);
if (this.isWindowsOS) {
if (getSysprepPasswordEnabled()) {
getSysprepAdminPassword().validateEntity(new IValidation[] { new NotEmptyValidation(), new MatchFieldsValidator(getSysprepAdminPassword().getEntity(), getSysprepAdminPasswordVerification().getEntity()) });
}
} else {
if (getRootPasswordEnabled()) {
getCloudInitRootPassword().validateEntity(new IValidation[] { new NotEmptyValidation(), new MatchFieldsValidator(getCloudInitRootPassword().getEntity(), getCloudInitRootPasswordVerification().getEntity()) });
}
}
if (getHostnameEnabled()) {
if (this.isWindowsOS) {
getWindowsHostname().validateEntity(new IValidation[] { new HostnameValidation(), new LengthValidation(AsyncDataProvider.getInstance().getMaxVmNameLengthSysprep()) });
} else {
getHostname().validateEntity(new IValidation[] { new HostnameValidation(), new LengthValidation(AsyncDataProvider.getInstance().getMaxVmNameLength()) });
}
}
getSysprepDomain().setIsValid(true);
if (getDomainEnabled()) {
getSysprepDomain().setIsValid(new HostAddressValidation().validate(getSysprepDomain().getSelectedItem()).getSuccess());
}
getAuthorizedKeys().setIsValid(true);
getTimeZoneList().setIsValid(true);
if (getTimeZoneEnabled().getEntity()) {
getTimeZoneList().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
}
boolean networkIsValid = true;
getNetworkList().setIsValid(true);
getNetworkIpAddress().setIsValid(true);
getNetworkNetmask().setIsValid(true);
getNetworkGateway().setIsValid(true);
getNetworkIpv6Address().setIsValid(true);
getNetworkIpv6Prefix().setIsValid(true);
getNetworkIpv6Gateway().setIsValid(true);
boolean dnsIsValid = true;
getDnsServers().setIsValid(true);
getDnsSearchDomains().setIsValid(true);
if (getNetworkEnabled().getEntity()) {
saveNetworkFields();
for (Map.Entry<String, VmInitNetwork> entry : networkMap.entrySet()) {
String name = entry.getKey();
VmInitNetwork vmInitNetwork = entry.getValue();
if (vmInitNetwork.getBootProtocol() == Ipv4BootProtocol.STATIC_IP) {
if (!validateHidden(getNetworkList(), name, null, new IValidation[] { new VmInitNetworkNameValidation(), new NotEmptyValidation() }) || !validateHidden(getNetworkIpAddress(), vmInitNetwork.getIp(), null, new IValidation[] { new Ipv4AddressValidation() }) || !validateHidden(getNetworkNetmask(), vmInitNetwork.getNetmask(), null, new IValidation[] { new SubnetMaskValidation() }) || !validateHidden(getNetworkGateway(), vmInitNetwork.getGateway(), null, new IValidation[] { new Ipv4AddressValidation(true) })) {
getNetworkList().setSelectedItem(name);
networkIsValid = false;
break;
}
}
if (vmInitNetwork.getIpv6BootProtocol() == Ipv6BootProtocol.STATIC_IP) {
if (!validateHidden(getNetworkList(), name, null, new IValidation[] { new VmInitNetworkNameValidation(), new NotEmptyValidation() }) || !validateHidden(getNetworkIpv6Address(), vmInitNetwork.getIpv6Address(), null, new IValidation[] { new Ipv6AddressValidation() }) || !validateHidden(getNetworkIpv6Prefix(), vmInitNetwork.getIpv6Prefix(), null, new IValidation[] { new IntegerValidation(0, 128) }) || !validateHidden(getNetworkIpv6Gateway(), vmInitNetwork.getIpv6Gateway(), null, new IValidation[] { new Ipv6AddressValidation(true) })) {
getNetworkList().setSelectedItem(name);
networkIsValid = false;
break;
}
}
}
if (!networkMap.isEmpty()) {
if (getDnsServers().getEntity() != null) {
for (String server : tokenizeString(getDnsServers().getEntity())) {
if (!validateHidden(getDnsServers(), server, dnsServerListMessage, new IValidation[] { new IpAddressValidation() })) {
dnsIsValid = false;
break;
}
}
}
if (getDnsSearchDomains().getEntity() != null) {
for (String domain : tokenizeString(getDnsSearchDomains().getEntity())) {
if (!validateHidden(getDnsSearchDomains(), domain, null, new IValidation[] { new HostnameValidation() })) {
dnsIsValid = false;
break;
}
}
}
}
}
return getHostname().getIsValid() && getWindowsHostname().getIsValid() && getSysprepDomain().getIsValid() && getAuthorizedKeys().getIsValid() && getTimeZoneList().getIsValid() && getCloudInitRootPassword().getIsValid() && getSysprepAdminPassword().getIsValid() && networkIsValid && dnsIsValid;
}
use of org.ovirt.engine.ui.uicommonweb.validation.IValidation in project ovirt-engine by oVirt.
the class StorageListModel method storageNameValidation.
public void storageNameValidation() {
StorageModel model = (StorageModel) getWindow();
String name = model.getName().getEntity();
model.getName().setIsValid(true);
AsyncDataProvider.getInstance().isStorageDomainNameUnique(new AsyncQuery<>(isNameUnique -> {
final StorageModel storageModel = (StorageModel) getWindow();
String name1 = storageModel.getName().getEntity();
String tempVar = storageModel.getOriginalName();
// $NON-NLS-1$
String originalName = (tempVar != null) ? tempVar : "";
if (!isNameUnique && name1.compareToIgnoreCase(originalName) != 0) {
storageModel.getName().getInvalidityReasons().add(ConstantsManager.getInstance().getConstants().nameMustBeUniqueInvalidReason());
storageModel.getName().setIsValid(false);
postStorageNameValidation();
} else {
AsyncDataProvider.getInstance().getStorageDomainMaxNameLength(new AsyncQuery<>(nameMaxLength -> {
RegexValidation tempVar2 = new RegexValidation();
// $NON-NLS-1$ //$NON-NLS-2$
tempVar2.setExpression("^[A-Za-z0-9_-]{1," + nameMaxLength + "}$");
tempVar2.setMessage(ConstantsManager.getInstance().getMessages().nameCanContainOnlyMsg(nameMaxLength));
storageModel.getName().validateEntity(new IValidation[] { new NotEmptyValidation(), tempVar2 });
postStorageNameValidation();
}));
}
}), name);
}
use of org.ovirt.engine.ui.uicommonweb.validation.IValidation in project ovirt-engine by oVirt.
the class DataCenterGuideModel method onAddStorage.
public void onAddStorage() {
StorageModel model = (StorageModel) getWindow();
String storageName = model.getName().getEntity();
AsyncDataProvider.getInstance().isStorageDomainNameUnique(new AsyncQuery<>(isNameUnique -> {
StorageModel storageModel = (StorageModel) getWindow();
String name = storageModel.getName().getEntity();
String tempVar = storageModel.getOriginalName();
// $NON-NLS-1$
String originalName = (tempVar != null) ? tempVar : "";
if (!isNameUnique && name.compareToIgnoreCase(originalName) != 0) {
storageModel.getName().getInvalidityReasons().add(ConstantsManager.getInstance().getConstants().nameMustBeUniqueInvalidReason());
storageModel.getName().setIsValid(false);
}
AsyncDataProvider.getInstance().getStorageDomainMaxNameLength(new AsyncQuery<>(nameMaxLength -> {
StorageModel storageModel1 = (StorageModel) getWindow();
RegexValidation tempVar2 = new RegexValidation();
// $NON-NLS-1$ //$NON-NLS-2$
tempVar2.setExpression("^[A-Za-z0-9_-]{1," + nameMaxLength + "}$");
tempVar2.setMessage(ConstantsManager.getInstance().getMessages().nameCanContainOnlyMsg(nameMaxLength));
storageModel1.getName().validateEntity(new IValidation[] { new NotEmptyValidation(), tempVar2 });
postOnAddStorage();
}));
}), storageName);
}
use of org.ovirt.engine.ui.uicommonweb.validation.IValidation in project ovirt-engine by oVirt.
the class SharedHostNetworkQosParametersModel method getOutLinkshareValidations.
@Override
protected Collection<IValidation> getOutLinkshareValidations() {
Collection<IValidation> validations = super.getOutLinkshareValidations();
validations.add(new NotEmptyValidation());
return validations;
}
Aggregations