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.duplicatehost;
17  
18  import org.codelibs.fess.app.web.CrudMode;
19  import org.codelibs.fess.util.ComponentUtil;
20  import org.lastaflute.web.validation.Required;
21  import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure;
22  
23  import jakarta.validation.constraints.Max;
24  import jakarta.validation.constraints.Min;
25  import jakarta.validation.constraints.Size;
26  
27  /**
28   * Form class for creating new duplicate host configuration entries.
29   * This form handles the creation of duplicate host mappings that redirect
30   * crawling from duplicate hostnames to the regular canonical hostname.
31   */
32  public class CreateForm {
33  
34      /**
35       * Creates a new CreateForm instance.
36       */
37      public CreateForm() {
38      }
39  
40      /** The CRUD operation mode for form processing */
41      @ValidateTypeFailure
42      public Integer crudMode;
43  
44      /** The regular canonical hostname that should be used */
45      @Required
46      @Size(max = 1000)
47      public String regularName;
48  
49      /** The duplicate hostname that should be redirected to the regular name */
50      @Required
51      @Size(max = 1000)
52      public String duplicateHostName;
53  
54      /** The sort order for displaying this duplicate host entry */
55      @Required
56      @Min(value = 0)
57      @Max(value = 2147483647)
58      @ValidateTypeFailure
59      public Integer sortOrder;
60  
61      /** The username of who created this duplicate host entry */
62      @Size(max = 1000)
63      public String createdBy;
64  
65      /** The timestamp when this duplicate host entry was created */
66      @ValidateTypeFailure
67      public Long createdTime;
68  
69      /**
70       * Initializes the form with default values for creating a new duplicate host entry.
71       */
72      public void initialize() {
73          crudMode = CrudMode.CREATE;
74          sortOrder = 0;
75          createdBy = ComponentUtil.getSystemHelper().getUsername();
76          createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
77      }
78  }