Search in sources :

Example 1 with IntegerValidation

use of org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation in project ovirt-engine by oVirt.

the class NfsStorageModel method validate.

@Override
public boolean validate() {
    getPath().validateEntity(new IValidation[] { new NotEmptyValidation(), new LinuxMountPointValidation(), new NonUtfValidation(), new NoSpacesValidation() });
    if (getRetransmissions().getIsValid()) {
        getRetransmissions().validateEntity(new IValidation[] { new IntegerValidation(0, RETRANS_MAX) });
    }
    if (getTimeout().getIsValid()) {
        getTimeout().validateEntity(new IValidation[] { new IntegerValidation(1, TIMEOUT_MAX) });
    }
    getMountOptions().validateEntity(new IValidation[] { new NonUtfValidation() });
    return getPath().getIsValid() && getRetransmissions().getIsValid() && getTimeout().getIsValid() && getMountOptions().getIsValid();
}
Also used : LinuxMountPointValidation(org.ovirt.engine.ui.uicommonweb.validation.LinuxMountPointValidation) NoSpacesValidation(org.ovirt.engine.ui.uicommonweb.validation.NoSpacesValidation) NonUtfValidation(org.ovirt.engine.ui.uicommonweb.validation.NonUtfValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation)

Example 2 with IntegerValidation

use of org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation in project ovirt-engine by oVirt.

the class EditQuotaClusterModel method validate.

public boolean validate() {
    IntegerValidation intValidation = new IntegerValidation();
    intValidation.setMinimum(1);
    LongValidation longValidation = new LongValidation();
    longValidation.setMinimum(1);
    getSpecificMemValue().setIsValid(true);
    getSpecificCpuValue().setIsValid(true);
    if (getSpecificMem().getEntity()) {
        getSpecificMemValue().validateEntity(new IValidation[] { longValidation, new NotEmptyValidation() });
    }
    if (getSpecificCpu().getEntity()) {
        getSpecificCpuValue().validateEntity(new IValidation[] { intValidation, new NotEmptyValidation() });
    }
    return getSpecificMemValue().getIsValid() && getSpecificCpuValue().getIsValid();
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) LongValidation(org.ovirt.engine.ui.uicommonweb.validation.LongValidation) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation)

Example 3 with IntegerValidation

use of org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation 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;
}
Also used : Ipv6AddressValidation(org.ovirt.engine.ui.uicommonweb.validation.Ipv6AddressValidation) HostnameValidation(org.ovirt.engine.ui.uicommonweb.validation.HostnameValidation) VmInitNetwork(org.ovirt.engine.core.common.businessentities.VmInitNetwork) Ipv4AddressValidation(org.ovirt.engine.ui.uicommonweb.validation.Ipv4AddressValidation) VmInitNetworkNameValidation(org.ovirt.engine.ui.uicommonweb.validation.VmInitNetworkNameValidation) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) IpAddressValidation(org.ovirt.engine.ui.uicommonweb.validation.IpAddressValidation) MatchFieldsValidator(org.ovirt.engine.ui.uicommonweb.validation.MatchFieldsValidator) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) HostAddressValidation(org.ovirt.engine.ui.uicommonweb.validation.HostAddressValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) SubnetMaskValidation(org.ovirt.engine.ui.uicommonweb.validation.SubnetMaskValidation) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation)

Example 4 with IntegerValidation

use of org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation in project ovirt-engine by oVirt.

the class HostModel method validate.

