code cleanup
This commit is contained in:
parent
21cf96fcc4
commit
f124be3298
22 changed files with 55 additions and 55 deletions
|
@ -117,7 +117,7 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
validate(form, messages -> {}, () -> asListHtml());
|
||||
verifyToken(() -> asListHtml());
|
||||
final String fileName = form.bulkFile.getFileName();
|
||||
File tempFile = ComponentUtil.getSystemHelper().createTempFile("fess_restore_", ".tmp");
|
||||
final File tempFile = ComponentUtil.getSystemHelper().createTempFile("fess_restore_", ".tmp");
|
||||
try (final InputStream in = form.bulkFile.getInputStream(); final OutputStream out = new FileOutputStream(tempFile)) {
|
||||
CopyUtil.copy(in, out);
|
||||
asyncImport(fileName, tempFile);
|
||||
|
@ -272,11 +272,11 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
}
|
||||
}
|
||||
|
||||
private Map<String, Map<String, String>> parseObject(final ObjectMapper mapper, String line) {
|
||||
private Map<String, Map<String, String>> parseObject(final ObjectMapper mapper, final String line) {
|
||||
try {
|
||||
return mapper.readValue(line, new TypeReference<Map<String, Map<String, String>>>() {
|
||||
});
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Failed to parse " + line, e);
|
||||
}
|
||||
|
@ -309,14 +309,14 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
}
|
||||
} else if (id.equals("fess.json")) {
|
||||
return asStream(id).contentTypeOctetStream().stream(out -> {
|
||||
Path fessJsonPath = getFessJsonPath();
|
||||
final Path fessJsonPath = getFessJsonPath();
|
||||
try (final InputStream in = Files.newInputStream(fessJsonPath)) {
|
||||
out.write(in);
|
||||
}
|
||||
});
|
||||
} else if (id.equals("doc.json")) {
|
||||
return asStream(id).contentTypeOctetStream().stream(out -> {
|
||||
Path fessJsonPath = getDocJsonPath();
|
||||
final Path fessJsonPath = getDocJsonPath();
|
||||
try (final InputStream in = Files.newInputStream(fessJsonPath)) {
|
||||
out.write(in);
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ public abstract class FessBaseAction extends TypicalAction // has several interf
|
|||
@Override
|
||||
public ActionResponse godHandPrologue(final ActionRuntime runtime) {
|
||||
fessLoginAssist.getSavedUserBean().ifPresent(u -> {
|
||||
boolean result = u.getFessUser().refresh();
|
||||
final boolean result = u.getFessUser().refresh();
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("refresh user info: {}", result);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.codelibs.fess.app.web.base.login;
|
|||
import org.lastaflute.web.login.credential.UserPasswordCredential;
|
||||
|
||||
public class LocalUserCredential extends UserPasswordCredential implements FessCredential {
|
||||
public LocalUserCredential(String user, String password) {
|
||||
public LocalUserCredential(final String user, final String password) {
|
||||
super(user, password);
|
||||
}
|
||||
|
||||
|
|
|
@ -384,9 +384,9 @@ public abstract class AbstractFessFileTransformer extends AbstractTransformer im
|
|||
params.put(HttpHeaders.CONTENT_TYPE, responseData.getMimeType());
|
||||
params.put(HttpHeaders.CONTENT_ENCODING, responseData.getCharSet());
|
||||
params.put(ExtractData.URL, responseData.getUrl());
|
||||
Map<String, String> configParam = crawlingConfig.getConfigParameterMap(ConfigName.CONFIG);
|
||||
final Map<String, String> configParam = crawlingConfig.getConfigParameterMap(ConfigName.CONFIG);
|
||||
if (configParam != null) {
|
||||
String keepOriginalBody = configParam.get(Config.KEEP_ORIGINAL_BODY);
|
||||
final String keepOriginalBody = configParam.get(Config.KEEP_ORIGINAL_BODY);
|
||||
if (StringUtil.isNotBlank(keepOriginalBody)) {
|
||||
params.put(TikaExtractor.NORMALIZE_TEXT, Constants.TRUE.equalsIgnoreCase(keepOriginalBody) ? Constants.FALSE
|
||||
: Constants.TRUE);
|
||||
|
|
|
@ -67,7 +67,7 @@ public interface CrawlingConfig {
|
|||
public enum ConfigType {
|
||||
WEB("W"), FILE("F"), DATA("D");
|
||||
|
||||
private final String typePrefix;
|
||||
private String typePrefix;
|
||||
|
||||
ConfigType(final String typePrefix) {
|
||||
this.typePrefix = typePrefix;
|
||||
|
|
|
@ -19,11 +19,11 @@ public class PluginException extends FessSystemException {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public PluginException(String message, Throwable cause) {
|
||||
public PluginException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public PluginException(String message) {
|
||||
public PluginException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@ public class ThemeException extends FessSystemException {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ThemeException(String message, Throwable cause) {
|
||||
public ThemeException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public ThemeException(String message) {
|
||||
public ThemeException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ public class ThumbnailGenerator {
|
|||
}
|
||||
executorService.shutdown();
|
||||
executorService.awaitTermination(60, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
} catch (final InterruptedException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Interrupted.", e);
|
||||
}
|
||||
|
|
|
@ -78,11 +78,11 @@ public class DocumentHelper {
|
|||
tikaExtractor.setReplaceDuplication(isDuplicateTermRemoved());
|
||||
tikaExtractor.setSpaceChars(getSpaceChars());
|
||||
}
|
||||
} catch (ComponentNotFoundException e) {
|
||||
} catch (final ComponentNotFoundException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("tikaExtractor is not found: " + e.getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
logger.warn("Failed to initiaize TikaExtractor.", e);
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public class DocumentHelper {
|
|||
}
|
||||
|
||||
if (crawlingConfig != null) {
|
||||
Map<String, String> configParam = crawlingConfig.getConfigParameterMap(ConfigName.CONFIG);
|
||||
final Map<String, String> configParam = crawlingConfig.getConfigParameterMap(ConfigName.CONFIG);
|
||||
if (configParam != null && Constants.TRUE.equalsIgnoreCase(configParam.get(Param.Config.KEEP_ORIGINAL_BODY))) {
|
||||
return content;
|
||||
}
|
||||
|
|
|
@ -236,11 +236,11 @@ public class PermissionHelper {
|
|||
return roleTypeList;
|
||||
}
|
||||
|
||||
public void setAllowPrefix(String allowPrefix) {
|
||||
public void setAllowPrefix(final String allowPrefix) {
|
||||
this.allowPrefix = allowPrefix;
|
||||
}
|
||||
|
||||
public void setDenyPrefix(String denyPrefix) {
|
||||
public void setDenyPrefix(final String denyPrefix) {
|
||||
this.denyPrefix = denyPrefix;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ public class SambaHelper {
|
|||
if (logger.isDebugEnabled()) {
|
||||
try {
|
||||
logger.debug("Processing SID: {} {} {}", type, sid, sid.toDisplayString());
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
|
|
@ -470,14 +470,14 @@ public class SystemHelper {
|
|||
return System.getProperty(Constants.FESS_LOG_LEVEL, Level.WARN.toString());
|
||||
}
|
||||
|
||||
public File createTempFile(String prefix, String suffix) {
|
||||
public File createTempFile(final String prefix, final String suffix) {
|
||||
try {
|
||||
final File file = File.createTempFile(prefix, suffix);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Create {} as a temp file.", file.getAbsolutePath());
|
||||
}
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,9 +36,9 @@ import org.slf4j.LoggerFactory;
|
|||
public class ThemeHelper {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ThemeHelper.class);
|
||||
|
||||
public void install(Artifact artifact) {
|
||||
Path jarPath = getJarFile(artifact);
|
||||
String themeName = getThemeName(artifact);
|
||||
public void install(final Artifact artifact) {
|
||||
final Path jarPath = getJarFile(artifact);
|
||||
final String themeName = getThemeName(artifact);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Theme: {}", themeName);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class ThemeHelper {
|
|||
ZipEntry entry;
|
||||
while ((entry = zis.getNextEntry()) != null) {
|
||||
if (!entry.isDirectory()) {
|
||||
String[] names = entry.getName().split("/");
|
||||
final String[] names = entry.getName().split("/");
|
||||
if (names.length < 2) {
|
||||
continue;
|
||||
}
|
||||
|
@ -55,54 +55,54 @@ public class ThemeHelper {
|
|||
}
|
||||
if ("view".equals(names[0])) {
|
||||
names[0] = themeName;
|
||||
Path path = ResourceUtil.getViewTemplatePath(names);
|
||||
final Path path = ResourceUtil.getViewTemplatePath(names);
|
||||
Files.createDirectories(path.getParent());
|
||||
Files.copy(zis, path, StandardCopyOption.REPLACE_EXISTING);
|
||||
} else if ("css".equals(names[0])) {
|
||||
names[0] = themeName;
|
||||
Path path = ResourceUtil.getCssPath(names);
|
||||
final Path path = ResourceUtil.getCssPath(names);
|
||||
Files.createDirectories(path.getParent());
|
||||
Files.copy(zis, path, StandardCopyOption.REPLACE_EXISTING);
|
||||
} else if ("js".equals(names[0])) {
|
||||
names[0] = themeName;
|
||||
Path path = ResourceUtil.getJavaScriptPath(names);
|
||||
final Path path = ResourceUtil.getJavaScriptPath(names);
|
||||
Files.createDirectories(path.getParent());
|
||||
Files.copy(zis, path, StandardCopyOption.REPLACE_EXISTING);
|
||||
} else if ("images".equals(names[0])) {
|
||||
names[0] = themeName;
|
||||
Path path = ResourceUtil.getImagePath(names);
|
||||
final Path path = ResourceUtil.getImagePath(names);
|
||||
Files.createDirectories(path.getParent());
|
||||
Files.copy(zis, path, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
throw new ThemeException("Failed to install " + artifact, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void uninstall(Artifact artifact) {
|
||||
String themeName = getThemeName(artifact);
|
||||
public void uninstall(final Artifact artifact) {
|
||||
final String themeName = getThemeName(artifact);
|
||||
|
||||
Path viewPath = ResourceUtil.getViewTemplatePath(themeName);
|
||||
final Path viewPath = ResourceUtil.getViewTemplatePath(themeName);
|
||||
closeQuietly(viewPath);
|
||||
Path imagePath = ResourceUtil.getImagePath(themeName);
|
||||
final Path imagePath = ResourceUtil.getImagePath(themeName);
|
||||
closeQuietly(imagePath);
|
||||
Path cssPath = ResourceUtil.getCssPath(themeName);
|
||||
final Path cssPath = ResourceUtil.getCssPath(themeName);
|
||||
closeQuietly(cssPath);
|
||||
Path jsPath = ResourceUtil.getJavaScriptPath(themeName);
|
||||
final Path jsPath = ResourceUtil.getJavaScriptPath(themeName);
|
||||
closeQuietly(jsPath);
|
||||
}
|
||||
|
||||
protected String getThemeName(Artifact artifact) {
|
||||
String themeName = artifact.getName().substring(ArtifactType.THEME.getId().length() + 1);
|
||||
protected String getThemeName(final Artifact artifact) {
|
||||
final String themeName = artifact.getName().substring(ArtifactType.THEME.getId().length() + 1);
|
||||
if (StringUtil.isBlank(themeName)) {
|
||||
throw new ThemeException("Theme name is empty: " + artifact);
|
||||
}
|
||||
return themeName;
|
||||
}
|
||||
|
||||
protected void closeQuietly(Path dir) {
|
||||
protected void closeQuietly(final Path dir) {
|
||||
try (Stream<Path> walk = Files.walk(dir, FileVisitOption.FOLLOW_LINKS)) {
|
||||
walk.sorted(Comparator.reverseOrder()).forEach(f -> {
|
||||
if (logger.isDebugEnabled()) {
|
||||
|
@ -110,18 +110,18 @@ public class ThemeHelper {
|
|||
}
|
||||
try {
|
||||
Files.delete(f);
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
logger.warn("Failed to delete " + f, e);
|
||||
}
|
||||
});
|
||||
Files.deleteIfExists(dir);
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
logger.warn("Failed to delete " + dir, e);
|
||||
}
|
||||
}
|
||||
|
||||
protected Path getJarFile(Artifact artifact) {
|
||||
Path jarPath = ResourceUtil.getPluginPath(artifact.getFileName());
|
||||
protected Path getJarFile(final Artifact artifact) {
|
||||
final Path jarPath = ResourceUtil.getPluginPath(artifact.getFileName());
|
||||
if (!Files.exists(jarPath)) {
|
||||
throw new ThemeException(artifact.getFileName() + " does not exist.");
|
||||
}
|
||||
|
|
|
@ -233,7 +233,7 @@ public class UserInfoHelper {
|
|||
this.cookieSecure = cookieSecure;
|
||||
}
|
||||
|
||||
public void setCookieHttpOnly(boolean httpOnly) {
|
||||
public void setCookieHttpOnly(final boolean httpOnly) {
|
||||
this.httpOnly = httpOnly;
|
||||
}
|
||||
}
|
|
@ -321,7 +321,7 @@ public class CrawlJob extends ExecJob {
|
|||
cmdList.add(Integer.toString(documentExpires));
|
||||
}
|
||||
|
||||
File propFile = ComponentUtil.getSystemHelper().createTempFile(getExecuteType() + "_", ".properties");
|
||||
final File propFile = ComponentUtil.getSystemHelper().createTempFile(getExecuteType() + "_", ".properties");
|
||||
try {
|
||||
cmdList.add("-p");
|
||||
cmdList.add(propFile.getAbsolutePath());
|
||||
|
|
|
@ -202,7 +202,7 @@ public class GenerateThumbnailJob extends ExecJob {
|
|||
cmdList.add("--cleanup");
|
||||
}
|
||||
|
||||
File propFile = ComponentUtil.getSystemHelper().createTempFile(getExecuteType() + "_", ".properties");
|
||||
final File propFile = ComponentUtil.getSystemHelper().createTempFile(getExecuteType() + "_", ".properties");
|
||||
try {
|
||||
cmdList.add("-p");
|
||||
cmdList.add(propFile.getAbsolutePath());
|
||||
|
|
|
@ -184,7 +184,7 @@ public class SuggestJob extends ExecJob {
|
|||
cmdList.add("--sessionId");
|
||||
cmdList.add(sessionId);
|
||||
|
||||
File propFile = ComponentUtil.getSystemHelper().createTempFile(getExecuteType() + "_", ".properties");
|
||||
final File propFile = ComponentUtil.getSystemHelper().createTempFile(getExecuteType() + "_", ".properties");
|
||||
try {
|
||||
cmdList.add("-p");
|
||||
cmdList.add(propFile.getAbsolutePath());
|
||||
|
|
|
@ -62,7 +62,7 @@ public class UpdateLabelJob {
|
|||
return builder.setDoc(XContentFactory.jsonBuilder().startObject()
|
||||
.field(fessConfig.getIndexFieldLabel(), labelSet.toArray(n -> new String[n])).endObject());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
logger.warn("Failed to process " + hit, e);
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -1984,7 +1984,7 @@ public interface FessProp {
|
|||
default Object getQueryTrackTotalHitsValue() {
|
||||
Object value = propMap.get(QUERY_TRACK_TOTAL_HITS_VALUE);
|
||||
if (value == null) {
|
||||
String v = getQueryTrackTotalHits();
|
||||
final String v = getQueryTrackTotalHits();
|
||||
if (Constants.TRUE.equalsIgnoreCase(v)) {
|
||||
value = Boolean.TRUE;
|
||||
} else if (Constants.FALSE.equalsIgnoreCase(v)) {
|
||||
|
@ -1992,7 +1992,7 @@ public interface FessProp {
|
|||
} else {
|
||||
try {
|
||||
value = Integer.valueOf(Integer.parseInt(v));
|
||||
} catch (NumberFormatException e) {
|
||||
} catch (final NumberFormatException e) {
|
||||
value = StringUtil.EMPTY;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -576,7 +576,7 @@ public class AzureAdAuthenticator implements SsoAuthenticator {
|
|||
this.acquisitionTimeout = acquisitionTimeout;
|
||||
}
|
||||
|
||||
public void setGroupCacheExpiry(long groupCacheExpiry) {
|
||||
public void setGroupCacheExpiry(final long groupCacheExpiry) {
|
||||
this.groupCacheExpiry = groupCacheExpiry;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ public class FessFunctions {
|
|||
}
|
||||
|
||||
public static String formatFileSize(final long value) {
|
||||
double target = (double) value;
|
||||
double target = value;
|
||||
String unit = ""; // TODO l10n?
|
||||
String format = "0.#";
|
||||
if (value < 1024) {
|
||||
|
|
|
@ -84,7 +84,7 @@ public class CommandGenerator extends BaseThumbnailGenerator {
|
|||
}
|
||||
|
||||
return process(thumbnailId, responseData -> {
|
||||
File tempFile = ComponentUtil.getSystemHelper().createTempFile("thumbnail_", "");
|
||||
final File tempFile = ComponentUtil.getSystemHelper().createTempFile("thumbnail_", "");
|
||||
try {
|
||||
CopyUtil.copy(responseData.getResponseBody(), tempFile);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue