@@ -87,18 +87,22 @@ public static void validateSubscription(Subscription subscription)
87
87
*/
88
88
private static void validateSubscriptionName (String subscriptionName )
89
89
throws SubscriptionValidationException {
90
- String invalidSubscriptionNameRegex = null ;
91
- invalidSubscriptionNameRegex = RegExProvider .SUBSCRIPTION_NAME ;
90
+ String invalidSubscriptionNameRegex = RegExProvider .SUBSCRIPTION_NAME ;
92
91
93
92
if (subscriptionName == null ) {
94
93
throw new SubscriptionValidationException (
95
94
"Required field SubscriptionName has not been set." );
96
- } else if (invalidSubscriptionNameRegex == null
95
+ }
96
+
97
+ if (invalidSubscriptionNameRegex == null
97
98
|| invalidSubscriptionNameRegex .isEmpty ()) {
98
99
throw new SubscriptionValidationException (
99
100
"A valid regular expression for validating subscription name is not provided." );
100
- } else if (Pattern .matches (invalidSubscriptionNameRegex ,
101
- subscriptionName )) {
101
+ }
102
+
103
+ Pattern pattern = Pattern .compile (invalidSubscriptionNameRegex );
104
+ Matcher matcher = pattern .matcher (subscriptionName );
105
+ if (matcher .find ()) {
102
106
throw new SubscriptionValidationException (
103
107
"Wrong format of SubscriptionName: " + subscriptionName );
104
108
}
@@ -224,8 +228,7 @@ private static void validateRestPostMediaType(String restPostMediaType)
224
228
*/
225
229
public static void validateEmail (String email )
226
230
throws SubscriptionValidationException {
227
- String validEmailRegEx = null ;
228
- validEmailRegEx = RegExProvider .NOTIFICATION_META ;
231
+ String validEmailRegEx = RegExProvider .NOTIFICATION_META ;
229
232
230
233
if (validEmailRegEx == null || validEmailRegEx .isEmpty ()) {
231
234
throw new SubscriptionValidationException (
0 commit comments