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.searchlog;
17
18 import org.codelibs.core.lang.StringUtil;
19 import org.codelibs.fess.app.pager.SearchLogPager;
20 import org.codelibs.fess.util.ComponentUtil;
21
22 /**
23 * The search form for Search Log.
24 */
25 public class SearchForm {
26
27 /**
28 * Default constructor for SearchForm.
29 */
30 public SearchForm() {
31 }
32
33 /**
34 * The log type field for filtering search logs.
35 */
36 public String logType;
37
38 /**
39 * The query ID field for searching specific queries.
40 */
41 public String queryId;
42
43 /**
44 * The user session ID field for filtering logs by session.
45 */
46 public String userSessionId;
47
48 /**
49 * The requested time range field for filtering logs by date.
50 */
51 public String requestedTimeRange;
52
53 /**
54 * The access type field for filtering logs by access method.
55 */
56 public String accessType;
57
58 /**
59 * The size field for controlling page size.
60 */
61 public String size;
62
63 /**
64 * Sets the page size for search log results.
65 *
66 * @param size the page size to set
67 */
68 public void setPageSize(final int size) {
69 this.size = Integer.toString(size);
70 }
71
72 /**
73 * Gets the page size for search log results with validation.
74 * Returns the default page size if the current size is invalid.
75 *
76 * @return the validated page size
77 */
78 public int getPageSize() {
79 if (StringUtil.isBlank(size)) {
80 return SearchLogPager.DEFAULT_PAGE_SIZE;
81 }
82 try {
83 final int value = Integer.parseInt(size);
84 if (value <= 0 || value > ComponentUtil.getFessConfig().getPageSearchlogMaxFetchSizeAsInteger()) {
85 return SearchLogPager.DEFAULT_PAGE_SIZE;
86 }
87 return value;
88 } catch (final NumberFormatException e) {
89 // ignore
90 return SearchLogPager.DEFAULT_PAGE_SIZE;
91 }
92 }
93 }