diff --git a/spring-content-azure-storage/src/main/java/internal/org/springframework/content/azure/config/AzureStorageConfiguration.java b/spring-content-azure-storage/src/main/java/internal/org/springframework/content/azure/config/AzureStorageConfiguration.java index 2712cbd3c..a4793a4cc 100644 --- a/spring-content-azure-storage/src/main/java/internal/org/springframework/content/azure/config/AzureStorageConfiguration.java +++ b/spring-content-azure-storage/src/main/java/internal/org/springframework/content/azure/config/AzureStorageConfiguration.java @@ -50,9 +50,11 @@ public PlacementService azureStoragePlacementService() { public static void addDefaultConverters(PlacementService conversion, String bucket) { // Serializable -> BlobId + logger.info("Adding Serializable->BlobId converter"); conversion.addConverter(new BlobIdResolverConverter(bucket)); // ContentPropertyInfo -> BlobId + logger.info("Adding ContentPropertyInfo->BlobId converter"); conversion.addConverter(new Converter, BlobId>() { private String defaultBucket = bucket; diff --git a/spring-content-azure-storage/src/main/java/internal/org/springframework/content/azure/store/DefaultAzureStorageImpl.java b/spring-content-azure-storage/src/main/java/internal/org/springframework/content/azure/store/DefaultAzureStorageImpl.java index 797e48fb0..fcc04c3b3 100644 --- a/spring-content-azure-storage/src/main/java/internal/org/springframework/content/azure/store/DefaultAzureStorageImpl.java +++ b/spring-content-azure-storage/src/main/java/internal/org/springframework/content/azure/store/DefaultAzureStorageImpl.java @@ -131,8 +131,10 @@ public Resource getResource(S entity, PropertyPath propertyPath, GetResourcePara BlobId blobId = null; TypeDescriptor contentPropertyInfoType = ContentPropertyInfoTypeDescriptor.withGenerics(entity, property); if (placementService.canConvert(contentPropertyInfoType, TypeDescriptor.valueOf(BlobId.class))) { - ContentPropertyInfo contentPropertyInfo = ContentPropertyInfo.of(entity, - (SID) property.getContentId(entity), propertyPath, property); + ContentPropertyInfo contentPropertyInfo = ContentPropertyInfo.of(entity, (SID) property.getContentId(entity), propertyPath, property); + + + blobId = placementService.convert(contentPropertyInfo, BlobId.class); if (blobId != null) { diff --git a/spring-content-commons/src/main/java/org/springframework/content/commons/utils/PlacementServiceImpl.java b/spring-content-commons/src/main/java/org/springframework/content/commons/utils/PlacementServiceImpl.java index d7053e7df..1e2dea73c 100644 --- a/spring-content-commons/src/main/java/org/springframework/content/commons/utils/PlacementServiceImpl.java +++ b/spring-content-commons/src/main/java/org/springframework/content/commons/utils/PlacementServiceImpl.java @@ -1,5 +1,7 @@ package org.springframework.content.commons.utils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.springframework.content.commons.config.ContentPropertyInfo; import org.springframework.core.ResolvableType; import org.springframework.core.convert.TypeDescriptor; @@ -15,6 +17,8 @@ public class PlacementServiceImpl extends DefaultConversionService implements PlacementService { + private static Log logger = LogFactory.getLog(PlacementServiceImpl.class); + public static final String CONTENT_PROPERTY_INFO_GENERIC_PARAMETERS_MISSING_MESSAGE = "Unable to determine entity type and content id type for " + ContentPropertyInfo.class.getName() + "; does the class parameterize those types?"; @@ -53,22 +57,29 @@ public void addConverter(Converter converter) { "Converter [" + converter.getClass().getName() + "]; does the class parameterize those types?"); } ResolvableType sourceType = generics[0]; + logger.info("generics[0] sourceType: " + sourceType.toString()); if (sourceType.resolve() == ContentPropertyInfo.class) { ResolvableType targetType = generics[1]; + logger.info("generics[1] targetType: " + targetType.toString()); ResolvableType[] sourceTypeGenerics = sourceType.getGenerics(); if (sourceTypeGenerics.length != 2) { throw new IllegalArgumentException(CONTENT_PROPERTY_INFO_GENERIC_PARAMETERS_MISSING_MESSAGE); } + logger.info("sourceTypeGenerics[0]: " + sourceTypeGenerics[0].toString()); + logger.info("sourceTypeGenerics[1]: " + sourceTypeGenerics[1].toString()); + Class entityClass = sourceTypeGenerics[0].resolve(); Class contentIdClass = sourceTypeGenerics[1].resolve(); if (entityClass == null || contentIdClass == null) { throw new IllegalArgumentException(CONTENT_PROPERTY_INFO_GENERIC_PARAMETERS_MISSING_MESSAGE); } + logger.info("Adding converter as ContentPropertyInfoConverterAdapter"); addConverter(new ContentPropertyInfoConverterAdapter(converter, sourceType, targetType, entityClass, contentIdClass)); } else { + logger.info("Adding as regular converter"); super.addConverter(converter); } }