code cleanup
This commit is contained in:
parent
c05bafb5ec
commit
778d328718
35 changed files with 227 additions and 218 deletions
|
@ -476,7 +476,8 @@ public class SearchLogService {
|
|||
}
|
||||
if (SearchLogPager.LOG_TYPE_FAVORITE.equalsIgnoreCase(logType)) {
|
||||
return favoriteLogBhv.selectByPK(id);
|
||||
} else if (SearchLogPager.LOG_TYPE_USERINFO.equalsIgnoreCase(logType)) {
|
||||
}
|
||||
if (SearchLogPager.LOG_TYPE_USERINFO.equalsIgnoreCase(logType)) {
|
||||
return userInfoBhv.selectByPK(id);
|
||||
} else {
|
||||
return searchLogBhv.selectByPK(id);
|
||||
|
@ -507,7 +508,8 @@ public class SearchLogService {
|
|||
params.put("Requested Time", FessFunctions.formatDate(e.getRequestedAt()));
|
||||
return params;
|
||||
}).get();
|
||||
} else if (SearchLogPager.LOG_TYPE_FAVORITE.equalsIgnoreCase(logType)) {
|
||||
}
|
||||
if (SearchLogPager.LOG_TYPE_FAVORITE.equalsIgnoreCase(logType)) {
|
||||
return favoriteLogBhv.selectByPK(id).map(e -> {
|
||||
final Map<String, String> params = new LinkedHashMap<>();
|
||||
params.put("ID", e.getId());
|
||||
|
|
|
@ -310,7 +310,8 @@ public class AdminAction extends FessAdminAction {
|
|||
}
|
||||
if (user.hasRoles(getActionRoles(AdminWizardAction.ROLE))) {
|
||||
return AdminWizardAction.class;
|
||||
} else if (user.hasRoles(getActionRoles(AdminGeneralAction.ROLE))) {
|
||||
}
|
||||
if (user.hasRoles(getActionRoles(AdminGeneralAction.ROLE))) {
|
||||
return AdminGeneralAction.class;
|
||||
} else if (user.hasRoles(getActionRoles(AdminSchedulerAction.ROLE))) {
|
||||
return AdminSchedulerAction.class;
|
||||
|
|
|
@ -302,7 +302,8 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
final String name = id.substring(0, id.length() - NDJSON_EXTENTION.length());
|
||||
if ("search_log".equals(name)) {
|
||||
return writeNdjsonResponse(id, getSearchLogNdjsonWriteCall());
|
||||
} else if ("user_info".equals(name)) {
|
||||
}
|
||||
if ("user_info".equals(name)) {
|
||||
return writeNdjsonResponse(id, getUserInfoNdjsonWriteCall());
|
||||
} else if ("click_log".equals(name)) {
|
||||
return writeNdjsonResponse(id, getClickLogNdjsonWriteCall());
|
||||
|
|
|
@ -265,9 +265,8 @@ public class AdminStorageAction extends FessAdminAction {
|
|||
}
|
||||
if (StringUtil.isEmpty(values[0])) {
|
||||
return values[1];
|
||||
} else {
|
||||
return values[0] + "/" + values[1];
|
||||
}
|
||||
return values[0] + "/" + values[1];
|
||||
}
|
||||
|
||||
public static String[] decodeId(final String id) {
|
||||
|
@ -279,16 +278,15 @@ public class AdminStorageAction extends FessAdminAction {
|
|||
}
|
||||
if (values.length == 1) {
|
||||
return new String[] { StringUtil.EMPTY, values[0] };
|
||||
} else {
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
for (int i = 0; i < values.length - 1; i++) {
|
||||
if (buf.length() > 0) {
|
||||
buf.append('/');
|
||||
}
|
||||
buf.append(values[i]);
|
||||
}
|
||||
return new String[] { buf.toString(), values[values.length - 1] };
|
||||
}
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
for (int i = 0; i < values.length - 1; i++) {
|
||||
if (buf.length() > 0) {
|
||||
buf.append('/');
|
||||
}
|
||||
buf.append(values[i]);
|
||||
}
|
||||
return new String[] { buf.toString(), values[values.length - 1] };
|
||||
}
|
||||
|
||||
protected static String createParentId(final String prefix) {
|
||||
|
|
|
@ -273,7 +273,8 @@ public class AdminWizardAction extends FessAdminAction {
|
|||
}
|
||||
if (path.startsWith("/")) {
|
||||
return "file:" + path;
|
||||
} else if (!path.startsWith("file:")) {
|
||||
}
|
||||
if (!path.startsWith("file:")) {
|
||||
return "file:/" + path.replace('\\', '/');
|
||||
}
|
||||
return path;
|
||||
|
|
|
@ -74,18 +74,7 @@ public class ApiAdminBackupAction extends FessApiAdminAction {
|
|||
}
|
||||
});
|
||||
}
|
||||
if (id.endsWith(NDJSON_EXTENTION)) {
|
||||
final String name = id.substring(0, id.length() - NDJSON_EXTENTION.length());
|
||||
if ("search_log".equals(name)) {
|
||||
return writeNdjsonResponse(id, getSearchLogNdjsonWriteCall());
|
||||
} else if ("user_info".equals(name)) {
|
||||
return writeNdjsonResponse(id, getUserInfoNdjsonWriteCall());
|
||||
} else if ("click_log".equals(name)) {
|
||||
return writeNdjsonResponse(id, getClickLogNdjsonWriteCall());
|
||||
} else if ("favorite_log".equals(name)) {
|
||||
return writeNdjsonResponse(id, getFavoriteLogNdjsonWriteCall());
|
||||
}
|
||||
} else {
|
||||
if (!id.endsWith(NDJSON_EXTENTION)) {
|
||||
final String index;
|
||||
final String filename;
|
||||
if (id.endsWith(".bulk")) {
|
||||
|
@ -112,6 +101,16 @@ public class ApiAdminBackupAction extends FessApiAdminAction {
|
|||
}
|
||||
});
|
||||
}
|
||||
final String name = id.substring(0, id.length() - NDJSON_EXTENTION.length());
|
||||
if ("search_log".equals(name)) {
|
||||
return writeNdjsonResponse(id, getSearchLogNdjsonWriteCall());
|
||||
} else if ("user_info".equals(name)) {
|
||||
return writeNdjsonResponse(id, getUserInfoNdjsonWriteCall());
|
||||
} else if ("click_log".equals(name)) {
|
||||
return writeNdjsonResponse(id, getClickLogNdjsonWriteCall());
|
||||
} else if ("favorite_log".equals(name)) {
|
||||
return writeNdjsonResponse(id, getFavoriteLogNdjsonWriteCall());
|
||||
}
|
||||
}
|
||||
|
||||
throwValidationErrorApi(messages -> messages.addErrorsCouldNotFindBackupIndex(GLOBAL));
|
||||
|
|
|
@ -130,23 +130,22 @@ public class GoAction extends FessSearchAction {
|
|||
if (!isFileSystemPath(targetUrl)) {
|
||||
return HtmlResponse.fromRedirectPathAsIs(DocumentUtil.encodeUrl(targetUrl + hash));
|
||||
}
|
||||
if (fessConfig.isSearchFileProxyEnabled()) {
|
||||
final ViewHelper viewHelper = ComponentUtil.getViewHelper();
|
||||
try {
|
||||
final StreamResponse response = viewHelper.asContentResponse(doc);
|
||||
if (response.getHttpStatus().orElse(200) == 404) {
|
||||
logger.debug("Not found: {}", targetUrl);
|
||||
saveError(messages -> messages.addErrorsNotFoundOnFileSystem(GLOBAL, targetUrl));
|
||||
return redirect(ErrorAction.class);
|
||||
}
|
||||
return response;
|
||||
} catch (final Exception e) {
|
||||
logger.warn("Failed to load: {}", doc, e);
|
||||
saveError(messages -> messages.addErrorsNotLoadFromServer(GLOBAL, targetUrl));
|
||||
if (!fessConfig.isSearchFileProxyEnabled()) {
|
||||
return HtmlResponse.fromRedirectPathAsIs(targetUrl + hash);
|
||||
}
|
||||
final ViewHelper viewHelper = ComponentUtil.getViewHelper();
|
||||
try {
|
||||
final StreamResponse response = viewHelper.asContentResponse(doc);
|
||||
if (response.getHttpStatus().orElse(200) == 404) {
|
||||
logger.debug("Not found: {}", targetUrl);
|
||||
saveError(messages -> messages.addErrorsNotFoundOnFileSystem(GLOBAL, targetUrl));
|
||||
return redirect(ErrorAction.class);
|
||||
}
|
||||
} else {
|
||||
return HtmlResponse.fromRedirectPathAsIs(targetUrl + hash);
|
||||
return response;
|
||||
} catch (final Exception e) {
|
||||
logger.warn("Failed to load: {}", doc, e);
|
||||
saveError(messages -> messages.addErrorsNotLoadFromServer(GLOBAL, targetUrl));
|
||||
return redirect(ErrorAction.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,8 @@ public class ThumbnailAction extends FessSearchAction {
|
|||
}
|
||||
if (path.endsWith(".gif")) {
|
||||
return "image/gif";
|
||||
} else if (path.endsWith(".jpg") || path.endsWith(".jpeg")) {
|
||||
}
|
||||
if (path.endsWith(".jpg") || path.endsWith(".jpeg")) {
|
||||
return "image/jpeg";
|
||||
} else {
|
||||
return "application/octet-stream";
|
||||
|
|
|
@ -103,9 +103,8 @@ public class CommandChain implements AuthenticationChain {
|
|||
}
|
||||
if ("$PASSWORD".equals(s)) {
|
||||
return password;
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
return s;
|
||||
}).toArray(n -> new String[n]));
|
||||
final ProcessBuilder pb = new ProcessBuilder(cmds);
|
||||
if (workingDirectory != null) {
|
||||
|
|
|
@ -144,7 +144,8 @@ public class FessCrawlerThread extends CrawlerThread {
|
|||
}
|
||||
if (responseData.getLastModified() == null) {
|
||||
return true;
|
||||
} else if (responseData.getLastModified().getTime() <= lastModified.getTime() && httpStatusCode == 200) {
|
||||
}
|
||||
if (responseData.getLastModified().getTime() <= lastModified.getTime() && httpStatusCode == 200) {
|
||||
|
||||
log(logHelper, LogType.NOT_MODIFIED, crawlerContext, urlQueue);
|
||||
|
||||
|
|
|
@ -430,7 +430,8 @@ public abstract class AbstractFessFileTransformer extends AbstractTransformer im
|
|||
final int pos = value.indexOf('/');
|
||||
if (pos > 0) {
|
||||
return value.substring(0, pos);
|
||||
} else if (pos == -1) {
|
||||
}
|
||||
if (pos == -1) {
|
||||
return value;
|
||||
} else {
|
||||
return "localhost";
|
||||
|
@ -472,7 +473,8 @@ public abstract class AbstractFessFileTransformer extends AbstractTransformer im
|
|||
// Unix
|
||||
return abbreviateSite(value);
|
||||
}
|
||||
} else if (url.startsWith("smb:") || url.startsWith("smb1:")) {
|
||||
}
|
||||
if (url.startsWith("smb:") || url.startsWith("smb1:")) {
|
||||
final String value = url.replaceFirst("^smb.?:/+", StringUtil.EMPTY);
|
||||
return abbreviateSite("\\\\" + value.replace('/', '\\'));
|
||||
}
|
||||
|
|
|
@ -242,7 +242,8 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
|
|||
logger.info("META(robots=noindex): {}", responseData.getUrl());
|
||||
storeChildUrls(responseData, resultData);
|
||||
throw new ChildUrlsException(resultData.getChildUrlSet(), "#processMetaRobots");
|
||||
} else if (nofollow) {
|
||||
}
|
||||
if (nofollow) {
|
||||
logger.info("META(robots=nofollow): {}", responseData.getUrl());
|
||||
responseData.setNoFollow(true);
|
||||
}
|
||||
|
@ -289,7 +290,8 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
|
|||
logger.info("HEADER(robots=noindex): {}", responseData.getUrl());
|
||||
storeChildUrls(responseData, resultData);
|
||||
throw new ChildUrlsException(resultData.getChildUrlSet(), "#processXRobotsTag");
|
||||
} else if (nofollow) {
|
||||
}
|
||||
if (nofollow) {
|
||||
logger.info("HEADER(robots=nofollow): {}", responseData.getUrl());
|
||||
responseData.setNoFollow(true);
|
||||
}
|
||||
|
@ -921,7 +923,8 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
|
|||
if (url.startsWith("//")) {
|
||||
final String protocol = currentUrl.split(":")[0];
|
||||
return new URL(protocol + ":" + url);
|
||||
} else if (url.startsWith("/") || url.indexOf(':') == -1) {
|
||||
}
|
||||
if (url.startsWith("/") || url.indexOf(':') == -1) {
|
||||
return new URL(new URL(currentUrl), url);
|
||||
}
|
||||
return new URL(url);
|
||||
|
|
|
@ -227,23 +227,22 @@ public class KuromojiFile extends DictionaryFile<KuromojiItem> {
|
|||
writer.write(Constants.LINE_SEPARATOR);
|
||||
return oldItem;
|
||||
}
|
||||
if (item.equals(oldItem)) {
|
||||
try {
|
||||
if (!item.isDeleted()) {
|
||||
// update
|
||||
writer.write(item.toLineString());
|
||||
writer.write(Constants.LINE_SEPARATOR);
|
||||
return new KuromojiItem(item.getId(), item.getNewToken(), item.getNewSegmentation(), item.getNewReading(),
|
||||
item.getNewPos());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
item.setNewToken(null);
|
||||
}
|
||||
} else {
|
||||
if (!item.equals(oldItem)) {
|
||||
throw new DictionaryException("Kuromoji file was updated: old=" + oldItem + " : new=" + item);
|
||||
}
|
||||
try {
|
||||
if (!item.isDeleted()) {
|
||||
// update
|
||||
writer.write(item.toLineString());
|
||||
writer.write(Constants.LINE_SEPARATOR);
|
||||
return new KuromojiItem(item.getId(), item.getNewToken(), item.getNewSegmentation(), item.getNewReading(),
|
||||
item.getNewPos());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
item.setNewToken(null);
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
throw new DictionaryException("Failed to write: " + oldItem + " -> " + item, e);
|
||||
}
|
||||
|
|
|
@ -241,23 +241,22 @@ public class CharMappingFile extends DictionaryFile<CharMappingItem> {
|
|||
writer.write(Constants.LINE_SEPARATOR);
|
||||
return oldItem;
|
||||
}
|
||||
if (item.equals(oldItem)) {
|
||||
try {
|
||||
if (!item.isDeleted()) {
|
||||
// update
|
||||
writer.write(item.toLineString());
|
||||
writer.write(Constants.LINE_SEPARATOR);
|
||||
return new CharMappingItem(item.getId(), item.getNewInputs(), item.getNewOutput());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
item.setNewInputs(null);
|
||||
item.setNewOutput(null);
|
||||
}
|
||||
} else {
|
||||
if (!item.equals(oldItem)) {
|
||||
throw new DictionaryException("Mapping file was updated: old=" + oldItem + " : new=" + item);
|
||||
}
|
||||
try {
|
||||
if (!item.isDeleted()) {
|
||||
// update
|
||||
writer.write(item.toLineString());
|
||||
writer.write(Constants.LINE_SEPARATOR);
|
||||
return new CharMappingItem(item.getId(), item.getNewInputs(), item.getNewOutput());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
item.setNewInputs(null);
|
||||
item.setNewOutput(null);
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
throw new DictionaryException("Failed to write: " + oldItem + " -> " + item, e);
|
||||
}
|
||||
|
|
|
@ -226,22 +226,21 @@ public class ProtwordsFile extends DictionaryFile<ProtwordsItem> {
|
|||
writer.write(Constants.LINE_SEPARATOR);
|
||||
return oldItem;
|
||||
}
|
||||
if (item.equals(oldItem)) {
|
||||
try {
|
||||
if (!item.isDeleted()) {
|
||||
// update
|
||||
writer.write(item.toLineString());
|
||||
writer.write(Constants.LINE_SEPARATOR);
|
||||
return new ProtwordsItem(item.getId(), item.getNewInput());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
item.setNewInput(null);
|
||||
}
|
||||
} else {
|
||||
if (!item.equals(oldItem)) {
|
||||
throw new DictionaryException("Protwords file was updated: old=" + oldItem + " : new=" + item);
|
||||
}
|
||||
try {
|
||||
if (!item.isDeleted()) {
|
||||
// update
|
||||
writer.write(item.toLineString());
|
||||
writer.write(Constants.LINE_SEPARATOR);
|
||||
return new ProtwordsItem(item.getId(), item.getNewInput());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
item.setNewInput(null);
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
throw new DictionaryException("Failed to write: " + oldItem + " -> " + item, e);
|
||||
}
|
||||
|
|
|
@ -238,23 +238,22 @@ public class StemmerOverrideFile extends DictionaryFile<StemmerOverrideItem> {
|
|||
writer.write(Constants.LINE_SEPARATOR);
|
||||
return oldItem;
|
||||
}
|
||||
if (item.equals(oldItem)) {
|
||||
try {
|
||||
if (!item.isDeleted()) {
|
||||
// update
|
||||
writer.write(item.toLineString());
|
||||
writer.write(Constants.LINE_SEPARATOR);
|
||||
return new StemmerOverrideItem(item.getId(), item.getNewInput(), item.getNewOutput());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
item.setNewInput(null);
|
||||
item.setNewOutput(null);
|
||||
}
|
||||
} else {
|
||||
if (!item.equals(oldItem)) {
|
||||
throw new DictionaryException("StemmerOverride file was updated: old=" + oldItem + " : new=" + item);
|
||||
}
|
||||
try {
|
||||
if (!item.isDeleted()) {
|
||||
// update
|
||||
writer.write(item.toLineString());
|
||||
writer.write(Constants.LINE_SEPARATOR);
|
||||
return new StemmerOverrideItem(item.getId(), item.getNewInput(), item.getNewOutput());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
item.setNewInput(null);
|
||||
item.setNewOutput(null);
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
throw new DictionaryException("Failed to write: " + oldItem + " -> " + item, e);
|
||||
}
|
||||
|
|
|
@ -226,22 +226,21 @@ public class StopwordsFile extends DictionaryFile<StopwordsItem> {
|
|||
writer.write(Constants.LINE_SEPARATOR);
|
||||
return oldItem;
|
||||
}
|
||||
if (item.equals(oldItem)) {
|
||||
try {
|
||||
if (!item.isDeleted()) {
|
||||
// update
|
||||
writer.write(item.toLineString());
|
||||
writer.write(Constants.LINE_SEPARATOR);
|
||||
return new StopwordsItem(item.getId(), item.getNewInput());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
item.setNewInput(null);
|
||||
}
|
||||
} else {
|
||||
if (!item.equals(oldItem)) {
|
||||
throw new DictionaryException("Stopwords file was updated: old=" + oldItem + " : new=" + item);
|
||||
}
|
||||
try {
|
||||
if (!item.isDeleted()) {
|
||||
// update
|
||||
writer.write(item.toLineString());
|
||||
writer.write(Constants.LINE_SEPARATOR);
|
||||
return new StopwordsItem(item.getId(), item.getNewInput());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
item.setNewInput(null);
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
throw new DictionaryException("Failed to write: " + oldItem + " -> " + item, e);
|
||||
}
|
||||
|
|
|
@ -226,7 +226,8 @@ public class SynonymFile extends DictionaryFile<SynonymItem> {
|
|||
if (pos >= end) {
|
||||
break; // ERROR, or let it go?
|
||||
}
|
||||
ch = s.charAt(pos++);
|
||||
ch = s.charAt(pos);
|
||||
pos++;
|
||||
}
|
||||
|
||||
sb.append(ch);
|
||||
|
@ -301,23 +302,22 @@ public class SynonymFile extends DictionaryFile<SynonymItem> {
|
|||
writer.write(Constants.LINE_SEPARATOR);
|
||||
return oldItem;
|
||||
}
|
||||
if (item.equals(oldItem)) {
|
||||
try {
|
||||
if (!item.isDeleted()) {
|
||||
// update
|
||||
writer.write(item.toLineString());
|
||||
writer.write(Constants.LINE_SEPARATOR);
|
||||
return new SynonymItem(item.getId(), item.getNewInputs(), item.getNewOutputs());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
item.setNewInputs(null);
|
||||
item.setNewOutputs(null);
|
||||
}
|
||||
} else {
|
||||
if (!item.equals(oldItem)) {
|
||||
throw new DictionaryException("Synonym file was updated: old=" + oldItem + " : new=" + item);
|
||||
}
|
||||
try {
|
||||
if (!item.isDeleted()) {
|
||||
// update
|
||||
writer.write(item.toLineString());
|
||||
writer.write(Constants.LINE_SEPARATOR);
|
||||
return new SynonymItem(item.getId(), item.getNewInputs(), item.getNewOutputs());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
item.setNewInputs(null);
|
||||
item.setNewOutputs(null);
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
throw new DictionaryException("Failed to write: " + oldItem + " -> " + item, e);
|
||||
}
|
||||
|
|
|
@ -126,15 +126,13 @@ public class SynonymItem extends DictionaryItem {
|
|||
if (isUpdated()) {
|
||||
if (Arrays.equals(newInputs, newOutputs)) {
|
||||
return StringUtils.join(newInputs, ",");
|
||||
} else {
|
||||
return StringUtils.join(newInputs, ",") + "=>" + StringUtils.join(newOutputs, ",");
|
||||
}
|
||||
return StringUtils.join(newInputs, ",") + "=>" + StringUtils.join(newOutputs, ",");
|
||||
}
|
||||
if (Arrays.equals(inputs, outputs)) {
|
||||
return StringUtils.join(inputs, ",");
|
||||
} else {
|
||||
return StringUtils.join(inputs, ",") + "=>" + StringUtils.join(outputs, ",");
|
||||
}
|
||||
return StringUtils.join(inputs, ",") + "=>" + StringUtils.join(outputs, ",");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -667,9 +667,8 @@ public class SearchEngineClient implements Client {
|
|||
final String message = "Configsync is not available. HTTP Status is " + httpStatusCode;
|
||||
if (response.getContentException() != null) {
|
||||
throw new FessSystemException(message, response.getContentException());
|
||||
} else {
|
||||
throw new FessSystemException(message);
|
||||
}
|
||||
throw new FessSystemException(message);
|
||||
} catch (final Exception e) {
|
||||
cause = new FessSystemException("Configsync is not available.", e);
|
||||
}
|
||||
|
|
|
@ -64,7 +64,8 @@ public class WebAuthentication extends BsWebAuthentication {
|
|||
}
|
||||
if (Constants.DIGEST.equals(scheme)) {
|
||||
return new DigestScheme();
|
||||
} else if (Constants.NTLM.equals(scheme)) {
|
||||
}
|
||||
if (Constants.NTLM.equals(scheme)) {
|
||||
final Properties props = new Properties();
|
||||
getWebConfig().getConfigParameterMap(ConfigName.CONFIG).entrySet().stream()
|
||||
.filter(e -> e.getKey().startsWith(Config.JCIFS_PREFIX)).forEach(e -> {
|
||||
|
|
|
@ -82,7 +82,8 @@ public class CrawlingConfigHelper {
|
|||
}
|
||||
if (ConfigType.FILE.getTypePrefix().equals(configType)) {
|
||||
return ConfigType.FILE;
|
||||
} else if (ConfigType.DATA.getTypePrefix().equals(configType)) {
|
||||
}
|
||||
if (ConfigType.DATA.getTypePrefix().equals(configType)) {
|
||||
return ConfigType.DATA;
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -201,23 +201,22 @@ public class DocumentHelper {
|
|||
}
|
||||
responseData.setRuleId(rule.getRuleId());
|
||||
final ResponseProcessor responseProcessor = rule.getResponseProcessor();
|
||||
if (responseProcessor instanceof DefaultResponseProcessor) {
|
||||
final Transformer transformer = ((DefaultResponseProcessor) responseProcessor).getTransformer();
|
||||
final ResultData resultData = transformer.transform(responseData);
|
||||
final byte[] data = resultData.getData();
|
||||
if (data != null) {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
final Map<String, Object> result = (Map<String, Object>) SerializeUtil.fromBinaryToObject(data);
|
||||
return result;
|
||||
} catch (final Exception e) {
|
||||
throw new CrawlerSystemException("Could not create an instance from bytes.", e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!(responseProcessor instanceof DefaultResponseProcessor)) {
|
||||
throw new CrawlingAccessException("The response processor is not DefaultResponseProcessor. responseProcessor: "
|
||||
+ responseProcessor + ", url: " + url);
|
||||
}
|
||||
final Transformer transformer = ((DefaultResponseProcessor) responseProcessor).getTransformer();
|
||||
final ResultData resultData = transformer.transform(responseData);
|
||||
final byte[] data = resultData.getData();
|
||||
if (data != null) {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
final Map<String, Object> result = (Map<String, Object>) SerializeUtil.fromBinaryToObject(data);
|
||||
return result;
|
||||
} catch (final Exception e) {
|
||||
throw new CrawlerSystemException("Could not create an instance from bytes.", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} catch (final Exception e) {
|
||||
throw new CrawlingAccessException("Failed to parse " + url, e);
|
||||
|
|
|
@ -155,7 +155,8 @@ public class IntervalControlHelper {
|
|||
if (h1 == h2) {
|
||||
if (m1 == m2) {
|
||||
return 0;
|
||||
} else if (m1 < m2) {
|
||||
}
|
||||
if (m1 < m2) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,21 +156,20 @@ public class PathMappingHelper {
|
|||
if (FUNCTION_ENCODEURL_MATCHER.equals(replacement)) {
|
||||
return (u, m) -> DocumentUtil.encodeUrl(u);
|
||||
}
|
||||
if (replacement.startsWith(GROOVY_MATCHER)) {
|
||||
final String template = replacement.substring(GROOVY_MATCHER.length());
|
||||
return (u, m) -> {
|
||||
final Map<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("url", u);
|
||||
paramMap.put("matcher", m);
|
||||
final Object value = GroovyUtil.evaluate(template, paramMap);
|
||||
if (value == null) {
|
||||
return u;
|
||||
}
|
||||
return value.toString();
|
||||
};
|
||||
} else {
|
||||
if (!replacement.startsWith(GROOVY_MATCHER)) {
|
||||
return (u, m) -> m.replaceAll(replacement);
|
||||
}
|
||||
final String template = replacement.substring(GROOVY_MATCHER.length());
|
||||
return (u, m) -> {
|
||||
final Map<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("url", u);
|
||||
paramMap.put("matcher", m);
|
||||
final Object value = GroovyUtil.evaluate(template, paramMap);
|
||||
if (value == null) {
|
||||
return u;
|
||||
}
|
||||
return value.toString();
|
||||
};
|
||||
}
|
||||
|
||||
protected String replaceUrl(final List<PathMapping> pathMappingList, final String url) {
|
||||
|
|
|
@ -78,9 +78,8 @@ public class PermissionHelper {
|
|||
if (lower.startsWith(userPrefix)) {
|
||||
if (permission.length() > userPrefix.length()) {
|
||||
return aclPrefix + systemHelper.getSearchRoleByUser(permission.substring(userPrefix.length()));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (lower.startsWith(groupPrefix)) {
|
||||
if (permission.length() > groupPrefix.length()) {
|
||||
|
@ -88,7 +87,8 @@ public class PermissionHelper {
|
|||
} else {
|
||||
return null;
|
||||
}
|
||||
} else if (lower.startsWith(rolePrefix)) {
|
||||
}
|
||||
if (lower.startsWith(rolePrefix)) {
|
||||
if (permission.length() > rolePrefix.length()) {
|
||||
return aclPrefix + systemHelper.getSearchRoleByRole(permission.substring(rolePrefix.length()));
|
||||
} else {
|
||||
|
@ -124,7 +124,8 @@ public class PermissionHelper {
|
|||
if (permission.startsWith(fessConfig.getRoleSearchGroupPrefix())
|
||||
&& permission.length() > fessConfig.getRoleSearchGroupPrefix().length()) {
|
||||
return aclPrefix + groupPrefix + permission.substring(fessConfig.getRoleSearchGroupPrefix().length());
|
||||
} else if (permission.startsWith(fessConfig.getRoleSearchRolePrefix())
|
||||
}
|
||||
if (permission.startsWith(fessConfig.getRoleSearchRolePrefix())
|
||||
&& permission.length() > fessConfig.getRoleSearchRolePrefix().length()) {
|
||||
return aclPrefix + rolePrefix + permission.substring(fessConfig.getRoleSearchRolePrefix().length());
|
||||
}
|
||||
|
|
|
@ -392,7 +392,8 @@ public class PluginHelper {
|
|||
}
|
||||
if (name.startsWith(THEME.getId())) {
|
||||
return THEME;
|
||||
} else if (name.startsWith(INGEST.getId())) {
|
||||
}
|
||||
if (name.startsWith(INGEST.getId())) {
|
||||
return INGEST;
|
||||
}
|
||||
return UNKNOWN;
|
||||
|
|
|
@ -430,7 +430,8 @@ public class QueryHelper {
|
|||
}
|
||||
if (query instanceof TermRangeQuery) {
|
||||
return convertTermRangeQuery(context, (TermRangeQuery) query, boost);
|
||||
} else if (query instanceof PhraseQuery) {
|
||||
}
|
||||
if (query instanceof PhraseQuery) {
|
||||
return convertPhraseQuery(context, (PhraseQuery) query, boost);
|
||||
} else if (query instanceof FuzzyQuery) {
|
||||
return convertFuzzyQuery(context, (FuzzyQuery) query, boost);
|
||||
|
@ -501,13 +502,12 @@ public class QueryHelper {
|
|||
if (isSearchField(field)) {
|
||||
context.addFieldLog(field, wildcardQuery.getTerm().text());
|
||||
return QueryBuilders.wildcardQuery(field, toLowercaseWildcard(wildcardQuery.getTerm().text())).boost(boost);
|
||||
} else {
|
||||
final String query = wildcardQuery.getTerm().toString();
|
||||
final String origQuery = toLowercaseWildcard(query);
|
||||
context.addFieldLog(Constants.DEFAULT_FIELD, query);
|
||||
context.addHighlightedQuery(origQuery);
|
||||
return buildDefaultQueryBuilder((f, b) -> QueryBuilders.wildcardQuery(f, origQuery).boost(b * boost));
|
||||
}
|
||||
final String query = wildcardQuery.getTerm().toString();
|
||||
final String origQuery = toLowercaseWildcard(query);
|
||||
context.addFieldLog(Constants.DEFAULT_FIELD, query);
|
||||
context.addHighlightedQuery(origQuery);
|
||||
return buildDefaultQueryBuilder((f, b) -> QueryBuilders.wildcardQuery(f, origQuery).boost(b * boost));
|
||||
}
|
||||
|
||||
protected QueryBuilder convertPrefixQuery(final QueryContext context, final PrefixQuery prefixQuery, final float boost) {
|
||||
|
@ -517,20 +517,19 @@ public class QueryHelper {
|
|||
return buildDefaultQueryBuilder((f, b) -> QueryBuilders
|
||||
.matchPhrasePrefixQuery(f, toLowercaseWildcard(prefixQuery.getPrefix().text())).boost(b * boost));
|
||||
}
|
||||
if (isSearchField(field)) {
|
||||
context.addFieldLog(field, prefixQuery.getPrefix().text());
|
||||
if (notAnalyzedFieldSet.contains(field)) {
|
||||
return QueryBuilders.prefixQuery(field, toLowercaseWildcard(prefixQuery.getPrefix().text())).boost(boost);
|
||||
} else {
|
||||
return QueryBuilders.matchPhrasePrefixQuery(field, toLowercaseWildcard(prefixQuery.getPrefix().text())).boost(boost);
|
||||
}
|
||||
} else {
|
||||
if (!isSearchField(field)) {
|
||||
final String query = prefixQuery.getPrefix().toString();
|
||||
final String origQuery = toLowercaseWildcard(query);
|
||||
context.addFieldLog(Constants.DEFAULT_FIELD, query);
|
||||
context.addHighlightedQuery(origQuery);
|
||||
return buildDefaultQueryBuilder((f, b) -> QueryBuilders.matchPhrasePrefixQuery(f, origQuery).boost(b * boost));
|
||||
}
|
||||
context.addFieldLog(field, prefixQuery.getPrefix().text());
|
||||
if (notAnalyzedFieldSet.contains(field)) {
|
||||
return QueryBuilders.prefixQuery(field, toLowercaseWildcard(prefixQuery.getPrefix().text())).boost(boost);
|
||||
} else {
|
||||
return QueryBuilders.matchPhrasePrefixQuery(field, toLowercaseWildcard(prefixQuery.getPrefix().text())).boost(boost);
|
||||
}
|
||||
}
|
||||
|
||||
protected QueryBuilder convertFuzzyQuery(final QueryContext context, final FuzzyQuery fuzzyQuery, final float boost) {
|
||||
|
@ -545,13 +544,12 @@ public class QueryHelper {
|
|||
if (isSearchField(field)) {
|
||||
context.addFieldLog(field, term.text());
|
||||
return QueryBuilders.fuzzyQuery(field, term.text()).boost(boost).fuzziness(Fuzziness.fromEdits(fuzzyQuery.getMaxEdits()));
|
||||
} else {
|
||||
final String origQuery = fuzzyQuery.toString();
|
||||
context.addFieldLog(Constants.DEFAULT_FIELD, origQuery);
|
||||
context.addHighlightedQuery(origQuery);
|
||||
return buildDefaultQueryBuilder((f, b) -> QueryBuilders.fuzzyQuery(f, origQuery)
|
||||
.fuzziness(Fuzziness.fromEdits(fuzzyQuery.getMaxEdits())).boost(b * boost));
|
||||
}
|
||||
final String origQuery = fuzzyQuery.toString();
|
||||
context.addFieldLog(Constants.DEFAULT_FIELD, origQuery);
|
||||
context.addHighlightedQuery(origQuery);
|
||||
return buildDefaultQueryBuilder(
|
||||
(f, b) -> QueryBuilders.fuzzyQuery(f, origQuery).fuzziness(Fuzziness.fromEdits(fuzzyQuery.getMaxEdits())).boost(b * boost));
|
||||
}
|
||||
|
||||
protected QueryBuilder convertTermRangeQuery(final QueryContext context, final TermRangeQuery termRangeQuery, final float boost) {
|
||||
|
@ -613,7 +611,8 @@ public class QueryHelper {
|
|||
context.addFieldLog(field, text);
|
||||
context.addHighlightedQuery(text);
|
||||
return buildDefaultTermQueryBuilder(boost, text);
|
||||
} else if ("sort".equals(field)) {
|
||||
}
|
||||
if ("sort".equals(field)) {
|
||||
split(text, ",").of(stream -> stream.filter(StringUtil::isNotBlank).forEach(t -> {
|
||||
final String[] values = t.split("\\.");
|
||||
if (values.length > 2) {
|
||||
|
|
|
@ -259,9 +259,8 @@ public class SearchHelper {
|
|||
}
|
||||
if (langSet.size() > 1 && langSet.contains(Constants.ALL_LANGUAGES)) {
|
||||
return new String[] { Constants.ALL_LANGUAGES };
|
||||
} else {
|
||||
langSet.remove(Constants.ALL_LANGUAGES);
|
||||
}
|
||||
langSet.remove(Constants.ALL_LANGUAGES);
|
||||
return langSet.toArray(new String[langSet.size()]);
|
||||
}
|
||||
if (ComponentUtil.getFessConfig().isBrowserLocaleForSearchUsed()) {
|
||||
|
|
|
@ -60,7 +60,8 @@ public class DocBoostMatcher {
|
|||
}
|
||||
if (value instanceof Long) {
|
||||
return ((Long) value).floatValue();
|
||||
} else if (value instanceof Float) {
|
||||
}
|
||||
if (value instanceof Float) {
|
||||
return ((Float) value);
|
||||
} else if (value instanceof Double) {
|
||||
return ((Double) value).floatValue();
|
||||
|
|
|
@ -908,7 +908,8 @@ public interface FessProp {
|
|||
}
|
||||
if (Constants.FILE_CRAWLER_TYPE.equals(type)) {
|
||||
return getJobTemplateTitleFile();
|
||||
} else if (Constants.DATA_CRAWLER_TYPE.equals(type)) {
|
||||
}
|
||||
if (Constants.DATA_CRAWLER_TYPE.equals(type)) {
|
||||
return getJobTemplateTitleData();
|
||||
}
|
||||
return "None";
|
||||
|
@ -960,9 +961,8 @@ public interface FessProp {
|
|||
}
|
||||
if (subValues.length == 2) {
|
||||
return new Tuple4<>(values[0], subValues[0], subValues[1], StringUtil.EMPTY);
|
||||
} else {
|
||||
return new Tuple4<>(values[0], values[1], Constants.MAPPING_TYPE_ARRAY, StringUtil.EMPTY);
|
||||
}
|
||||
return new Tuple4<>(values[0], values[1], Constants.MAPPING_TYPE_ARRAY, StringUtil.EMPTY);
|
||||
}
|
||||
return null;
|
||||
}).collect(Collectors.toMap(Tuple4::getValue1, d -> new Tuple3<>(d.getValue2(), d.getValue3(), d.getValue4()))));
|
||||
|
|
|
@ -177,7 +177,8 @@ public class SpnegoAuthenticator implements SsoAuthenticator {
|
|||
final String logLevel = getProperty(SPNEGO_LOGGER_LEVEL, StringUtil.EMPTY);
|
||||
if (StringUtil.isNotBlank(logLevel)) {
|
||||
return logLevel;
|
||||
} else if (logger.isDebugEnabled()) {
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
return "3";
|
||||
} else if (logger.isInfoEnabled()) {
|
||||
return "5";
|
||||
|
@ -191,7 +192,8 @@ public class SpnegoAuthenticator implements SsoAuthenticator {
|
|||
}
|
||||
if (SpnegoHttpFilter.Constants.LOGIN_CONF.equals(name)) {
|
||||
return getResourcePath(getProperty(SPNEGO_LOGIN_CONF, "auth_login.conf"));
|
||||
} else if (SpnegoHttpFilter.Constants.KRB5_CONF.equals(name)) {
|
||||
}
|
||||
if (SpnegoHttpFilter.Constants.KRB5_CONF.equals(name)) {
|
||||
return getResourcePath(getProperty(SPNEGO_KRB5_CONF, "krb5.conf"));
|
||||
} else if (SpnegoHttpFilter.Constants.CLIENT_MODULE.equals(name)) {
|
||||
return getProperty(SPNEGO_LOGIN_CLIENT_MODULE, "spnego-client");
|
||||
|
|
|
@ -57,7 +57,8 @@ public final class DocumentUtil {
|
|||
if (value instanceof List) {
|
||||
if (clazz.isAssignableFrom(List.class)) {
|
||||
return (T) value;
|
||||
} else if (clazz.isAssignableFrom(String[].class)) {
|
||||
}
|
||||
if (clazz.isAssignableFrom(String[].class)) {
|
||||
return (T) ((List<?>) value).stream().filter(s -> s != null).map(Object::toString).toArray(n -> new String[n]);
|
||||
}
|
||||
|
||||
|
@ -70,7 +71,8 @@ public final class DocumentUtil {
|
|||
if (value instanceof String[]) {
|
||||
if (clazz.isAssignableFrom(String[].class)) {
|
||||
return (T) value;
|
||||
} else if (clazz.isAssignableFrom(List.class)) {
|
||||
}
|
||||
if (clazz.isAssignableFrom(List.class)) {
|
||||
final List<String> list = new ArrayList<>();
|
||||
Collections.addAll(list, (String[]) value);
|
||||
return (T) list;
|
||||
|
@ -101,7 +103,8 @@ public final class DocumentUtil {
|
|||
} else {
|
||||
return (T) FessFunctions.parseDate(value.toString());
|
||||
}
|
||||
} else if (clazz.isAssignableFrom(Long.class)) {
|
||||
}
|
||||
if (clazz.isAssignableFrom(Long.class)) {
|
||||
if (value instanceof Long) {
|
||||
return (T) value;
|
||||
} else {
|
||||
|
|
|
@ -254,7 +254,8 @@ public class GsaConfigParser extends DefaultHandler {
|
|||
final String v = s.substring(CONTAINS.length());
|
||||
final StringBuilder buf = new StringBuilder(100);
|
||||
return ".*" + appendFileterPath(buf, escape(v)) + ".*";
|
||||
} else if (s.startsWith(REGEXP_IGNORE_CASE)) {
|
||||
}
|
||||
if (s.startsWith(REGEXP_IGNORE_CASE)) {
|
||||
final String v = s.substring(REGEXP_IGNORE_CASE.length());
|
||||
final StringBuilder buf = new StringBuilder(100);
|
||||
buf.append("(?i)");
|
||||
|
@ -282,7 +283,8 @@ public class GsaConfigParser extends DefaultHandler {
|
|||
}
|
||||
if (s.startsWith("^") && s.endsWith("$")) {
|
||||
return "^" + Pattern.quote(s.substring(1, s.length() - 1)) + "$";
|
||||
} else if (s.startsWith("^")) {
|
||||
}
|
||||
if (s.startsWith("^")) {
|
||||
return "^" + Pattern.quote(s.substring(1));
|
||||
} else if (s.endsWith("$")) {
|
||||
return Pattern.quote(s.substring(0, s.length() - 1)) + "$";
|
||||
|
|
|
@ -55,7 +55,8 @@ public final class MemoryUtil {
|
|||
}
|
||||
if (obj instanceof String) {
|
||||
return ((String) obj).length() + 56L;
|
||||
} else if (obj instanceof Number) {
|
||||
}
|
||||
if (obj instanceof Number) {
|
||||
return 24L;
|
||||
} else if (obj instanceof Date) {
|
||||
return 32L;
|
||||
|
|
Loading…
Add table
Reference in a new issue