View Javadoc
1   /*
2    * Copyright 2012-2021 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.es.config.exentity;
17  
18  import org.apache.logging.log4j.LogManager;
19  import org.apache.logging.log4j.Logger;
20  import org.codelibs.fess.app.service.FileConfigService;
21  import org.codelibs.fess.es.config.bsentity.BsFileAuthentication;
22  import org.codelibs.fess.util.ComponentUtil;
23  
24  /**
25   * @author FreeGen
26   */
27  public class FileAuthentication extends BsFileAuthentication {
28  
29      private static final long serialVersionUID = 1L;
30  
31      private static final Logger logger = LogManager.getLogger(FileAuthentication.class);
32  
33      private FileConfig fileConfig;
34  
35      public String getId() {
36          return asDocMeta().id();
37      }
38  
39      public void setId(final String id) {
40          asDocMeta().id(id);
41      }
42  
43      public Long getVersionNo() {
44          return asDocMeta().version();
45      }
46  
47      public void setVersionNo(final Long version) {
48          asDocMeta().version(version);
49      }
50  
51      public FileConfig getFileConfig() {
52          if (fileConfig == null) {
53              final FileConfigService fileConfigService = ComponentUtil.getComponent(FileConfigService.class);
54              try {
55                  fileConfig = fileConfigService.getFileConfig(getFileConfigId()).get();
56              } catch (final Exception e) {
57                  logger.warn("File Config {} does not exist.", getFileConfigId(), e);
58              }
59          }
60          return fileConfig;
61      }
62  
63      @Override
64      public String toString() {
65          return "FileAuthentication [fileConfig=" + fileConfig + ", createdBy=" + createdBy + ", createdTime=" + createdTime
66                  + ", fileConfigId=" + fileConfigId + ", hostname=" + hostname + ", parameters=" + parameters + ", port=" + port
67                  + ", protocolScheme=" + protocolScheme + ", updatedBy=" + updatedBy + ", updatedTime=" + updatedTime + ", username="
68                  + username + ", docMeta=" + docMeta + "]";
69      }
70  }