code cleanup
This commit is contained in:
parent
1a204e1cd4
commit
12a57af1c6
107 changed files with 608 additions and 629 deletions
|
@ -30,9 +30,8 @@ public class WebApiRequest extends HttpServletRequestWrapper {
|
|||
public String getServletPath() {
|
||||
if (getQueryString() != null && getQueryString().indexOf("SAStruts.method") != -1) {
|
||||
return super.getServletPath();
|
||||
} else {
|
||||
return servletPath;
|
||||
}
|
||||
return servletPath;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ public class EsApiManager extends BaseApiManager {
|
|||
}
|
||||
}
|
||||
|
||||
if (path.equals("/_plugin") || path.startsWith("/_plugin/")) {
|
||||
if ("/_plugin".equals(path) || path.startsWith("/_plugin/")) {
|
||||
processPluginRequest(request, response, path.replaceFirst("^/_plugin", StringUtil.EMPTY));
|
||||
return;
|
||||
}
|
||||
|
@ -158,11 +158,10 @@ public class EsApiManager extends BaseApiManager {
|
|||
logger.debug("Client aborts this request.", e);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
if (e.getCause() instanceof ClientAbortException) {
|
||||
logger.debug("Client aborts this request.", e);
|
||||
} else {
|
||||
if (!(e.getCause() instanceof ClientAbortException)) {
|
||||
throw new WebApiException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e);
|
||||
}
|
||||
logger.debug("Client aborts this request.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -549,7 +549,8 @@ public class GsaApiManager extends BaseApiManager implements WebApiManager {
|
|||
}
|
||||
buf.append(",score.desc");
|
||||
return buf.toString();
|
||||
} else if ("meta".equals(values[0]) && values.length > 1) {
|
||||
}
|
||||
if ("meta".equals(values[0]) && values.length > 1) {
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
buf.append(fessConfig.getQueryGsaMetaPrefix() + values[1]);
|
||||
if (values.length > 2) {
|
||||
|
|
|
@ -387,25 +387,24 @@ public class JsonApiManager extends BaseJsonApiManager {
|
|||
return "Unknown";
|
||||
}
|
||||
Throwable target = t;
|
||||
if (target.getCause() != null) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
while (target != null) {
|
||||
sb.append(target.getClass().getSimpleName());
|
||||
if (target.getMessage() != null) {
|
||||
sb.append("[");
|
||||
sb.append(target.getMessage());
|
||||
sb.append("]");
|
||||
}
|
||||
sb.append("; ");
|
||||
target = target.getCause();
|
||||
if (target != null) {
|
||||
sb.append("nested: ");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
} else {
|
||||
if (target.getCause() == null) {
|
||||
return target.getClass().getSimpleName() + "[" + target.getMessage() + "]";
|
||||
}
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
while (target != null) {
|
||||
sb.append(target.getClass().getSimpleName());
|
||||
if (target.getMessage() != null) {
|
||||
sb.append("[");
|
||||
sb.append(target.getMessage());
|
||||
sb.append("]");
|
||||
}
|
||||
sb.append("; ");
|
||||
target = target.getCause();
|
||||
if (target != null) {
|
||||
sb.append("nested: ");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected void processLabelRequest(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) {
|
||||
|
@ -532,7 +531,8 @@ public class JsonApiManager extends BaseJsonApiManager {
|
|||
|
||||
if (StringUtil.isBlank(userCode)) {
|
||||
throw new WebApiException(2, "No user session.");
|
||||
} else if (StringUtil.isBlank(favoriteUrl)) {
|
||||
}
|
||||
if (StringUtil.isBlank(favoriteUrl)) {
|
||||
throw new WebApiException(2, "URL is null.");
|
||||
}
|
||||
|
||||
|
@ -610,7 +610,8 @@ public class JsonApiManager extends BaseJsonApiManager {
|
|||
|
||||
if (StringUtil.isBlank(userCode)) {
|
||||
throw new WebApiException(2, "No user session.");
|
||||
} else if (StringUtil.isBlank(queryId)) {
|
||||
}
|
||||
if (StringUtil.isBlank(queryId)) {
|
||||
throw new WebApiException(3, "Query ID is null.");
|
||||
}
|
||||
|
||||
|
|
|
@ -473,7 +473,8 @@ public class SearchLogService {
|
|||
public OptionalEntity<?> getSearchLog(final String logType, final String id) {
|
||||
if (SearchLogPager.LOG_TYPE_CLICK.equalsIgnoreCase(logType)) {
|
||||
return clickLogBhv.selectByPK(id);
|
||||
} else if (SearchLogPager.LOG_TYPE_FAVORITE.equalsIgnoreCase(logType)) {
|
||||
}
|
||||
if (SearchLogPager.LOG_TYPE_FAVORITE.equalsIgnoreCase(logType)) {
|
||||
return favoriteLogBhv.selectByPK(id);
|
||||
} else if (SearchLogPager.LOG_TYPE_USERINFO.equalsIgnoreCase(logType)) {
|
||||
return userInfoBhv.selectByPK(id);
|
||||
|
@ -491,7 +492,8 @@ public class SearchLogService {
|
|||
params.put("Updated Time", FessFunctions.formatDate(e.getUpdatedAt()));
|
||||
return params;
|
||||
}).get();
|
||||
} else if (SearchLogPager.LOG_TYPE_CLICK.equalsIgnoreCase(logType)) {
|
||||
}
|
||||
if (SearchLogPager.LOG_TYPE_CLICK.equalsIgnoreCase(logType)) {
|
||||
return clickLogBhv.selectByPK(id).map(e -> {
|
||||
final Map<String, String> params = new LinkedHashMap<>();
|
||||
params.put("ID", e.getId());
|
||||
|
|
|
@ -307,7 +307,8 @@ public class AdminAction extends FessAdminAction {
|
|||
public static Class<? extends FessAdminAction> getAdminActionClass(final FessUserBean user) {
|
||||
if (user.hasRoles(getActionRoles(AdminDashboardAction.ROLE))) {
|
||||
return AdminDashboardAction.class;
|
||||
} else if (user.hasRoles(getActionRoles(AdminWizardAction.ROLE))) {
|
||||
}
|
||||
if (user.hasRoles(getActionRoles(AdminWizardAction.ROLE))) {
|
||||
return AdminWizardAction.class;
|
||||
} else if (user.hasRoles(getActionRoles(AdminGeneralAction.ROLE))) {
|
||||
return AdminGeneralAction.class;
|
||||
|
|
|
@ -185,10 +185,9 @@ public class AdminAccesstokenAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -288,7 +288,7 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
@Secured({ ROLE, ROLE + VIEW })
|
||||
public ActionResponse download(final String id) {
|
||||
if (stream(fessConfig.getIndexBackupAllTargets()).get(stream -> stream.anyMatch(s -> s.equals(id)))) {
|
||||
if (id.equals("system.properties")) {
|
||||
if ("system.properties".equals(id)) {
|
||||
return asStream(id).contentTypeOctetStream().stream(out -> {
|
||||
try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
||||
ComponentUtil.getSystemProperties().store(baos, id);
|
||||
|
@ -297,7 +297,8 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
}
|
||||
}
|
||||
});
|
||||
} else if (id.endsWith(NDJSON_EXTENTION)) {
|
||||
}
|
||||
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());
|
||||
|
@ -308,14 +309,14 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
} else if ("favorite_log".equals(name)) {
|
||||
return writeNdjsonResponse(id, getFavoriteLogNdjsonWriteCall());
|
||||
}
|
||||
} else if (id.equals("fess.json")) {
|
||||
} else if ("fess.json".equals(id)) {
|
||||
return asStream(id).contentTypeOctetStream().stream(out -> {
|
||||
final Path fessJsonPath = getFessJsonPath();
|
||||
try (final InputStream in = Files.newInputStream(fessJsonPath)) {
|
||||
out.write(in);
|
||||
}
|
||||
});
|
||||
} else if (id.equals("doc.json")) {
|
||||
} else if ("doc.json".equals(id)) {
|
||||
return asStream(id).contentTypeOctetStream().stream(out -> {
|
||||
final Path fessJsonPath = getDocJsonPath();
|
||||
try (final InputStream in = Files.newInputStream(fessJsonPath)) {
|
||||
|
|
|
@ -160,10 +160,9 @@ public class AdminBadwordAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -144,10 +144,9 @@ public class AdminBoostdocAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -185,10 +185,9 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -165,10 +165,9 @@ public class AdminDictKuromojiAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -168,10 +168,9 @@ public class AdminDictMappingAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -164,10 +164,9 @@ public class AdminDictProtwordsAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -166,10 +166,9 @@ public class AdminDictStemmeroverrideAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -162,10 +162,9 @@ public class AdminDictStopwordsAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -168,10 +168,9 @@ public class AdminDictSynonymAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -144,10 +144,9 @@ public class AdminDuplicatehostAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -178,10 +178,9 @@ public class AdminElevatewordAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -159,10 +159,9 @@ public class AdminFileauthAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -180,10 +180,9 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -153,10 +153,9 @@ public class AdminGroupAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -151,10 +151,9 @@ public class AdminKeymatchAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -164,10 +164,9 @@ public class AdminLabeltypeAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -145,10 +145,9 @@ public class AdminPathmapAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -144,10 +144,9 @@ public class AdminRelatedcontentAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -156,10 +156,9 @@ public class AdminRelatedqueryAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -157,10 +157,9 @@ public class AdminReqheaderAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -180,10 +180,9 @@ public class AdminSchedulerAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml(id);
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -262,7 +262,8 @@ public class AdminStorageAction extends FessAdminAction {
|
|||
final String[] values = decodeId(id);
|
||||
if (StringUtil.isEmpty(values[0]) && StringUtil.isEmpty(values[1])) {
|
||||
return StringUtil.EMPTY;
|
||||
} else if (StringUtil.isEmpty(values[0])) {
|
||||
}
|
||||
if (StringUtil.isEmpty(values[0])) {
|
||||
return values[1];
|
||||
} else {
|
||||
return values[0] + "/" + values[1];
|
||||
|
@ -275,7 +276,8 @@ public class AdminStorageAction extends FessAdminAction {
|
|||
if (values.length == 0) {
|
||||
// invalid?
|
||||
return new String[] { StringUtil.EMPTY, StringUtil.EMPTY };
|
||||
} else if (values.length == 1) {
|
||||
}
|
||||
if (values.length == 1) {
|
||||
return new String[] { StringUtil.EMPTY, values[0] };
|
||||
} else {
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
|
|
|
@ -172,10 +172,9 @@ public class AdminUserAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -157,10 +157,9 @@ public class AdminWebauthAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -184,10 +184,9 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
|
|
@ -270,7 +270,8 @@ public class AdminWizardAction extends FessAdminAction {
|
|||
|
||||
if (path.startsWith("//")) {
|
||||
return "file://" + path;
|
||||
} else if (path.startsWith("/")) {
|
||||
}
|
||||
if (path.startsWith("/")) {
|
||||
return "file:" + path;
|
||||
} else if (!path.startsWith("file:")) {
|
||||
return "file:/" + path.replace('\\', '/');
|
||||
|
|
|
@ -64,7 +64,7 @@ public class ApiAdminBackupAction extends FessApiAdminAction {
|
|||
public StreamResponse get$file(final String id) {
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
if (stream(fessConfig.getIndexBackupAllTargets()).get(stream -> stream.anyMatch(s -> s.equals(id)))) {
|
||||
if (id.equals("system.properties")) {
|
||||
if ("system.properties".equals(id)) {
|
||||
return asStream(id).contentTypeOctetStream().stream(out -> {
|
||||
try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
||||
ComponentUtil.getSystemProperties().store(baos, id);
|
||||
|
@ -73,7 +73,8 @@ public class ApiAdminBackupAction extends FessApiAdminAction {
|
|||
}
|
||||
}
|
||||
});
|
||||
} else if (id.endsWith(NDJSON_EXTENTION)) {
|
||||
}
|
||||
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());
|
||||
|
|
|
@ -54,18 +54,16 @@ public class OpenIdConnectCredential implements LoginCredential, FessCredential
|
|||
final String value = ComponentUtil.getFessConfig().getSystemProperty("oic.default.groups");
|
||||
if (StringUtil.isBlank(value)) {
|
||||
return StringUtil.EMPTY_STRINGS;
|
||||
} else {
|
||||
return split(value, ",").get(stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).toArray(n -> new String[n]));
|
||||
}
|
||||
return split(value, ",").get(stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).toArray(n -> new String[n]));
|
||||
}
|
||||
|
||||
protected static String[] getDefaultRolesAsArray() {
|
||||
final String value = ComponentUtil.getFessConfig().getSystemProperty("oic.default.roles");
|
||||
if (StringUtil.isBlank(value)) {
|
||||
return StringUtil.EMPTY_STRINGS;
|
||||
} else {
|
||||
return split(value, ",").get(stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).toArray(n -> new String[n]));
|
||||
}
|
||||
return split(value, ",").get(stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).toArray(n -> new String[n]));
|
||||
}
|
||||
|
||||
public static class OpenIdUser implements FessUser {
|
||||
|
|
|
@ -127,27 +127,26 @@ public class GoAction extends FessSearchAction {
|
|||
}
|
||||
|
||||
final String targetUrl = pathMappingHelper.replaceUrl(url);
|
||||
if (isFileSystemPath(targetUrl)) {
|
||||
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 (!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);
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
} else {
|
||||
return HtmlResponse.fromRedirectPathAsIs(DocumentUtil.encodeUrl(targetUrl + hash));
|
||||
return HtmlResponse.fromRedirectPathAsIs(targetUrl + hash);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,9 +51,8 @@ public class LogoutAction extends FessSearchAction {
|
|||
userInfoHelper.deleteUserCodeFromCookie(request);
|
||||
if (StringUtil.isNotBlank(redirectUrl)) {
|
||||
return HtmlResponse.fromRedirectPathAsIs(redirectUrl);
|
||||
} else {
|
||||
return redirect(LoginAction.class);
|
||||
}
|
||||
return redirect(LoginAction.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -56,7 +56,8 @@ public class SsoAction extends FessLoginAction {
|
|||
saveError(messages -> messages.addErrorsSsoLoginError(GLOBAL));
|
||||
}
|
||||
return redirect(LoginAction.class);
|
||||
} else if (loginCredential instanceof ActionResponseCredential) {
|
||||
}
|
||||
if (loginCredential instanceof ActionResponseCredential) {
|
||||
return ((ActionResponseCredential) loginCredential).execute();
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -79,7 +79,8 @@ public class ThumbnailAction extends FessSearchAction {
|
|||
final String path = imageFile.getAbsolutePath();
|
||||
if (path.endsWith(".png")) {
|
||||
return "image/png";
|
||||
} else if (path.endsWith(".gif")) {
|
||||
}
|
||||
if (path.endsWith(".gif")) {
|
||||
return "image/gif";
|
||||
} else if (path.endsWith(".jpg") || path.endsWith(".jpeg")) {
|
||||
return "image/jpeg";
|
||||
|
|
|
@ -100,7 +100,8 @@ public class CommandChain implements AuthenticationChain {
|
|||
final String[] cmds = stream(commands).get(stream -> stream.map(s -> {
|
||||
if ("$USERNAME".equals(s)) {
|
||||
return username;
|
||||
} else if ("$PASSWORD".equals(s)) {
|
||||
}
|
||||
if ("$PASSWORD".equals(s)) {
|
||||
return password;
|
||||
} else {
|
||||
return s;
|
||||
|
|
|
@ -141,7 +141,8 @@ public class FessCrawlerThread extends CrawlerThread {
|
|||
logger.debug("Failed to delete 404 document: {}", url);
|
||||
}
|
||||
return false;
|
||||
} else if (responseData.getLastModified() == null) {
|
||||
}
|
||||
if (responseData.getLastModified() == null) {
|
||||
return true;
|
||||
} else if (responseData.getLastModified().getTime() <= lastModified.getTime() && httpStatusCode == 200) {
|
||||
|
||||
|
|
|
@ -339,7 +339,8 @@ public abstract class AbstractFessFileTransformer extends AbstractTransformer im
|
|||
final Object lastModifiedObj = dataMap.get(fessConfig.getIndexFieldLastModified());
|
||||
if (lastModifiedObj instanceof Date) {
|
||||
return (Date) lastModifiedObj;
|
||||
} else if (lastModifiedObj instanceof String) {
|
||||
}
|
||||
if (lastModifiedObj instanceof String) {
|
||||
final Date lastModified = FessFunctions.parseDate(lastModifiedObj.toString());
|
||||
if (lastModified != null) {
|
||||
return lastModified;
|
||||
|
@ -362,9 +363,8 @@ public abstract class AbstractFessFileTransformer extends AbstractTransformer im
|
|||
if (titleObj != null) {
|
||||
if (titleObj instanceof String[]) {
|
||||
return stream((String[]) titleObj).get(stream -> stream.anyMatch(StringUtil::isNotBlank));
|
||||
} else {
|
||||
return StringUtil.isNotBlank(titleObj.toString());
|
||||
}
|
||||
return StringUtil.isNotBlank(titleObj.toString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -435,7 +435,8 @@ public abstract class AbstractFessFileTransformer extends AbstractTransformer im
|
|||
} else {
|
||||
return "localhost";
|
||||
}
|
||||
} else if (url.startsWith("file:")) {
|
||||
}
|
||||
if (url.startsWith("file:")) {
|
||||
return "localhost";
|
||||
}
|
||||
|
||||
|
@ -461,7 +462,8 @@ public abstract class AbstractFessFileTransformer extends AbstractTransformer im
|
|||
if (url.startsWith("file:////")) {
|
||||
final String value = decodeUrlAsName(url.substring(9), true);
|
||||
return abbreviateSite("\\\\" + value.replace('/', '\\'));
|
||||
} else if (url.startsWith("file:")) {
|
||||
}
|
||||
if (url.startsWith("file:")) {
|
||||
final String value = decodeUrlAsName(url.substring(5), true);
|
||||
if (value.length() > 2 && value.charAt(2) == ':') {
|
||||
// Windows
|
||||
|
|
|
@ -169,9 +169,8 @@ public interface FessTransformer {
|
|||
final int maxSiteLength = getMaxSiteLength();
|
||||
if (maxSiteLength > -1) {
|
||||
return StringUtils.abbreviate(value, maxSiteLength);
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
default String getFileName(final String url, final String encoding) {
|
||||
|
|
|
@ -237,7 +237,8 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
|
|||
if (noindex && nofollow) {
|
||||
logger.info("META(robots=noindex,nofollow): {}", responseData.getUrl());
|
||||
throw new ChildUrlsException(Collections.emptySet(), "#processMetaRobots");
|
||||
} else if (noindex) {
|
||||
}
|
||||
if (noindex) {
|
||||
logger.info("META(robots=noindex): {}", responseData.getUrl());
|
||||
storeChildUrls(responseData, resultData);
|
||||
throw new ChildUrlsException(resultData.getChildUrlSet(), "#processMetaRobots");
|
||||
|
@ -264,7 +265,7 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
|
|||
}
|
||||
|
||||
// X-Robots-Tag
|
||||
responseData.getMetaDataMap().entrySet().stream().filter(e -> e.getKey().equalsIgnoreCase(X_ROBOTS_TAG) && e.getValue() != null)
|
||||
responseData.getMetaDataMap().entrySet().stream().filter(e -> X_ROBOTS_TAG.equalsIgnoreCase(e.getKey()) && e.getValue() != null)
|
||||
.forEach(e -> {
|
||||
boolean noindex = false;
|
||||
boolean nofollow = false;
|
||||
|
@ -283,7 +284,8 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
|
|||
if (noindex && nofollow) {
|
||||
logger.info("HEADER(robots=noindex,nofollow): {}", responseData.getUrl());
|
||||
throw new ChildUrlsException(Collections.emptySet(), "#processXRobotsTag");
|
||||
} else if (noindex) {
|
||||
}
|
||||
if (noindex) {
|
||||
logger.info("HEADER(robots=noindex): {}", responseData.getUrl());
|
||||
storeChildUrls(responseData, resultData);
|
||||
throw new ChildUrlsException(resultData.getChildUrlSet(), "#processXRobotsTag");
|
||||
|
@ -560,15 +562,14 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
|
|||
int pos = value.indexOf("<!--");
|
||||
while (pos >= 0) {
|
||||
final int lastPos = value.indexOf("-->", pos);
|
||||
if (lastPos >= 0) {
|
||||
if (pos == 0) {
|
||||
value = " " + value.substring(lastPos + 3);
|
||||
} else {
|
||||
value = value.substring(0, pos) + " " + value.substring(lastPos + 3);
|
||||
}
|
||||
} else {
|
||||
if (lastPos < 0) {
|
||||
break;
|
||||
}
|
||||
if (pos == 0) {
|
||||
value = " " + value.substring(lastPos + 3);
|
||||
} else {
|
||||
value = value.substring(0, pos) + " " + value.substring(lastPos + 3);
|
||||
}
|
||||
pos = value.indexOf("<!--");
|
||||
}
|
||||
return value;
|
||||
|
@ -852,7 +853,8 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
|
|||
final Integer width = getAttributeAsInteger(attributes, "width");
|
||||
if (!fessConfig.isThumbnailHtmlImageUrl(thumbnailUrl)) {
|
||||
continue;
|
||||
} else if (height != null && width != null) {
|
||||
}
|
||||
if (height != null && width != null) {
|
||||
try {
|
||||
if (fessConfig.validateThumbnailSize(width, height)) {
|
||||
return thumbnailUrl;
|
||||
|
@ -915,7 +917,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("//")) {
|
||||
}
|
||||
if (url.startsWith("//")) {
|
||||
final String protocol = currentUrl.split(":")[0];
|
||||
return new URL(protocol + ":" + url);
|
||||
} else if (url.startsWith("/") || url.indexOf(':') == -1) {
|
||||
|
|
|
@ -222,29 +222,28 @@ public class KuromojiFile extends DictionaryFile<KuromojiItem> {
|
|||
|
||||
public KuromojiItem write(final KuromojiItem oldItem) {
|
||||
try {
|
||||
if (item != null && item.getId() == oldItem.getId() && item.isUpdated()) {
|
||||
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 {
|
||||
throw new DictionaryException("Kuromoji file was updated: old=" + oldItem + " : new=" + item);
|
||||
}
|
||||
} else {
|
||||
if ((item == null) || (item.getId() != oldItem.getId()) || !item.isUpdated()) {
|
||||
writer.write(oldItem.toLineString());
|
||||
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 {
|
||||
throw new DictionaryException("Kuromoji file was updated: old=" + oldItem + " : new=" + item);
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
throw new DictionaryException("Failed to write: " + oldItem + " -> " + item, e);
|
||||
}
|
||||
|
|
|
@ -236,29 +236,28 @@ public class CharMappingFile extends DictionaryFile<CharMappingItem> {
|
|||
|
||||
public CharMappingItem write(final CharMappingItem oldItem) {
|
||||
try {
|
||||
if (item != null && item.getId() == oldItem.getId() && item.isUpdated()) {
|
||||
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 {
|
||||
throw new DictionaryException("Mapping file was updated: old=" + oldItem + " : new=" + item);
|
||||
}
|
||||
} else {
|
||||
if ((item == null) || (item.getId() != oldItem.getId()) || !item.isUpdated()) {
|
||||
writer.write(oldItem.toLineString());
|
||||
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 {
|
||||
throw new DictionaryException("Mapping file was updated: old=" + oldItem + " : new=" + item);
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
throw new DictionaryException("Failed to write: " + oldItem + " -> " + item, e);
|
||||
}
|
||||
|
|
|
@ -129,9 +129,8 @@ public class CharMappingItem extends DictionaryItem {
|
|||
public String toLineString() {
|
||||
if (isUpdated()) {
|
||||
return StringUtils.join(newInputs, ",") + "=>" + newOutput;
|
||||
} else {
|
||||
return StringUtils.join(inputs, ",") + "=>" + output;
|
||||
}
|
||||
return StringUtils.join(inputs, ",") + "=>" + output;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -170,7 +170,8 @@ public class ProtwordsFile extends DictionaryFile<ProtwordsItem> {
|
|||
for (int i = 0; i < s.length(); i++) {
|
||||
final char ch = s.charAt(i);
|
||||
if (ch == '\\' && i < s.length() - 1) {
|
||||
sb.append(s.charAt(++i));
|
||||
i++;
|
||||
sb.append(s.charAt(i));
|
||||
} else {
|
||||
sb.append(ch);
|
||||
}
|
||||
|
@ -220,28 +221,27 @@ public class ProtwordsFile extends DictionaryFile<ProtwordsItem> {
|
|||
|
||||
public ProtwordsItem write(final ProtwordsItem oldItem) {
|
||||
try {
|
||||
if (item != null && item.getId() == oldItem.getId() && item.isUpdated()) {
|
||||
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 {
|
||||
throw new DictionaryException("Protwords file was updated: old=" + oldItem + " : new=" + item);
|
||||
}
|
||||
} else {
|
||||
if ((item == null) || (item.getId() != oldItem.getId()) || !item.isUpdated()) {
|
||||
writer.write(oldItem.toLineString());
|
||||
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 {
|
||||
throw new DictionaryException("Protwords file was updated: old=" + oldItem + " : new=" + item);
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
throw new DictionaryException("Failed to write: " + oldItem + " -> " + item, e);
|
||||
}
|
||||
|
|
|
@ -95,9 +95,8 @@ public class ProtwordsItem extends DictionaryItem {
|
|||
public String toLineString() {
|
||||
if (isUpdated()) {
|
||||
return StringUtils.join(newInput);
|
||||
} else {
|
||||
return StringUtils.join(input);
|
||||
}
|
||||
return StringUtils.join(input);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -233,29 +233,28 @@ public class StemmerOverrideFile extends DictionaryFile<StemmerOverrideItem> {
|
|||
|
||||
public StemmerOverrideItem write(final StemmerOverrideItem oldItem) {
|
||||
try {
|
||||
if (item != null && item.getId() == oldItem.getId() && item.isUpdated()) {
|
||||
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 {
|
||||
throw new DictionaryException("StemmerOverride file was updated: old=" + oldItem + " : new=" + item);
|
||||
}
|
||||
} else {
|
||||
if ((item == null) || (item.getId() != oldItem.getId()) || !item.isUpdated()) {
|
||||
writer.write(oldItem.toLineString());
|
||||
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 {
|
||||
throw new DictionaryException("StemmerOverride file was updated: old=" + oldItem + " : new=" + item);
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
throw new DictionaryException("Failed to write: " + oldItem + " -> " + item, e);
|
||||
}
|
||||
|
|
|
@ -107,9 +107,8 @@ public class StemmerOverrideItem extends DictionaryItem {
|
|||
public String toLineString() {
|
||||
if (isUpdated()) {
|
||||
return newInput + "=>" + newOutput;
|
||||
} else {
|
||||
return input + "=>" + output;
|
||||
}
|
||||
return input + "=>" + output;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -170,7 +170,8 @@ public class StopwordsFile extends DictionaryFile<StopwordsItem> {
|
|||
for (int i = 0; i < s.length(); i++) {
|
||||
final char ch = s.charAt(i);
|
||||
if (ch == '\\' && i < s.length() - 1) {
|
||||
sb.append(s.charAt(++i));
|
||||
i++;
|
||||
sb.append(s.charAt(i));
|
||||
} else {
|
||||
sb.append(ch);
|
||||
}
|
||||
|
@ -220,28 +221,27 @@ public class StopwordsFile extends DictionaryFile<StopwordsItem> {
|
|||
|
||||
public StopwordsItem write(final StopwordsItem oldItem) {
|
||||
try {
|
||||
if (item != null && item.getId() == oldItem.getId() && item.isUpdated()) {
|
||||
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 {
|
||||
throw new DictionaryException("Stopwords file was updated: old=" + oldItem + " : new=" + item);
|
||||
}
|
||||
} else {
|
||||
if ((item == null) || (item.getId() != oldItem.getId()) || !item.isUpdated()) {
|
||||
writer.write(oldItem.toLineString());
|
||||
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 {
|
||||
throw new DictionaryException("Stopwords file was updated: old=" + oldItem + " : new=" + item);
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
throw new DictionaryException("Failed to write: " + oldItem + " -> " + item, e);
|
||||
}
|
||||
|
|
|
@ -95,9 +95,8 @@ public class StopwordsItem extends DictionaryItem {
|
|||
public String toLineString() {
|
||||
if (isUpdated()) {
|
||||
return StringUtils.join(newInput);
|
||||
} else {
|
||||
return StringUtils.join(input);
|
||||
}
|
||||
return StringUtils.join(input);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -219,7 +219,8 @@ public class SynonymFile extends DictionaryFile<SynonymItem> {
|
|||
continue;
|
||||
}
|
||||
|
||||
char ch = s.charAt(pos++);
|
||||
char ch = s.charAt(pos);
|
||||
pos++;
|
||||
if (ch == '\\') {
|
||||
sb.append(ch);
|
||||
if (pos >= end) {
|
||||
|
@ -244,7 +245,8 @@ public class SynonymFile extends DictionaryFile<SynonymItem> {
|
|||
for (int i = 0; i < s.length(); i++) {
|
||||
final char ch = s.charAt(i);
|
||||
if (ch == '\\' && i < s.length() - 1) {
|
||||
sb.append(s.charAt(++i));
|
||||
i++;
|
||||
sb.append(s.charAt(i));
|
||||
} else {
|
||||
sb.append(ch);
|
||||
}
|
||||
|
@ -294,29 +296,28 @@ public class SynonymFile extends DictionaryFile<SynonymItem> {
|
|||
|
||||
public SynonymItem write(final SynonymItem oldItem) {
|
||||
try {
|
||||
if (item != null && item.getId() == oldItem.getId() && item.isUpdated()) {
|
||||
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 {
|
||||
throw new DictionaryException("Synonym file was updated: old=" + oldItem + " : new=" + item);
|
||||
}
|
||||
} else {
|
||||
if ((item == null) || (item.getId() != oldItem.getId()) || !item.isUpdated()) {
|
||||
writer.write(oldItem.toLineString());
|
||||
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 {
|
||||
throw new DictionaryException("Synonym file was updated: old=" + oldItem + " : new=" + item);
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
throw new DictionaryException("Failed to write: " + oldItem + " -> " + item, e);
|
||||
}
|
||||
|
|
|
@ -129,7 +129,8 @@ public class SynonymItem extends DictionaryItem {
|
|||
} else {
|
||||
return StringUtils.join(newInputs, ",") + "=>" + StringUtils.join(newOutputs, ",");
|
||||
}
|
||||
} else if (Arrays.equals(inputs, outputs)) {
|
||||
}
|
||||
if (Arrays.equals(inputs, outputs)) {
|
||||
return StringUtils.join(inputs, ",");
|
||||
} else {
|
||||
return StringUtils.join(inputs, ",") + "=>" + StringUtils.join(outputs, ",");
|
||||
|
|
|
@ -67,10 +67,10 @@ public abstract class AbstractDataStore implements DataStore {
|
|||
final Map<String, String> configParamMap = config.getHandlerParameterMap().entrySet().stream().map(e -> {
|
||||
final String key = e.getKey();
|
||||
String value = e.getValue();
|
||||
for (Map.Entry<String, String> entry : paramEnvMap.entrySet()) {
|
||||
for (final Map.Entry<String, String> entry : paramEnvMap.entrySet()) {
|
||||
value = value.replace("${" + entry.getKey() + "}", entry.getValue());
|
||||
}
|
||||
return new Pair<String, String>(key, value);
|
||||
return new Pair<>(key, value);
|
||||
}).collect(Collectors.toMap(Pair<String, String>::getFirst, Pair<String, String>::getSecond));
|
||||
final Map<String, String> configScriptMap = config.getHandlerScriptMap();
|
||||
|
||||
|
|
|
@ -165,7 +165,8 @@ public class FileListIndexUpdateCallbackImpl implements IndexUpdateCallback {
|
|||
final Object recursive = dataMap.remove(getParamValue(paramMap, "field.recursive", "recursive"));
|
||||
if (recursive == null || Constants.FALSE.equalsIgnoreCase(recursive.toString())) {
|
||||
return 1L;
|
||||
} else if (Constants.TRUE.equalsIgnoreCase(recursive.toString())) {
|
||||
}
|
||||
if (Constants.TRUE.equalsIgnoreCase(recursive.toString())) {
|
||||
return -1L;
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -68,14 +68,15 @@ public class FacetInfo {
|
|||
final String[] values = sort.split("\\.");
|
||||
final boolean asc;
|
||||
if (values.length > 1) {
|
||||
asc = !values[1].equalsIgnoreCase("desc");
|
||||
asc = !"desc".equalsIgnoreCase(values[1]);
|
||||
} else {
|
||||
asc = true;
|
||||
}
|
||||
if (values.length > 0) {
|
||||
if ("term".equals(values[0]) || "key".equals(values[0])) {
|
||||
return BucketOrder.key(asc);
|
||||
} else if ("count".equals(values[0])) {
|
||||
}
|
||||
if ("count".equals(values[0])) {
|
||||
return BucketOrder.count(asc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,21 +58,20 @@ public class GeoInfo {
|
|||
geoMap.put(geoField, list);
|
||||
}
|
||||
final String[] values = pt.split(",");
|
||||
if (values.length == 2) {
|
||||
try {
|
||||
final double lat = Double.parseDouble(values[0]);
|
||||
final double lon = Double.parseDouble(values[1]);
|
||||
list.add(QueryBuilders.geoDistanceQuery(geoField).distance(distance).point(lat, lon));
|
||||
} catch (final Exception ex) {
|
||||
throw new InvalidQueryException(
|
||||
messages -> messages.addErrorsInvalidQueryUnknown(UserMessages.GLOBAL_PROPERTY_KEY),
|
||||
ex.getLocalizedMessage(), ex);
|
||||
}
|
||||
} else {
|
||||
if (values.length != 2) {
|
||||
throw new InvalidQueryException(
|
||||
messages -> messages.addErrorsInvalidQueryUnknown(UserMessages.GLOBAL_PROPERTY_KEY),
|
||||
"Invalid geo point: " + pt);
|
||||
}
|
||||
try {
|
||||
final double lat = Double.parseDouble(values[0]);
|
||||
final double lon = Double.parseDouble(values[1]);
|
||||
list.add(QueryBuilders.geoDistanceQuery(geoField).distance(distance).point(lat, lon));
|
||||
} catch (final Exception ex) {
|
||||
throw new InvalidQueryException(
|
||||
messages -> messages.addErrorsInvalidQueryUnknown(UserMessages.GLOBAL_PROPERTY_KEY),
|
||||
ex.getLocalizedMessage(), ex);
|
||||
}
|
||||
}));
|
||||
}
|
||||
break;
|
||||
|
@ -83,7 +82,8 @@ public class GeoInfo {
|
|||
final QueryBuilder[] queryBuilders = geoMap.values().stream().map(list -> {
|
||||
if (list.size() == 1) {
|
||||
return list.get(0);
|
||||
} else if (list.size() > 1) {
|
||||
}
|
||||
if (list.size() > 1) {
|
||||
final BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
|
||||
list.forEach(boolQuery::should);
|
||||
return boolQuery;
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.codelibs.fess.mylasta.direction.FessConfig;
|
|||
import org.codelibs.fess.util.ComponentUtil;
|
||||
|
||||
public class CrawlerEngineClient extends FesenClient {
|
||||
@Override
|
||||
protected Client createClient() {
|
||||
final Builder builder = Settings.builder().putList("http.hosts", address);
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
|
|
|
@ -244,39 +244,37 @@ public class SearchEngineClient implements Client {
|
|||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
|
||||
String httpAddress = System.getProperty(Constants.FESS_ES_HTTP_ADDRESS);
|
||||
if (StringUtil.isBlank(httpAddress)) {
|
||||
if (runner == null) {
|
||||
switch (fessConfig.getFesenType()) {
|
||||
case Constants.FESEN_TYPE_CLOUD:
|
||||
case Constants.FESEN_TYPE_AWS:
|
||||
httpAddress = org.codelibs.fess.util.ResourceUtil.getFesenHttpUrl();
|
||||
break;
|
||||
default:
|
||||
runner = new FesenRunner();
|
||||
final Configs config = newConfigs().clusterName(clusterName).numOfNode(1).useLogger();
|
||||
final String esDir = System.getProperty("fess.es.dir");
|
||||
if (esDir != null) {
|
||||
config.basePath(esDir);
|
||||
}
|
||||
config.disableESLogger();
|
||||
runner.onBuild((number, settingsBuilder) -> {
|
||||
final File pluginDir = new File(esDir, "plugins");
|
||||
if (pluginDir.isDirectory()) {
|
||||
settingsBuilder.put("path.plugins", pluginDir.getAbsolutePath());
|
||||
} else {
|
||||
settingsBuilder.put("path.plugins", new File(System.getProperty("user.dir"), "plugins").getAbsolutePath());
|
||||
}
|
||||
if (settings != null) {
|
||||
settingsBuilder.putProperties(settings, s -> s);
|
||||
}
|
||||
});
|
||||
runner.build(config);
|
||||
|
||||
final int port = runner.node().settings().getAsInt("http.port", 9200);
|
||||
httpAddress = "http://localhost:" + port;
|
||||
logger.warn("Embedded Fesen is running. This configuration is not recommended for production use.");
|
||||
break;
|
||||
if (StringUtil.isBlank(httpAddress) && (runner == null)) {
|
||||
switch (fessConfig.getFesenType()) {
|
||||
case Constants.FESEN_TYPE_CLOUD:
|
||||
case Constants.FESEN_TYPE_AWS:
|
||||
httpAddress = org.codelibs.fess.util.ResourceUtil.getFesenHttpUrl();
|
||||
break;
|
||||
default:
|
||||
runner = new FesenRunner();
|
||||
final Configs config = newConfigs().clusterName(clusterName).numOfNode(1).useLogger();
|
||||
final String esDir = System.getProperty("fess.es.dir");
|
||||
if (esDir != null) {
|
||||
config.basePath(esDir);
|
||||
}
|
||||
config.disableESLogger();
|
||||
runner.onBuild((number, settingsBuilder) -> {
|
||||
final File pluginDir = new File(esDir, "plugins");
|
||||
if (pluginDir.isDirectory()) {
|
||||
settingsBuilder.put("path.plugins", pluginDir.getAbsolutePath());
|
||||
} else {
|
||||
settingsBuilder.put("path.plugins", new File(System.getProperty("user.dir"), "plugins").getAbsolutePath());
|
||||
}
|
||||
if (settings != null) {
|
||||
settingsBuilder.putProperties(settings, s -> s);
|
||||
}
|
||||
});
|
||||
runner.build(config);
|
||||
|
||||
final int port = runner.node().settings().getAsInt("http.port", 9200);
|
||||
httpAddress = "http://localhost:" + port;
|
||||
logger.warn("Embedded Fesen is running. This configuration is not recommended for production use.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
client = createHttpClient(fessConfig, httpAddress);
|
||||
|
@ -293,7 +291,7 @@ public class SearchEngineClient implements Client {
|
|||
final String configIndex = values[0];
|
||||
final String configType = values[1];
|
||||
|
||||
final boolean isFessIndex = configIndex.equals("fess");
|
||||
final boolean isFessIndex = "fess".equals(configIndex);
|
||||
final String indexName;
|
||||
if (isFessIndex) {
|
||||
final boolean exists = existsIndex(fessConfig.getIndexDocumentUpdateIndex());
|
||||
|
@ -379,9 +377,8 @@ public class SearchEngineClient implements Client {
|
|||
.param("wait_for_completion", Boolean.toString(waitForCompletion)).body(source).execute()) {
|
||||
if (response.getHttpStatusCode() == 200) {
|
||||
return true;
|
||||
} else {
|
||||
logger.warn("Failed to reindex from {} to {}", fromIndex, toIndex);
|
||||
}
|
||||
logger.warn("Failed to reindex from {} to {}", fromIndex, toIndex);
|
||||
} catch (final IOException e) {
|
||||
logger.warn("Failed to reindex from {} to {}", fromIndex, toIndex, e);
|
||||
}
|
||||
|
@ -419,7 +416,8 @@ public class SearchEngineClient implements Client {
|
|||
if (indexResponse.isAcknowledged()) {
|
||||
logger.info("Created {} index.", indexName);
|
||||
return true;
|
||||
} else if (logger.isDebugEnabled()) {
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Failed to create {} index.", indexName);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
|
@ -527,7 +525,7 @@ public class SearchEngineClient implements Client {
|
|||
stream(aliasConfigDir.listFiles((dir, name) -> name.endsWith(".json"))).of(stream -> stream.forEach(f -> {
|
||||
final String aliasName = f.getName().replaceFirst(".json$", "");
|
||||
String source = FileUtil.readUTF8(f);
|
||||
if (source.trim().equals("{}")) {
|
||||
if ("{}".equals(source.trim())) {
|
||||
source = null;
|
||||
}
|
||||
final AcknowledgedResponse response = client.admin().indices().prepareAliases()
|
||||
|
@ -593,7 +591,8 @@ public class SearchEngineClient implements Client {
|
|||
});
|
||||
if (result.containsKey("index") || result.containsKey("update")) {
|
||||
return line;
|
||||
} else if (result.containsKey("delete")) {
|
||||
}
|
||||
if (result.containsKey("delete")) {
|
||||
return StringUtil.EMPTY;
|
||||
}
|
||||
} else {
|
||||
|
@ -664,13 +663,12 @@ public class SearchEngineClient implements Client {
|
|||
if (httpStatusCode == 200) {
|
||||
logger.info("ConfigSync is ready.");
|
||||
return;
|
||||
}
|
||||
final String message = "Configsync is not available. HTTP Status is " + httpStatusCode;
|
||||
if (response.getContentException() != null) {
|
||||
throw new FessSystemException(message, response.getContentException());
|
||||
} else {
|
||||
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);
|
||||
|
@ -1181,11 +1179,11 @@ public class SearchEngineClient implements Client {
|
|||
protected void buildTrackTotalHits(final FessConfig fessConfig) {
|
||||
if (StringUtil.isNotBlank(trackTotalHits)) {
|
||||
if (Constants.TRUE.equalsIgnoreCase(trackTotalHits) || Constants.FALSE.equalsIgnoreCase(trackTotalHits)) {
|
||||
searchRequestBuilder.setTrackTotalHits(Boolean.valueOf(trackTotalHits));
|
||||
searchRequestBuilder.setTrackTotalHits(Boolean.parseBoolean(trackTotalHits));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
searchRequestBuilder.setTrackTotalHitsUpTo(Integer.valueOf(trackTotalHits));
|
||||
searchRequestBuilder.setTrackTotalHitsUpTo(Integer.parseInt(trackTotalHits));
|
||||
return;
|
||||
} catch (final NumberFormatException e) {
|
||||
// ignore
|
||||
|
@ -1201,24 +1199,23 @@ public class SearchEngineClient implements Client {
|
|||
|
||||
protected void buildFacet(final QueryHelper queryHelper, final FessConfig fessConfig) {
|
||||
stream(facetInfo.field).of(stream -> stream.forEach(f -> {
|
||||
if (queryHelper.isFacetField(f)) {
|
||||
final String encodedField = BaseEncoding.base64().encode(f.getBytes(StandardCharsets.UTF_8));
|
||||
final TermsAggregationBuilder termsBuilder =
|
||||
AggregationBuilders.terms(Constants.FACET_FIELD_PREFIX + encodedField).field(f);
|
||||
termsBuilder.order(facetInfo.getBucketOrder());
|
||||
if (facetInfo.size != null) {
|
||||
termsBuilder.size(facetInfo.size);
|
||||
}
|
||||
if (facetInfo.minDocCount != null) {
|
||||
termsBuilder.minDocCount(facetInfo.minDocCount);
|
||||
}
|
||||
if (facetInfo.missing != null) {
|
||||
termsBuilder.missing(facetInfo.missing);
|
||||
}
|
||||
searchRequestBuilder.addAggregation(termsBuilder);
|
||||
} else {
|
||||
if (!queryHelper.isFacetField(f)) {
|
||||
throw new SearchQueryException("Invalid facet field: " + f);
|
||||
}
|
||||
final String encodedField = BaseEncoding.base64().encode(f.getBytes(StandardCharsets.UTF_8));
|
||||
final TermsAggregationBuilder termsBuilder =
|
||||
AggregationBuilders.terms(Constants.FACET_FIELD_PREFIX + encodedField).field(f);
|
||||
termsBuilder.order(facetInfo.getBucketOrder());
|
||||
if (facetInfo.size != null) {
|
||||
termsBuilder.size(facetInfo.size);
|
||||
}
|
||||
if (facetInfo.minDocCount != null) {
|
||||
termsBuilder.minDocCount(facetInfo.minDocCount);
|
||||
}
|
||||
if (facetInfo.missing != null) {
|
||||
termsBuilder.missing(facetInfo.missing);
|
||||
}
|
||||
searchRequestBuilder.addAggregation(termsBuilder);
|
||||
}));
|
||||
stream(facetInfo.query).of(stream -> stream.forEach(fq -> {
|
||||
final QueryContext facetContext = new QueryContext(fq, false);
|
||||
|
|
|
@ -61,7 +61,8 @@ public class WebAuthentication extends BsWebAuthentication {
|
|||
final String scheme = getProtocolScheme();
|
||||
if (Constants.BASIC.equals(scheme)) {
|
||||
return new BasicScheme();
|
||||
} else if (Constants.DIGEST.equals(scheme)) {
|
||||
}
|
||||
if (Constants.DIGEST.equals(scheme)) {
|
||||
return new DigestScheme();
|
||||
} else if (Constants.NTLM.equals(scheme)) {
|
||||
final Properties props = new Properties();
|
||||
|
|
|
@ -84,7 +84,8 @@ public class SearchLog extends BsSearchLog implements SearchLogEvent {
|
|||
public OptionalEntity<UserInfo> getUserInfo() {
|
||||
if (getUserInfoId() == null) {
|
||||
return OptionalEntity.empty();
|
||||
} else if (userInfo == null) {
|
||||
}
|
||||
if (userInfo == null) {
|
||||
final UserInfoBhv userInfoBhv = ComponentUtil.getComponent(UserInfoBhv.class);
|
||||
userInfo = userInfoBhv.selectByPK(getUserInfoId());
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public class CorsFilter implements Filter {
|
|||
httpResponse.addHeader(ACCESS_CONTROL_MAX_AGE, fessConfig.getApiCorsMaxAge());
|
||||
httpResponse.addHeader(ACCESS_CONTROL_ALLOW_CREDENTIALS, fessConfig.getApiCorsAllowCredentials());
|
||||
|
||||
if (httpRequest.getMethod().equals(OPTIONS)) {
|
||||
if (OPTIONS.equals(httpRequest.getMethod())) {
|
||||
httpResponse.setStatus(HttpServletResponse.SC_ACCEPTED);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -122,9 +122,8 @@ public class EncodingFilter implements Filter {
|
|||
final String queryString = request.getQueryString();
|
||||
if (StringUtil.isNotBlank(queryString)) {
|
||||
return parseQueryString(queryString, enc);
|
||||
} else {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
protected Map<String, String[]> parseQueryString(final String queryString, final String enc) throws IOException {
|
||||
|
|
|
@ -39,7 +39,8 @@ public class AccessTokenHelper {
|
|||
final String[] values = token.trim().split(" ");
|
||||
if (values.length == 2 && "Bearer".equals(values[0])) {
|
||||
return values[1];
|
||||
} else if (values.length == 1) {
|
||||
}
|
||||
if (values.length == 1) {
|
||||
return values[0];
|
||||
}
|
||||
throw new InvalidAccessTokenException("invalid_request", "Invalid format: " + token);
|
||||
|
|
|
@ -79,7 +79,8 @@ public class CrawlingConfigHelper {
|
|||
final String configType = configId.substring(0, 1);
|
||||
if (ConfigType.WEB.getTypePrefix().equals(configType)) {
|
||||
return ConfigType.WEB;
|
||||
} else if (ConfigType.FILE.getTypePrefix().equals(configType)) {
|
||||
}
|
||||
if (ConfigType.FILE.getTypePrefix().equals(configType)) {
|
||||
return ConfigType.FILE;
|
||||
} else if (ConfigType.DATA.getTypePrefix().equals(configType)) {
|
||||
return ConfigType.DATA;
|
||||
|
@ -163,9 +164,8 @@ public class CrawlingConfigHelper {
|
|||
public List<WebConfig> getWebConfigListByIds(final List<String> idList) {
|
||||
if (idList == null) {
|
||||
return getAllWebConfigList();
|
||||
} else {
|
||||
return getAllWebConfigList(true, true, false, idList);
|
||||
}
|
||||
return getAllWebConfigList(true, true, false, idList);
|
||||
}
|
||||
|
||||
public List<WebConfig> getAllWebConfigList(final boolean withLabelType, final boolean withRoleType, final boolean available,
|
||||
|
@ -191,9 +191,8 @@ public class CrawlingConfigHelper {
|
|||
public List<FileConfig> getFileConfigListByIds(final List<String> idList) {
|
||||
if (idList == null) {
|
||||
return getAllFileConfigList();
|
||||
} else {
|
||||
return getAllFileConfigList(true, true, false, idList);
|
||||
}
|
||||
return getAllFileConfigList(true, true, false, idList);
|
||||
}
|
||||
|
||||
public List<FileConfig> getAllFileConfigList(final boolean withLabelType, final boolean withRoleType, final boolean available,
|
||||
|
@ -219,9 +218,8 @@ public class CrawlingConfigHelper {
|
|||
public List<DataConfig> getDataConfigListByIds(final List<String> idList) {
|
||||
if (idList == null) {
|
||||
return getAllDataConfigList();
|
||||
} else {
|
||||
return getAllDataConfigList(true, true, false, idList);
|
||||
}
|
||||
return getAllDataConfigList(true, true, false, idList);
|
||||
}
|
||||
|
||||
public List<DataConfig> getAllDataConfigList(final boolean withLabelType, final boolean withRoleType, final boolean available,
|
||||
|
|
|
@ -130,7 +130,7 @@ public class DataIndexHelper {
|
|||
|
||||
// check status
|
||||
for (int i = 0; i < startedCrawlerNum; i++) {
|
||||
if (!dataCrawlingThreadList.get(i).isRunning() && dataCrawlingThreadStatusList.get(i).equals(Constants.RUNNING)) {
|
||||
if (!dataCrawlingThreadList.get(i).isRunning() && Constants.RUNNING.equals(dataCrawlingThreadStatusList.get(i))) {
|
||||
dataCrawlingThreadList.get(i).awaitTermination();
|
||||
dataCrawlingThreadStatusList.set(i, Constants.DONE);
|
||||
activeCrawlerNum--;
|
||||
|
@ -144,10 +144,10 @@ public class DataIndexHelper {
|
|||
finishedAll = true;
|
||||
for (int i = 0; i < dataCrawlingThreadList.size(); i++) {
|
||||
dataCrawlingThreadList.get(i).awaitTermination(crawlingExecutionInterval);
|
||||
if (!dataCrawlingThreadList.get(i).isRunning() && dataCrawlingThreadStatusList.get(i).equals(Constants.RUNNING)) {
|
||||
if (!dataCrawlingThreadList.get(i).isRunning() && Constants.RUNNING.equals(dataCrawlingThreadStatusList.get(i))) {
|
||||
dataCrawlingThreadStatusList.set(i, Constants.DONE);
|
||||
}
|
||||
if (!dataCrawlingThreadStatusList.get(i).equals(Constants.DONE)) {
|
||||
if (!Constants.DONE.equals(dataCrawlingThreadStatusList.get(i))) {
|
||||
finishedAll = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,26 +198,25 @@ public class DocumentHelper {
|
|||
final Rule rule = ruleManager.getRule(responseData);
|
||||
if (rule == null) {
|
||||
throw new CrawlingAccessException("No url rule for " + url);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
}
|
||||
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 {
|
||||
throw new CrawlingAccessException("The response processor is not DefaultResponseProcessor. responseProcessor: "
|
||||
+ responseProcessor + ", url: " + url);
|
||||
}
|
||||
} else {
|
||||
throw new CrawlingAccessException("The response processor is not DefaultResponseProcessor. responseProcessor: "
|
||||
+ responseProcessor + ", url: " + url);
|
||||
}
|
||||
return null;
|
||||
} catch (final Exception e) {
|
||||
|
|
|
@ -119,16 +119,15 @@ public class IntervalControlHelper {
|
|||
}
|
||||
|
||||
public boolean isTarget(final int hours, final int minutes, final int day) {
|
||||
if (reverse) {
|
||||
if ((compareTime(hours, minutes, toHours, toMinutes) >= 0 && isInDays(day + 1))
|
||||
|| (compareTime(fromHours, fromMinutes, hours, minutes) >= 0 && isInDays(day))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
if (!reverse) {
|
||||
return compareTime(fromHours, fromMinutes, hours, minutes) >= 0 && compareTime(hours, minutes, toHours, toMinutes) >= 0
|
||||
&& isInDays(day);
|
||||
}
|
||||
if ((compareTime(hours, minutes, toHours, toMinutes) >= 0 && isInDays(day + 1))
|
||||
|| (compareTime(fromHours, fromMinutes, hours, minutes) >= 0 && isInDays(day))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isInDays(final int day) {
|
||||
|
@ -152,7 +151,8 @@ public class IntervalControlHelper {
|
|||
protected int compareTime(final int h1, final int m1, final int h2, final int m2) {
|
||||
if (h1 < h2) {
|
||||
return 1;
|
||||
} else if (h1 == h2) {
|
||||
}
|
||||
if (h1 == h2) {
|
||||
if (m1 == m2) {
|
||||
return 0;
|
||||
} else if (m1 < m2) {
|
||||
|
|
|
@ -254,25 +254,7 @@ public class LabelTypeHelper {
|
|||
}
|
||||
|
||||
public boolean match(final String path) {
|
||||
if (includedPaths != null) {
|
||||
if (includedPaths.matcher(path).matches()) {
|
||||
if (excludedPaths != null && excludedPaths.matcher(path).matches()) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Path {} matches the include/exclude path expression {} on {} of label.", path, excludedPaths,
|
||||
value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Path {} matches the include path expression {} on {} of label.", path, excludedPaths, value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Path {} does not match the include path expression {} on {} of label.", path, excludedPaths, value);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
if (includedPaths == null) {
|
||||
if (excludedPaths != null && excludedPaths.matcher(path).matches()) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Path {} matches the exclude path expression {} on {} of label.", path, excludedPaths, value);
|
||||
|
@ -284,6 +266,22 @@ public class LabelTypeHelper {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
if (includedPaths.matcher(path).matches()) {
|
||||
if (excludedPaths != null && excludedPaths.matcher(path).matches()) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Path {} matches the include/exclude path expression {} on {} of label.", path, excludedPaths, value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Path {} matches the include path expression {} on {} of label.", path, excludedPaths, value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Path {} does not match the include path expression {} on {} of label.", path, excludedPaths, value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -153,9 +153,10 @@ public class PathMappingHelper {
|
|||
}
|
||||
|
||||
public BiFunction<String, Matcher, String> createPathMatcher(final Matcher matcher, final String replacement) { // for PathMapping
|
||||
if (replacement.equals(FUNCTION_ENCODEURL_MATCHER)) {
|
||||
if (FUNCTION_ENCODEURL_MATCHER.equals(replacement)) {
|
||||
return (u, m) -> DocumentUtil.encodeUrl(u);
|
||||
} else if (replacement.startsWith(GROOVY_MATCHER)) {
|
||||
}
|
||||
if (replacement.startsWith(GROOVY_MATCHER)) {
|
||||
final String template = replacement.substring(GROOVY_MATCHER.length());
|
||||
return (u, m) -> {
|
||||
final Map<String, Object> paramMap = new HashMap<>();
|
||||
|
|
|
@ -81,7 +81,8 @@ public class PermissionHelper {
|
|||
} else {
|
||||
return null;
|
||||
}
|
||||
} else if (lower.startsWith(groupPrefix)) {
|
||||
}
|
||||
if (lower.startsWith(groupPrefix)) {
|
||||
if (permission.length() > groupPrefix.length()) {
|
||||
return aclPrefix + systemHelper.getSearchRoleByGroup(permission.substring(groupPrefix.length()));
|
||||
} else {
|
||||
|
@ -119,7 +120,8 @@ public class PermissionHelper {
|
|||
if (permission.startsWith(fessConfig.getRoleSearchUserPrefix())
|
||||
&& permission.length() > fessConfig.getRoleSearchUserPrefix().length()) {
|
||||
return aclPrefix + userPrefix + permission.substring(fessConfig.getRoleSearchUserPrefix().length());
|
||||
} else if (permission.startsWith(fessConfig.getRoleSearchGroupPrefix())
|
||||
}
|
||||
if (permission.startsWith(fessConfig.getRoleSearchGroupPrefix())
|
||||
&& permission.length() > fessConfig.getRoleSearchGroupPrefix().length()) {
|
||||
return aclPrefix + groupPrefix + permission.substring(fessConfig.getRoleSearchGroupPrefix().length());
|
||||
} else if (permission.startsWith(fessConfig.getRoleSearchRolePrefix())
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.nio.file.Path;
|
|||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -210,7 +211,7 @@ public class PluginHelper {
|
|||
for (final File file : jarFiles) {
|
||||
list.add(getArtifactFromFileName(artifactType, file.getName()));
|
||||
}
|
||||
list.sort((a, b) -> a.getName().compareTo(b.getName()));
|
||||
list.sort(Comparator.comparing(Artifact::getName));
|
||||
return list.toArray(new Artifact[list.size()]);
|
||||
}
|
||||
|
||||
|
@ -219,7 +220,7 @@ public class PluginHelper {
|
|||
for (final File file : jarFiles) {
|
||||
list.add(getArtifactFromFileName(artifactType, file.getName()));
|
||||
}
|
||||
list.sort((a, b) -> a.getName().compareTo(b.getName()));
|
||||
list.sort(Comparator.comparing(Artifact::getName));
|
||||
return list.toArray(new Artifact[list.size()]);
|
||||
}
|
||||
|
||||
|
@ -262,7 +263,8 @@ public class PluginHelper {
|
|||
final String url = artifact.getUrl();
|
||||
if (StringUtil.isBlank(url)) {
|
||||
throw new PluginException("url is blank: " + artifact.getName());
|
||||
} else if (url.startsWith("http:") || url.startsWith("https:")) {
|
||||
}
|
||||
if (url.startsWith("http:") || url.startsWith("https:")) {
|
||||
try (final CurlResponse response = createCurlRequest(url).execute()) {
|
||||
if (response.getHttpStatusCode() != 200) {
|
||||
throw new PluginException("HTTP Status " + response.getHttpStatusCode() + " : failed to get the artifact from " + url);
|
||||
|
@ -387,7 +389,8 @@ public class PluginHelper {
|
|||
public static ArtifactType getType(final String name) {
|
||||
if (name.startsWith(DATA_STORE.getId())) {
|
||||
return DATA_STORE;
|
||||
} else if (name.startsWith(THEME.getId())) {
|
||||
}
|
||||
if (name.startsWith(THEME.getId())) {
|
||||
return THEME;
|
||||
} else if (name.startsWith(INGEST.getId())) {
|
||||
return INGEST;
|
||||
|
|
|
@ -152,16 +152,15 @@ public class ProcessHelper {
|
|||
|
||||
public void sendCommand(final String sessionId, final String command) {
|
||||
final JobProcess jobProcess = runningProcessMap.get(sessionId);
|
||||
if (jobProcess != null) {
|
||||
try {
|
||||
final OutputStream out = jobProcess.getProcess().getOutputStream();
|
||||
IOUtils.write(command + "\n", out, Constants.CHARSET_UTF_8);
|
||||
out.flush();
|
||||
} catch (final IOException e) {
|
||||
throw new JobProcessingException(e);
|
||||
}
|
||||
} else {
|
||||
if (jobProcess == null) {
|
||||
throw new JobNotFoundException("Job for " + sessionId + " is not found.");
|
||||
}
|
||||
try {
|
||||
final OutputStream out = jobProcess.getProcess().getOutputStream();
|
||||
IOUtils.write(command + "\n", out, Constants.CHARSET_UTF_8);
|
||||
out.flush();
|
||||
} catch (final IOException e) {
|
||||
throw new JobProcessingException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -427,7 +427,8 @@ public class QueryHelper {
|
|||
protected QueryBuilder convertQuery(final QueryContext context, final Query query, final float boost) {
|
||||
if (query instanceof TermQuery) {
|
||||
return convertTermQuery(context, (TermQuery) query, boost);
|
||||
} else if (query instanceof TermRangeQuery) {
|
||||
}
|
||||
if (query instanceof TermRangeQuery) {
|
||||
return convertTermRangeQuery(context, (TermRangeQuery) query, boost);
|
||||
} else if (query instanceof PhraseQuery) {
|
||||
return convertPhraseQuery(context, (PhraseQuery) query, boost);
|
||||
|
@ -496,7 +497,8 @@ public class QueryHelper {
|
|||
context.addFieldLog(field, wildcardQuery.getTerm().text());
|
||||
return buildDefaultQueryBuilder(
|
||||
(f, b) -> QueryBuilders.wildcardQuery(f, toLowercaseWildcard(wildcardQuery.getTerm().text())).boost(b * boost));
|
||||
} else if (isSearchField(field)) {
|
||||
}
|
||||
if (isSearchField(field)) {
|
||||
context.addFieldLog(field, wildcardQuery.getTerm().text());
|
||||
return QueryBuilders.wildcardQuery(field, toLowercaseWildcard(wildcardQuery.getTerm().text())).boost(boost);
|
||||
} else {
|
||||
|
@ -514,7 +516,8 @@ public class QueryHelper {
|
|||
context.addFieldLog(field, prefixQuery.getPrefix().text());
|
||||
return buildDefaultQueryBuilder((f, b) -> QueryBuilders
|
||||
.matchPhrasePrefixQuery(f, toLowercaseWildcard(prefixQuery.getPrefix().text())).boost(b * boost));
|
||||
} else if (isSearchField(field)) {
|
||||
}
|
||||
if (isSearchField(field)) {
|
||||
context.addFieldLog(field, prefixQuery.getPrefix().text());
|
||||
if (notAnalyzedFieldSet.contains(field)) {
|
||||
return QueryBuilders.prefixQuery(field, toLowercaseWildcard(prefixQuery.getPrefix().text())).boost(boost);
|
||||
|
@ -538,7 +541,8 @@ public class QueryHelper {
|
|||
context.addFieldLog(field, term.text());
|
||||
return buildDefaultQueryBuilder((f, b) -> QueryBuilders.fuzzyQuery(f, term.text())
|
||||
.fuzziness(Fuzziness.fromEdits(fuzzyQuery.getMaxEdits())).boost(b * boost));
|
||||
} else if (isSearchField(field)) {
|
||||
}
|
||||
if (isSearchField(field)) {
|
||||
context.addFieldLog(field, term.text());
|
||||
return QueryBuilders.fuzzyQuery(field, term.text()).boost(boost).fuzziness(Fuzziness.fromEdits(fuzzyQuery.getMaxEdits()));
|
||||
} else {
|
||||
|
@ -552,33 +556,32 @@ public class QueryHelper {
|
|||
|
||||
protected QueryBuilder convertTermRangeQuery(final QueryContext context, final TermRangeQuery termRangeQuery, final float boost) {
|
||||
final String field = getSearchField(context, termRangeQuery.getField());
|
||||
if (isSearchField(field)) {
|
||||
context.addFieldLog(field, termRangeQuery.toString(field));
|
||||
final RangeQueryBuilder rangeQuery = QueryBuilders.rangeQuery(field);
|
||||
final BytesRef min = termRangeQuery.getLowerTerm();
|
||||
if (min != null) {
|
||||
if (termRangeQuery.includesLower()) {
|
||||
rangeQuery.gte(min.utf8ToString());
|
||||
} else {
|
||||
rangeQuery.gt(min.utf8ToString());
|
||||
}
|
||||
}
|
||||
final BytesRef max = termRangeQuery.getUpperTerm();
|
||||
if (max != null) {
|
||||
if (termRangeQuery.includesUpper()) {
|
||||
rangeQuery.lte(max.utf8ToString());
|
||||
} else {
|
||||
rangeQuery.lt(max.utf8ToString());
|
||||
}
|
||||
}
|
||||
rangeQuery.boost(boost);
|
||||
return rangeQuery;
|
||||
} else {
|
||||
if (!isSearchField(field)) {
|
||||
final String origQuery = termRangeQuery.toString();
|
||||
context.addFieldLog(Constants.DEFAULT_FIELD, origQuery);
|
||||
context.addHighlightedQuery(origQuery);
|
||||
return buildDefaultQueryBuilder((f, b) -> QueryBuilders.matchPhraseQuery(f, origQuery).boost(b));
|
||||
}
|
||||
context.addFieldLog(field, termRangeQuery.toString(field));
|
||||
final RangeQueryBuilder rangeQuery = QueryBuilders.rangeQuery(field);
|
||||
final BytesRef min = termRangeQuery.getLowerTerm();
|
||||
if (min != null) {
|
||||
if (termRangeQuery.includesLower()) {
|
||||
rangeQuery.gte(min.utf8ToString());
|
||||
} else {
|
||||
rangeQuery.gt(min.utf8ToString());
|
||||
}
|
||||
}
|
||||
final BytesRef max = termRangeQuery.getUpperTerm();
|
||||
if (max != null) {
|
||||
if (termRangeQuery.includesUpper()) {
|
||||
rangeQuery.lte(max.utf8ToString());
|
||||
} else {
|
||||
rangeQuery.lt(max.utf8ToString());
|
||||
}
|
||||
}
|
||||
rangeQuery.boost(boost);
|
||||
return rangeQuery;
|
||||
}
|
||||
|
||||
protected QueryBuilder buildMatchPhraseQuery(final String f, final String text) {
|
||||
|
@ -605,7 +608,8 @@ public class QueryHelper {
|
|||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
if (fessConfig.getQueryReplaceTermWithPrefixQueryAsBoolean() && text.length() > 1 && text.endsWith("*")) {
|
||||
return convertPrefixQuery(context, new PrefixQuery(new Term(field, text.substring(0, text.length() - 1))), boost);
|
||||
} else if (Constants.DEFAULT_FIELD.equals(field)) {
|
||||
}
|
||||
if (Constants.DEFAULT_FIELD.equals(field)) {
|
||||
context.addFieldLog(field, text);
|
||||
context.addHighlightedQuery(text);
|
||||
return buildDefaultTermQueryBuilder(boost, text);
|
||||
|
@ -800,7 +804,8 @@ public class QueryHelper {
|
|||
final Object accessType = r.getAttribute(Constants.SEARCH_LOG_ACCESS_TYPE);
|
||||
if (Constants.SEARCH_LOG_ACCESS_TYPE_JSON.equals(accessType)) {
|
||||
return processJsonSearchPreference(r, query);
|
||||
} else if (Constants.SEARCH_LOG_ACCESS_TYPE_GSA.equals(accessType)) {
|
||||
}
|
||||
if (Constants.SEARCH_LOG_ACCESS_TYPE_GSA.equals(accessType)) {
|
||||
return processGsaSearchPreference(r, query);
|
||||
}
|
||||
return null;
|
||||
|
@ -811,7 +816,8 @@ public class QueryHelper {
|
|||
final String pref = ComponentUtil.getFessConfig().getQueryJsonDefaultPreference();
|
||||
if (PREFERENCE_QUERY.equals(pref)) {
|
||||
return Integer.toString(query.hashCode());
|
||||
} else if (StringUtil.isNotBlank(pref)) {
|
||||
}
|
||||
if (StringUtil.isNotBlank(pref)) {
|
||||
return pref;
|
||||
}
|
||||
return null;
|
||||
|
@ -821,7 +827,8 @@ public class QueryHelper {
|
|||
final String pref = ComponentUtil.getFessConfig().getQueryGsaDefaultPreference();
|
||||
if (PREFERENCE_QUERY.equals(pref)) {
|
||||
return Integer.toString(query.hashCode());
|
||||
} else if (StringUtil.isNotBlank(pref)) {
|
||||
}
|
||||
if (StringUtil.isNotBlank(pref)) {
|
||||
return pref;
|
||||
}
|
||||
return null;
|
||||
|
@ -961,9 +968,8 @@ public class QueryHelper {
|
|||
protected SortBuilder<?> createFieldSortBuilder(final String field, final SortOrder order) {
|
||||
if (SCORE_FIELD.equals(field) || ES_SCORE_FIELD.equals(field)) {
|
||||
return SortBuilders.scoreSort().order(order);
|
||||
} else {
|
||||
return SortBuilders.fieldSort(field).order(order);
|
||||
}
|
||||
return SortBuilders.fieldSort(field).order(order);
|
||||
}
|
||||
|
||||
public void setHighlightPrefix(final String highlightPrefix) {
|
||||
|
|
|
@ -68,7 +68,8 @@ public class SambaHelper {
|
|||
final Integer id = fessConfig.getAvailableSmbSidType(type);
|
||||
if (id != null) {
|
||||
return createSearchRole(id, sid.getAccountName());
|
||||
} else if (logger.isDebugEnabled()) {
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Ignored SID: {} {}", type, sid);
|
||||
}
|
||||
return null;
|
||||
|
@ -86,7 +87,8 @@ public class SambaHelper {
|
|||
final Integer id = fessConfig.getAvailableSmbSidType(type);
|
||||
if (id != null) {
|
||||
return createSearchRole(id, sid.getAccountName());
|
||||
} else if (logger.isDebugEnabled()) {
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Ignored SID: {} {}", type, sid);
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -263,7 +263,8 @@ public class SearchHelper {
|
|||
langSet.remove(Constants.ALL_LANGUAGES);
|
||||
}
|
||||
return langSet.toArray(new String[langSet.size()]);
|
||||
} else if (ComponentUtil.getFessConfig().isBrowserLocaleForSearchUsed()) {
|
||||
}
|
||||
if (ComponentUtil.getFessConfig().isBrowserLocaleForSearchUsed()) {
|
||||
final Set<String> langSet = new HashSet<>();
|
||||
final Enumeration<Locale> locales = request.getLocales();
|
||||
if (locales != null) {
|
||||
|
@ -346,9 +347,8 @@ public class SearchHelper {
|
|||
final BulkResponse response = builder.execute().get();
|
||||
if (response.hasFailures()) {
|
||||
throw new SearchEngineClientException(response.buildFailureMessage());
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
throw new SearchEngineClientException("Failed to update bulk data.", e);
|
||||
}
|
||||
|
|
|
@ -214,11 +214,10 @@ public class SystemHelper {
|
|||
final String value = System.getProperty("fess.log.path");
|
||||
if (value != null) {
|
||||
return value;
|
||||
} else {
|
||||
final String userDir = System.getProperty("user.dir");
|
||||
final File targetDir = new File(userDir, "target");
|
||||
return new File(targetDir, "logs").getAbsolutePath();
|
||||
}
|
||||
final String userDir = System.getProperty("user.dir");
|
||||
final File targetDir = new File(userDir, "target");
|
||||
return new File(targetDir, "logs").getAbsolutePath();
|
||||
}
|
||||
|
||||
public String encodeUrlFilter(final String path) {
|
||||
|
@ -324,7 +323,7 @@ public class SystemHelper {
|
|||
public void refreshDesignJspFiles() {
|
||||
final ServletContext servletContext = LaServletContextUtil.getServletContext();
|
||||
stream(ComponentUtil.getVirtualHostHelper().getVirtualHostPaths())
|
||||
.of(stream -> stream.filter(s -> s != null && !s.equals("/")).forEach(key -> {
|
||||
.of(stream -> stream.filter(s -> s != null && !"/".equals(s)).forEach(key -> {
|
||||
designJspFileNameMap.entrySet().stream().forEach(e -> {
|
||||
final File jspFile = new File(servletContext.getRealPath("/WEB-INF/view" + key + "/" + e.getValue()));
|
||||
if (!jspFile.exists()) {
|
||||
|
@ -403,7 +402,8 @@ public class SystemHelper {
|
|||
final Map<String, String> env = getEnvMap();
|
||||
if (env.containsKey("COMPUTERNAME")) {
|
||||
return env.get("COMPUTERNAME");
|
||||
} else if (env.containsKey("HOSTNAME")) {
|
||||
}
|
||||
if (env.containsKey("HOSTNAME")) {
|
||||
return env.get("HOSTNAME");
|
||||
}
|
||||
try {
|
||||
|
@ -591,7 +591,7 @@ public class SystemHelper {
|
|||
public Map<String, String> getFilteredEnvMap(final String keyPattern) {
|
||||
final Pattern pattern = Pattern.compile(keyPattern);
|
||||
return getEnvMap().entrySet().stream().filter(e -> {
|
||||
String key = e.getKey();
|
||||
final String key = e.getKey();
|
||||
if (StringUtil.isBlank(key)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -433,10 +433,8 @@ public class ViewHelper {
|
|||
}
|
||||
|
||||
final String mimetype = DocumentUtil.getValue(document, fessConfig.getIndexFieldMimetype(), String.class);
|
||||
if (StringUtil.isNotBlank(mimetype)) {
|
||||
if ("application/pdf".equals(mimetype)) {
|
||||
return appendPDFSearchWord(url);
|
||||
}
|
||||
if (StringUtil.isNotBlank(mimetype) && "application/pdf".equals(mimetype)) {
|
||||
return appendPDFSearchWord(url);
|
||||
}
|
||||
}
|
||||
return url;
|
||||
|
@ -608,9 +606,8 @@ public class ViewHelper {
|
|||
final int size = fessConfig.getResponseMaxSitePathLengthAsInteger();
|
||||
if (size > -1) {
|
||||
return StringUtils.abbreviate(site, size);
|
||||
} else {
|
||||
return site;
|
||||
}
|
||||
return site;
|
||||
}
|
||||
final Object urlLink = docMap.get(fessConfig.getResponseFieldUrlLink());
|
||||
if (urlLink != null) {
|
||||
|
@ -626,9 +623,8 @@ public class ViewHelper {
|
|||
final int size = fessConfig.getResponseMaxSitePathLengthAsInteger();
|
||||
if (size > -1) {
|
||||
return StringUtils.abbreviate(returnUrl, size);
|
||||
} else {
|
||||
return returnUrl;
|
||||
}
|
||||
return returnUrl;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -746,9 +742,8 @@ public class ViewHelper {
|
|||
final String value = request.getHeader("x-forwarded-for");
|
||||
if (StringUtil.isNotBlank(value)) {
|
||||
return value;
|
||||
} else {
|
||||
return request.getRemoteAddr();
|
||||
}
|
||||
return request.getRemoteAddr();
|
||||
}
|
||||
|
||||
public FacetResponse getCachedFacetResponse(final String query) {
|
||||
|
|
|
@ -373,7 +373,7 @@ public class WebFsIndexHelper {
|
|||
// check status
|
||||
for (int i = 0; i < startedCrawlerNum; i++) {
|
||||
if (crawlerList.get(i).getCrawlerContext().getStatus() == CrawlerStatus.DONE
|
||||
&& crawlerStatusList.get(i).equals(Constants.RUNNING)) {
|
||||
&& Constants.RUNNING.equals(crawlerStatusList.get(i))) {
|
||||
crawlerList.get(i).awaitTermination();
|
||||
crawlerStatusList.set(i, Constants.DONE);
|
||||
final String sid = crawlerList.get(i).getCrawlerContext().getSessionId();
|
||||
|
@ -390,12 +390,12 @@ public class WebFsIndexHelper {
|
|||
for (int i = 0; i < crawlerList.size(); i++) {
|
||||
crawlerList.get(i).awaitTermination(crawlingExecutionInterval);
|
||||
if (crawlerList.get(i).getCrawlerContext().getStatus() == CrawlerStatus.DONE
|
||||
&& !crawlerStatusList.get(i).equals(Constants.DONE)) {
|
||||
&& !Constants.DONE.equals(crawlerStatusList.get(i))) {
|
||||
crawlerStatusList.set(i, Constants.DONE);
|
||||
final String sid = crawlerList.get(i).getCrawlerContext().getSessionId();
|
||||
indexUpdater.addFinishedSessionId(sid);
|
||||
}
|
||||
if (!crawlerStatusList.get(i).equals(Constants.DONE)) {
|
||||
if (!Constants.DONE.equals(crawlerStatusList.get(i))) {
|
||||
finishedAll = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,8 @@ public class DocBoostMatcher {
|
|||
final Object value = GroovyUtil.evaluate(boostExpression, map);
|
||||
if (value instanceof Integer) {
|
||||
return ((Integer) value).floatValue();
|
||||
} else if (value instanceof Long) {
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
return ((Long) value).floatValue();
|
||||
} else if (value instanceof Float) {
|
||||
return ((Float) value);
|
||||
|
|
|
@ -362,9 +362,8 @@ public class IndexUpdater extends Thread {
|
|||
logger.debug("Skipped. This document is not a index target. ");
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
map.remove(Constants.INDEXING_TARGET);
|
||||
}
|
||||
map.remove(Constants.INDEXING_TARGET);
|
||||
|
||||
updateDocument(map);
|
||||
|
||||
|
|
|
@ -253,7 +253,7 @@ public class CrawlJob extends ExecJob {
|
|||
|
||||
final String systemLastaEnv = System.getProperty("lasta.env");
|
||||
if (StringUtil.isNotBlank(systemLastaEnv)) {
|
||||
if (systemLastaEnv.equals("web")) {
|
||||
if ("web".equals(systemLastaEnv)) {
|
||||
cmdList.add("-Dlasta.env=" + getExecuteType());
|
||||
} else {
|
||||
cmdList.add("-Dlasta.env=" + systemLastaEnv);
|
||||
|
@ -274,7 +274,7 @@ public class CrawlJob extends ExecJob {
|
|||
addSystemProperty(cmdList, "fess.log.level", null, null);
|
||||
} else {
|
||||
cmdList.add("-Dfess.log.level=" + logLevel);
|
||||
if (logLevel.equalsIgnoreCase("debug")) {
|
||||
if ("debug".equalsIgnoreCase(logLevel)) {
|
||||
cmdList.add("-Dorg.apache.tika.service.error.warn=true");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ public class GenerateThumbnailJob extends ExecJob {
|
|||
|
||||
final String systemLastaEnv = System.getProperty("lasta.env");
|
||||
if (StringUtil.isNotBlank(systemLastaEnv)) {
|
||||
if (systemLastaEnv.equals("web")) {
|
||||
if ("web".equals(systemLastaEnv)) {
|
||||
cmdList.add("-Dlasta.env=" + getExecuteType());
|
||||
} else {
|
||||
cmdList.add("-Dlasta.env=" + systemLastaEnv);
|
||||
|
|
|
@ -137,7 +137,7 @@ public class SuggestJob extends ExecJob {
|
|||
|
||||
final String systemLastaEnv = System.getProperty("lasta.env");
|
||||
if (StringUtil.isNotBlank(systemLastaEnv)) {
|
||||
if (systemLastaEnv.equals("web")) {
|
||||
if ("web".equals(systemLastaEnv)) {
|
||||
cmdList.add("-Dlasta.env=" + getExecuteType());
|
||||
} else {
|
||||
cmdList.add("-Dlasta.env=" + systemLastaEnv);
|
||||
|
|
|
@ -1024,13 +1024,12 @@ public class LdapManager {
|
|||
final Supplier<Hashtable<String, String>> adminEnv = this::createAdminEnv;
|
||||
final String userDN = fessConfig.getLdapAdminUserSecurityPrincipal(username);
|
||||
search(fessConfig.getLdapAdminUserBaseDn(), fessConfig.getLdapAdminUserFilter(username), null, adminEnv, result -> {
|
||||
if (!result.isEmpty()) {
|
||||
final List<ModificationItem> modifyList = new ArrayList<>();
|
||||
modifyReplaceEntry(modifyList, "userPassword", password);
|
||||
modify(userDN, modifyList, adminEnv);
|
||||
} else {
|
||||
if (result.isEmpty()) {
|
||||
throw new LdapOperationException("User is not found: " + username);
|
||||
}
|
||||
final List<ModificationItem> modifyList = new ArrayList<>();
|
||||
modifyReplaceEntry(modifyList, "userPassword", password);
|
||||
modify(userDN, modifyList, adminEnv);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
@ -1108,19 +1107,18 @@ public class LdapManager {
|
|||
|
||||
protected DirContextHolder getDirContext(final Supplier<Hashtable<String, String>> envSupplier) {
|
||||
DirContextHolder holder = contextLocal.get();
|
||||
if (holder == null) {
|
||||
final Hashtable<String, String> env = envSupplier.get();
|
||||
try {
|
||||
holder = new DirContextHolder(new InitialDirContext(env));
|
||||
contextLocal.set(holder);
|
||||
return holder;
|
||||
} catch (final NamingException e) {
|
||||
throw new LdapOperationException("Failed to create DirContext.", e);
|
||||
}
|
||||
} else {
|
||||
if (holder != null) {
|
||||
holder.inc();
|
||||
return holder;
|
||||
}
|
||||
final Hashtable<String, String> env = envSupplier.get();
|
||||
try {
|
||||
holder = new DirContextHolder(new InitialDirContext(env));
|
||||
contextLocal.set(holder);
|
||||
return holder;
|
||||
} catch (final NamingException e) {
|
||||
throw new LdapOperationException("Failed to create DirContext.", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected class DirContextHolder implements AutoCloseable {
|
||||
|
|
|
@ -325,7 +325,7 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
/** The key of the configuration. e.g. file,smb,smb1,ftp,storage */
|
||||
String CRAWLER_FILE_PROTOCOLS = "crawler.file.protocols";
|
||||
|
||||
/** The key of the configuration. e.g. ^FESS_ENV_ */
|
||||
/** The key of the configuration. e.g. ^FESS_ENV_.* */
|
||||
String CRAWLER_DATA_ENV_PARAM_KEY_PATTERN = "crawler.data.env.param.key.pattern";
|
||||
|
||||
/** The key of the configuration. e.g. false */
|
||||
|
@ -2522,7 +2522,7 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
|
||||
/**
|
||||
* Get the value for the key 'crawler.data.env.param.key.pattern'. <br>
|
||||
* The value is, e.g. ^FESS_ENV_ <br>
|
||||
* The value is, e.g. ^FESS_ENV_.* <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
*/
|
||||
String getCrawlerDataEnvParamKeyPattern();
|
||||
|
@ -9864,7 +9864,7 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
defaultMap.put(FessConfig.CRAWLER_CRAWLING_DATA_ENCODING, "UTF-8");
|
||||
defaultMap.put(FessConfig.CRAWLER_WEB_PROTOCOLS, "http,https");
|
||||
defaultMap.put(FessConfig.CRAWLER_FILE_PROTOCOLS, "file,smb,smb1,ftp,storage");
|
||||
defaultMap.put(FessConfig.CRAWLER_DATA_ENV_PARAM_KEY_PATTERN, "^FESS_ENV_");
|
||||
defaultMap.put(FessConfig.CRAWLER_DATA_ENV_PARAM_KEY_PATTERN, "^FESS_ENV_.*");
|
||||
defaultMap.put(FessConfig.CRAWLER_IGNORE_ROBOTS_TXT, "false");
|
||||
defaultMap.put(FessConfig.CRAWLER_IGNORE_ROBOTS_TAGS, "false");
|
||||
defaultMap.put(FessConfig.CRAWLER_IGNORE_CONTENT_EXCEPTION, "true");
|
||||
|
|
|
@ -163,9 +163,8 @@ public class FessFwAssistantDirector extends CachedFwAssistantDirector {
|
|||
protected String getShowErrorsForwardPath(final ActionRuntime runtime) {
|
||||
if (FessAdminAction.class.isAssignableFrom(runtime.getActionType())) {
|
||||
return "/admin/error/error.jsp";
|
||||
} else {
|
||||
return "/error/system.jsp";
|
||||
}
|
||||
return "/error/system.jsp";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ public interface FessProp {
|
|||
final String value = getSystemProperty(key);
|
||||
if (value != null) {
|
||||
try {
|
||||
return Integer.valueOf(value);
|
||||
return Integer.parseInt(value);
|
||||
} catch (final NumberFormatException e) {
|
||||
// ignore
|
||||
}
|
||||
|
@ -223,7 +223,8 @@ public interface FessProp {
|
|||
final String[] pair = s.split("=");
|
||||
if (pair.length == 1) {
|
||||
return new Pair<>(StringUtil.EMPTY, pair[0].trim());
|
||||
} else if (pair.length == 2) {
|
||||
}
|
||||
if (pair.length == 2) {
|
||||
String sortValue = pair[1].trim();
|
||||
if (StringUtil.isBlank(sortValue) || "score".equals(sortValue)) {
|
||||
sortValue = "score.desc";
|
||||
|
@ -241,8 +242,8 @@ public interface FessProp {
|
|||
return p.getSecond();
|
||||
}
|
||||
if (userBean
|
||||
.map(user -> stream(user.getRoles()).get(stream -> stream.anyMatch(s -> key.equals(ROLE_VALUE_PREFIX + s)))
|
||||
|| stream(user.getGroups()).get(stream -> stream.anyMatch(s -> key.equals(GROUP_VALUE_PREFIX + s))))
|
||||
.map(user -> stream(user.getRoles()).get(stream -> stream.anyMatch(s -> (ROLE_VALUE_PREFIX + s).equals(key)))
|
||||
|| stream(user.getGroups()).get(stream -> stream.anyMatch(s -> (GROUP_VALUE_PREFIX + s).equals(key))))
|
||||
.orElse(false)) {
|
||||
return p.getSecond();
|
||||
}
|
||||
|
@ -272,7 +273,8 @@ public interface FessProp {
|
|||
final String[] pair = s.split("=");
|
||||
if (pair.length == 1) {
|
||||
return new Pair<>(StringUtil.EMPTY, pair[0].trim());
|
||||
} else if (pair.length == 2) {
|
||||
}
|
||||
if (pair.length == 2) {
|
||||
return new Pair<>(pair[0].trim(), pair[1].trim());
|
||||
}
|
||||
return null;
|
||||
|
@ -287,8 +289,8 @@ public interface FessProp {
|
|||
return e.getValue().stream();
|
||||
}
|
||||
if (userBean
|
||||
.map(user -> stream(user.getRoles()).get(stream -> stream.anyMatch(s -> key.equals(ROLE_VALUE_PREFIX + s)))
|
||||
|| stream(user.getGroups()).get(stream -> stream.anyMatch(s -> key.equals(GROUP_VALUE_PREFIX + s))))
|
||||
.map(user -> stream(user.getRoles()).get(stream -> stream.anyMatch(s -> (ROLE_VALUE_PREFIX + s).equals(key)))
|
||||
|| stream(user.getGroups()).get(stream -> stream.anyMatch(s -> (GROUP_VALUE_PREFIX + s).equals(key))))
|
||||
.orElse(false)) {
|
||||
return e.getValue().stream();
|
||||
}
|
||||
|
@ -836,7 +838,8 @@ public interface FessProp {
|
|||
if (v.length == 1) {
|
||||
final int x = DfTypeUtil.toInteger(v[0].trim());
|
||||
return new Pair<>(x, x);
|
||||
} else if (v.length == 2) {
|
||||
}
|
||||
if (v.length == 2) {
|
||||
final int x = DfTypeUtil.toInteger(v[0].trim());
|
||||
final int y = DfTypeUtil.toInteger(v[1].trim());
|
||||
return new Pair<>(x, y);
|
||||
|
@ -902,7 +905,8 @@ public interface FessProp {
|
|||
default String getJobTemplateTitle(final String type) {
|
||||
if (Constants.WEB_CRAWLER_TYPE.equals(type)) {
|
||||
return getJobTemplateTitleWeb();
|
||||
} else if (Constants.FILE_CRAWLER_TYPE.equals(type)) {
|
||||
}
|
||||
if (Constants.FILE_CRAWLER_TYPE.equals(type)) {
|
||||
return getJobTemplateTitleFile();
|
||||
} else if (Constants.DATA_CRAWLER_TYPE.equals(type)) {
|
||||
return getJobTemplateTitleData();
|
||||
|
@ -953,7 +957,8 @@ public interface FessProp {
|
|||
final String[] subValues = values[1].split(":", 3);
|
||||
if (subValues.length == 3) {
|
||||
return new Tuple4<>(values[0], subValues[0], subValues[1], subValues[2]);
|
||||
} else if (subValues.length == 2) {
|
||||
}
|
||||
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);
|
||||
|
@ -988,7 +993,7 @@ public interface FessProp {
|
|||
String getQueryReplaceTermWithPrefixQuery();
|
||||
|
||||
default boolean getQueryReplaceTermWithPrefixQueryAsBoolean() {
|
||||
return Boolean.valueOf(getQueryReplaceTermWithPrefixQuery());
|
||||
return Boolean.parseBoolean(getQueryReplaceTermWithPrefixQuery());
|
||||
}
|
||||
|
||||
String getQueryDefaultLanguages();
|
||||
|
@ -1664,10 +1669,9 @@ public interface FessProp {
|
|||
final SortBuilder[] sortBuilders = split(sorts, ",").get(stream -> stream.filter(StringUtil::isNotBlank).map(s -> {
|
||||
final String[] values = s.split(":");
|
||||
if (values.length > 1) {
|
||||
return SortBuilders.fieldSort(values[0]).order(values[0].equalsIgnoreCase("desc") ? SortOrder.DESC : SortOrder.ASC);
|
||||
} else {
|
||||
return SortBuilders.fieldSort(values[0]).order(SortOrder.ASC);
|
||||
return SortBuilders.fieldSort(values[0]).order("desc".equalsIgnoreCase(values[0]) ? SortOrder.DESC : SortOrder.ASC);
|
||||
}
|
||||
return SortBuilders.fieldSort(values[0]).order(SortOrder.ASC);
|
||||
}).toArray(n -> new SortBuilder[n]));
|
||||
ot = OptionalThing.of(sortBuilders);
|
||||
}
|
||||
|
@ -1854,7 +1858,8 @@ public interface FessProp {
|
|||
final String[] values = name.split("\\\\");
|
||||
if (values.length == 0) {
|
||||
return null;
|
||||
} else if (values.length == 1) {
|
||||
}
|
||||
if (values.length == 1) {
|
||||
return values[0];
|
||||
}
|
||||
return String.join("\\", Arrays.copyOfRange(values, 1, values.length));
|
||||
|
|
|
@ -50,9 +50,8 @@ public class FessApiFailureHook implements ApiFailureHook { // #change_it for ha
|
|||
public ApiResponse handleApplicationException(final ApiFailureResource resource, final RuntimeException cause) {
|
||||
if (cause instanceof LoginUnauthorizedException) {
|
||||
return asJson(createFailureBean(Status.UNAUTHORIZED, "Unauthorized request.")).httpStatus(HTTP_UNAUTHORIZED);
|
||||
} else {
|
||||
return asJson(createFailureBean(Status.BAD_REQUEST, createMessage(resource, cause))).httpStatus(HTTP_BAD_REQUEST);
|
||||
}
|
||||
return asJson(createFailureBean(Status.BAD_REQUEST, createMessage(resource, cause))).httpStatus(HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
|
|
|
@ -366,9 +366,8 @@ public class FessMultipartRequestHandler implements MultipartRequestHandler {
|
|||
final int backslashIndex = fileName.lastIndexOf('\\');
|
||||
if (colonIndex > -1 && backslashIndex > -1) {
|
||||
return fileName.substring(backslashIndex + 1);
|
||||
} else {
|
||||
return fileName;
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -205,11 +205,10 @@ public class AzureAdAuthenticator implements SsoAuthenticator {
|
|||
validateNonce(stateData, authData);
|
||||
|
||||
return new AzureAdCredential(authData);
|
||||
} else {
|
||||
final AuthenticationErrorResponse oidcResponse = (AuthenticationErrorResponse) authResponse;
|
||||
throw new SsoLoginException(String.format("Request for auth code failed: %s - %s", oidcResponse.getErrorObject().getCode(),
|
||||
oidcResponse.getErrorObject().getDescription()));
|
||||
}
|
||||
final AuthenticationErrorResponse oidcResponse = (AuthenticationErrorResponse) authResponse;
|
||||
throw new SsoLoginException(String.format("Request for auth code failed: %s - %s", oidcResponse.getErrorObject().getCode(),
|
||||
oidcResponse.getErrorObject().getDescription()));
|
||||
}
|
||||
|
||||
protected AuthenticationResponse parseAuthenticationResponse(final String url, final Map<String, List<String>> params) {
|
||||
|
@ -344,7 +343,7 @@ public class AzureAdAuthenticator implements SsoAuthenticator {
|
|||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("HTTP Method: {}", request.getMethod());
|
||||
}
|
||||
if (!request.getMethod().equalsIgnoreCase("POST")) {
|
||||
if (!"POST".equalsIgnoreCase(request.getMethod())) {
|
||||
return false;
|
||||
}
|
||||
final Map<String, String[]> params = request.getParameterMap();
|
||||
|
@ -510,21 +509,19 @@ public class AzureAdAuthenticator implements SsoAuthenticator {
|
|||
final String value = ComponentUtil.getFessConfig().getSystemProperty("aad.default.groups");
|
||||
if (StringUtil.isBlank(value)) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
return split(value, ",").get(stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).collect(Collectors.toList()));
|
||||
}
|
||||
return split(value, ",").get(stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
protected List<String> getDefaultRoleList() {
|
||||
final String value = ComponentUtil.getFessConfig().getSystemProperty("aad.default.roles");
|
||||
if (StringUtil.isBlank(value)) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
return split(value, ",").get(stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).collect(Collectors.toList()));
|
||||
}
|
||||
return split(value, ",").get(stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
protected class StateData {
|
||||
protected static class StateData {
|
||||
private final String nonce;
|
||||
private final long expiration;
|
||||
|
||||
|
|
|
@ -232,18 +232,17 @@ public class SamlAuthenticator implements SsoAuthenticator {
|
|||
settings.setSPValidationOnly(true);
|
||||
final String metadata = settings.getSPMetadata();
|
||||
final List<String> errors = Saml2Settings.validateMetadata(metadata);
|
||||
if (errors.isEmpty()) {
|
||||
return new StreamResponse("metadata").contentType("application/xhtml+xml").stream(out -> {
|
||||
try (final Writer writer = new OutputStreamWriter(out.stream(), Constants.UTF_8_CHARSET)) {
|
||||
writer.write(metadata);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (!errors.isEmpty()) {
|
||||
final String msg = errors.stream().collect(Collectors.joining(", "));
|
||||
throw new SsoMessageException(
|
||||
messages -> messages.addErrorsFailedToProcessSsoRequest(UserMessages.GLOBAL_PROPERTY_KEY, msg),
|
||||
"Failed to log out.", new SsoProcessException(msg));
|
||||
}
|
||||
return new StreamResponse("metadata").contentType("application/xhtml+xml").stream(out -> {
|
||||
try (final Writer writer = new OutputStreamWriter(out.stream(), Constants.UTF_8_CHARSET)) {
|
||||
writer.write(metadata);
|
||||
}
|
||||
});
|
||||
} catch (final SsoMessageException e) {
|
||||
throw e;
|
||||
} catch (final Exception e) {
|
||||
|
@ -268,12 +267,11 @@ public class SamlAuthenticator implements SsoAuthenticator {
|
|||
final List<String> errors = auth.getErrors();
|
||||
if (errors.isEmpty()) {
|
||||
throw new SsoMessageException(messages -> messages.addSuccessSsoLogout(UserMessages.GLOBAL_PROPERTY_KEY), "Logged out");
|
||||
} else {
|
||||
final String msg = errors.stream().collect(Collectors.joining(", "));
|
||||
throw new SsoMessageException(
|
||||
messages -> messages.addErrorsFailedToProcessSsoRequest(UserMessages.GLOBAL_PROPERTY_KEY, msg),
|
||||
"Failed to log out.", new SsoProcessException(msg));
|
||||
}
|
||||
final String msg = errors.stream().collect(Collectors.joining(", "));
|
||||
throw new SsoMessageException(
|
||||
messages -> messages.addErrorsFailedToProcessSsoRequest(UserMessages.GLOBAL_PROPERTY_KEY, msg),
|
||||
"Failed to log out.", new SsoProcessException(msg));
|
||||
} catch (final SsoMessageException e) {
|
||||
throw e;
|
||||
} catch (final Exception e) {
|
||||
|
|
|
@ -188,7 +188,8 @@ public class SpnegoAuthenticator implements SsoAuthenticator {
|
|||
} else {
|
||||
return "0";
|
||||
}
|
||||
} else if (SpnegoHttpFilter.Constants.LOGIN_CONF.equals(name)) {
|
||||
}
|
||||
if (SpnegoHttpFilter.Constants.LOGIN_CONF.equals(name)) {
|
||||
return getResourcePath(getProperty(SPNEGO_LOGIN_CONF, "auth_login.conf"));
|
||||
} else if (SpnegoHttpFilter.Constants.KRB5_CONF.equals(name)) {
|
||||
return getResourcePath(getProperty(SPNEGO_KRB5_CONF, "krb5.conf"));
|
||||
|
|
|
@ -209,14 +209,13 @@ public class ThumbnailManager {
|
|||
cb.fetchFirst(fessConfig.getPageThumbnailQueueMaxFetchSizeAsInteger());
|
||||
}).stream().map(entity -> {
|
||||
idList.add(entity.getId());
|
||||
if (cleanup) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Removing thumbnail queue: {}", entity);
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
if (!cleanup) {
|
||||
return executorService.submit(() -> process(fessConfig, entity));
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Removing thumbnail queue: {}", entity);
|
||||
}
|
||||
return null;
|
||||
}).filter(f -> f != null).forEach(f -> {
|
||||
try {
|
||||
f.get();
|
||||
|
|
|
@ -222,9 +222,8 @@ public abstract class BaseThumbnailGenerator implements ThumbnailGenerator {
|
|||
} catch (final CrawlingAccessException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
throw new ThumbnailGenerationException("Failed to process a thumbnail content: " + url, e);
|
||||
} else {
|
||||
throw new ThumbnailGenerationException(e.getMessage());
|
||||
}
|
||||
throw new ThumbnailGenerationException(e.getMessage());
|
||||
} catch (final Exception e) {
|
||||
throw new ThumbnailGenerationException("Failed to process a thumbnail content: " + url, e);
|
||||
}
|
||||
|
|
|
@ -487,9 +487,8 @@ public final class ComponentUtil {
|
|||
} catch (final NullPointerException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
throw new ContainerNotAvailableException(clazz.getCanonicalName(), e);
|
||||
} else {
|
||||
throw new ContainerNotAvailableException(clazz.getCanonicalName());
|
||||
}
|
||||
throw new ContainerNotAvailableException(clazz.getCanonicalName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -499,9 +498,8 @@ public final class ComponentUtil {
|
|||
} catch (final NullPointerException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
throw new ContainerNotAvailableException(componentName, e);
|
||||
} else {
|
||||
throw new ContainerNotAvailableException(componentName);
|
||||
}
|
||||
throw new ContainerNotAvailableException(componentName);
|
||||
} catch (final ComponentNotFoundException e) {
|
||||
if (componentMap.containsKey(componentName)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
@ -66,7 +66,8 @@ public final class DocumentUtil {
|
|||
}
|
||||
|
||||
return convertObj(((List<?>) value).get(0), clazz);
|
||||
} else if (value instanceof String[]) {
|
||||
}
|
||||
if (value instanceof String[]) {
|
||||
if (clazz.isAssignableFrom(String[].class)) {
|
||||
return (T) value;
|
||||
} else if (clazz.isAssignableFrom(List.class)) {
|
||||
|
@ -93,7 +94,8 @@ public final class DocumentUtil {
|
|||
|
||||
if (clazz.isAssignableFrom(String.class)) {
|
||||
return (T) value.toString();
|
||||
} else if (clazz.isAssignableFrom(Date.class)) {
|
||||
}
|
||||
if (clazz.isAssignableFrom(Date.class)) {
|
||||
if (value instanceof Date) {
|
||||
return (T) value;
|
||||
} else {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue