Eliraz Levi has posted comments on this change.

Change subject: common: adding maskValidator util
......................................................................


Patch Set 8:

(6 comments)

http://gerrit.ovirt.org/#/c/35144/8/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/ValidationUtils.java
File 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/ValidationUtils.java:

Line 21:     public static final String ONLY_I18N_ASCII_OR_NONE = 
"[\\p{ASCII}\\p{L}]*";
Line 22:     public static final String ONLY_ASCII_OR_NONE = "[\\p{ASCII}]*";
Line 23:     public static final String NO_SPECIAL_CHARACTERS_WITH_DOT = 
"[0-9a-zA-Z-_\\.]+";
Line 24:     public static final String NO_TRIMMING_WHITE_SPACES_PATTERN = 
"^$|\\S.*\\S";
Line 25:     public static final String IP_PATTERN =
> This should be change to "^" + IP_PATTERN_NON_EMPTY + "$|^$".
Done
Line 26:             
"^\\b((25[0-5]|2[0-4]\\d|[01]\\d\\d|\\d?\\d)\\.){3}(25[0-5]|2[0-4]\\d|[01]\\d\\d|\\d?\\d)\\b$|^$";
Line 27:     public static final String IP_PATTERN_NON_EMPTY =
Line 28:             
"\\b((25[0-5]|2[0-4]\\d|[01]\\d\\d|\\d?\\d)\\.){3}(25[0-5]|2[0-4]\\d|[01]\\d\\d|\\d?\\d)";
Line 29:     public static final String SUB_NET_PREFIX_PATTERN = 
"(?:3[0-2]|[12]?[0-9])";


Line 25:     public static final String IP_PATTERN =
Line 26:             
"^\\b((25[0-5]|2[0-4]\\d|[01]\\d\\d|\\d?\\d)\\.){3}(25[0-5]|2[0-4]\\d|[01]\\d\\d|\\d?\\d)\\b$|^$";
Line 27:     public static final String IP_PATTERN_NON_EMPTY =
Line 28:             
"\\b((25[0-5]|2[0-4]\\d|[01]\\d\\d|\\d?\\d)\\.){3}(25[0-5]|2[0-4]\\d|[01]\\d\\d|\\d?\\d)";
Line 29:     public static final String SUB_NET_PREFIX_PATTERN = 
"(?:3[0-2]|[12]?[0-9])";
> Subnet is usually one word.
Done
Line 30:     public static final String CIDR_FORMAT_PATTERN = "^" + 
IP_PATTERN_NON_EMPTY + "/" + SUB_NET_PREFIX_PATTERN + "$";
Line 31:     public static final String ISO_SUFFIX = ".iso";
Line 32:     public static final String ISO_SUFFIX_PATTERN = "^$|^.+\\.iso$";
Line 33: 


http://gerrit.ovirt.org/#/c/35144/8/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/validation/MaskValidator.java
File 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/validation/MaskValidator.java:

Line 27:      * @param isPrefixAllowed
Line 28:      *            indicates if mask in prefix format is allowed
Line 29:      * @return true if correct IPv4 format or string [0-32] (possible 
with /), false otherwise.
Line 30:      */
Line 31:     public boolean isMaskFormatValid(String mask, boolean 
isPrefixAllowed) {
> I apologize, unifying the two formats isn't a good idea. There should still
Done
Line 32:         return mask != null && (isPrefixAllowed ? mask.matches("(^" + 
ValidationUtils.IP_PATTERN_NON_EMPTY + "$)"
Line 33:                 + "|" + "/?" + ValidationUtils.SUB_NET_PREFIX_PATTERN)
Line 34:                 : mask.matches(ValidationUtils.IP_PATTERN_NON_EMPTY));
Line 35:     }


Line 30:      */
Line 31:     public boolean isMaskFormatValid(String mask, boolean 
isPrefixAllowed) {
Line 32:         return mask != null && (isPrefixAllowed ? mask.matches("(^" + 
ValidationUtils.IP_PATTERN_NON_EMPTY + "$)"
Line 33:                 + "|" + "/?" + ValidationUtils.SUB_NET_PREFIX_PATTERN)
Line 34:                 : mask.matches(ValidationUtils.IP_PATTERN_NON_EMPTY));
> I think you also want the "^" and "$" here.
Done
Line 35:     }
Line 36: 
Line 37:     /***
Line 38:      * check if mask value is valid and return true if does


Line 41:      *            indicates if mask in prefix format is allowed
Line 42:      * @return true for valid mask value, false otherwise
Line 43:      */
Line 44:     public boolean isMaskValid(String mask, boolean isPrefixAllowed) {
Line 45:         if (isPrefixAllowed) {
> This is weird - again the method isn't granular enough. It doesn't make sen
Done
Line 46:             if (mask.matches("/?" + 
ValidationUtils.SUB_NET_PREFIX_PATTERN)) {
Line 47:                 return true;
Line 48:             }
Line 49: 


http://gerrit.ovirt.org/#/c/35144/8/backend/manager/modules/common/src/test/java/org/ovirt/engine/core/common/utils/IpAddressConverterTest.java
File 
backend/manager/modules/common/src/test/java/org/ovirt/engine/core/common/utils/IpAddressConverterTest.java:

Line 36:                 { "1.255.4.255", 33490175 },
Line 37:                 { "0.128.0.7", 8388615 },
Line 38:                 { "1.2.3.4", 16909060 },
Line 39:                 { "127.63.31.7", 2134843143 },
Line 40:                 { "0.0.0.1", 1 }, });
> You haven't taken into consideration my comment from the last patchset.
sorry my bad
done
Line 41:     }
Line 42: 


-- 
To view, visit http://gerrit.ovirt.org/35144
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I04fb0aa2193801688f1bfc5dc7684cabdfa2827d
Gerrit-PatchSet: 8
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Eliraz Levi <el...@redhat.com>
Gerrit-Reviewer: Alona Kaplan <alkap...@redhat.com>
Gerrit-Reviewer: Eliraz Levi <el...@redhat.com>
Gerrit-Reviewer: Lior Vernia <lver...@redhat.com>
Gerrit-Reviewer: Martin Mucha <mmu...@redhat.com>
Gerrit-Reviewer: Yevgeny Zaspitsky <yzasp...@redhat.com>
Gerrit-Reviewer: automat...@ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to