Skip to content

Commit 2cd1258

Browse files
authored
Merge pull request #220 from RWS/fix-for-404-bug
Fix for 404 bug
2 parents eefc65e + e29f229 commit 2cd1258

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

dxa-framework/dxa-common-api/src/main/java/com/sdl/dxa/DxaSpringInitialization.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
import com.fasterxml.jackson.annotation.JsonInclude;
44
import com.fasterxml.jackson.annotation.JsonTypeInfo;
5-
import com.fasterxml.jackson.databind.DeserializationFeature;
6-
import com.fasterxml.jackson.databind.ObjectMapper;
7-
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
8-
import com.fasterxml.jackson.databind.SerializationFeature;
5+
import com.fasterxml.jackson.databind.*;
96
import com.fasterxml.jackson.databind.ser.FilterProvider;
107
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
118
import com.fasterxml.jackson.databind.util.StdDateFormat;
@@ -178,7 +175,7 @@ public ObjectMapper objectMapper() {
178175
objectMapper.setFilterProvider(jsonFilterProvider());
179176
objectMapper.setDateFormat(new StdDateFormat());
180177
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
181-
objectMapper.setPropertyNamingStrategy(new PropertyNamingStrategy.UpperCamelCaseStrategy());
178+
objectMapper.setPropertyNamingStrategy(PropertyNamingStrategies.UPPER_CAMEL_CASE);
182179
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
183180
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_ABSENT);
184181

dxa-framework/dxa-tridion-provider/src/main/java/com/sdl/dxa/tridion/graphql/GraphQLProvider.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ private ApiClient getPcaClient() {
6868
// To determine this, DXA first tries the regular Page and if it doesn't exist, it appends /index.html and tries again.
6969
// TODO: The above should be handled by GraphQL (See CRQ-11703)
7070
public <T> T loadPage(Class<T> type, PageRequestDto pageRequest, ContentType contentType) throws ContentProviderException {
71+
T result = null;
7172
try {
7273
JsonNode pageNode = getPcaClient().getPageModelData(
7374
GraphQLUtils.convertUriToGraphQLContentNamespace(pageRequest.getUriType()),
@@ -79,7 +80,7 @@ public <T> T loadPage(Class<T> type, PageRequestDto pageRequest, ContentType con
7980
ContentIncludeMode.INCLUDE_DATA_AND_RENDER,
8081
null
8182
);
82-
T result = mapToType(type, pageNode);
83+
result = mapToType(type, pageNode);
8384
// result may be 'null' starting from Jackson 2.18.3, so checking for this condition
8485
if (result == null) {
8586
String pathToDefaults = normalizePathToDefaults(pageRequest.getPath(), true);
@@ -95,10 +96,6 @@ public <T> T loadPage(Class<T> type, PageRequestDto pageRequest, ContentType con
9596
null);
9697
result = mapToType(type, pageNode);
9798
}
98-
if (log.isTraceEnabled()) {
99-
log.trace("Loaded '{}' for pageRequest '{}'", result, pageRequest);
100-
}
101-
return result;
10299
}
103100
catch (IOException e) {
104101
// Keeping this for users who may override the Jackson version and utilize a version prior to 2.18.3
@@ -115,11 +112,7 @@ public <T> T loadPage(Class<T> type, PageRequestDto pageRequest, ContentType con
115112
PageInclusion.valueOf(pageRequest.getIncludePages().toString()),
116113
ContentIncludeMode.INCLUDE_DATA_AND_RENDER,
117114
null);
118-
T result = mapToType(type, node);
119-
if (log.isTraceEnabled()) {
120-
log.trace("Loaded '{}' for pageRequest '{}'", result, pageRequest);
121-
}
122-
return result;
115+
result = mapToType(type, node);
123116
}
124117
catch (IOException ex) {
125118
if (log.isTraceEnabled()) {
@@ -128,6 +121,13 @@ public <T> T loadPage(Class<T> type, PageRequestDto pageRequest, ContentType con
128121
throw new PageNotFoundException("Unable to load page, by request " + pageRequest, ex);
129122
}
130123
}
124+
if (log.isTraceEnabled()) {
125+
log.trace("Loaded '{}' for pageRequest '{}'", result, pageRequest);
126+
}
127+
if (result == null) {
128+
throw new PageNotFoundException("Unable to load page (retrieved 'null'), by request " + pageRequest);
129+
}
130+
return result;
131131
}
132132

133133
public <T> T loadPage(Class<T> type, String namespace, int publicationId, int pageId, ContentType contentType, DataModelType modelType, PageInclusion pageInclusion, ContextData contextData) throws ContentProviderException {

0 commit comments

Comments
 (0)