public boolean validate() {
    getName().validateEntity(new IValidation[] { new HostnameValidation() });
    getComment().validateEntity(new IValidation[] { new SpecialAsciiI18NOrNoneValidation() });
    getHost().validateEntity(new IValidation[] { new NotEmptyValidation(), new LengthValidation(255), new HostAddressValidation() });
    if (Boolean.TRUE.equals(getIsDiscoveredHosts().getEntity())) {
        getUserPassword().validateEntity(new IValidation[] { new NotEmptyValidation(), new LengthValidation(255) });
        getExternalComputeResource().setIsValid(getExternalComputeResource().getSelectedItem() != null);
        getExternalHostGroups().setIsValid(getExternalHostGroups().getSelectedItem() != null);
    } else {
        getExternalComputeResource().setIsValid(true);
        getExternalHostGroups().setIsValid(true);
    }
    if (getExternalHostProviderEnabled().getEntity() && getProviders().getSelectedItem() == null) {
        getProviders().getInvalidityReasons().add(constants.validateSelectExternalProvider());
        getProviders().setIsValid(false);
    }
    getAuthSshPort().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(1, 65535) });
    if (getConsoleAddressEnabled().getEntity()) {
        getConsoleAddress().validateEntity(new IValidation[] { new NotEmptyValidation(), new HostAddressValidation() });
    } else {
        // the console address is ignored so can not be invalid
        getConsoleAddress().setIsValid(true);
    }
    setValidTab(TabName.CONSOLE_TAB, getConsoleAddress().getIsValid());
    getDataCenter().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    getCluster().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    boolean fenceAgentsValid = true;
    if (getIsPm().getEntity()) {
        fenceAgentsValid = getFenceAgentListModel().validate();
    }
    setValidTab(TabName.GENERAL_TAB, getName().getIsValid() && getComment().getIsValid() && getHost().getIsValid() && getAuthSshPort().getIsValid() && getCluster().getIsValid() && getExternalHostGroups().getIsValid() && getExternalComputeResource().getIsValid() && getUserPassword().getIsValid() && getProviders().getIsValid());
    setValidTab(TabName.POWER_MANAGEMENT_TAB, fenceAgentsValid);
    getNetworkProviderModel().validate();
    ValidationCompleteEvent.fire(getEventBus(), this);
    return isValidTab(TabName.GENERAL_TAB) && isValidTab(TabName.POWER_MANAGEMENT_TAB) && getConsoleAddress().getIsValid() && getNetworkProviderModel().getIsValid();
}
Also used : HostnameValidation(org.ovirt.engine.ui.uicommonweb.validation.HostnameValidation) SpecialAsciiI18NOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) HostAddressValidation(org.ovirt.engine.ui.uicommonweb.validation.HostAddressValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation)

Example 5 with IntegerValidation

use of org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation in project ovirt-engine by oVirt.

the class VfsConfigModel method validate.

public boolean validate() {
    numOfVfs.validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(0, getMaxNumOfVfs().getEntity()) });
    labelsModel.validate();
    return labelsModel.getIsValid() && numOfVfs.getIsValid();
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation)

Aggregations

IntegerValidation (org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation)22 NotEmptyValidation (org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)21 LengthValidation (org.ovirt.engine.ui.uicommonweb.validation.LengthValidation)9 HostAddressValidation (org.ovirt.engine.ui.uicommonweb.validation.HostAddressValidation)4 IValidation (org.ovirt.engine.ui.uicommonweb.validation.IValidation)3 SpecialAsciiI18NOrNoneValidation (org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation)3 DiskStorageType (org.ovirt.engine.core.common.businessentities.storage.DiskStorageType)2 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)2 AsciiNameValidation (org.ovirt.engine.ui.uicommonweb.validation.AsciiNameValidation)2 HostnameValidation (org.ovirt.engine.ui.uicommonweb.validation.HostnameValidation)2 Ipv4AddressValidation (org.ovirt.engine.ui.uicommonweb.validation.Ipv4AddressValidation)2 Ipv6AddressValidation (org.ovirt.engine.ui.uicommonweb.validation.Ipv6AddressValidation)2 SubnetMaskValidation (org.ovirt.engine.ui.uicommonweb.validation.SubnetMaskValidation)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 VmInitNetwork (org.ovirt.engine.core.common.businessentities.VmInitNetwork)1 NewVnicProfileModel (org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel)1 VnicProfileModel (org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel)1