Bläddra i källkod

add UriType and CronExpression validators

Shinsuke Sugaya 9 år sedan
förälder
incheckning
8c1369fd8f

+ 0 - 50
src/main/java/org/codelibs/fess/annotation/CronExpression.java

@@ -1,50 +0,0 @@
-/*
- * Copyright 2012-2015 CodeLibs Project and the Others.
- *
- * Licensed 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 org.codelibs.fess.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.codelibs.core.lang.StringUtil;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-//@Validator("cronExpression")
-public @interface CronExpression {
-    /**
-     * A validation message.
-     *
-     * @return
-     */
-    //Msg msg() default @Msg(key = "errors.cronexpression");
-
-    /**
-     * Argument for a message
-     *
-     * @return
-     */
-    //Arg arg0() default @Arg(key = StringUtil.EMPTY);
-
-    /**
-     * a target name for this validation
-     *
-     * @return
-     */
-    String target() default StringUtil.EMPTY;
-
-}

+ 0 - 35
src/main/java/org/codelibs/fess/annotation/Token.java

@@ -1,35 +0,0 @@
-/*
- * Copyright 2012-2015 CodeLibs Project and the Others.
- *
- * Licensed 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 org.codelibs.fess.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @author shinsuke
- *
- */
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Token {
-    boolean save();
-
-    boolean validate();
-
-    boolean keep() default false;
-}

+ 0 - 53
src/main/java/org/codelibs/fess/annotation/UriType.java

@@ -1,53 +0,0 @@
-/*
- * Copyright 2012-2015 CodeLibs Project and the Others.
- *
- * Licensed 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 org.codelibs.fess.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.codelibs.core.lang.StringUtil;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-//@Validator("uriType")
-public @interface UriType {
-
-    String protocols();
-
-    /**
-     * A validation message.
-     *
-     * @return
-     */
-    //Msg msg() default @Msg(key = "errors.cronexpression");
-
-    /**
-     * Argument for a message
-     *
-     * @return
-     */
-    //Arg arg0() default @Arg(key = StringUtil.EMPTY);
-
-    /**
-     * a target name for this validation
-     *
-     * @return
-     */
-    String target() default StringUtil.EMPTY;
-
-}

+ 0 - 31
src/main/java/org/codelibs/fess/annotation/User.java

@@ -1,31 +0,0 @@
-/*
- * Copyright 2012-2015 CodeLibs Project and the Others.
- *
- * Licensed 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 org.codelibs.fess.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @author shinsuke
- *
- */
-@Target({ ElementType.FIELD, ElementType.METHOD })
-@Retention(RetentionPolicy.RUNTIME)
-public @interface User {
-
-}

+ 2 - 2
src/main/java/org/codelibs/fess/app/web/admin/fileconfig/CreateForm.java

@@ -23,10 +23,10 @@ import javax.validation.constraints.Size;
 
 
 import org.codelibs.core.lang.StringUtil;
 import org.codelibs.core.lang.StringUtil;
 import org.codelibs.fess.Constants;
 import org.codelibs.fess.Constants;
-import org.codelibs.fess.annotation.UriType;
 import org.codelibs.fess.app.web.CrudMode;
 import org.codelibs.fess.app.web.CrudMode;
 import org.codelibs.fess.util.ComponentUtil;
 import org.codelibs.fess.util.ComponentUtil;
 import org.codelibs.fess.util.StreamUtil;
 import org.codelibs.fess.util.StreamUtil;
+import org.codelibs.fess.validation.UriType;
 import org.lastaflute.web.validation.Required;
 import org.lastaflute.web.validation.Required;
 import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure;
 import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure;
 
 
