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.dict;
17  
18  import org.codelibs.fess.annotation.Secured;
19  import org.codelibs.fess.app.web.base.FessAdminAction;
20  import org.codelibs.fess.dict.DictionaryFile;
21  import org.codelibs.fess.dict.DictionaryItem;
22  import org.codelibs.fess.dict.DictionaryManager;
23  import org.codelibs.fess.util.RenderDataUtil;
24  import org.lastaflute.web.Execute;
25  import org.lastaflute.web.response.HtmlResponse;
26  import org.lastaflute.web.ruts.process.ActionRuntime;
27  
28  import jakarta.annotation.Resource;
29  
30  /**
31   * Admin action for Dictionary management.
32   *
33   */
34  public class AdminDictAction extends FessAdminAction {
35  
36      /**
37       * Default constructor.
38       */
39      public AdminDictAction() {
40          super();
41      }
42  
43      /** The role for this action. */
44      public static final String ROLE = "admin-dict";
45  
46      // ===================================================================================
47      //                                                                           Attribute
48      //                                                                           =========
49      /** The dictionary manager. */
50      @Resource
51      protected DictionaryManager dictionaryManager;
52  
53      // ===================================================================================
54      //                                                                               Hook
55      //                                                                              ======
56      @Override
57      protected void setupHtmlData(final ActionRuntime runtime) {
58          super.setupHtmlData(runtime);
59          runtime.registerData("helpLink", systemHelper.getHelpLink(fessConfig.getOnlineHelpNameDict()));
60      }
61  
62      @Override
63      protected String getActionRole() {
64          return ROLE;
65      }
66  
67      // ===================================================================================
68      //                                                                      Search Execute
69      //                                                                      ==============
70      /**
71       * Show the index page.
72       * @return The HTML response.
73       */
74      @Execute
75      @Secured({ ROLE, ROLE + VIEW })
76      public HtmlResponse index() {
77          return asHtml(path_AdminDict_AdminDictJsp).renderWith(data -> {
78              final DictionaryFile<? extends DictionaryItem>[] dictFiles = dictionaryManager.getDictionaryFiles();
79              RenderDataUtil.register(data, "dictFiles", dictFiles);
80          });
81      }
82  }