View Javadoc

1   /*
2    * Copyright 2004-2008 the Seasar Foundation and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.seasar.cubby.validator;
17  
18  import java.lang.reflect.Method;
19  
20  import javax.servlet.http.HttpServletRequest;
21  
22  import org.seasar.cubby.CubbyConstants;
23  import org.seasar.cubby.action.Action;
24  import org.seasar.cubby.action.ActionErrors;
25  import org.seasar.cubby.action.ActionResult;
26  
27  /**
28   * 入力検証処理です。
29   * 
30   * @author baba
31   * @since 1.0.0
32   */
33  public interface ValidationProcessor {
34  
35  	/**
36  	 * 入力検証を行います。
37  	 * <p>
38  	 * 入力検証はフェーズごとに実行され、そのフェーズの入力検証でエラーがあった({@link ActionErrors}
39  	 * にメッセージが登録された)場合には {@link ValidationException} をスローします。
40  	 * </p>
41  	 * 
42  	 * @param request
43  	 *            リクエスト
44  	 * @param action
45  	 *            アクション
46  	 * @param actionClass
47  	 *            アクションクラス
48  	 * @param method
49  	 *            メソッド
50  	 * @throws ValidationException
51  	 *             入力検証にエラーがあった場合
52  	 */
53  	void process(HttpServletRequest request, Action action,
54  			Class<? extends Action> actionClass, Method method);
55  
56  	/**
57  	 * {@link #process(HttpServletRequest, Action, Class, Method)} で発生した
58  	 * {@link ValidationException} を処理します。
59  	 * <p>
60  	 * <ul>
61  	 * <li>{@link ValidationException} にメッセージが指定されていた場合はそれを
62  	 * {@link ActionErrors} に設定</li>
63  	 * <li>リクエストの属性 {@link CubbyConstants#ATTR_VALIDATION_FAIL} に
64  	 * <code>true</code> を設定</li>
65  	 * <li>{@link ValidationRules#fail(String)} の呼び出し</li>
66  	 * </ul>
67  	 * </p>
68  	 * 
69  	 * @param e
70  	 *            処理対象の例外
71  	 * @param request
72  	 *            リクエスト
73  	 * @param action
74  	 *            アクション
75  	 * @param method
76  	 *            メソッド
77  	 * @return {@link ValidationRules#fail(String)} が返す値
78  	 * @since 1.1.0
79  	 */
80  	ActionResult handleValidationException(ValidationException e,
81  			HttpServletRequest request, Action action, Method method);
82  
83  }