Skip to content

Commit

Permalink
* Changed TemplateEngineInlineContentItemsResolver to an interface.
Browse files Browse the repository at this point in the history
* Changed default retry policy from 0 to 3.
  • Loading branch information
aweigold committed Jul 29, 2018
1 parent 46c5fb8 commit 82a989a
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.gradle
/build/
/out/
build/
out/
signing.gpg
deploy_key
deploy_key.pub
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public TaxonomyGroup getTaxonomyGroup(String taxonomyGroupCodename) throws IOExc

public TaxonomyGroup getTaxonomyGroup(String taxonomyGroupCodename, List<NameValuePair> params) throws IOException {
HttpUriRequest request = buildGetRequest(
String.format("%s/%s", TAXONOMIES, taxonomyGroupCodename), params);
String.format(URL_CONCAT, TAXONOMIES, taxonomyGroupCodename), params);
return executeRequest(request, TaxonomyGroup.class);
}

Expand Down Expand Up @@ -456,7 +456,7 @@ private void handleErrorIfNecessary(HttpResponse response) throws IOException {
logger.error("Kentico API server error, status: {}", status);
throw new IOException("Unknown error with Kentico API. Kentico is likely suffering site issues.");
} else if (status >= 400) {
logger.error("Kentico API request error, status: ", status);
logger.error("Kentico API request error, status: {}", status);
InputStream inputStream = response.getEntity().getContent();
KenticoError kenticoError = objectMapper.readValue(inputStream, KenticoError.class);
inputStream.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class DeliveryOptions {
String previewApiKey;
boolean usePreviewApi = false;
boolean waitForLoadingNewContent = false;
int retryAttempts = 0;
int retryAttempts = 3;

/**
* Constructs an empty settings instance of {@link DeliveryOptions}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public void init() {
if (isAutoRegister()) {
FastClasspathScanner scanner =
new FastClasspathScanner(getPathsToScan().toArray(new String[0]));
scanner.matchSubclassesOf(TemplateEngineInlineContentItemsResolver.class, subclass -> {
scanner.matchClassesImplementing(TemplateEngineInlineContentItemsResolver.class, implementingClass -> {
try {
TemplateEngineInlineContentItemsResolver resolver =
ConstructorUtils.invokeConstructor(subclass, null);
ConstructorUtils.invokeConstructor(implementingClass, null);
resolver.getTemplateEngine().setViewResolverConfiguration(getViewResolverConfiguration());
addResolvers(resolver);
logger.info("Registered inline content template resolver: {}", resolver.getClass().getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,14 @@

package com.kenticocloud.delivery.template;

public abstract class TemplateEngineInlineContentItemsResolver {
public interface TemplateEngineInlineContentItemsResolver {

public TemplateEngineInlineContentItemsResolver() {
//Default constructor
}

public String resolve(TemplateEngineModel data) {
default String resolve(TemplateEngineModel data) {
TemplateEngine templateEngine = getTemplateEngine();
return templateEngine.process(data);
}

public abstract boolean supports(TemplateEngineModel data);
boolean supports(TemplateEngineModel data);

public abstract TemplateEngine getTemplateEngine();
TemplateEngine getTemplateEngine();
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.slf4j.LoggerFactory;
import org.thymeleaf.Thymeleaf;

public class ThymeleafInlineContentItemsResolver extends TemplateEngineInlineContentItemsResolver {
public class ThymeleafInlineContentItemsResolver implements TemplateEngineInlineContentItemsResolver {
private static final Logger logger = LoggerFactory.getLogger(ThymeleafInlineContentItemsResolver.class);

protected ThymeleafTemplateEngine thymeleafTemplateEngine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import com.kenticocloud.delivery.template.TemplateEngineInlineContentItemsResolver;
import com.kenticocloud.delivery.template.TemplateEngineModel;

public class BadResolver extends TemplateEngineInlineContentItemsResolver {
public class BadResolver implements TemplateEngineInlineContentItemsResolver {

public BadResolver() throws RenderingEngineMissingException {
throw new RenderingEngineMissingException("Bad resolver", new Exception());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@

import com.kenticocloud.delivery.template.*;

public class GoodResolver extends TemplateEngineInlineContentItemsResolver {

public GoodResolver() {
}
public class GoodResolver implements TemplateEngineInlineContentItemsResolver {

@Override
public boolean supports(TemplateEngineModel data) {
Expand Down

0 comments on commit 82a989a

Please sign in to comment.