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

Handle duplicate keys in map #10734 #10736

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ private Map<String, ImageStyle> getImageStyleMap( final StyleDescriptors styleDe
return styleDescriptors.stream()
.flatMap( styleDescriptor -> styleDescriptor.getElements().stream() )
.filter( elementStyle -> ImageStyle.STYLE_ELEMENT_NAME.equals( elementStyle.getElement() ) )
.collect( Collectors.toUnmodifiableMap( ElementStyle::getName, elementStyle -> (ImageStyle) elementStyle ) );
.collect( Collectors.toUnmodifiableMap( ElementStyle::getName, elementStyle -> (ImageStyle) elementStyle,
( existingKey, newKey ) -> existingKey ) );
}

private StyleDescriptors getStyleDescriptors( final PortalRequest portalRequest )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,16 +551,18 @@ public void testCustomStyleDescriptorCallback()
when( this.contentService.getById( media.getId() ) ).thenReturn( media );

final ImageStyle imageStyle = ImageStyle.create().name( "mystyle" ).aspectRatio( "2:1" ).filter( "myfilter" ).build();
final StyleDescriptor styleDescriptor =
StyleDescriptor.create().application( ApplicationKey.from( "myapp" ) ).addStyleElement( imageStyle ).build();
final StyleDescriptor styleDescriptor1 =
StyleDescriptor.create().application( ApplicationKey.from( "myapp1" ) ).addStyleElement( imageStyle ).build();
final StyleDescriptor styleDescriptor2 =
StyleDescriptor.create().application( ApplicationKey.from( "myapp2" ) ).addStyleElement( imageStyle ).build();

final Map<String, String> imageProjection = new HashMap<>();

//Process an html text containing a style
//Process a html text containing a style
final String link1 = "<img src=\"image://" + media.getId() + "?style=mystyle\">";

final ProcessHtmlParams params = new ProcessHtmlParams().portalRequest( this.portalRequest )
.customStyleDescriptorsCallback( () -> StyleDescriptors.from( styleDescriptor ) )
.customStyleDescriptorsCallback( () -> StyleDescriptors.from( styleDescriptor1, styleDescriptor2 ) )
.customHtmlProcessor( processorParams -> {
processorParams.processDefault( ( element, properties ) -> {
if ( "img".equals( element.getTagName() ) )
Expand Down