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

Issue 29709 make personalization work with keytag #29715

Merged
merged 7 commits into from
Aug 23, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,13 @@ private Persona find(final String identifier, final User user, final boolean res
final Contentlet contentlet = APILocator.getContentletAPI().findContentletByIdentifier(identifier, live,
APILocator.getLanguageAPI().getDefaultLanguage().getId(), user, respectFrontEndRoles);

return UtilMethods.isSet(contentlet) ? fromContentlet(contentlet) : null;

if(contentlet != null) {
return fromContentlet(contentlet);
}


return findPersonaByTag(identifier, user, respectFrontEndRoles).orElseGet(()->null);
}

@Override
Expand Down Expand Up @@ -502,11 +508,15 @@ public Structure getDefaultPersonaStructure() throws DotSecurityException, DotDa
public Optional<Persona> findPersonaByTag(final String personaTag, final User user, final boolean respectFrontEndRoles)
throws DotSecurityException, DotDataException {

if(UtilMethods.isEmpty(personaTag)){
return Optional.empty();
}

final StringBuilder query = new StringBuilder(" +baseType:").append(BaseContentType.PERSONA.getType())
.append(" +").append(PERSONA_KEY_TAG).append(":").append(personaTag);

final List<Contentlet> contentlets =
APILocator.getContentletAPI().search(query.toString(), -1, 0, StringPool.BLANK, user, respectFrontEndRoles);
APILocator.getContentletAPI().search(query.toString(), 1, 0, StringPool.BLANK, user, respectFrontEndRoles);
final Optional<Contentlet> persona = null != contentlets ? contentlets.stream().findFirst() : Optional.empty();
return persona.isPresent() ? Optional.ofNullable(fromContentlet(persona.get())) : Optional.empty();
}
Expand Down
Loading
Loading