Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: events should only be published once per content operation #1901

Merged
merged 23 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7e52606
fix: events should only be published once per content operation
paulcwarren Apr 9, 2024
a439d0d
event handler methods need to match store package
paulcwarren Apr 16, 2024
e1d93d6
setContent should only call aftersetcontent events once only
paulcwarren Apr 17, 2024
a23c461
Switch back to spring-content-examples main branch
paulcwarren Apr 17, 2024
4ed5acf
need to check spring-content first
paulcwarren Apr 18, 2024
978f7b6
assert entityClass and contentIdClass are non-null
paulcwarren Apr 18, 2024
0318c1e
exit early if either class is null
paulcwarren Apr 18, 2024
686573d
Add some logging so we can see if afterPropertiesSet is being called
paulcwarren Apr 18, 2024
10cc734
more logging around the placement service default converters
paulcwarren Apr 19, 2024
6323019
more logging in azure storage impl to see what the typedescriptor of …
paulcwarren Apr 19, 2024
6271b2a
log the conversionservice and its converters
paulcwarren Apr 19, 2024
dcc928b
Log the placement service's hashcode so we cancheck if the storage im…
paulcwarren Apr 19, 2024
9873027
wip: more logging
paulcwarren Apr 23, 2024
471a488
wip: more logging around converters getClassHierarchy to see if the p…
paulcwarren Apr 23, 2024
7387878
Temporarily make placementserviceimpl an impl of genericconversionser…
paulcwarren Apr 24, 2024
8dab706
add a default set of converters
paulcwarren Apr 24, 2024
00a64fd
temporarily disable NaturalIdIT test
paulcwarren Apr 24, 2024
b5c1bbd
add a toString to placement service for better logging
paulcwarren Apr 24, 2024
3453e82
even more logging
paulcwarren Apr 26, 2024
8f4b1bc
Call convert with the same type descriptors as used for the canConver…
paulcwarren Apr 26, 2024
929443e
Re-instate the original placement service
paulcwarren Apr 26, 2024
075256c
fix NPE
paulcwarren Apr 26, 2024
dc647ab
Add logging in s3 reactive storage where content id and length are set
paulcwarren Apr 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ jobs:
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ github.run_id }}
- uses: actions/checkout@v2
with:
path: spring-content
- name: Re-build spring-content
run: |
pushd spring-content
mvn install -DskipTests=true
popd
- uses: actions/checkout@v2
with:
repository: paulcwarren/spring-content-examples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.io.Serializable;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -21,11 +23,14 @@
import org.springframework.core.convert.converter.ConverterRegistry;

import com.azure.spring.autoconfigure.storage.resource.AzureStorageProtocolResolver;
import org.springframework.core.convert.converter.GenericConverter;

@Configuration
@Import(AzureStorageProtocolResolver.class)
public class AzureStorageConfiguration implements InitializingBean {

private static Log logger = LogFactory.getLog(AzureStorageConfiguration.class);

@Autowired(required = false)
private List<AzureStorageConfigurer> configurers;

Expand All @@ -46,10 +51,12 @@ 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
conversion.addConverter(new Converter<ContentPropertyInfo<Object, Serializable>, BlobId>() {
logger.info("Adding ContentPropertyInfo->BlobId converter");
Converter converter = new Converter<ContentPropertyInfo<Object, Serializable>, BlobId>() {

private String defaultBucket = bucket;

Expand All @@ -73,7 +80,8 @@ public BlobId convert(ContentPropertyInfo<Object, Serializable> info) {
return (key != null) ? new BlobId(strBucket, key.toString()) : null;
}

});
};
conversion.addConverter(converter);
}

private void addConverters(ConverterRegistry registry) {
Expand All @@ -89,5 +97,6 @@ private void addConverters(ConverterRegistry registry) {
public void afterPropertiesSet() throws Exception {
addDefaultConverters(conversion, bucket);
addConverters(conversion);
logger.info(conversion.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.UUID;
import java.util.*;

import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
Expand All @@ -26,8 +26,10 @@
import org.springframework.content.commons.utils.BeanUtils;
import org.springframework.content.commons.utils.Condition;
import org.springframework.content.commons.utils.PlacementService;
import org.springframework.content.commons.utils.PlacementServiceImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.converter.GenericConverter;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.WritableResource;
Expand All @@ -38,6 +40,7 @@

import internal.org.springframework.content.azure.io.AzureBlobResource;
import internal.org.springframework.content.commons.utils.ContentPropertyInfoTypeDescriptor;
import org.springframework.util.ClassUtils;

@Transactional
public class DefaultAzureStorageImpl<S, SID extends Serializable>
Expand Down Expand Up @@ -131,8 +134,8 @@ 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<S, SID> contentPropertyInfo = ContentPropertyInfo.of(entity,
(SID) property.getContentId(entity), propertyPath, property);
ContentPropertyInfo<S, SID> contentPropertyInfo = ContentPropertyInfo.of(entity, (SID) property.getContentId(entity), propertyPath, property);

blobId = (BlobId) placementService.convert(contentPropertyInfo, contentPropertyInfoType, TypeDescriptor.valueOf(BlobId.class));

if (blobId != null) {
Expand Down
Loading
Loading