View Javadoc
1   /*
2    * Copyright 2012-2017 CodeLibs Project 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.codelibs.fess.app.web.admin.dataconfig;
17  
18  import javax.validation.constraints.Max;
19  import javax.validation.constraints.Min;
20  import javax.validation.constraints.Size;
21  
22  import org.codelibs.fess.app.web.CrudMode;
23  import org.codelibs.fess.util.ComponentUtil;
24  import org.codelibs.fess.validation.CustomSize;
25  import org.lastaflute.web.validation.Required;
26  import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure;
27  
28  /**
29   * @author codelibs
30   * @author Keiichi Watanabe
31   */
32  public class CreateForm {
33  
34      public String[] labelTypeIds;
35  
36      @ValidateTypeFailure
37      public Integer crudMode;
38  
39      @Required
40      @Size(max = 200)
41      public String name;
42  
43      @Size(max = 1000)
44      public String description;
45  
46      @Required
47      @CustomSize(maxKey = "form.admin.max.input.size")
48      public String handlerName;
49  
50      @CustomSize(maxKey = "form.admin.max.input.size")
51      public String handlerParameter;
52  
53      @CustomSize(maxKey = "form.admin.max.input.size")
54      public String handlerScript;
55  
56      @Required
57      @ValidateTypeFailure
58      public Float boost;
59  
60      @Required
61      @Size(max = 5)
62      public String available;
63  
64      @CustomSize(maxKey = "form.admin.max.input.size")
65      public String permissions;
66  
67      @CustomSize(maxKey = "form.admin.max.input.size")
68      public String virtualHosts;
69  
70      @Required
71      @Min(value = 0)
72      @Max(value = 2147483647)
73      @ValidateTypeFailure
74      public Integer sortOrder;
75  
76      @Size(max = 1000)
77      public String createdBy;
78  
79      @ValidateTypeFailure
80      public Long createdTime;
81  
82      public void initialize() {
83          crudMode = CrudMode.CREATE;
84          boost = 1.0f;
85          sortOrder = 0;
86          createdBy = ComponentUtil.getSystemHelper().getUsername();
87          createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
88          permissions = ComponentUtil.getFessConfig().getSearchDefaultDisplayPermission();
89      }
90  }