@@ -50,7 +50,7 @@ public class CreateForm implements Serializable {
     public String name;
     public String name;
 
 
     @Required
     @Required
-    @UriType(protocols = "file:,smb:")
+    @UriType(protocols = { "file:", "smb:" })
     @Size(max = 4000)
     @Size(max = 4000)
     public String paths;
     public String paths;
 
 

+ 1 - 1
src/main/java/org/codelibs/fess/app/web/admin/scheduler/CreateForm.java

@@ -22,8 +22,8 @@ import javax.validation.constraints.Min;
 import javax.validation.constraints.Size;
 import javax.validation.constraints.Size;
 
 
 import org.codelibs.fess.Constants;
 import org.codelibs.fess.Constants;
-import org.codelibs.fess.annotation.CronExpression;
 import org.codelibs.fess.util.ComponentUtil;
 import org.codelibs.fess.util.ComponentUtil;
+import org.codelibs.fess.validation.CronExpression;
 import org.lastaflute.web.validation.Required;
 import org.lastaflute.web.validation.Required;
 import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure;
 import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure;
 
 

+ 2 - 2
src/main/java/org/codelibs/fess/app/web/admin/webconfig/CreateForm.java

@@ -23,10 +23,10 @@ import javax.validation.constraints.Size;
 
 
 import org.codelibs.core.lang.StringUtil;
 import org.codelibs.core.lang.StringUtil;
 import org.codelibs.fess.Constants;
 import org.codelibs.fess.Constants;
-import org.codelibs.fess.annotation.UriType;
 import org.codelibs.fess.app.web.CrudMode;
 import org.codelibs.fess.app.web.CrudMode;
 import org.codelibs.fess.util.ComponentUtil;
 import org.codelibs.fess.util.ComponentUtil;
 import org.codelibs.fess.util.StreamUtil;
 import org.codelibs.fess.util.StreamUtil;
+import org.codelibs.fess.validation.UriType;
 import org.lastaflute.web.validation.Required;
 import org.lastaflute.web.validation.Required;
 import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure;
 import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure;
 
 
@@ -51,7 +51,7 @@ public class CreateForm implements Serializable {
     public String name;
     public String name;
 
 
     @Required
     @Required
-    @UriType(protocols = "http:,https:")
+    @UriType(protocols = { "http:", "https:" })
     @Size(max = 4000)
     @Size(max = 4000)
     public String urls;
     public String urls;
 
 

+ 36 - 0
src/main/java/org/codelibs/fess/mylasta/action/FessMessages.java

@@ -140,6 +140,12 @@ public class FessMessages extends FessLabels {
     /** The key of the message: {item} cannot convert as {propertyType}. */
     /** The key of the message: {item} cannot convert as {propertyType}. */
     public static final String CONSTRAINTS_TypeAny_MESSAGE = "{constraints.TypeAny.message}";
     public static final String CONSTRAINTS_TypeAny_MESSAGE = "{constraints.TypeAny.message}";
 
 
+    /** The key of the message: {item} has wrong URI. */
+    public static final String CONSTRAINTS_UriType_MESSAGE = "{constraints.UriType.message}";
+
+    /** The key of the message: {item} is invalid cron expression. */
+    public static final String CONSTRAINTS_CronExpression_MESSAGE = "{constraints.CronExpression.message}";
+
     /** The key of the message: Login failed. */
     /** The key of the message: Login failed. */
     public static final String ERRORS_LOGIN_FAILURE = "{errors.login.failure}";
     public static final String ERRORS_LOGIN_FAILURE = "{errors.login.failure}";
 
 
@@ -932,6 +938,36 @@ public class FessMessages extends FessLabels {
         return this;
         return this;
     }
     }
 
 
+    /**
+     * Add the created action message for the key 'constraints.UriType.message' with parameters.
+     * <pre>
+     * message: {item} has wrong URI.
+     * </pre>
+     * @param property The property name for the message. (NotNull)
+     * @param item The parameter item for message. (NotNull)
+     * @return this. (NotNull)
+     */
+    public FessMessages addConstraintsUriTypeMessage(String property, String item) {
+        assertPropertyNotNull(property);
+        add(property, new ActionMessage(CONSTRAINTS_UriType_MESSAGE, item));
+        return this;
+    }
+
+    /**
+     * Add the created action message for the key 'constraints.CronExpression.message' with parameters.
+     * <pre>
+     * message: {item} is invalid cron expression.
+     * </pre>
+     * @param property The property name for the message. (NotNull)
+     * @param item The parameter item for message. (NotNull)
+     * @return this. (NotNull)
+     */
+    public FessMessages addConstraintsCronExpressionMessage(String property, String item) {
+        assertPropertyNotNull(property);
+        add(property, new ActionMessage(CONSTRAINTS_CronExpression_MESSAGE, item));
+        return this;
+    }
+
     /**
     /**
      * Add the created action message for the key 'errors.login.failure' with parameters.
      * Add the created action message for the key 'errors.login.failure' with parameters.
      * <pre>
      * <pre>

+ 44 - 0
src/main/java/org/codelibs/fess/validation/CronExpression.java

@@ -0,0 +1,44 @@
+/*
+ * Copyright 2012-2015 CodeLibs Project and the Others.
+ *
+ * Licensed 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 org.codelibs.fess.validation;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.CONSTRUCTOR;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
+@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
+@Retention(RUNTIME)
+@Documented
+@Constraint(validatedBy = CronExpressionValidator.class)
+public @interface CronExpression {
+
+    String message() default "{org.lastaflute.validator.constraints.CronExpression.message}";
+
+    Class<?>[] groups() default {};
+
+    Class<? extends Payload>[] payload() default {};
+
+}

+ 41 - 0
src/main/java/org/codelibs/fess/validation/CronExpressionValidator.java

@@ -0,0 +1,41 @@
+/*
+ * Copyright 2012-2015 CodeLibs Project and the Others.
+ *
+ * Licensed 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 org.codelibs.fess.validation;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+import org.codelibs.core.lang.StringUtil;
+
+public class CronExpressionValidator implements ConstraintValidator<CronExpression, String> {
+
+    @Override
+    public void initialize(CronExpression constraintAnnotation) {
+    }
+
+    @Override
+    public boolean isValid(String value, ConstraintValidatorContext context) {
+        return determineValid(value);
+    }
+
+    protected boolean determineValid(String value) {
+        if (StringUtil.isNotBlank(value) && !org.quartz.CronExpression.isValidExpression(value)) {
+            return false;
+        }
+        return true;
+    }
+
+}

+ 46 - 0
src/main/java/org/codelibs/fess/validation/UriType.java

@@ -0,0 +1,46 @@
+/*
+ * Copyright 2012-2015 CodeLibs Project and the Others.
+ *
+ * Licensed 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 org.codelibs.fess.validation;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.CONSTRUCTOR;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
+@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
+@Retention(RUNTIME)
+@Documented
+@Constraint(validatedBy = UriTypeValidator.class)
+public @interface UriType {
+
+    String[] protocols();
+
+    String message() default "{org.lastaflute.validator.constraints.UriType.message}";
+
+    Class<?>[] groups() default {};
+
+    Class<? extends Payload>[] payload() default {};
+
+}

+ 61 - 0
src/main/java/org/codelibs/fess/validation/UriTypeValidator.java

@@ -0,0 +1,61 @@
+/*
+ * Copyright 2012-2015 CodeLibs Project and the Others.
+ *
+ * Licensed 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 org.codelibs.fess.validation;
+
+import javax.validation.ConstraintDefinitionException;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+import org.codelibs.core.lang.StringUtil;
+
+public class UriTypeValidator implements ConstraintValidator<UriType, String> {
+    private String[] protocols;
+
+    @Override
+    public void initialize(UriType uriType) {
+        protocols = uriType.protocols();
+        if (protocols == null || protocols.length == 0) {
+            throw new ConstraintDefinitionException("protocols is emtpy.");
+        }
+    }
+
+    @Override
+    public boolean isValid(String value, ConstraintValidatorContext context) {
+        if (StringUtil.isNotBlank(value)) {
+            return check(protocols, value);
+        }
+        return true;
+    }
+
+    protected static boolean check(final String[] protocols, final String value) {
+        final String[] paths = value.split("[\r\n]");
+        for (final String path : paths) {
+            if (StringUtil.isNotBlank(path) && !path.trim().startsWith("#")) {
+                boolean flag = false;
+                for (final String protocol : protocols) {
+                    if (path.trim().startsWith(protocol.trim())) {
+                        flag = true;
+                        break;
+                    }
+                }
+                if (!flag) {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+}

+ 0 - 20
src/main/java/org/codelibs/fess/validator/CronExpressionChecks.java

@@ -1,20 +0,0 @@
-/*
- * Copyright 2012-2015 CodeLibs Project and the Others.
- *
- * Licensed 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 org.codelibs.fess.validator;
-
-//TODO replace with hibernate validator
-public class CronExpressionChecks /*extends S2FieldChecks*/{
-}

+ 0 - 59
src/main/java/org/codelibs/fess/validator/UriTypeChecks.java

@@ -1,59 +0,0 @@
-/*
- * Copyright 2012-2015 CodeLibs Project and the Others.
- *
- * Licensed 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 org.codelibs.fess.validator;
-
-import org.codelibs.core.lang.StringUtil;
-
-// TODO replace with hibernate validator
-public class UriTypeChecks /*extends S2FieldChecks*/{
-
-    /*
-        public static boolean validateUriType(final Object bean, final ValidatorAction validatorAction, final Field field,
-                final ActionMessages errors, final Validator validator, final HttpServletRequest request) {
-            final String value = getValueAsString(bean, field);
-            if (StringUtil.isNotBlank(value)) {
-                final String protocols = field.getVarValue("protocols");
-                if (StringUtil.isEmpty(protocols)) {
-                    throw new FessSystemException("protocols is empty.");
-                }
-                if (!check(protocols, value)) {
-                    addError(errors, field, validator, validatorAction, request);
-                    return false;
-                }
-            }
-            return true;
-        }
-    */
-    protected static boolean check(final String protocols, final String values) {
-        final String[] prtcls = protocols.split(",");
-        final String[] paths = values.split("[\r\n]");
-        for (final String path : paths) {
-            if (StringUtil.isNotBlank(path) && !path.trim().startsWith("#")) {
-                boolean flag = false;
-                for (final String protocol : prtcls) {
-                    if (path.trim().startsWith(protocol.trim())) {
-                        flag = true;
-                        break;
-                    }
-                }
-                if (!flag) {
-                    return false;
-                }
-            }
-        }
-        return true;
-    }
-}

+ 2 - 0
src/main/resources/fess_message.properties

@@ -51,6 +51,8 @@ constraints.TypeLong.message                = {item} should be numeric.
 constraints.TypeFloat.message               = {item} should be numeric.
 constraints.TypeFloat.message               = {item} should be numeric.
 constraints.TypeDouble.message              = {item} should be numeric.
 constraints.TypeDouble.message              = {item} should be numeric.
 constraints.TypeAny.message                 = {item} cannot convert as {propertyType}.
 constraints.TypeAny.message                 = {item} cannot convert as {propertyType}.
+constraints.UriType.message                 = {item} has wrong URI.
+constraints.CronExpression.message          = {item} is invalid cron expression.
 
 
 # ----------------------------------------------------------
 # ----------------------------------------------------------
 #                                      Application Exception
 #                                      Application Exception

+ 2 - 0
src/main/resources/fess_message_en.properties

@@ -51,6 +51,8 @@ constraints.TypeLong.message                = {item} should be numeric.
 constraints.TypeFloat.message               = {item} should be numeric.
 constraints.TypeFloat.message               = {item} should be numeric.
 constraints.TypeDouble.message              = {item} should be numeric.
 constraints.TypeDouble.message              = {item} should be numeric.
 constraints.TypeAny.message                 = {item} cannot convert as {propertyType}.
 constraints.TypeAny.message                 = {item} cannot convert as {propertyType}.
+constraints.UriType.message                 = {item} has wrong URI.
+constraints.CronExpression.message          = {item} is invalid cron expression.
 
 
 # ----------------------------------------------------------
 # ----------------------------------------------------------
 #                                      Application Exception
 #                                      Application Exception

+ 3 - 0
src/main/resources/fess_message_ja.properties

@@ -48,6 +48,9 @@ constraints.TypeLong.message = {item} \u306f\u6570\u5024\u3067\u306a\u3051\u308c
 constraints.TypeFloat.message = {item} \u306f\u6570\u5024\u3067\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002
 constraints.TypeFloat.message = {item} \u306f\u6570\u5024\u3067\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002
 constraints.TypeDouble.message = {item} \u306f\u6570\u5024\u3067\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002
 constraints.TypeDouble.message = {item} \u306f\u6570\u5024\u3067\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002
 constraints.TypeAny.message = {item} \u306f {propertyType} \u306b\u5909\u63db\u3067\u304d\u307e\u305b\u3093\u3002
 constraints.TypeAny.message = {item} \u306f {propertyType} \u306b\u5909\u63db\u3067\u304d\u307e\u305b\u3093\u3002
+constraints.UriType.message = {item} \u306b\u8a8d\u8b58\u3067\u304d\u306a\u3044 URI \u304c\u3042\u308a\u307e\u3059\u3002
+constraints.CronExpression.message = {item} \u306f\u6b63\u3057\u3044 CRON \u8868\u8a18\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002
+
 # ----------------------------------------------------------
 # ----------------------------------------------------------
 # Application Exception
 # Application Exception
 # ---------------------
 # ---------------------

+ 84 - 0
src/test/java/org/codelibs/fess/validation/UriTypeValidatorTest.java

@@ -0,0 +1,84 @@
+/*
+ * Copyright 2012-2015 CodeLibs Project and the Others.
+ *
+ * Licensed 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 org.codelibs.fess.validation;
+
+import org.codelibs.fess.unit.UnitFessTestCase;
+import org.codelibs.fess.validation.UriTypeValidator;
+
+public class UriTypeValidatorTest extends UnitFessTestCase {
+    public void test_check_ok() {
+        String[] protocols;
+        String values;
+
+        protocols = new String[] { "http:" };
+        values = "http://www.foo.com/";
+        assertTrue(UriTypeValidator.check(protocols, values));
+
+        protocols = new String[] { "http:" };
+        values = "http://www.foo.com/\nhttp://www.bar.com/";
+        assertTrue(UriTypeValidator.check(protocols, values));
+
+        protocols = new String[] { "http:" };
+        values = "http://www.foo.com/ \r\nhttp://www.bar.com/";
+        assertTrue(UriTypeValidator.check(protocols, values));
+
+        protocols = new String[] { "http:" };
+        values = "http://www.foo.com/\nhttp://www.bar.com/\n http://www.baz.com/";
+        assertTrue(UriTypeValidator.check(protocols, values));
+
+        protocols = new String[] { "http:", "https:" };
+        values = "https://www.foo.com/";
+        assertTrue(UriTypeValidator.check(protocols, values));
+
+        protocols = new String[] { "http:", "https:" };
+        values = "http://www.foo.com/\r\nhttp://www.bar.com/";
+        assertTrue(UriTypeValidator.check(protocols, values));
+
+        protocols = new String[] { "http:", "https:" };
+        values = "http://www.foo.com/\nhttps://www.bar.com/";
+        assertTrue(UriTypeValidator.check(protocols, values));
+
+        protocols = new String[] { "http:", "https:" };
+        values = "http://www.foo.com/\n \nhttps://www.bar.com/";
+        assertTrue(UriTypeValidator.check(protocols, values));
+
+        protocols = new String[] { "http:", "https:" };
+        values = "http://www.foo.com/\nhttps://www.bar.com/\n http://www.baz.com/";
+        assertTrue(UriTypeValidator.check(protocols, values));
+    }
+
+    public void test_check_ng() {
+        String[] protocols;
+        String values;
+
+        protocols = new String[] { "http:" };
+        values = "https://www.foo.com/";
+        assertFalse(UriTypeValidator.check(protocols, values));
+
+        protocols = new String[] { "http:" };
+        values = "https://www.foo.com/\nhttps://www.bar.com/";
+        assertFalse(UriTypeValidator.check(protocols, values));
+
+        protocols = new String[] { "http:" };
+        values = "https://www.foo.com/\n \nhttps://www.bar.com/";
+        assertFalse(UriTypeValidator.check(protocols, values));
+
+        protocols = new String[] { "http:" };
+        values = "https://www.foo.com/\nhttps://www.bar.com/\n https://www.baz.com/";
+        assertFalse(UriTypeValidator.check(protocols, values));
+
+    }
+}

+ 0 - 83
src/test/java/org/codelibs/fess/validator/UriTypeChecksTest.java

@@ -1,83 +0,0 @@
-/*
- * Copyright 2012-2015 CodeLibs Project and the Others.
- *
- * Licensed 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 org.codelibs.fess.validator;
-
-import org.codelibs.fess.unit.UnitFessTestCase;
-
-public class UriTypeChecksTest extends UnitFessTestCase {
-    public void test_check_ok() {
-        String protocols;
-        String values;
-
-        protocols = "http:";
-        values = "http://www.foo.com/";
-        assertTrue(UriTypeChecks.check(protocols, values));
-
-        protocols = "http:";
-        values = "http://www.foo.com/\nhttp://www.bar.com/";
-        assertTrue(UriTypeChecks.check(protocols, values));
-
-        protocols = "http:";
-        values = "http://www.foo.com/ \r\nhttp://www.bar.com/";
-        assertTrue(UriTypeChecks.check(protocols, values));
-
-        protocols = "http:";
-        values = "http://www.foo.com/\nhttp://www.bar.com/\n http://www.baz.com/";
-        assertTrue(UriTypeChecks.check(protocols, values));
-
-        protocols = "http:,https:";
-        values = "https://www.foo.com/";
-        assertTrue(UriTypeChecks.check(protocols, values));
-
-        protocols = "http:,https:";
-        values = "http://www.foo.com/\r\nhttp://www.bar.com/";
-        assertTrue(UriTypeChecks.check(protocols, values));
-
-        protocols = "http:,https:";
-        values = "http://www.foo.com/\nhttps://www.bar.com/";
-        assertTrue(UriTypeChecks.check(protocols, values));
-
-        protocols = "http:,https:";
-        values = "http://www.foo.com/\n \nhttps://www.bar.com/";
-        assertTrue(UriTypeChecks.check(protocols, values));
-
-        protocols = "http:, https:";
-        values = "http://www.foo.com/\nhttps://www.bar.com/\n http://www.baz.com/";
-        assertTrue(UriTypeChecks.check(protocols, values));
-    }
-
-    public void test_check_ng() {
-        String protocols;
-        String values;
-
-        protocols = "http:";
-        values = "https://www.foo.com/";
-        assertFalse(UriTypeChecks.check(protocols, values));
-
-        protocols = "http:";
-        values = "https://www.foo.com/\nhttps://www.bar.com/";
-        assertFalse(UriTypeChecks.check(protocols, values));
-
-        protocols = "http:";
-        values = "https://www.foo.com/\n \nhttps://www.bar.com/";
-        assertFalse(UriTypeChecks.check(protocols, values));
-
-        protocols = "http:";
-        values = "https://www.foo.com/\nhttps://www.bar.com/\n https://www.baz.com/";
-        assertFalse(UriTypeChecks.check(protocols, values));
-
-    }
-}