Search in sources :

Example 1 with RegexValidation

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

the class KeyValueModel method setKeyValueString.

public void setKeyValueString(List<String> lines) {
    if (lines == null) {
        return;
    }
    allKeyValueMap = new HashMap<>();
    allRegExKeys = new HashMap<>();
    RegexValidation regexValidation = new RegexValidation();
    // $NON-NLS-1$
    regexValidation.setExpression("\\^\\((([a-zA-Z0-9_]+[|]+)*)[a-zA-Z0-9_]+\\)\\$");
    String[] splitLine;
    for (String line : lines) {
        if (line.isEmpty()) {
            continue;
        }
        splitLine = line.split(KEY_VALUE_DELIMETER, 2);
        String key = splitLine[0];
        allKeyValueMap.put(key, splitLine[1]);
        ValidationResult valid = regexValidation.validate(allKeyValueMap.get(key));
        if (valid.getSuccess()) {
            String[] values = allKeyValueMap.get(key).substring(2, allKeyValueMap.get(key).length() - 2).split(// $NON-NLS-1$
            "\\|");
            allRegExKeys.put(key, Arrays.asList(values));
        }
    }
    deserialize(saveEntity);
}
Also used : RegexValidation(org.ovirt.engine.ui.uicommonweb.validation.RegexValidation) ValidationResult(org.ovirt.engine.ui.uicommonweb.validation.ValidationResult)

Example 2 with RegexValidation

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

the class KeyValueModel method validate.

public boolean validate() {
    setIsValid(true);
    if (getItems() == null || !getIsAvailable()) {
        return true;
    }
    boolean isValid = true;
    for (KeyValueLineModel keyValueLineModel : getItems()) {
        String key = keyValueLineModel.getKeys().getSelectedItem();
        if (!isKeyValid(key)) {
            continue;
        }
        keyValueLineModel.getValue().setIsValid(true);
        RegexValidation regexValidation = new RegexValidation();
        regexValidation.setMessage(ConstantsManager.getInstance().getMessages().customPropertyValueShouldBeInFormatReason(key, allKeyValueMap.get(key)));
        regexValidation.setExpression(allKeyValueMap.get(key));
        keyValueLineModel.getValue().validateEntity(new IValidation[] { regexValidation });
        isValid &= keyValueLineModel.getValue().getIsValid();
    }
    setIsValid(isValid);
    return isValid;
}
Also used : RegexValidation(org.ovirt.engine.ui.uicommonweb.validation.RegexValidation)

Example 3 with RegexValidation

use of org.ovirt.engine.ui.uicommonweb.validation.RegexValidation 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);
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) Arrays(java.util.Arrays) FrontendActionAsyncResult(org.ovirt.engine.ui.uicompat.FrontendActionAsyncResult) SearchObjects(org.ovirt.engine.core.searchbackend.SearchObjects) RegexValidation(org.ovirt.engine.ui.uicommonweb.validation.RegexValidation) Inject(com.google.inject.Inject) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ExtendSANStorageDomainParameters(org.ovirt.engine.core.common.action.ExtendSANStorageDomainParameters) DiskProfileListModel(org.ovirt.engine.ui.uicommonweb.models.profiles.DiskProfileListModel) ActionType(org.ovirt.engine.core.common.action.ActionType) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) NfsVersion(org.ovirt.engine.core.common.businessentities.NfsVersion) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) AttachStorageDomainToPoolParameters(org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ReduceSANStorageDomainDevicesCommandParameters(org.ovirt.engine.core.common.action.ReduceSANStorageDomainDevicesCommandParameters) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) Set(java.util.Set) AddSANStorageDomainParameters(org.ovirt.engine.core.common.action.AddSANStorageDomainParameters) StorageDomainSharedStatus(org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus) StringHelper(org.ovirt.engine.core.compat.StringHelper) List(java.util.List) Cloner(org.ovirt.engine.ui.uicommonweb.Cloner) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) PermissionListModel(org.ovirt.engine.ui.uicommonweb.models.configure.PermissionListModel) ITaskTarget(org.ovirt.engine.ui.uicompat.ITaskTarget) Guid(org.ovirt.engine.core.compat.Guid) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) TaskContext(org.ovirt.engine.ui.uicompat.TaskContext) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) Task(org.ovirt.engine.ui.uicompat.Task) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) GetDeviceListQueryParameters(org.ovirt.engine.core.common.queries.GetDeviceListQueryParameters) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Frontend(org.ovirt.engine.ui.frontend.Frontend) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) LinkedList(java.util.LinkedList) Model(org.ovirt.engine.ui.uicommonweb.models.Model) RemoveStorageDomainParameters(org.ovirt.engine.core.common.action.RemoveStorageDomainParameters) StorageDomainManagementParameter(org.ovirt.engine.core.common.action.StorageDomainManagementParameter) Linq(org.ovirt.engine.ui.uicommonweb.Linq) SearchStringMapping(org.ovirt.engine.ui.uicommonweb.models.SearchStringMapping) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) StorageServerConnectionParametersBase(org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) WebAdminApplicationPlaces(org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces) VDS(org.ovirt.engine.core.common.businessentities.VDS) StorageDomainParametersBase(org.ovirt.engine.core.common.action.StorageDomainParametersBase) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) RegexValidation(org.ovirt.engine.ui.uicommonweb.validation.RegexValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)

