1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.codelibs.fess.app.service;
17
18 import java.util.List;
19
20 import org.codelibs.core.beans.util.BeanUtil;
21 import org.codelibs.fess.Constants;
22 import org.codelibs.fess.app.pager.WebAuthPager;
23 import org.codelibs.fess.mylasta.direction.FessConfig;
24 import org.codelibs.fess.opensearch.config.cbean.WebAuthenticationCB;
25 import org.codelibs.fess.opensearch.config.exbhv.WebAuthenticationBhv;
26 import org.codelibs.fess.opensearch.config.exentity.WebAuthentication;
27 import org.codelibs.fess.util.ParameterUtil;
28 import org.dbflute.cbean.result.PagingResultBean;
29 import org.dbflute.optional.OptionalEntity;
30
31 import jakarta.annotation.Resource;
32
33
34
35
36
37
38 public class WebAuthenticationService {
39
40
41
42
43 public WebAuthenticationService() {
44
45 }
46
47
48
49
50 @Resource
51 protected WebAuthenticationBhv webAuthenticationBhv;
52
53
54
55
56 @Resource
57 protected FessConfig fessConfig;
58
59
60
61
62
63
64
65 public List<WebAuthentication> getWebAuthenticationList(final WebAuthPager webAuthenticationPager) {
66
67 final PagingResultBean<WebAuthentication> webAuthenticationList = webAuthenticationBhv.selectPage(cb -> {
68 cb.paging(webAuthenticationPager.getPageSize(), webAuthenticationPager.getCurrentPageNumber());
69 setupListCondition(cb, webAuthenticationPager);
70 });
71
72
73 BeanUtil.copyBeanToBean(webAuthenticationList, webAuthenticationPager, option -> option.include(Constants.PAGER_CONVERSION_RULE));
74 webAuthenticationPager.setPageNumberList(webAuthenticationList.pageRange(op -> {
75 op.rangeSize(fessConfig.getPagingPageRangeSizeAsInteger());
76 }).createPageNumberList());
77
78 return webAuthenticationList;
79 }
80
81
82
83
84
85
86
87 public OptionalEntity<WebAuthentication> getWebAuthentication(final String id) {
88 return webAuthenticationBhv.selectByPK(id);
89 }
90
91
92
93
94
95
96
97 public void store(final WebAuthentication webAuthentication) {
98 webAuthentication.setParameters(ParameterUtil.encrypt(webAuthentication.getParameters()));
99 webAuthenticationBhv.insertOrUpdate(webAuthentication, op -> {
100 op.setRefreshPolicy(Constants.TRUE);
101 });
102
103 }
104
105
106
107
108
109
110 public void delete(final WebAuthentication webAuthentication) {
111
112 webAuthenticationBhv.delete(webAuthentication, op -> {
113 op.setRefreshPolicy(Constants.TRUE);
114 });
115
116 }
117
118
119
120
121
122
123
124 protected void setupListCondition(final WebAuthenticationCB cb, final WebAuthPager webAuthenticationPager) {
125 if (webAuthenticationPager.id != null) {
126 cb.query().docMeta().setId_Equal(webAuthenticationPager.id);
127 }
128
129
130 cb.query().addOrderBy_Hostname_Asc();
131 cb.query().addOrderBy_WebConfigId_Asc();
132
133
134
135 }
136
137
138
139
140
141
142
143 public List<WebAuthentication> getWebAuthenticationList(final String webConfigId) {
144 return webAuthenticationBhv.selectList(cb -> {
145 cb.query().setWebConfigId_Equal(webConfigId);
146 cb.fetchFirst(fessConfig.getPageWebAuthMaxFetchSizeAsInteger());
147 });
148 }
149
150 }