This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch WW-5017-drop-validation in repository https://gitbox.apache.org/repos/asf/struts.git
commit 13cbf0e4188fef8b44e61a51b619cf57e62fbabd Author: Lukasz Lenart <lukaszlen...@apache.org> AuthorDate: Sun Apr 26 07:50:13 2020 +0200 WW-5017 Drops deprecated Validation annotation as not needed --- .../AnnotationValidationConfigurationBuilder.java | 10 -- .../xwork2/validator/annotations/Validation.java | 141 --------------------- .../xwork2/SimpleAnnotationAction.java | 6 +- .../xwork2/test/AnnotationDataAware.java | 1 - .../opensymphony/xwork2/test/AnnotationUser.java | 23 ++-- .../xwork2/test/AnnotationUserMarker.java | 22 ++-- .../ValidateAnnotatedMethodOnlyAction.java | 7 +- 7 files changed, 21 insertions(+), 189 deletions(-) diff --git a/core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java b/core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java index 5b41afd..64f46d5 100644 --- a/core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java +++ b/core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java @@ -73,16 +73,6 @@ public class AnnotationValidationConfigurationBuilder { if (a instanceof Validations) { processValidationAnnotation(a, fieldName, methodName, result); } - - // Process single custom validator - if (a instanceof Validation) { - Validation v = (Validation) a; - if (v.validations() != null) { - for (Validations val : v.validations()) { - processValidationAnnotation(val, fieldName, methodName, result); - } - } - } // Process single custom validator else if (a instanceof ExpressionValidator) { ExpressionValidator v = (ExpressionValidator) a; diff --git a/core/src/main/java/com/opensymphony/xwork2/validator/annotations/Validation.java b/core/src/main/java/com/opensymphony/xwork2/validator/annotations/Validation.java deleted file mode 100644 index 036b2dd..0000000 --- a/core/src/main/java/com/opensymphony/xwork2/validator/annotations/Validation.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.opensymphony.xwork2.validator.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * <!-- START SNIPPET: description --> - * This annotation has been deprecated since 2.1 as its previous purpose, to define classes that support annotation validations, - * is no longer necessary. - * <!-- END SNIPPET: description --> - * - * <p><u>Annotation usage:</u></p> - * - * <!-- START SNIPPET: usage --> - * <p>The Validation annotation must be applied at Type level.</p> - * <!-- END SNIPPET: usage --> - * - * <p><u>Annotation parameters:</u></p> - * - * <!-- START SNIPPET: parameters --> - * <table class='confluenceTable' summary=''> - * <tr> - * <th class='confluenceTh'> Parameter </th> - * <th class='confluenceTh'> Required </th> - * <th class='confluenceTh'> Default </th> - * <th class='confluenceTh'> Notes </th> - * </tr> - * <tr> - * <td class='confluenceTd'>validations</td> - * <td class='confluenceTd'>yes</td> - * <td class='confluenceTd'> </td> - * <td class='confluenceTd'></td> - * </tr> - * </table> - * <!-- END SNIPPET: parameters --> - * - * <p><u>Example code:</u></p> - * - * <u>An Annotated Interface</u> - * <pre> - * <!-- START SNIPPET: example --> - * @Validation() - * public interface AnnotationDataAware { - * - * void setBarObj(Bar b); - * - * Bar getBarObj(); - * - * @RequiredFieldValidator(message = "You must enter a value for data.") - * @RequiredStringValidator(message = "You must enter a value for data.") - * void setData(String data); - * - * String getData(); - * } - * <!-- END SNIPPET: example --> - * </pre> - * - * <p><u>Example code:</u></p> - * - * <u>An Annotated Class</u> - * <pre> - * <!-- START SNIPPET: example2 --> - * @Validation() - * public class SimpleAnnotationAction extends ActionSupport { - * - * @RequiredFieldValidator(type = ValidatorType.FIELD, message = "You must enter a value for bar.") - * @IntRangeFieldValidator(type = ValidatorType.FIELD, min = "6", max = "10", message = "bar must be between ${min} and ${max}, current value is ${bar}.") - * public void setBar(int bar) { - * this.bar = bar; - * } - * - * public int getBar() { - * return bar; - * } - * - * @Validations( - * requiredFields = - * {@RequiredFieldValidator(type = ValidatorType.SIMPLE, fieldName = "customfield", message = "You must enter a value for field.")}, - * requiredStrings = - * {@RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = "stringisrequired", message = "You must enter a value for string.")}, - * emails = - * { @EmailValidator(type = ValidatorType.SIMPLE, fieldName = "emailaddress", message = "You must enter a value for email.")}, - * urls = - * { @UrlValidator(type = ValidatorType.SIMPLE, fieldName = "hreflocation", message = "You must enter a value for email.")}, - * stringLengthFields = - * {@StringLengthFieldValidator(type = ValidatorType.SIMPLE, trim = true, minLength="10" , maxLength = "12", fieldName = "needstringlength", message = "You must enter a stringlength.")}, - * intRangeFields = - * { @IntRangeFieldValidator(type = ValidatorType.SIMPLE, fieldName = "intfield", min = "6", max = "10", message = "bar must be between ${min} and ${max}, current value is ${bar}.")}, - * dateRangeFields = - * {@DateRangeFieldValidator(type = ValidatorType.SIMPLE, fieldName = "datefield", min = "-1", max = "99", message = "bar must be between ${min} and ${max}, current value is ${bar}.")}, - * expressions = { - * @ExpressionValidator(expression = "foo > 1", message = "Foo must be greater than Bar 1. Foo = ${foo}, Bar = ${bar}."), - * @ExpressionValidator(expression = "foo > 2", message = "Foo must be greater than Bar 2. Foo = ${foo}, Bar = ${bar}."), - * @ExpressionValidator(expression = "foo > 3", message = "Foo must be greater than Bar 3. Foo = ${foo}, Bar = ${bar}."), - * @ExpressionValidator(expression = "foo > 4", message = "Foo must be greater than Bar 4. Foo = ${foo}, Bar = ${bar}."), - * @ExpressionValidator(expression = "foo > 5", message = "Foo must be greater than Bar 5. Foo = ${foo}, Bar = ${bar}.") - * } - * ) - * public String execute() throws Exception { - * return SUCCESS; - * } - * } - * - * <!-- END SNIPPET: example2 --> - * </pre> - * - * @author Rainer Hermanns - * @deprecated Since Struts 2.1 because it isn't necessary anymore - */ -@Deprecated -@Target({ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -public @interface Validation { - - /** - * Used for class or interface validation rules. - * - * @return array of validations - */ - Validations[] validations() default {}; -} diff --git a/core/src/test/java/com/opensymphony/xwork2/SimpleAnnotationAction.java b/core/src/test/java/com/opensymphony/xwork2/SimpleAnnotationAction.java index eda907d..5e21a09 100644 --- a/core/src/test/java/com/opensymphony/xwork2/SimpleAnnotationAction.java +++ b/core/src/test/java/com/opensymphony/xwork2/SimpleAnnotationAction.java @@ -26,12 +26,8 @@ import java.util.Properties; /** - * Simple Test Action for annotaton processing. - * - * @author Rainer Hermanns - * @version $Revision$ + * Simple Test Action for annotation processing. */ -@Validation() public class SimpleAnnotationAction extends ActionSupport { //~ Static fields/initializers ///////////////////////////////////////////// diff --git a/core/src/test/java/com/opensymphony/xwork2/test/AnnotationDataAware.java b/core/src/test/java/com/opensymphony/xwork2/test/AnnotationDataAware.java index 9ec0d60..13a65ed 100644 --- a/core/src/test/java/com/opensymphony/xwork2/test/AnnotationDataAware.java +++ b/core/src/test/java/com/opensymphony/xwork2/test/AnnotationDataAware.java @@ -24,7 +24,6 @@ import com.opensymphony.xwork2.conversion.impl.FooBarConverter; import com.opensymphony.xwork2.util.Bar; import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator; import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator; -import com.opensymphony.xwork2.validator.annotations.Validation; /** diff --git a/core/src/test/java/com/opensymphony/xwork2/test/AnnotationUser.java b/core/src/test/java/com/opensymphony/xwork2/test/AnnotationUser.java index 91b6569..0b941b1 100644 --- a/core/src/test/java/com/opensymphony/xwork2/test/AnnotationUser.java +++ b/core/src/test/java/com/opensymphony/xwork2/test/AnnotationUser.java @@ -21,7 +21,11 @@ package com.opensymphony.xwork2.test; import com.opensymphony.xwork2.conversion.annotations.ConversionRule; import com.opensymphony.xwork2.conversion.annotations.TypeConversion; import com.opensymphony.xwork2.util.KeyProperty; -import com.opensymphony.xwork2.validator.annotations.*; +import com.opensymphony.xwork2.validator.annotations.EmailValidator; +import com.opensymphony.xwork2.validator.annotations.ExpressionValidator; +import com.opensymphony.xwork2.validator.annotations.FieldExpressionValidator; +import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator; +import com.opensymphony.xwork2.validator.annotations.Validations; import java.util.Collection; import java.util.List; @@ -30,17 +34,12 @@ import java.util.Map; /** * Test bean. - * - * @author Mark Woon - * @author Rainer Hermanns */ -@Validation( - validations = @Validations( - expressions = { - @ExpressionValidator(expression = "email.startsWith('mark')", message = "Email does not start with mark"), - @ExpressionValidator(expression = "email2.startsWith('mark')", message = "Email2 does not start with mark") - } - ) +@Validations( + expressions = { + @ExpressionValidator(expression = "email.startsWith('mark')", message = "Email does not start with mark"), + @ExpressionValidator(expression = "email2.startsWith('mark')", message = "Email2 does not start with mark") + } ) public class AnnotationUser implements AnnotationUserMarker { @@ -84,7 +83,7 @@ public class AnnotationUser implements AnnotationUserMarker { list = l; } - @KeyProperty( value = "name") + @KeyProperty(value = "name") @TypeConversion(converterClass = String.class, rule = ConversionRule.COLLECTION) public List getList() { return list; diff --git a/core/src/test/java/com/opensymphony/xwork2/test/AnnotationUserMarker.java b/core/src/test/java/com/opensymphony/xwork2/test/AnnotationUserMarker.java index e4820cf..f68adb4 100644 --- a/core/src/test/java/com/opensymphony/xwork2/test/AnnotationUserMarker.java +++ b/core/src/test/java/com/opensymphony/xwork2/test/AnnotationUserMarker.java @@ -20,25 +20,19 @@ package com.opensymphony.xwork2.test; import com.opensymphony.xwork2.validator.annotations.ExpressionValidator; import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator; -import com.opensymphony.xwork2.validator.annotations.Validation; import com.opensymphony.xwork2.validator.annotations.Validations; /** * Marker interface to help test hierarchy traversal. - * - * @author Mark Woon - * @author Rainer Hermanns */ -@Validation( - validations = @Validations( - requiredFields = { - @RequiredFieldValidator(fieldName = "email", shortCircuit = true, message = "You must enter a value for email."), - @RequiredFieldValidator(fieldName = "email2", shortCircuit = true, message = "You must enter a value for email2.") - }, - expressions = { - @ExpressionValidator(shortCircuit = true, expression = "email.equals(email2)", message = "Email not the same as email2" ) - } - ) +@Validations( + requiredFields = { + @RequiredFieldValidator(fieldName = "email", shortCircuit = true, message = "You must enter a value for email."), + @RequiredFieldValidator(fieldName = "email2", shortCircuit = true, message = "You must enter a value for email2.") + }, + expressions = { + @ExpressionValidator(shortCircuit = true, expression = "email.equals(email2)", message = "Email not the same as email2") + } ) public interface AnnotationUserMarker { } diff --git a/core/src/test/java/com/opensymphony/xwork2/test/annotations/ValidateAnnotatedMethodOnlyAction.java b/core/src/test/java/com/opensymphony/xwork2/test/annotations/ValidateAnnotatedMethodOnlyAction.java index cfb9b16..b57361c 100644 --- a/core/src/test/java/com/opensymphony/xwork2/test/annotations/ValidateAnnotatedMethodOnlyAction.java +++ b/core/src/test/java/com/opensymphony/xwork2/test/annotations/ValidateAnnotatedMethodOnlyAction.java @@ -20,15 +20,10 @@ package com.opensymphony.xwork2.test.annotations; import com.opensymphony.xwork2.ActionSupport; import com.opensymphony.xwork2.validator.annotations.ExpressionValidator; -import com.opensymphony.xwork2.validator.annotations.Validation; /** * <code>ValidateAnnotatedMethodOnlyAction</code> - * - * @author <a href="mailto:herma...@aixcept.de">Rainer Hermanns</a> - * @version $Id$ */ -@Validation public class ValidateAnnotatedMethodOnlyAction extends ActionSupport { String param1; @@ -52,7 +47,7 @@ public class ValidateAnnotatedMethodOnlyAction extends ActionSupport { } @ExpressionValidator(expression = "(param1 != null) || (param2 != null)", - message = "Need param1 or param2.") + message = "Need param1 or param2.") public String annotatedMethod() { try { // do search