code cleanup
This commit is contained in:
parent
0b154758bd
commit
197fa76743
7 changed files with 55 additions and 61 deletions
|
@ -189,9 +189,11 @@ public class CrawlerStatsHelper {
|
|||
}
|
||||
if (keyObj instanceof final StatsKeyObject statsKey) {
|
||||
return escapeValue(statsKey.getUrl());
|
||||
} else if (keyObj instanceof final String key) {
|
||||
}
|
||||
if (keyObj instanceof final String key) {
|
||||
return escapeValue(key);
|
||||
} else if (keyObj instanceof final Number key) {
|
||||
}
|
||||
if (keyObj instanceof final Number key) {
|
||||
return key.toString();
|
||||
}
|
||||
return "-";
|
||||
|
@ -203,9 +205,11 @@ public class CrawlerStatsHelper {
|
|||
}
|
||||
if (keyObj instanceof final StatsKeyObject statsKey) {
|
||||
return OptionalThing.of(statsKey.getId());
|
||||
} else if (keyObj instanceof final String key) {
|
||||
}
|
||||
if (keyObj instanceof final String key) {
|
||||
return OptionalThing.of(key);
|
||||
} else if (keyObj instanceof final Number key) {
|
||||
}
|
||||
if (keyObj instanceof final Number key) {
|
||||
return OptionalThing.of(key.toString());
|
||||
}
|
||||
return OptionalThing.empty();
|
||||
|
|
|
@ -107,19 +107,21 @@ public class CrawlingConfigHelper {
|
|||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
switch (configType) {
|
||||
case WEB:
|
||||
return switch (configType) {
|
||||
case WEB -> {
|
||||
final WebConfigService webConfigService = ComponentUtil.getComponent(WebConfigService.class);
|
||||
return webConfigService.getWebConfig(id).get();
|
||||
case FILE:
|
||||
final FileConfigService fileConfigService = ComponentUtil.getComponent(FileConfigService.class);
|
||||
return fileConfigService.getFileConfig(id).get();
|
||||
case DATA:
|
||||
final DataConfigService dataConfigService = ComponentUtil.getComponent(DataConfigService.class);
|
||||
return dataConfigService.getDataConfig(id).get();
|
||||
default:
|
||||
return null;
|
||||
yield webConfigService.getWebConfig(id).get();
|
||||
}
|
||||
case FILE -> {
|
||||
final FileConfigService fileConfigService = ComponentUtil.getComponent(FileConfigService.class);
|
||||
yield fileConfigService.getFileConfig(id).get();
|
||||
}
|
||||
case DATA -> {
|
||||
final DataConfigService dataConfigService = ComponentUtil.getComponent(DataConfigService.class);
|
||||
yield dataConfigService.getDataConfig(id).get();
|
||||
}
|
||||
default -> null;
|
||||
};
|
||||
});
|
||||
} catch (final ExecutionException e) {
|
||||
logger.warn("Failed to access a crawling config cache: {}", configId, e);
|
||||
|
@ -278,18 +280,20 @@ public class CrawlingConfigHelper {
|
|||
public OptionalEntity<CrawlingConfig> getDefaultConfig(final ConfigType configType) {
|
||||
final String name = ComponentUtil.getFessConfig().getFormAdminDefaultTemplateName();
|
||||
|
||||
switch (configType) {
|
||||
case WEB:
|
||||
return switch (configType) {
|
||||
case WEB -> {
|
||||
final WebConfigService webConfigService = ComponentUtil.getComponent(WebConfigService.class);
|
||||
return webConfigService.getWebConfigByName(name).map(o -> (CrawlingConfig) o);
|
||||
case FILE:
|
||||
final FileConfigService fileConfigService = ComponentUtil.getComponent(FileConfigService.class);
|
||||
return fileConfigService.getFileConfigByName(name).map(o -> (CrawlingConfig) o);
|
||||
case DATA:
|
||||
final DataConfigService dataConfigService = ComponentUtil.getComponent(DataConfigService.class);
|
||||
return dataConfigService.getDataConfigByName(name).map(o -> (CrawlingConfig) o);
|
||||
default:
|
||||
return OptionalEntity.empty();
|
||||
yield webConfigService.getWebConfigByName(name).map(o -> (CrawlingConfig) o);
|
||||
}
|
||||
case FILE -> {
|
||||
final FileConfigService fileConfigService = ComponentUtil.getComponent(FileConfigService.class);
|
||||
yield fileConfigService.getFileConfigByName(name).map(o -> (CrawlingConfig) o);
|
||||
}
|
||||
case DATA -> {
|
||||
final DataConfigService dataConfigService = ComponentUtil.getComponent(DataConfigService.class);
|
||||
yield dataConfigService.getDataConfigByName(name).map(o -> (CrawlingConfig) o);
|
||||
}
|
||||
default -> OptionalEntity.empty();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,8 @@ public class WebFsIndexHelper {
|
|||
|
||||
private static final Logger logger = LogManager.getLogger(WebFsIndexHelper.class);
|
||||
|
||||
private static final String DISABLE_URL_ENCODE = "#DISABLE_URL_ENCODE";
|
||||
|
||||
protected long maxAccessCount = Long.MAX_VALUE;
|
||||
|
||||
protected long crawlingExecutionInterval = Constants.DEFAULT_CRAWLING_EXECUTION_INTERVAL;
|
||||
|
@ -176,7 +178,7 @@ public class WebFsIndexHelper {
|
|||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Included URL: {}", urlValue);
|
||||
}
|
||||
} else if (line.startsWith("#DISABLE_URL_ENCODE")) {
|
||||
} else if (line.startsWith(DISABLE_URL_ENCODE)) {
|
||||
urlEncodeDisabled.set(true);
|
||||
}
|
||||
}));
|
||||
|
@ -196,7 +198,7 @@ public class WebFsIndexHelper {
|
|||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Excluded URL: {}", urlValue);
|
||||
}
|
||||
} else if (line.startsWith("#DISABLE_URL_ENCODE")) {
|
||||
} else if (line.startsWith(DISABLE_URL_ENCODE)) {
|
||||
urlEncodeDisabled.set(true);
|
||||
}
|
||||
}));
|
||||
|
@ -309,7 +311,7 @@ public class WebFsIndexHelper {
|
|||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Included Path: {}", urlValue);
|
||||
}
|
||||
} else if (line.startsWith("#DISABLE_URL_ENCODE")) {
|
||||
} else if (line.startsWith(DISABLE_URL_ENCODE)) {
|
||||
urlEncodeDisabled.set(true);
|
||||
}
|
||||
}));
|
||||
|
@ -329,7 +331,7 @@ public class WebFsIndexHelper {
|
|||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Excluded Path: {}", urlValue);
|
||||
}
|
||||
} else if (line.startsWith("#DISABLE_URL_ENCODE")) {
|
||||
} else if (line.startsWith(DISABLE_URL_ENCODE)) {
|
||||
urlEncodeDisabled.set(true);
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -334,13 +334,10 @@ public interface FessProp {
|
|||
}
|
||||
|
||||
default boolean isResultCollapsed() {
|
||||
switch (getFesenType()) {
|
||||
case Constants.FESEN_TYPE_CLOUD:
|
||||
case Constants.FESEN_TYPE_AWS:
|
||||
return false;
|
||||
default:
|
||||
return getSystemPropertyAsBoolean(Constants.RESULT_COLLAPSED_PROPERTY, false);
|
||||
}
|
||||
return switch (getFesenType()) {
|
||||
case Constants.FESEN_TYPE_CLOUD, Constants.FESEN_TYPE_AWS -> false;
|
||||
default -> getSystemPropertyAsBoolean(Constants.RESULT_COLLAPSED_PROPERTY, false);
|
||||
};
|
||||
}
|
||||
|
||||
default void setLoginLinkEnabled(final boolean value) {
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -171,9 +170,7 @@ public class FessMultipartRequestHandler implements MultipartRequestHandler {
|
|||
|
||||
protected void mappingParameter(final HttpServletRequest request, final List<FileItem> items) {
|
||||
showFieldLoggingTitle();
|
||||
final Iterator<FileItem> iter = items.iterator();
|
||||
while (iter.hasNext()) {
|
||||
final FileItem item = iter.next();
|
||||
for (final FileItem item : items) {
|
||||
if (item.isFormField()) {
|
||||
showFormFieldParameter(item);
|
||||
addTextParameter(request, item);
|
||||
|
@ -235,9 +232,7 @@ public class FessMultipartRequestHandler implements MultipartRequestHandler {
|
|||
// =========
|
||||
@Override
|
||||
public void rollback() {
|
||||
final Iterator<MultipartFormFile> iter = elementsFile.values().iterator();
|
||||
while (iter.hasNext()) {
|
||||
final MultipartFormFile formFile = iter.next();
|
||||
for (final MultipartFormFile formFile : elementsFile.values()) {
|
||||
formFile.destroy();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,14 +210,11 @@ public class SamlAuthenticator implements SsoAuthenticator {
|
|||
|
||||
@Override
|
||||
public ActionResponse getResponse(final SsoResponseType responseType) {
|
||||
switch (responseType) {
|
||||
case METADATA:
|
||||
return getMetadataResponse();
|
||||
case LOGOUT:
|
||||
return getLogoutResponse();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return switch (responseType) {
|
||||
case METADATA -> getMetadataResponse();
|
||||
case LOGOUT -> getLogoutResponse();
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
protected ActionResponse getMetadataResponse() {
|
||||
|
|
|
@ -133,15 +133,10 @@ public class HtmlTagBasedGenerator extends BaseThumbnailGenerator {
|
|||
return true;
|
||||
}
|
||||
|
||||
switch (mimeType) {
|
||||
case "image/png":
|
||||
case "image/gif":
|
||||
case "image/jpeg":
|
||||
case "image/bmp":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return switch (mimeType) {
|
||||
case "image/png", "image/gif", "image/jpeg", "image/bmp" -> true;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
||||
protected Result saveImage(final ImageInputStream input, final File outputFile) throws IOException {
|
||||
|
|
Loading…
Add table
Reference in a new issue