apply code formatter
This commit is contained in:
parent
51c357e5a2
commit
2501da853b
15 changed files with 99 additions and 66 deletions
|
@ -159,7 +159,7 @@ public class SuggestApiManager extends BaseApiManager {
|
|||
|
||||
private final int num;
|
||||
|
||||
private HttpServletRequest request;
|
||||
private final HttpServletRequest request;
|
||||
|
||||
protected RequestParameter(final HttpServletRequest request, final String query, final String[] fields, final int num) {
|
||||
this.query = query;
|
||||
|
@ -189,6 +189,7 @@ public class SuggestApiManager extends BaseApiManager {
|
|||
return new RequestParameter(request, query, fields, num);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
@ -247,7 +248,7 @@ public class SuggestApiManager extends BaseApiManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String name) {
|
||||
public Object getAttribute(final String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ public class FailureUrlService {
|
|||
}
|
||||
|
||||
final FailureUrlBhv bhv = ComponentUtil.getComponent(FailureUrlBhv.class);
|
||||
FailureUrl failureUrl = bhv.selectEntity(cb -> {
|
||||
final FailureUrl failureUrl = bhv.selectEntity(cb -> {
|
||||
cb.query().setUrl_Equal(url);
|
||||
if (crawlingConfig != null) {
|
||||
cb.query().setConfigId_Equal(crawlingConfig.getConfigId());
|
||||
|
@ -178,7 +178,7 @@ public class FailureUrlService {
|
|||
entity.setErrorCount(entity.getErrorCount() + 1);
|
||||
return entity;
|
||||
}).orElseGet(() -> {
|
||||
FailureUrl entity = new FailureUrl();
|
||||
final FailureUrl entity = new FailureUrl();
|
||||
entity.setErrorCount(1);
|
||||
entity.setUrl(url);
|
||||
if (crawlingConfig != null) {
|
||||
|
|
|
@ -317,7 +317,7 @@ public class AdminSearchlistAction extends FessAdminAction {
|
|||
protected void validateCreateFields(final CreateForm form) {
|
||||
|
||||
if (!fessConfig.validateIndexRequiredFields(form.doc)) {
|
||||
List<String> invalidRequiredFields = fessConfig.invalidIndexRequiredFields(form.doc);
|
||||
final List<String> invalidRequiredFields = fessConfig.invalidIndexRequiredFields(form.doc);
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudFailedToCreateInstance("doc." + invalidRequiredFields.get(0));
|
||||
// TODO messages.addConstraintsRequiredMessage("doc." + invalidRequiredFields.get(0), invalidRequiredFields.get(0));
|
||||
|
@ -325,37 +325,37 @@ public class AdminSearchlistAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
if (!fessConfig.validateIndexArrayFields(form.doc)) {
|
||||
List<String> invalidArrayFields = fessConfig.invalidIndexArrayFields(form.doc);
|
||||
final List<String> invalidArrayFields = fessConfig.invalidIndexArrayFields(form.doc);
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudFailedToCreateInstance("doc." + invalidArrayFields.get(0));
|
||||
}, () -> asEditHtml());
|
||||
}
|
||||
if (!fessConfig.validateIndexDateFields(form.doc)) {
|
||||
List<String> invalidDateFields = fessConfig.invalidIndexDateFields(form.doc);
|
||||
final List<String> invalidDateFields = fessConfig.invalidIndexDateFields(form.doc);
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudFailedToCreateInstance("doc." + invalidDateFields.get(0));
|
||||
}, () -> asEditHtml());
|
||||
}
|
||||
if (!fessConfig.validateIndexIntegerFields(form.doc)) {
|
||||
List<String> invalidIntegerFields = fessConfig.invalidIndexIntegerFields(form.doc);
|
||||
final List<String> invalidIntegerFields = fessConfig.invalidIndexIntegerFields(form.doc);
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudFailedToCreateInstance("doc." + invalidIntegerFields.get(0));
|
||||
}, () -> asEditHtml());
|
||||
}
|
||||
if (!fessConfig.validateIndexLongFields(form.doc)) {
|
||||
List<String> invalidLongFields = fessConfig.invalidIndexLongFields(form.doc);
|
||||
final List<String> invalidLongFields = fessConfig.invalidIndexLongFields(form.doc);
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudFailedToCreateInstance("doc." + invalidLongFields.get(0));
|
||||
}, () -> asEditHtml());
|
||||
}
|
||||
if (!fessConfig.validateIndexFloatFields(form.doc)) {
|
||||
List<String> invalidFloatFields = fessConfig.invalidIndexFloatFields(form.doc);
|
||||
final List<String> invalidFloatFields = fessConfig.invalidIndexFloatFields(form.doc);
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudFailedToCreateInstance("doc." + invalidFloatFields.get(0));
|
||||
}, () -> asEditHtml());
|
||||
}
|
||||
if (!fessConfig.validateIndexDoubleFields(form.doc)) {
|
||||
List<String> invalidDoubleFields = fessConfig.invalidIndexDoubleFields(form.doc);
|
||||
final List<String> invalidDoubleFields = fessConfig.invalidIndexDoubleFields(form.doc);
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudFailedToCreateInstance("doc." + invalidDoubleFields.get(0));
|
||||
}, () -> asEditHtml());
|
||||
|
@ -365,44 +365,44 @@ public class AdminSearchlistAction extends FessAdminAction {
|
|||
protected void validateUpdateFields(final EditForm form) {
|
||||
|
||||
if (!fessConfig.validateIndexRequiredFields(form.doc)) {
|
||||
List<String> invalidRequiredFields = fessConfig.invalidIndexRequiredFields(form.doc);
|
||||
final List<String> invalidRequiredFields = fessConfig.invalidIndexRequiredFields(form.doc);
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudCouldNotFindCrudTable("doc." + invalidRequiredFields.get(0), form.docId);
|
||||
}, () -> asEditHtml());
|
||||
}
|
||||
|
||||
if (!fessConfig.validateIndexArrayFields(form.doc)) {
|
||||
List<String> invalidArrayFields = fessConfig.invalidIndexArrayFields(form.doc);
|
||||
final List<String> invalidArrayFields = fessConfig.invalidIndexArrayFields(form.doc);
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudCouldNotFindCrudTable("doc." + invalidArrayFields.get(0), form.docId);
|
||||
}, () -> asEditHtml());
|
||||
}
|
||||
if (!fessConfig.validateIndexDateFields(form.doc)) {
|
||||
List<String> invalidDateFields = fessConfig.invalidIndexDateFields(form.doc);
|
||||
final List<String> invalidDateFields = fessConfig.invalidIndexDateFields(form.doc);
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudCouldNotFindCrudTable("doc." + invalidDateFields.get(0), form.docId);
|
||||
}, () -> asEditHtml());
|
||||
}
|
||||
if (!fessConfig.validateIndexIntegerFields(form.doc)) {
|
||||
List<String> invalidIntegerFields = fessConfig.invalidIndexIntegerFields(form.doc);
|
||||
final List<String> invalidIntegerFields = fessConfig.invalidIndexIntegerFields(form.doc);
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudCouldNotFindCrudTable("doc." + invalidIntegerFields.get(0), form.docId);
|
||||
}, () -> asEditHtml());
|
||||
}
|
||||
if (!fessConfig.validateIndexLongFields(form.doc)) {
|
||||
List<String> invalidLongFields = fessConfig.invalidIndexLongFields(form.doc);
|
||||
final List<String> invalidLongFields = fessConfig.invalidIndexLongFields(form.doc);
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudCouldNotFindCrudTable("doc." + invalidLongFields.get(0), form.docId);
|
||||
}, () -> asEditHtml());
|
||||
}
|
||||
if (!fessConfig.validateIndexFloatFields(form.doc)) {
|
||||
List<String> invalidFloatFields = fessConfig.invalidIndexFloatFields(form.doc);
|
||||
final List<String> invalidFloatFields = fessConfig.invalidIndexFloatFields(form.doc);
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudCouldNotFindCrudTable("doc." + invalidFloatFields.get(0), form.docId);
|
||||
}, () -> asEditHtml());
|
||||
}
|
||||
if (!fessConfig.validateIndexDoubleFields(form.doc)) {
|
||||
List<String> invalidDoubleFields = fessConfig.invalidIndexDoubleFields(form.doc);
|
||||
final List<String> invalidDoubleFields = fessConfig.invalidIndexDoubleFields(form.doc);
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudCouldNotFindCrudTable("doc." + invalidDoubleFields.get(0), form.docId);
|
||||
}, () -> asEditHtml());
|
||||
|
@ -423,7 +423,7 @@ public class AdminSearchlistAction extends FessAdminAction {
|
|||
protected OptionalEntity<Map<String, Object>> getDoc(final CreateForm form) {
|
||||
switch (form.crudMode) {
|
||||
case CrudMode.CREATE:
|
||||
Map<String, Object> entity = new HashMap<>();
|
||||
final Map<String, Object> entity = new HashMap<>();
|
||||
entity.put(fessConfig.getIndexFieldDocId(), systemHelper.generateDocId(entity));
|
||||
return OptionalEntity.of(entity);
|
||||
case CrudMode.EDIT:
|
||||
|
|
|
@ -61,12 +61,12 @@ public class FessLoginAssist extends TypicalLoginAssist<String, FessUserBean, Fe
|
|||
// Find User
|
||||
// =========
|
||||
@Override
|
||||
public boolean checkUserLoginable(LoginCredential credential) {
|
||||
public boolean checkUserLoginable(final LoginCredential credential) {
|
||||
throw new UnsupportedOperationException("checkUserLoginable is not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkCredential(TypicalLoginAssist<String, FessUserBean, FessUser>.CredentialChecker checker) {
|
||||
protected void checkCredential(final TypicalLoginAssist<String, FessUserBean, FessUser>.CredentialChecker checker) {
|
||||
throw new UnsupportedOperationException("checkCredential is not supported.");
|
||||
}
|
||||
|
||||
|
@ -136,9 +136,9 @@ public class FessLoginAssist extends TypicalLoginAssist<String, FessUserBean, Fe
|
|||
// ==============
|
||||
|
||||
@Override
|
||||
protected void resolveCredential(CredentialResolver resolver) {
|
||||
protected void resolveCredential(final CredentialResolver resolver) {
|
||||
resolver.resolve(UserPasswordCredential.class, credential -> {
|
||||
final UserPasswordCredential userCredential = (UserPasswordCredential) credential;
|
||||
final UserPasswordCredential userCredential = credential;
|
||||
final String username = userCredential.getUser();
|
||||
final String password = userCredential.getPassword();
|
||||
if (!fessConfig.isAdminUser(username)) {
|
||||
|
@ -150,14 +150,14 @@ public class FessLoginAssist extends TypicalLoginAssist<String, FessUserBean, Fe
|
|||
return doFindLoginUser(username, encryptPassword(password));
|
||||
});
|
||||
resolver.resolve(SpnegoCredential.class, credential -> {
|
||||
final String username = ((SpnegoCredential) credential).getUsername();
|
||||
final String username = credential.getUsername();
|
||||
if (!fessConfig.isAdminUser(username)) {
|
||||
return ComponentUtil.getLdapManager().login(username);
|
||||
}
|
||||
return OptionalEntity.empty();
|
||||
});
|
||||
resolver.resolve(OpenIdConnectCredential.class, credential -> {
|
||||
return OptionalEntity.of(((OpenIdConnectCredential) credential).getUser());
|
||||
return OptionalEntity.of(credential.getUser());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ public class FileListIndexUpdateCallbackImpl implements IndexUpdateCallback, Aut
|
|||
this.maxDeleteDocumentCacheSize = maxDeleteDocumentCacheSize;
|
||||
}
|
||||
|
||||
public void setMaxRedirectCount(int maxRedirectCount) {
|
||||
public void setMaxRedirectCount(final int maxRedirectCount) {
|
||||
this.maxRedirectCount = maxRedirectCount;
|
||||
}
|
||||
|
||||
|
|
|
@ -677,17 +677,17 @@ public class FessEsClient implements Client {
|
|||
public OptionalEntity<Map<String, Object>> getDocumentByQuery(final String index, final String type, final QueryBuilder queryBuilder) {
|
||||
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
SearchResponse response =
|
||||
final SearchResponse response =
|
||||
client.prepareSearch(index).setTypes(type).setSize(1).setQuery(queryBuilder).addField(fessConfig.getIndexFieldId())
|
||||
.setPreference(Constants.SEARCH_PREFERENCE_PRIMARY).execute().actionGet(fessConfig.getIndexSearchTimeout());
|
||||
SearchHits hits = response.getHits();
|
||||
final SearchHits hits = response.getHits();
|
||||
if (hits.getTotalHits() != 0) {
|
||||
SearchHit hit = hits.getAt(0);
|
||||
String id = hit.getId();
|
||||
GetResponse getResponse =
|
||||
final SearchHit hit = hits.getAt(0);
|
||||
final String id = hit.getId();
|
||||
final GetResponse getResponse =
|
||||
client.prepareGet(index, type, id).setPreference(Constants.SEARCH_PREFERENCE_PRIMARY).execute()
|
||||
.actionGet(fessConfig.getIndexSearchTimeout());
|
||||
Map<String, Object> source = BeanUtil.copyMapToNewMap(getResponse.getSource());
|
||||
final Map<String, Object> source = BeanUtil.copyMapToNewMap(getResponse.getSource());
|
||||
source.put(fessConfig.getIndexFieldId(), id);
|
||||
source.put(fessConfig.getIndexFieldVersion(), getResponse.getVersion());
|
||||
return OptionalEntity.of(source);
|
||||
|
@ -966,7 +966,7 @@ public class FessEsClient implements Client {
|
|||
.actionGet(fessConfig.getIndexIndexTimeout());
|
||||
} else {
|
||||
// create or update
|
||||
IndexRequestBuilder builder =
|
||||
final IndexRequestBuilder builder =
|
||||
client.prepareIndex(index, type, id).setSource(source).setRefresh(true).setOpType(OpType.INDEX);
|
||||
if (version != null && version.longValue() > 0) {
|
||||
builder.setVersion(version);
|
||||
|
|
|
@ -1,10 +1,25 @@
|
|||
/*
|
||||
* Copyright 2012-2016 CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.exception;
|
||||
|
||||
public class JobProcessingException extends FessSystemException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public JobProcessingException(Throwable e) {
|
||||
public JobProcessingException(final Throwable e) {
|
||||
super(e);
|
||||
}
|
||||
|
||||
|
|
|
@ -790,7 +790,7 @@ public class QueryHelper {
|
|||
return UUID.randomUUID().toString().replace("-", StringUtil.EMPTY);
|
||||
}
|
||||
|
||||
public void setLowercaseWildcard(boolean lowercaseWildcard) {
|
||||
public void setLowercaseWildcard(final boolean lowercaseWildcard) {
|
||||
this.lowercaseWildcard = lowercaseWildcard;
|
||||
}
|
||||
|
||||
|
|
|
@ -339,7 +339,7 @@ public class ViewHelper {
|
|||
buf.append(URLEncoder.encode(queries.trim(), Constants.UTF_8));
|
||||
buf.append("%22");
|
||||
return buf.toString();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
} catch (final UnsupportedEncodingException e) {
|
||||
logger.warn("Unsupported encoding.", e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2012-2016 CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.job;
|
||||
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
|
@ -23,7 +38,7 @@ public class PurgeThumbnailJob {
|
|||
return expiry;
|
||||
}
|
||||
|
||||
public PurgeThumbnailJob expiry(long expiry) {
|
||||
public PurgeThumbnailJob expiry(final long expiry) {
|
||||
this.expiry = expiry;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -1226,7 +1226,7 @@ public interface FessProp {
|
|||
final String key = e.getKey();
|
||||
Object value = e.getValue();
|
||||
if (value instanceof String || value == null) {
|
||||
return new Pair<String, Object>(key, value);
|
||||
return new Pair<>(key, value);
|
||||
}
|
||||
if (arrayFieldSet.contains(key)) {
|
||||
if (value instanceof String[]) {
|
||||
|
@ -1247,7 +1247,7 @@ public interface FessProp {
|
|||
} else if (doubleFieldSet.contains(key)) {
|
||||
value = value.toString();
|
||||
}
|
||||
return new Pair<String, Object>(key, value);
|
||||
return new Pair<>(key, value);
|
||||
}).collect(Collectors.toMap(Pair::getFirst, Pair::getSecond));
|
||||
}
|
||||
|
||||
|
@ -1283,7 +1283,7 @@ public interface FessProp {
|
|||
} else if (doubleFieldSet.contains(key)) {
|
||||
value = Double.parseDouble(value.toString());
|
||||
}
|
||||
return new Pair<String, Object>(key, value);
|
||||
return new Pair<>(key, value);
|
||||
}).collect(Collectors.toMap(Pair::getFirst, Pair::getSecond));
|
||||
}
|
||||
|
||||
|
@ -1310,7 +1310,7 @@ public interface FessProp {
|
|||
public default int[] getCrawlerDocumentSpaceCharsAsArray() {
|
||||
int[] spaceChars = (int[]) propMap.get(CRAWLER_DOCUMENT_SPACE_CHARS);
|
||||
if (spaceChars == null) {
|
||||
int length = getCrawlerDocumentSpaceChars().length();
|
||||
final int length = getCrawlerDocumentSpaceChars().length();
|
||||
spaceChars = new int[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
spaceChars[i] = getCrawlerDocumentSpaceChars().codePointAt(i);
|
||||
|
|
|
@ -125,7 +125,7 @@ public class ThumbnailManager {
|
|||
thumbnailGeneratorThread.interrupt();
|
||||
try {
|
||||
thumbnailGeneratorThread.join(10000);
|
||||
} catch (InterruptedException e) {
|
||||
} catch (final InterruptedException e) {
|
||||
logger.warn("Thumbnail thread is timeouted.", e);
|
||||
}
|
||||
generatorList.forEach(g -> {
|
||||
|
@ -233,7 +233,7 @@ public class ThumbnailManager {
|
|||
|
||||
private static class FilePurgeVisitor implements FileVisitor<Path> {
|
||||
|
||||
private long expiry;
|
||||
private final long expiry;
|
||||
|
||||
private long count;
|
||||
|
||||
|
@ -340,23 +340,23 @@ public class ThumbnailManager {
|
|||
|
||||
}
|
||||
|
||||
public void setThumbnailPathCacheSize(int thumbnailPathCacheSize) {
|
||||
public void setThumbnailPathCacheSize(final int thumbnailPathCacheSize) {
|
||||
this.thumbnailPathCacheSize = thumbnailPathCacheSize;
|
||||
}
|
||||
|
||||
public void setImageExtention(String imageExtention) {
|
||||
public void setImageExtention(final String imageExtention) {
|
||||
this.imageExtention = imageExtention;
|
||||
}
|
||||
|
||||
public void setSplitSize(int splitSize) {
|
||||
public void setSplitSize(final int splitSize) {
|
||||
this.splitSize = splitSize;
|
||||
}
|
||||
|
||||
public void setThumbnailTaskQueueSize(int thumbnailTaskQueueSize) {
|
||||
public void setThumbnailTaskQueueSize(final int thumbnailTaskQueueSize) {
|
||||
this.thumbnailTaskQueueSize = thumbnailTaskQueueSize;
|
||||
}
|
||||
|
||||
public void setNoImageExpired(long noImageExpired) {
|
||||
public void setNoImageExpired(final long noImageExpired) {
|
||||
this.noImageExpired = noImageExpired;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ public abstract class BaseThumbnailGenerator implements ThumbnailGenerator {
|
|||
}
|
||||
return generatorList.stream().map(s -> {
|
||||
if (s.startsWith("${path}")) {
|
||||
for (String p : pathList) {
|
||||
for (final String p : pathList) {
|
||||
final File f = new File(s.replace("${path}", p));
|
||||
if (f.exists()) {
|
||||
final String filePath = f.getAbsolutePath();
|
||||
|
@ -88,18 +88,18 @@ public abstract class BaseThumbnailGenerator implements ThumbnailGenerator {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void setDirectoryNameLength(int directoryNameLength) {
|
||||
public void setDirectoryNameLength(final int directoryNameLength) {
|
||||
this.directoryNameLength = directoryNameLength;
|
||||
}
|
||||
|
||||
protected String expandPath(String value) {
|
||||
protected String expandPath(final String value) {
|
||||
if (value != null && filePathMap.containsKey(value)) {
|
||||
return filePathMap.get(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setGeneratorList(List<String> generatorList) {
|
||||
public void setGeneratorList(final List<String> generatorList) {
|
||||
this.generatorList = generatorList;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ public class CommandGenerator extends BaseThumbnailGenerator {
|
|||
destoryTimer = new Timer("CommandGeneratorDestoryTimer-" + System.currentTimeMillis(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
destoryTimer.cancel();
|
||||
destoryTimer = null;
|
||||
|
|
|
@ -72,7 +72,7 @@ public class WebDriverGenerator extends BaseThumbnailGenerator {
|
|||
webDriver = new PhantomJSDriver();
|
||||
} else {
|
||||
if (webDriverCapabilities instanceof DesiredCapabilities) {
|
||||
DesiredCapabilities capabilities = (DesiredCapabilities) webDriverCapabilities;
|
||||
final DesiredCapabilities capabilities = (DesiredCapabilities) webDriverCapabilities;
|
||||
webDriverCapabilities.asMap().entrySet().stream()
|
||||
.filter(e -> e.getValue() instanceof String && filePathMap.containsKey(e.getValue().toString()))
|
||||
.forEach(e -> capabilities.setCapability(e.getKey(), filePathMap.get(e.getValue().toString())));
|
||||
|
@ -91,6 +91,7 @@ public class WebDriverGenerator extends BaseThumbnailGenerator {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (webDriver != null) {
|
||||
webDriver.quit();
|
||||
|
@ -160,7 +161,7 @@ public class WebDriverGenerator extends BaseThumbnailGenerator {
|
|||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected PhantomJSDriverService createDriverService(Capabilities desiredCapabilities) {
|
||||
protected PhantomJSDriverService createDriverService(final Capabilities desiredCapabilities) {
|
||||
// Look for Proxy configuration within the Capabilities
|
||||
Proxy proxy = null;
|
||||
if (desiredCapabilities != null) {
|
||||
|
@ -177,7 +178,7 @@ public class WebDriverGenerator extends BaseThumbnailGenerator {
|
|||
phantomjspath = System.getProperty(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, phantomjspath);
|
||||
}
|
||||
|
||||
File phantomjsfile = new File(phantomjspath);
|
||||
final File phantomjsfile = new File(phantomjspath);
|
||||
|
||||
// Build & return service
|
||||
return new Builder()//
|
||||
|
@ -188,18 +189,18 @@ public class WebDriverGenerator extends BaseThumbnailGenerator {
|
|||
.build();
|
||||
}
|
||||
|
||||
private static String[] findCLIArgumentsFromCaps(Capabilities desiredCapabilities, String capabilityName) {
|
||||
private static String[] findCLIArgumentsFromCaps(final Capabilities desiredCapabilities, final String capabilityName) {
|
||||
if (desiredCapabilities != null) {
|
||||
Object cap = desiredCapabilities.getCapability(capabilityName);
|
||||
final Object cap = desiredCapabilities.getCapability(capabilityName);
|
||||
if (cap != null) {
|
||||
if (cap instanceof String[]) {
|
||||
return (String[]) cap;
|
||||
} else if (cap instanceof Collection) {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<String> capCollection = (Collection<String>) cap;
|
||||
final Collection<String> capCollection = (Collection<String>) cap;
|
||||
return capCollection.toArray(new String[capCollection.size()]);
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
// If casting fails, log an error and assume no CLI arguments are provided
|
||||
logger.warn(String.format("Unable to set Capability '%s' as it was neither a String[] or a Collection<String>",
|
||||
capabilityName));
|
||||
|
@ -210,31 +211,31 @@ public class WebDriverGenerator extends BaseThumbnailGenerator {
|
|||
return new String[] {}; // nothing found: return an empty array of arguments
|
||||
}
|
||||
|
||||
public void setWebDriver(WebDriver webDriver) {
|
||||
public void setWebDriver(final WebDriver webDriver) {
|
||||
this.webDriver = webDriver;
|
||||
}
|
||||
|
||||
public void setWebDriverCapabilities(Capabilities webDriverCapabilities) {
|
||||
public void setWebDriverCapabilities(final Capabilities webDriverCapabilities) {
|
||||
this.webDriverCapabilities = webDriverCapabilities;
|
||||
}
|
||||
|
||||
public void setWindowWidth(int windowWidth) {
|
||||
public void setWindowWidth(final int windowWidth) {
|
||||
this.windowWidth = windowWidth;
|
||||
}
|
||||
|
||||
public void setWindowHeight(int windowHeight) {
|
||||
public void setWindowHeight(final int windowHeight) {
|
||||
this.windowHeight = windowHeight;
|
||||
}
|
||||
|
||||
public void setThumbnailWidth(int thumbnailWidth) {
|
||||
public void setThumbnailWidth(final int thumbnailWidth) {
|
||||
this.thumbnailWidth = thumbnailWidth;
|
||||
}
|
||||
|
||||
public void setImageFormatName(String imageFormatName) {
|
||||
public void setImageFormatName(final String imageFormatName) {
|
||||
this.imageFormatName = imageFormatName;
|
||||
}
|
||||
|
||||
public void setThumbnailHeight(int thumbnailHeight) {
|
||||
public void setThumbnailHeight(final int thumbnailHeight) {
|
||||
this.thumbnailHeight = thumbnailHeight;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue