Skip to content

Commit

Permalink
fix: rest layer should recognize stores interfaces from new 'store' p…
Browse files Browse the repository at this point in the history
…ackages (#1345)
  • Loading branch information
paulcwarren authored Apr 5, 2023
1 parent f3e8411 commit 676cb06
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ public void afterPropertiesSet() {
ClassTypeInformation.from(factory.getStoreInterface()).getRequiredSuperTypeInformation(ContentStore.class).getTypeArguments().get(0).getType(),
new StoreSupplier(this.factory, beanNameFromFactoryBeanName(name)));
storeInfos.add(info);
} else if (org.springframework.content.commons.store.ContentStore.class.isAssignableFrom(factory.getStoreInterface())) {
StoreInfo info = new StoreInfoImpl(
factory.getStoreInterface(),
ClassTypeInformation.from(factory.getStoreInterface()).getRequiredSuperTypeInformation(org.springframework.content.commons.store.ContentStore.class).getTypeArguments().get(0).getType(),
new StoreSupplier(this.factory, beanNameFromFactoryBeanName(name)));
storeInfos.add(info);
}
else {
StoreInfo info = new StoreInfoImpl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ public ContentServiceFactory(RestConfiguration config, Repositories repositories

public ContentService getContentService(StoreResource resource) {

if (ContentStore.class.isAssignableFrom(resource.getStoreInfo().getInterface())) {
if (ContentStore.class.isAssignableFrom(resource.getStoreInfo().getInterface()) || org.springframework.content.commons.store.ContentStore.class.isAssignableFrom(resource.getStoreInfo().getInterface())) {

Object entity = ((AssociatedStoreResource)resource).getAssociation();

return new ContentStoreContentService(config, null, repoInvokerFactory.getInvokerFor(entity.getClass()), mappingContext, exportContext, byteRangeRestRequestHandler);

} else if (AssociativeStore.class.isAssignableFrom(resource.getStoreInfo().getInterface())) {
} else if (AssociativeStore.class.isAssignableFrom(resource.getStoreInfo().getInterface()) || org.springframework.content.commons.store.AssociativeStore.class.isAssignableFrom(resource.getStoreInfo().getInterface())) {

Object entity = ((AssociatedStoreResource)resource).getAssociation();
return new AssociativeStoreContentService(config, null, repoInvokerFactory.getInvokerFor(entity.getClass()), entity, byteRangeRestRequestHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer m
throw new IllegalArgumentException(String.format("Store for path %s not found", store));
}

if (AssociativeStore.class.isAssignableFrom(info.getInterface())) {
if (AssociativeStore.class.isAssignableFrom(info.getInterface()) || org.springframework.content.commons.store.AssociativeStore.class.isAssignableFrom(info.getInterface())) {

String resolvedContentPropertyPath = requestMappingContext.resolveContentPropertyPath(info.getDomainObjectClass(), ContentPropertyRequest.from(pathInfo).getContentPropertyPath());
String resolvedStoreLookupPath = ContentPropertyRequest.from(pathSegments[1], pathSegments[2], resolvedContentPropertyPath).getRequestURI();
Expand Down Expand Up @@ -136,7 +136,7 @@ public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer m

return matchedResolver.resolve(webRequest, info, result.getEntity(), result.getProperty());

} else if (Store.class.isAssignableFrom(info.getInterface())) {
} else if (Store.class.isAssignableFrom(info.getInterface()) || org.springframework.content.commons.store.Store.class.isAssignableFrom(info.getInterface())) {

return resolveStoreArgument(webRequest, info);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ private boolean isExcludedShortcutContentPropertyRequest(HttpServletRequest requ
}

private boolean isFullyQualifiedContentPropertyRequest(String[] path, StoreInfo info2) {
return AssociativeStore.class.isAssignableFrom(info2.getInterface()) && path.length >= 4;
return (AssociativeStore.class.isAssignableFrom(info2.getInterface()) ||
org.springframework.content.commons.store.AssociativeStore.class.isAssignableFrom(info2.getInterface())) && path.length >= 4;
}

@Override
Expand Down

0 comments on commit 676cb06

Please sign in to comment.