|
@@ -32,8 +32,7 @@ import org.codelibs.core.misc.DynamicProperties;
|
|
import org.codelibs.elasticsearch.runner.net.Curl;
|
|
import org.codelibs.elasticsearch.runner.net.Curl;
|
|
import org.codelibs.elasticsearch.runner.net.CurlResponse;
|
|
import org.codelibs.elasticsearch.runner.net.CurlResponse;
|
|
import org.codelibs.fess.Constants;
|
|
import org.codelibs.fess.Constants;
|
|
-import org.codelibs.fess.mylasta.direction.FessConfig;
|
|
|
|
-import org.codelibs.fess.util.ComponentUtil;
|
|
|
|
|
|
+import org.codelibs.fess.util.ResourceUtil;
|
|
import org.dbflute.optional.OptionalEntity;
|
|
import org.dbflute.optional.OptionalEntity;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -54,9 +53,8 @@ public class DictionaryManager {
|
|
}
|
|
}
|
|
|
|
|
|
public DictionaryFile<? extends DictionaryItem>[] getDictionaryFiles() {
|
|
public DictionaryFile<? extends DictionaryItem>[] getDictionaryFiles() {
|
|
- final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
|
|
|
try (CurlResponse response =
|
|
try (CurlResponse response =
|
|
- Curl.get(fessConfig.getElasticsearchHttpUrl() + "/_configsync/file").param("fields", "path,@timestamp").execute()) {
|
|
|
|
|
|
+ Curl.get(ResourceUtil.getElasticsearchHttpUrl() + "/_configsync/file").param("fields", "path,@timestamp").execute()) {
|
|
final Map<String, Object> contentMap = response.getContentAsMap();
|
|
final Map<String, Object> contentMap = response.getContentAsMap();
|
|
@SuppressWarnings("unchecked")
|
|
@SuppressWarnings("unchecked")
|
|
final List<Map<String, Object>> fileList = (List<Map<String, Object>>) contentMap.get("file");
|
|
final List<Map<String, Object>> fileList = (List<Map<String, Object>>) contentMap.get("file");
|
|
@@ -94,7 +92,6 @@ public class DictionaryManager {
|
|
}
|
|
}
|
|
|
|
|
|
public void store(final DictionaryFile<? extends DictionaryItem> dictFile, final File file) {
|
|
public void store(final DictionaryFile<? extends DictionaryItem> dictFile, final File file) {
|
|
- final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
|
|
|
getDictionaryFile(dictFile.getId()).ifPresent(currentFile -> {
|
|
getDictionaryFile(dictFile.getId()).ifPresent(currentFile -> {
|
|
if (currentFile.getTimestamp().getTime() > dictFile.getTimestamp().getTime()) {
|
|
if (currentFile.getTimestamp().getTime() > dictFile.getTimestamp().getTime()) {
|
|
throw new DictionaryException(dictFile.getPath() + " was updated.");
|
|
throw new DictionaryException(dictFile.getPath() + " was updated.");
|
|
@@ -102,7 +99,7 @@ public class DictionaryManager {
|
|
|
|
|
|
// TODO use stream
|
|
// TODO use stream
|
|
try (CurlResponse response =
|
|
try (CurlResponse response =
|
|
- Curl.post(fessConfig.getElasticsearchHttpUrl() + "/_configsync/file").param("path", dictFile.getPath())
|
|
|
|
|
|
+ Curl.post(ResourceUtil.getElasticsearchHttpUrl() + "/_configsync/file").param("path", dictFile.getPath())
|
|
.body(FileUtil.readUTF8(file)).execute()) {
|
|
.body(FileUtil.readUTF8(file)).execute()) {
|
|
final Map<String, Object> contentMap = response.getContentAsMap();
|
|
final Map<String, Object> contentMap = response.getContentAsMap();
|
|
if (!Constants.TRUE.equalsIgnoreCase(contentMap.get("acknowledged").toString())) {
|
|
if (!Constants.TRUE.equalsIgnoreCase(contentMap.get("acknowledged").toString())) {
|
|
@@ -118,9 +115,8 @@ public class DictionaryManager {
|
|
}
|
|
}
|
|
|
|
|
|
public InputStream getContentInputStream(final DictionaryFile<? extends DictionaryItem> dictFile) {
|
|
public InputStream getContentInputStream(final DictionaryFile<? extends DictionaryItem> dictFile) {
|
|
- final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
|
|
|
try {
|
|
try {
|
|
- return Curl.get(fessConfig.getElasticsearchHttpUrl() + "/_configsync/file").param("path", dictFile.getPath()).execute()
|
|
|
|
|
|
+ return Curl.get(ResourceUtil.getElasticsearchHttpUrl() + "/_configsync/file").param("path", dictFile.getPath()).execute()
|
|
.getContentAsStream();
|
|
.getContentAsStream();
|
|
} catch (final IOException e) {
|
|
} catch (final IOException e) {
|
|
throw new DictionaryException("Failed to access " + dictFile.getPath(), e);
|
|
throw new DictionaryException("Failed to access " + dictFile.getPath(), e);
|