code clean-up
This commit is contained in:
parent
fb3cb33fee
commit
646e1bde1b
23 changed files with 74 additions and 106 deletions
|
@ -184,7 +184,8 @@ public class Constants extends CoreLibConstants {
|
|||
+ ",YandexBot"//
|
||||
+ ",Chilkat"//
|
||||
+ ",CloudFront"//
|
||||
+ ",Mediapartners";
|
||||
+ ",Mediapartners"//
|
||||
+ ",MSIE 6";
|
||||
|
||||
public static final String DEFAULT_FROM_EMAIL = "Administrator <root@localhost>";
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ public class EsApiManager extends BaseApiManager {
|
|||
}
|
||||
}
|
||||
|
||||
if (path.startsWith("/_plugin/") || path.equals("/_plugin")) {
|
||||
if (path.equals("/_plugin") || path.startsWith("/_plugin/")) {
|
||||
processPluginRequest(request, response, path.replaceFirst("^/_plugin", StringUtil.EMPTY));
|
||||
return;
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ public class EsApiManager extends BaseApiManager {
|
|||
});
|
||||
}
|
||||
|
||||
private void processPluginRequest(final HttpServletRequest request, final HttpServletResponse response, final String path) {
|
||||
protected void processPluginRequest(final HttpServletRequest request, final HttpServletResponse response, final String path) {
|
||||
Path filePath = ResourceUtil.getSitePath(path.replaceAll("\\.\\.+", StringUtil.EMPTY).replaceAll("/+", "/").split("/"));
|
||||
if (Files.isDirectory(filePath)) {
|
||||
filePath = filePath.resolve("index.html");
|
||||
|
|
|
@ -59,9 +59,9 @@ import org.slf4j.LoggerFactory;
|
|||
public class GsaApiManager extends BaseApiManager implements WebApiManager {
|
||||
private static final Logger logger = LoggerFactory.getLogger(GsaApiManager.class);
|
||||
|
||||
public String gsaPathPrefix = "/gsa";
|
||||
protected String gsaPathPrefix = "/gsa";
|
||||
|
||||
public String gsaMetaPrefix = "MT_";
|
||||
protected String gsaMetaPrefix = "MT_";
|
||||
|
||||
private static final String GSA_META_SUFFIX = "_s";
|
||||
|
||||
|
@ -284,9 +284,6 @@ public class GsaApiManager extends BaseApiManager implements WebApiManager {
|
|||
buf.append("<GSP VER=\"");
|
||||
buf.append(Constants.GSA_API_VERSION);
|
||||
buf.append("\">");
|
||||
// buf.append("<status>");
|
||||
// buf.append(status);
|
||||
// buf.append("</status>");
|
||||
if (status == 0) {
|
||||
buf.append(body);
|
||||
} else {
|
||||
|
@ -394,24 +391,6 @@ public class GsaApiManager extends BaseApiManager implements WebApiManager {
|
|||
|
||||
@Override
|
||||
public String[] getExtraQueries() {
|
||||
/*
|
||||
List<String> additional = new ArrayList<String>();
|
||||
// collections
|
||||
final String site = (String) request.getParameter("site");
|
||||
if (StringUtil.isNotBlank(site)) {
|
||||
additional.add(" (label:" + site.replace(".", " AND label:").replace("|", " OR label:") + ")");
|
||||
}
|
||||
// dynmic fields
|
||||
final String requiredFields = (String) request.getParameter("requiredfields");
|
||||
if (StringUtil.isNotBlank(requiredFields)) {
|
||||
additional.add(" (" + gsaMetaPrefix
|
||||
+ requiredFields.replace(":", "_s:").replace(".", " AND " + gsaMetaPrefix).replace("|", " OR " + gsaMetaPrefix)
|
||||
+ ")");
|
||||
}
|
||||
if (!additional.isEmpty()) {
|
||||
extraParams.put("additional", (String[]) additional.toArray(new String[additional.size()]));
|
||||
}
|
||||
*/
|
||||
return getParamValueArray(request, "ex_q");
|
||||
}
|
||||
|
||||
|
@ -445,28 +424,6 @@ public class GsaApiManager extends BaseApiManager implements WebApiManager {
|
|||
|
||||
@Override
|
||||
public String getSort() {
|
||||
/*
|
||||
// sorting
|
||||
final String sort = request.getParameter("sort");
|
||||
if (StringUtil.isNotBlank(sort)) {
|
||||
final String[] sortParams = sort.split(":");
|
||||
String sortDirection = "desc";
|
||||
if ("date".equals(sortParams[0])) {
|
||||
if ("A".equals(sortParams[1])) {
|
||||
sortDirection = "asc";
|
||||
} else if ("D".equals(sortParams[1])) {
|
||||
sortDirection = "desc";
|
||||
}
|
||||
// TODO: Now ignore sort mode
|
||||
// if ("S".equals(sortParams[2])) {
|
||||
// } else if ("R".equals(sortParams[2])) {
|
||||
// } else if ("L".equals(sortParams[2])) {
|
||||
// }
|
||||
// sortParams[3]=<mode> is fixed as "d1"
|
||||
extraParams.put("sort", new String[] { "lastModified." + sortDirection });
|
||||
}
|
||||
}
|
||||
*/
|
||||
return request.getParameter("sort");
|
||||
}
|
||||
|
||||
|
@ -532,4 +489,12 @@ public class GsaApiManager extends BaseApiManager implements WebApiManager {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
public void setGsaPathPrefix(final String gsaPathPrefix) {
|
||||
this.gsaPathPrefix = gsaPathPrefix;
|
||||
}
|
||||
|
||||
public void setGsaMetaPrefix(final String gsaMetaPrefix) {
|
||||
this.gsaMetaPrefix = gsaMetaPrefix;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -299,28 +299,29 @@ public class JsonApiManager extends BaseJsonApiManager {
|
|||
}
|
||||
}
|
||||
|
||||
protected String detailedMessage(Throwable t) {
|
||||
protected String detailedMessage(final Throwable t) {
|
||||
if (t == null) {
|
||||
return "Unknown";
|
||||
}
|
||||
if (t.getCause() != null) {
|
||||
Throwable target = t;
|
||||
if (target.getCause() != null) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
while (t != null) {
|
||||
sb.append(t.getClass().getSimpleName());
|
||||
if (t.getMessage() != null) {
|
||||
while (target != null) {
|
||||
sb.append(target.getClass().getSimpleName());
|
||||
if (target.getMessage() != null) {
|
||||
sb.append("[");
|
||||
sb.append(t.getMessage());
|
||||
sb.append(target.getMessage());
|
||||
sb.append("]");
|
||||
}
|
||||
sb.append("; ");
|
||||
t = t.getCause();
|
||||
if (t != null) {
|
||||
target = target.getCause();
|
||||
if (target != null) {
|
||||
sb.append("nested: ");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
} else {
|
||||
return t.getClass().getSimpleName() + "[" + t.getMessage() + "]";
|
||||
return target.getClass().getSimpleName() + "[" + target.getMessage() + "]";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -328,7 +328,7 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
static public List<Map<String, String>> getBackupItems() {
|
||||
FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
return stream(fessConfig.getIndexBackupAllTargets()).get(stream -> stream.map(name -> {
|
||||
final Map<String, String> map = new HashMap<>();
|
||||
map.put("id", name);
|
||||
|
|
|
@ -202,7 +202,7 @@ public class AdminUpgradeAction extends FessAdminAction {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean startReindex(boolean replaceAliases) {
|
||||
private boolean startReindex(final boolean replaceAliases) {
|
||||
final String docIndex = "fess";
|
||||
final String fromIndex = fessConfig.getIndexDocumentUpdateIndex();
|
||||
final String toIndex = docIndex + "." + new SimpleDateFormat("yyyyMMddHHmm").format(new Date());
|
||||
|
|
|
@ -190,10 +190,10 @@ public class ApiResult {
|
|||
// facet field
|
||||
if (facetResponse.getFieldList() != null) {
|
||||
facetField = facetResponse.getFieldList().stream().map(field -> {
|
||||
Map<String, Object> fieldMap = new HashMap<>(2, 1f);
|
||||
final Map<String, Object> fieldMap = new HashMap<>(2, 1f);
|
||||
fieldMap.put("name", field.getName());
|
||||
fieldMap.put("result", field.getValueCountMap().entrySet().stream().map(e -> {
|
||||
Map<String, Object> valueCount = new HashMap<>(2, 1f);
|
||||
final Map<String, Object> valueCount = new HashMap<>(2, 1f);
|
||||
valueCount.put("value", e.getKey());
|
||||
valueCount.put("count", e.getValue());
|
||||
return valueCount;
|
||||
|
@ -204,7 +204,7 @@ public class ApiResult {
|
|||
// facet q
|
||||
if (facetResponse.getQueryCountMap() != null) {
|
||||
facetQuery = facetResponse.getQueryCountMap().entrySet().stream().map(e -> {
|
||||
Map<String, Object> valueCount = new HashMap<>(2, 1f);
|
||||
final Map<String, Object> valueCount = new HashMap<>(2, 1f);
|
||||
valueCount.put("value", e.getKey());
|
||||
valueCount.put("count", e.getValue());
|
||||
return valueCount;
|
||||
|
|
|
@ -63,7 +63,7 @@ public class ApiAdminBackupAction extends FessApiAdminAction {
|
|||
// GET /api/admin/backup/file/{id}
|
||||
@Execute
|
||||
public StreamResponse get$file(final String id) {
|
||||
FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
if (stream(fessConfig.getIndexBackupAllTargets()).get(stream -> stream.anyMatch(s -> s.equals(id)))) {
|
||||
if (id.equals("system.properties")) {
|
||||
return asStream(id).contentTypeOctetStream().stream(out -> {
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.codelibs.fess.app.web.api.admin.dict.kuromoji;
|
|||
import static org.codelibs.fess.app.web.admin.dict.kuromoji.AdminDictKuromojiAction.createKuromojiItem;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -116,8 +117,7 @@ public class ApiAdminDictKuromojiAction extends FessApiAdminAction {
|
|||
});
|
||||
try (InputStream inputStream = form.kuromojiFile.getInputStream()) {
|
||||
file.update(inputStream);
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
} catch (final IOException e) {
|
||||
throwValidationErrorApi(messages -> messages.addErrorsFailedToUploadProtwordsFile(GLOBAL));
|
||||
}
|
||||
return asJson(new ApiResult.ApiResponse().status(ApiResult.Status.OK).result());
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
package org.codelibs.fess.app.web.api.admin.dict.mapping;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -121,8 +122,7 @@ public class ApiAdminDictMappingAction extends FessApiAdminAction {
|
|||
});
|
||||
try (InputStream inputStream = form.charMappingFile.getInputStream()) {
|
||||
file.update(inputStream);
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
} catch (final IOException e) {
|
||||
throwValidationErrorApi(messages -> messages.addErrorsFailedToUploadProtwordsFile(GLOBAL));
|
||||
}
|
||||
return asJson(new ApiResult.ApiResponse().status(ApiResult.Status.OK).result());
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.codelibs.fess.app.web.api.admin.dict.protwords;
|
|||
import static org.codelibs.fess.app.web.admin.dict.protwords.AdminDictProtwordsAction.createProtwordsItem;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -121,8 +122,7 @@ public class ApiAdminDictProtwordsAction extends FessApiAdminAction {
|
|||
});
|
||||
try (InputStream inputStream = form.protwordsFile.getInputStream()) {
|
||||
file.update(inputStream);
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
} catch (final IOException e) {
|
||||
throwValidationErrorApi(messages -> messages.addErrorsFailedToUploadProtwordsFile(GLOBAL));
|
||||
}
|
||||
return asJson(new ApiResult.ApiResponse().status(ApiResult.Status.OK).result());
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
package org.codelibs.fess.app.web.api.admin.dict.seunjeon;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -121,8 +122,7 @@ public class ApiAdminDictSeunjeonAction extends FessApiAdminAction {
|
|||
});
|
||||
try (InputStream inputStream = form.seunjeonFile.getInputStream()) {
|
||||
file.update(inputStream);
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
} catch (final IOException e) {
|
||||
throwValidationErrorApi(messages -> messages.addErrorsFailedToUploadProtwordsFile(GLOBAL));
|
||||
}
|
||||
return asJson(new ApiResult.ApiResponse().status(ApiResult.Status.OK).result());
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
package org.codelibs.fess.app.web.api.admin.dict.synonym;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -121,8 +122,7 @@ public class ApiAdminDictSynonymAction extends FessApiAdminAction {
|
|||
});
|
||||
try (InputStream inputStream = form.synonymFile.getInputStream()) {
|
||||
file.update(inputStream);
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
} catch (final IOException e) {
|
||||
throwValidationErrorApi(messages -> messages.addErrorsFailedToUploadProtwordsFile(GLOBAL));
|
||||
}
|
||||
return asJson(new ApiResult.ApiResponse().status(ApiResult.Status.OK).result());
|
||||
|
|
|
@ -222,7 +222,7 @@ public abstract class FessSearchAction extends FessBaseAction {
|
|||
return newHtmlResponseAsRediect(StringUtil.isBlank(contextPath) ? "/" : contextPath);
|
||||
}
|
||||
|
||||
protected HtmlNext virtualHost(HtmlNext path) {
|
||||
protected HtmlNext virtualHost(final HtmlNext path) {
|
||||
return fessConfig.getVirtualHostPath(path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -253,9 +253,9 @@ public class FessCrawlerThread extends CrawlerThread {
|
|||
protected void processResponse(final UrlQueue<?> urlQueue, final ResponseData responseData) {
|
||||
super.processResponse(urlQueue, responseData);
|
||||
|
||||
FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
if (fessConfig.isCrawlerFailureUrlStatusCodes(responseData.getHttpStatusCode())) {
|
||||
String sessionId = crawlerContext.getSessionId();
|
||||
final String sessionId = crawlerContext.getSessionId();
|
||||
final CrawlingConfig crawlingConfig = ComponentUtil.getCrawlingConfigHelper().get(sessionId);
|
||||
final String url = urlQueue.getUrl();
|
||||
|
||||
|
|
|
@ -727,7 +727,7 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
|
|||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
logger.debug("Failed to parse " + imgNode + " at " + responseData.getUrl(), e);
|
||||
}
|
||||
} else if (firstSrcNode == null) {
|
||||
|
@ -744,7 +744,7 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
|
|||
if (thumbnailUrl != null) {
|
||||
return thumbnailUrl.toExternalForm();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
logger.debug("Failed to parse " + firstSrcNode + " at " + responseData.getUrl(), e);
|
||||
}
|
||||
}
|
||||
|
@ -755,7 +755,7 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
|
|||
}
|
||||
|
||||
protected Integer getAttributeAsInteger(final NamedNodeMap attributes, final String name) {
|
||||
Node namedItem = attributes.getNamedItem(name);
|
||||
final Node namedItem = attributes.getNamedItem(name);
|
||||
if (namedItem == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl {
|
|||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
final Map<String, String> map = (Map) curlResponse.getContentAsMap();
|
||||
assert (map.containsKey("version"));
|
||||
assert (map.containsKey("source_label") && map.containsKey("wiki_label") & map.containsKey("issue_label"));
|
||||
assert (map.containsKey("source_label") && map.containsKey("wiki_label") && map.containsKey("issue_label"));
|
||||
return map;
|
||||
|
||||
} catch (final Exception e) {
|
||||
|
@ -205,12 +205,13 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl {
|
|||
assert (map.containsKey("repositories"));
|
||||
|
||||
totalCount = (int) map.get("total_count");
|
||||
int responseCount = (int) map.get("response_count");
|
||||
if (responseCount == 0)
|
||||
final int responseCount = (int) map.get("response_count");
|
||||
if (responseCount == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Map<String, Object>> repos = (ArrayList<Map<String, Object>>) map.get("repositories");
|
||||
final List<Map<String, Object>> repos = (ArrayList<Map<String, Object>>) map.get("repositories");
|
||||
repoList.addAll(repos);
|
||||
} catch (final Exception e) {
|
||||
logger.warn("Failed to access to " + urlWithOffset, e);
|
||||
|
@ -332,14 +333,15 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl {
|
|||
|
||||
private List<String> getIssueComments(final String issueUrl, final String authToken) {
|
||||
final String commentsUrl = issueUrl + "/comments";
|
||||
final List<String> commentList = new ArrayList<String>();
|
||||
final List<String> commentList = new ArrayList<>();
|
||||
|
||||
try (CurlResponse curlResponse = Curl.get(commentsUrl).header("Authorization", "token " + authToken).execute()) {
|
||||
final String commentsJson = curlResponse.getContentAsString();
|
||||
List<Map<String, Object>> comments = new ObjectMapper().readValue(commentsJson, new TypeReference<List<Map<String, Object>>>() {
|
||||
});
|
||||
final List<Map<String, Object>> comments =
|
||||
new ObjectMapper().readValue(commentsJson, new TypeReference<List<Map<String, Object>>>() {
|
||||
});
|
||||
|
||||
for (Map<String, Object> comment : comments) {
|
||||
for (final Map<String, Object> comment : comments) {
|
||||
if (comment.containsKey("body")) {
|
||||
commentList.add((String) comment.get("body"));
|
||||
}
|
||||
|
|
|
@ -311,7 +311,7 @@ public class FessEsClient implements Client {
|
|||
} else {
|
||||
indexName = configIndex;
|
||||
}
|
||||
boolean exists = existsIndex(indexName);
|
||||
final boolean exists = existsIndex(indexName);
|
||||
if (!exists) {
|
||||
final String createdIndexName;
|
||||
if (isFessIndex) {
|
||||
|
@ -370,7 +370,7 @@ public class FessEsClient implements Client {
|
|||
} else {
|
||||
logger.warn("Failed to reindex from " + fromIndex + " to " + toIndex);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
logger.warn("Failed to reindex from " + fromIndex + " to " + toIndex, e);
|
||||
}
|
||||
return false;
|
||||
|
@ -442,8 +442,8 @@ public class FessEsClient implements Client {
|
|||
|
||||
public boolean updateAlias(final String newIndex) {
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
String updateAlias = fessConfig.getIndexDocumentUpdateIndex();
|
||||
String searchAlias = fessConfig.getIndexDocumentSearchIndex();
|
||||
final String updateAlias = fessConfig.getIndexDocumentUpdateIndex();
|
||||
final String searchAlias = fessConfig.getIndexDocumentSearchIndex();
|
||||
final GetIndexResponse response1 =
|
||||
client.admin().indices().prepareGetIndex().addIndices(updateAlias).execute().actionGet(fessConfig.getIndexIndicesTimeout());
|
||||
final String[] updateIndices = response1.indices();
|
||||
|
@ -451,15 +451,15 @@ public class FessEsClient implements Client {
|
|||
client.admin().indices().prepareGetIndex().addIndices(searchAlias).execute().actionGet(fessConfig.getIndexIndicesTimeout());
|
||||
final String[] searchIndices = response2.indices();
|
||||
|
||||
IndicesAliasesRequestBuilder builder =
|
||||
final IndicesAliasesRequestBuilder builder =
|
||||
client.admin().indices().prepareAliases().addAlias(newIndex, updateAlias).addAlias(newIndex, searchAlias);
|
||||
for (String index : updateIndices) {
|
||||
for (final String index : updateIndices) {
|
||||
builder.removeAlias(index, updateAlias);
|
||||
}
|
||||
for (String index : searchIndices) {
|
||||
for (final String index : searchIndices) {
|
||||
builder.removeAlias(index, searchAlias);
|
||||
}
|
||||
IndicesAliasesResponse response = builder.execute().actionGet(fessConfig.getIndexIndicesTimeout());
|
||||
final IndicesAliasesResponse response = builder.execute().actionGet(fessConfig.getIndexIndicesTimeout());
|
||||
return response.isAcknowledged();
|
||||
}
|
||||
|
||||
|
@ -1413,12 +1413,12 @@ public class FessEsClient implements Client {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionFuture<FieldCapabilitiesResponse> fieldCaps(FieldCapabilitiesRequest request) {
|
||||
public ActionFuture<FieldCapabilitiesResponse> fieldCaps(final FieldCapabilitiesRequest request) {
|
||||
return client.fieldCaps(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fieldCaps(FieldCapabilitiesRequest request, ActionListener<FieldCapabilitiesResponse> listener) {
|
||||
public void fieldCaps(final FieldCapabilitiesRequest request, final ActionListener<FieldCapabilitiesResponse> listener) {
|
||||
client.fieldCaps(request, listener);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public class ContentNotFoundException extends FessSystemException {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ContentNotFoundException(String url) {
|
||||
public ContentNotFoundException(final String url) {
|
||||
super("Not Found: " + url, false, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -1568,7 +1568,7 @@ public interface FessProp {
|
|||
if (v1.length == 2) {
|
||||
final String[] v2 = v1[0].split(":");
|
||||
if (v2.length == 2) {
|
||||
return new Tuple3<String, String, String>(v2[0].trim(), v2[0].trim(), "/" + v1[1].trim());
|
||||
return new Tuple3<>(v2[0].trim(), v2[0].trim(), "/" + v1[1].trim());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -1577,7 +1577,7 @@ public interface FessProp {
|
|||
}
|
||||
final Tuple3<String, String, String>[] vHosts = hosts;
|
||||
return LaRequestUtil.getOptionalRequest().map(req -> {
|
||||
for (Tuple3<String, String, String> host : vHosts) {
|
||||
for (final Tuple3<String, String, String> host : vHosts) {
|
||||
final String headerValue = req.getHeader(host.getValue1());
|
||||
if (host.getValue2().equalsIgnoreCase(headerValue)) {
|
||||
return new HtmlNext(host.getValue3() + page.getRoutingPath());
|
||||
|
@ -1597,7 +1597,7 @@ public interface FessProp {
|
|||
stream -> stream.filter(StringUtil::isNotBlank).mapToInt(Integer::parseInt).toArray());
|
||||
propMap.put(CRAWLER_FAILURE_URL_STATUS_CODES, codes);
|
||||
}
|
||||
for (int v : codes) {
|
||||
for (final int v : codes) {
|
||||
if (v == code) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -212,7 +212,7 @@ public class ThumbnailManager {
|
|||
if (!generator.generate(entity.getThumbnailId(), entity.getUrl(), outputFile)) {
|
||||
new File(outputFile.getAbsolutePath() + NOIMAGE_FILE_SUFFIX).setLastModified(System.currentTimeMillis());
|
||||
} else {
|
||||
long interval = fessConfig.getThumbnailGeneratorIntervalAsInteger().longValue();
|
||||
final long interval = fessConfig.getThumbnailGeneratorIntervalAsInteger().longValue();
|
||||
if (interval > 0) {
|
||||
Thread.sleep(interval);
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ public abstract class BaseThumbnailGenerator implements ThumbnailGenerator {
|
|||
try {
|
||||
ComponentUtil.getIndexingHelper().updateDocument(ComponentUtil.getFessEsClient(), thumbnailId,
|
||||
fessConfig.getIndexFieldThumbnail(), null);
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
logger.warn("Failed to update thumbnail field at " + url, e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,9 +124,8 @@ public class HtmlTagBasedGenerator extends BaseThumbnailGenerator {
|
|||
final BufferedImage image = reader.read(0, param);
|
||||
final int thumbnailWidth = fessConfig.getThumbnailHtmlImageThumbnailWidthAsInteger();
|
||||
final int thumbnailHeight =
|
||||
(int) (((float) (height > width ? width : height))
|
||||
* fessConfig.getThumbnailHtmlImageThumbnailWidthAsInteger().floatValue() / (float) width);
|
||||
BufferedImage thumbnail = new BufferedImage(thumbnailWidth, thumbnailHeight, image.getType());
|
||||
(int) ((height > width ? width : height) * fessConfig.getThumbnailHtmlImageThumbnailWidthAsInteger().floatValue() / width);
|
||||
final BufferedImage thumbnail = new BufferedImage(thumbnailWidth, thumbnailHeight, image.getType());
|
||||
thumbnail.getGraphics().drawImage(image.getScaledInstance(thumbnailWidth, thumbnailHeight, Image.SCALE_AREA_AVERAGING), 0,
|
||||
0, thumbnailWidth, thumbnailHeight, null);
|
||||
ImageIO.write(thumbnail, fessConfig.getThumbnailHtmlImageFormat(), outputFile);
|
||||
|
|
Loading…
Add table
Reference in a new issue