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.webconfig;
17  
18  import javax.validation.constraints.Max;
19  import javax.validation.constraints.Min;
20  import javax.validation.constraints.Size;
21  
22  import org.codelibs.core.lang.StringUtil;
23  import org.codelibs.fess.Constants;
24  import org.codelibs.fess.app.web.CrudMode;
25  import org.codelibs.fess.util.ComponentUtil;
26  import org.codelibs.fess.validation.CustomSize;
27  import org.codelibs.fess.validation.UriType;
28  import org.codelibs.fess.validation.UriTypeValidator.ProtocolType;
29  import org.lastaflute.web.validation.Required;
30  import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure;
31  
32  /**
33   * @author shinsuke
34   * @author Shunji Makino
35   * @author Keiichi Watanabe
36   */
37  public class CreateForm {
38  
39      public String[] labelTypeIds;
40  
41      @ValidateTypeFailure
42      public Integer crudMode;
43  
44      @Required
45      @Size(max = 200)
46      public String name;
47  
48      @Size(max = 1000)
49      public String description;
50  
51      @Required
52      @UriType(protocolType = ProtocolType.WEB)
53      @CustomSize(maxKey = "form.admin.max.input.size")
54      public String urls;
55  
56      @CustomSize(maxKey = "form.admin.max.input.size")
57      public String includedUrls;
58  
59      @CustomSize(maxKey = "form.admin.max.input.size")
60      public String excludedUrls;
61  
62      @CustomSize(maxKey = "form.admin.max.input.size")
63      public String includedDocUrls;
64  
65      @CustomSize(maxKey = "form.admin.max.input.size")
66      public String excludedDocUrls;
67  
68      @CustomSize(maxKey = "form.admin.max.input.size")
69      public String configParameter;
70  
71      @Min(value = 0)
72      @Max(value = 2147483647)
73      @ValidateTypeFailure
74      public Integer depth;
75  
76      @Min(value = 0)
77      @Max(value = 9223372036854775807L)
78      @ValidateTypeFailure
79      public Long maxAccessCount;
80  
81      @Required
82      @Size(max = 200)
83      public String userAgent;
84  
85      @Required
86      @Min(value = 1)
87      @Max(value = 2147483647)
88      @ValidateTypeFailure
89      public Integer numOfThread;
90  
91      @Required
92      @Min(value = 0)
93      @Max(value = 2147483647)
94      @ValidateTypeFailure
95      public Integer intervalTime;
96  
97      @Required
98      @ValidateTypeFailure
99      public Float boost;
100 
101     @Required
102     @Size(max = 5)
103     public String available;
104 
105     @CustomSize(maxKey = "form.admin.max.input.size")
106     public String permissions;
107 
108     @CustomSize(maxKey = "form.admin.max.input.size")
109     public String virtualHosts;
110 
111     @Required
112     @Min(value = 0)
113     @Max(value = 2147483647)
114     @ValidateTypeFailure
115     public Integer sortOrder;
116 
117     @Size(max = 1000)
118     public String createdBy;
119 
120     @ValidateTypeFailure
121     public Long createdTime;
122 
123     public void initialize() {
124         crudMode = CrudMode.CREATE;
125         boost = 1.0f;
126         if (StringUtil.isBlank(userAgent)) {
127             userAgent = ComponentUtil.getFessConfig().getUserAgentName();
128         }
129         numOfThread = Constants.DEFAULT_NUM_OF_THREAD_FOR_WEB;
130         intervalTime = Constants.DEFAULT_INTERVAL_TIME_FOR_WEB;
131         sortOrder = 0;
132         createdBy = ComponentUtil.getSystemHelper().getUsername();
133         createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
134         permissions = ComponentUtil.getFessConfig().getSearchDefaultDisplayPermission();
135     }
136 }