refactoring
This commit is contained in:
parent
30f0f67b2d
commit
ec0bbcb4b2
7 changed files with 27 additions and 27 deletions
|
@ -74,18 +74,20 @@ public abstract class BaseApiManager implements WebApiManager {
|
|||
buf.append(contentType);
|
||||
}
|
||||
buf.append("; charset=");
|
||||
final String enc;
|
||||
if (encoding == null) {
|
||||
if (LaRequestUtil.getRequest().getCharacterEncoding() == null) {
|
||||
buf.append(Constants.UTF_8);
|
||||
enc = Constants.UTF_8;
|
||||
} else {
|
||||
buf.append(LaRequestUtil.getRequest().getCharacterEncoding());
|
||||
enc = LaRequestUtil.getRequest().getCharacterEncoding();
|
||||
}
|
||||
} else {
|
||||
buf.append(encoding);
|
||||
enc = encoding;
|
||||
}
|
||||
buf.append(enc);
|
||||
final HttpServletResponse response = LaResponseUtil.getResponse();
|
||||
response.setContentType(buf.toString());
|
||||
try (PrintWriter out = new PrintWriter(new OutputStreamWriter(response.getOutputStream(), encoding))) {
|
||||
try (PrintWriter out = new PrintWriter(new OutputStreamWriter(response.getOutputStream(), enc))) {
|
||||
out.print(text);
|
||||
} catch (final IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.io.PrintWriter;
|
|||
import java.io.Serializable;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -138,7 +139,7 @@ public class FailureUrlService implements Serializable {
|
|||
}
|
||||
|
||||
if (failureCount < 0) {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
final int count = failureCount;
|
||||
|
@ -147,7 +148,7 @@ public class FailureUrlService implements Serializable {
|
|||
cb.query().setErrorCount_GreaterEqual(count);
|
||||
});
|
||||
if (list.isEmpty()) {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Pattern pattern = null;
|
||||
|
@ -174,8 +175,8 @@ public class FailureUrlService implements Serializable {
|
|||
}
|
||||
|
||||
public void store(final CrawlingConfig crawlingConfig, final String errorName, final String url, final Throwable e) {
|
||||
final FailureUrlBhv failureUrlBhv = SingletonLaContainer.getComponent(FailureUrlBhv.class);
|
||||
FailureUrl failureUrl = failureUrlBhv.selectEntity(cb -> {
|
||||
final FailureUrlBhv bhv = SingletonLaContainer.getComponent(FailureUrlBhv.class);
|
||||
FailureUrl failureUrl = bhv.selectEntity(cb -> {
|
||||
cb.query().setUrl_Equal(url);
|
||||
if (crawlingConfig != null) {
|
||||
cb.query().setConfigId_Equal(crawlingConfig.getConfigId());
|
||||
|
@ -199,7 +200,7 @@ public class FailureUrlService implements Serializable {
|
|||
failureUrl.setLastAccessTime(ComponentUtil.getSystemHelper().getCurrentTimeAsLong());
|
||||
failureUrl.setThreadName(Thread.currentThread().getName());
|
||||
|
||||
failureUrlBhv.insertOrUpdate(failureUrl);
|
||||
bhv.insertOrUpdate(failureUrl);
|
||||
}
|
||||
|
||||
private String getStackTrace(final Throwable t) {
|
||||
|
|
|
@ -132,7 +132,9 @@ public class ScheduledJobService implements Serializable {
|
|||
try {
|
||||
unregister(scheduledJob);
|
||||
} catch (final Exception e) {
|
||||
logger.debug("Failed to delete Job " + scheduledJob, e);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Failed to delete Job " + scheduledJob, e);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -206,7 +208,6 @@ public class ScheduledJobService implements Serializable {
|
|||
return true;
|
||||
}
|
||||
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
final String myName = fessConfig.getSchedulerTargetName();
|
||||
|
||||
final String[] targets = target.split(",");
|
||||
|
|
|
@ -59,7 +59,7 @@ public class KuromojiFile extends DictionaryFile<KuromojiItem> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public OptionalEntity<KuromojiItem> get(final long id) {
|
||||
public synchronized OptionalEntity<KuromojiItem> get(final long id) {
|
||||
if (kuromojiItemList == null) {
|
||||
reload(null, null);
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ public class KuromojiFile extends DictionaryFile<KuromojiItem> {
|
|||
return new BufferedInputStream(dictionaryManager.getContentInputStream(this));
|
||||
}
|
||||
|
||||
public void update(final InputStream in) throws IOException {
|
||||
public synchronized void update(final InputStream in) throws IOException {
|
||||
try (KuromojiUpdater updater = new KuromojiUpdater(null)) {
|
||||
reload(updater, in);
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class SynonymFile extends DictionaryFile<SynonymItem> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public OptionalEntity<SynonymItem> get(final long id) {
|
||||
public synchronized OptionalEntity<SynonymItem> get(final long id) {
|
||||
if (synonymItemList == null) {
|
||||
reload(null, null);
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ public class SynonymFile extends DictionaryFile<SynonymItem> {
|
|||
return new BufferedInputStream(dictionaryManager.getContentInputStream(this));
|
||||
}
|
||||
|
||||
public void update(final InputStream in) throws IOException {
|
||||
public synchronized void update(final InputStream in) throws IOException {
|
||||
try (SynonymUpdater updater = new SynonymUpdater(null)) {
|
||||
reload(updater, in);
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.codelibs.fess.ds.DataStoreCrawlingException;
|
|||
import org.codelibs.fess.ds.DataStoreException;
|
||||
import org.codelibs.fess.ds.IndexUpdateCallback;
|
||||
import org.codelibs.fess.es.config.exentity.DataConfig;
|
||||
import org.codelibs.fess.util.StreamUtil;
|
||||
import org.lastaflute.di.core.SingletonLaContainer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -94,10 +95,7 @@ public class CsvDataStoreImpl extends AbstractDataStoreImpl {
|
|||
for (final String path : values) {
|
||||
final File dir = new File(path);
|
||||
if (dir.isDirectory()) {
|
||||
final File[] files = dir.listFiles((FilenameFilter) (file, name) -> isCsvFile(file, name));
|
||||
for (final File file : files) {
|
||||
fileList.add(file);
|
||||
}
|
||||
StreamUtil.of(dir.listFiles()).filter(f -> isCsvFile(f.getParentFile(), f.getName())).forEach(f -> fileList.add(f));
|
||||
} else {
|
||||
logger.warn(path + " is not a directory.");
|
||||
}
|
||||
|
|
|
@ -223,14 +223,12 @@ public class WebFsIndexHelper implements Serializable {
|
|||
|
||||
// failure url
|
||||
final List<String> excludedUrlList = failureUrlService.getExcludedUrlList(webConfig.getConfigId());
|
||||
if (excludedUrlList != null) {
|
||||
for (final String u : excludedUrlList) {
|
||||
if (StringUtil.isNotBlank(u)) {
|
||||
final String urlValue = u.trim();
|
||||
crawler.addExcludeFilter(urlValue);
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Excluded URL from failures: " + urlValue);
|
||||
}
|
||||
for (final String u : excludedUrlList) {
|
||||
if (StringUtil.isNotBlank(u)) {
|
||||
final String urlValue = u.trim();
|
||||
crawler.addExcludeFilter(urlValue);
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Excluded URL from failures: " + urlValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue