View Javadoc
1   /*
2    * Copyright 2012-2025 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.labeltype;
17  
18  import org.codelibs.fess.app.web.CrudMode;
19  import org.codelibs.fess.util.ComponentUtil;
20  import org.codelibs.fess.validation.CustomSize;
21  import org.lastaflute.web.validation.Required;
22  import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure;
23  
24  import jakarta.validation.constraints.Max;
25  import jakarta.validation.constraints.Min;
26  import jakarta.validation.constraints.Pattern;
27  import jakarta.validation.constraints.Size;
28  
29  /**
30   * The create form for Label Type.
31   */
32  public class CreateForm {
33  
34      /**
35       * Creates a new CreateForm instance.
36       */
37      public CreateForm() {
38      }
39  
40      /**
41       * The CRUD mode for the form.
42       */
43      @ValidateTypeFailure
44      public Integer crudMode;
45  
46      /**
47       * The name of the label type.
48       */
49      @Required
50      @Size(max = 100)
51      public String name;
52  
53      /**
54       * The value of the label type (alphanumeric and underscore only).
55       */
56      @Required
57      @Size(max = 100)
58      @Pattern(regexp = "^[a-zA-Z0-9_]+$")
59      public String value;
60  
61      /**
62       * The paths to include for this label type.
63       */
64      @CustomSize(maxKey = "form.admin.max.input.size")
65      public String includedPaths;
66  
67      /**
68       * The paths to exclude for this label type.
69       */
70      @CustomSize(maxKey = "form.admin.max.input.size")
71      public String excludedPaths;
72  
73      /**
74       * The permissions required to view this label type.
75       */
76      @CustomSize(maxKey = "form.admin.max.input.size")
77      public String permissions;
78  
79      /**
80       * The virtual host for the label type.
81       */
82      @Size(max = 1000)
83      public String virtualHost;
84  
85      /**
86       * The sort order for displaying this label type.
87       */
88      @Min(value = 0)
89      @Max(value = 2147483647)
90      @ValidateTypeFailure
91      public Integer sortOrder;
92  
93      /**
94       * The user who created this label type.
95       */
96      @Size(max = 1000)
97      public String createdBy;
98  
99      /**
100      * The timestamp when this label type was created.
101      */
102     @ValidateTypeFailure
103     public Long createdTime;
104 
105     /**
106      * Initializes the form with default values.
107      */
108     public void initialize() {
109         crudMode = CrudMode.CREATE;
110         sortOrder = 0;
111         createdBy = ComponentUtil.getSystemHelper().getUsername();
112         createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
113         permissions = ComponentUtil.getFessConfig().getSearchDefaultDisplayPermission();
114     }
115 }