View Javadoc
1   /*
2    * Copyright 2012-2021 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.fileconfig;
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.Constants;
23  import org.codelibs.fess.app.web.CrudMode;
24  import org.codelibs.fess.util.ComponentUtil;
25  import org.codelibs.fess.validation.CustomSize;
26  import org.codelibs.fess.validation.UriType;
27  import org.codelibs.fess.validation.UriTypeValidator.ProtocolType;
28  import org.lastaflute.web.validation.Required;
29  import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure;
30  
31  /**
32   * @author codelibs
33   * @author Keiichi Watanabe
34   */
35  public class CreateForm {
36  
37      public String[] labelTypeIds;
38  
39      @ValidateTypeFailure
40      public Integer crudMode;
41  
42      @Required
43      @Size(max = 200)
44      public String name;
45  
46      @Size(max = 1000)
47      public String description;
48  
49      @Required
50      @UriType(protocolType = ProtocolType.FILE)
51      @CustomSize(maxKey = "form.admin.max.input.size")
52      public String paths;
53  
54      @CustomSize(maxKey = "form.admin.max.input.size")
55      public String includedPaths;
56  
57      @CustomSize(maxKey = "form.admin.max.input.size")
58      public String excludedPaths;
59  
60      @CustomSize(maxKey = "form.admin.max.input.size")
61      public String includedDocPaths;
62  
63      @CustomSize(maxKey = "form.admin.max.input.size")
64      public String excludedDocPaths;
65  
66      @CustomSize(maxKey = "form.admin.max.input.size")
67      public String configParameter;
68  
69      @Min(value = 0)
70      @Max(value = 2147483647)
71      @ValidateTypeFailure
72      public Integer depth;
73  
74      @Min(value = 0)
75      @Max(value = 9223372036854775807L)
76      @ValidateTypeFailure
77      public Long maxAccessCount;
78  
79      @Required
80      @Min(value = 1)
81      @Max(value = 2147483647)
82      @ValidateTypeFailure
83      public Integer numOfThread;
84  
85      @Required
86      @Min(value = 0)
87      @Max(value = 2147483647)
88      @ValidateTypeFailure
89      public Integer intervalTime;
90  
91      @Required
92      @ValidateTypeFailure
93      public Float boost;
94  
95      @Required
96      @Size(max = 5)
97      public String available;
98  
99      @CustomSize(maxKey = "form.admin.max.input.size")
100     public String permissions;
101 
102     @CustomSize(maxKey = "form.admin.max.input.size")
103     public String virtualHosts;
104 
105     @Required
106     @Min(value = 0)
107     @Max(value = 2147483647)
108     @ValidateTypeFailure
109     public Integer sortOrder;
110 
111     @Size(max = 1000)
112     public String createdBy;
113 
114     @ValidateTypeFailure
115     public Long createdTime;
116 
117     public void initialize() {
118         crudMode = CrudMode.CREATE;
119         boost = 1.0f;
120         numOfThread = Constants.DEFAULT_NUM_OF_THREAD_FOR_FS;
121         intervalTime = Constants.DEFAULT_INTERVAL_TIME_FOR_FS;
122         sortOrder = 0;
123         createdBy = ComponentUtil.getSystemHelper().getUsername();
124         createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
125         permissions = ComponentUtil.getFessConfig().getSearchDefaultDisplayPermission();
126     }
127 }