Example 4 with RegexValidation

use of org.ovirt.engine.ui.uicommonweb.validation.RegexValidation 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);
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) Arrays(java.util.Arrays) RegexValidation(org.ovirt.engine.ui.uicommonweb.validation.RegexValidation) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) NewHostModel(org.ovirt.engine.ui.uicommonweb.models.hosts.NewHostModel) GuideModel(org.ovirt.engine.ui.uicommonweb.models.GuideModel) IFrontendMultipleActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) ManagementNetworkOnClusterOperationParameters(org.ovirt.engine.core.common.action.ManagementNetworkOnClusterOperationParameters) PosixStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.PosixStorageModel) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) NewEditStorageModelBehavior(org.ovirt.engine.ui.uicommonweb.models.storage.NewEditStorageModelBehavior) AttachStorageDomainToPoolParameters(org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Set(java.util.Set) AddSANStorageDomainParameters(org.ovirt.engine.core.common.action.AddSANStorageDomainParameters) StorageDomainSharedStatus(org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus) Collectors(java.util.stream.Collectors) MoveHost(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHost) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) IStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.IStorageModel) StorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) ClusterModel(org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterModel) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) HostModel(org.ovirt.engine.ui.uicommonweb.models.hosts.HostModel) ITaskTarget(org.ovirt.engine.ui.uicompat.ITaskTarget) Guid(org.ovirt.engine.core.compat.Guid) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) TaskContext(org.ovirt.engine.ui.uicompat.TaskContext) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) FrontendMultipleActionAsyncResult(org.ovirt.engine.ui.uicompat.FrontendMultipleActionAsyncResult) Task(org.ovirt.engine.ui.uicompat.Task) NfsStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.NfsStorageModel) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) GetDeviceListQueryParameters(org.ovirt.engine.core.common.queries.GetDeviceListQueryParameters) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Frontend(org.ovirt.engine.ui.frontend.Frontend) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) ClusterListModel(org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterListModel) Model(org.ovirt.engine.ui.uicommonweb.models.Model) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) MoveHostData(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHostData) SanStorageModelBase(org.ovirt.engine.ui.uicommonweb.models.storage.SanStorageModelBase) StorageDomainManagementParameter(org.ovirt.engine.core.common.action.StorageDomainManagementParameter) Linq(org.ovirt.engine.ui.uicommonweb.Linq) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) ApproveVdsParameters(org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters) LocalStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.LocalStorageModel) StorageServerConnectionParametersBase(org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) LunModel(org.ovirt.engine.ui.uicommonweb.models.storage.LunModel) Timer(com.google.gwt.user.client.Timer) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) RegexValidation(org.ovirt.engine.ui.uicommonweb.validation.RegexValidation) PosixStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.PosixStorageModel) IStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.IStorageModel) StorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel) NfsStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.NfsStorageModel) LocalStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.LocalStorageModel) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)

Example 5 with RegexValidation

use of org.ovirt.engine.ui.uicommonweb.validation.RegexValidation 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();
}
Also used : RegexValidation(org.ovirt.engine.ui.uicommonweb.validation.RegexValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) SpecialAsciiI18NOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation) NewVnicProfileModel(org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel) VnicProfileModel(org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel) AsciiNameValidation(org.ovirt.engine.ui.uicommonweb.validation.AsciiNameValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation)

Aggregations

RegexValidation (org.ovirt.engine.ui.uicommonweb.validation.RegexValidation)9 NotEmptyValidation (org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)6 ArrayList (java.util.ArrayList)3 Linq (org.ovirt.engine.ui.uicommonweb.Linq)3 IValidation (org.ovirt.engine.ui.uicommonweb.validation.IValidation)3 Arrays (java.util.Arrays)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Set (java.util.Set)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)2 ActionType (org.ovirt.engine.core.common.action.ActionType)2 AddSANStorageDomainParameters (org.ovirt.engine.core.common.action.AddSANStorageDomainParameters)2 AttachStorageDomainToPoolParameters (org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters)2 StorageDomainManagementParameter (org.ovirt.engine.core.common.action.StorageDomainManagementParameter)2 StorageServerConnectionParametersBase (org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 StorageDomainSharedStatus (org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus)2 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)2 StorageDomainStatus (org.ovirt.engine.core.common.businessentities.StorageDomainStatus)2