diff --git a/modules/apps/frontend-token/frontend-token-definition-api/src/main/java/com/liferay/frontend/token/definition/FrontendTokenDefinitionRegistry.java b/modules/apps/frontend-token/frontend-token-definition-api/src/main/java/com/liferay/frontend/token/definition/FrontendTokenDefinitionRegistry.java index 2ea17c30962540..ddb8bb1a91ccf6 100644 --- a/modules/apps/frontend-token/frontend-token-definition-api/src/main/java/com/liferay/frontend/token/definition/FrontendTokenDefinitionRegistry.java +++ b/modules/apps/frontend-token/frontend-token-definition-api/src/main/java/com/liferay/frontend/token/definition/FrontendTokenDefinitionRegistry.java @@ -14,10 +14,10 @@ */ public interface FrontendTokenDefinitionRegistry { - public List getAllFrontendTokenDefinition( - long companyId); - public FrontendTokenDefinition getFrontendTokenDefinition( LayoutSet layoutSet); + public List getFrontendTokenDefinitions( + long companyId); + } \ No newline at end of file diff --git a/modules/apps/frontend-token/frontend-token-definition-impl/src/main/java/com/liferay/frontend/token/definition/internal/FrontendTokenDefinitionRegistryImpl.java b/modules/apps/frontend-token/frontend-token-definition-impl/src/main/java/com/liferay/frontend/token/definition/internal/FrontendTokenDefinitionRegistryImpl.java index 22585731bf0fad..3d307901396997 100644 --- a/modules/apps/frontend-token/frontend-token-definition-impl/src/main/java/com/liferay/frontend/token/definition/internal/FrontendTokenDefinitionRegistryImpl.java +++ b/modules/apps/frontend-token/frontend-token-definition-impl/src/main/java/com/liferay/frontend/token/definition/internal/FrontendTokenDefinitionRegistryImpl.java @@ -61,32 +61,35 @@ public class FrontendTokenDefinitionRegistryImpl implements FrontendTokenDefinitionRegistry { @Override - public List getAllFrontendTokenDefinition( + public FrontendTokenDefinition getFrontendTokenDefinition( + LayoutSet layoutSet) { + + return _getFrontendTokenDefinition( + layoutSet.getCompanyId(), + _getCETExternalReferenceCode(layoutSet.getLayoutSetId()), + layoutSet.getThemeId()); + } + + @Override + public List getFrontendTokenDefinitions( long companyId) { List themesFrontendTokenDefinitions = (List) - _frontendTokenDefinitionImpls.values(); + _themeFrontendTokenDefinitions.values(); + + Map + companyCETFrontendTokenDefinitions = + _cetFrontendTokenDefinitions.get(companyId); List cetFrontendTokenDefinitions = - (List)_frontendTokenDefinitionsMap.get( - companyId - ).values(); + (List) + companyCETFrontendTokenDefinitions.values(); return ListUtil.concat( themesFrontendTokenDefinitions, cetFrontendTokenDefinitions); } - @Override - public FrontendTokenDefinition getFrontendTokenDefinition( - LayoutSet layoutSet) { - - return _getFrontendTokenDefinition( - layoutSet.getCompanyId(), - _getCETExternalReferenceCode(layoutSet.getLayoutSetId()), - layoutSet.getThemeId()); - } - @Activate protected void activate(BundleContext bundleContext) { _bundleTracker = new BundleTracker<>( @@ -242,7 +245,7 @@ private void _addingService(ThemeCSSCET themeCSSCET) { themeCSSCET.getFrontendTokenDefinitionJSON()); Map frontendTokenDefinitions = - _frontendTokenDefinitionsMap.computeIfAbsent( + _cetFrontendTokenDefinitions.computeIfAbsent( themeCSSCET.getCompanyId(), entry -> new ConcurrentHashMap<>()); @@ -292,11 +295,11 @@ private FrontendTokenDefinition _getFrontendTokenDefinition( } Map frontendTokenDefinitionImpls = - _frontendTokenDefinitionImplsDCLSingleton.getSingleton( + _frontendTokenDefinitionsDCLSingleton.getSingleton( () -> { _bundleTracker.open(); - return _frontendTokenDefinitionImpls; + return _themeFrontendTokenDefinitions; }); return frontendTokenDefinitionImpls.get(themeId); @@ -322,7 +325,7 @@ private String _getFrontendTokenDefinitionJSON(Bundle bundle) { private Map _getFrontendTokenDefinitions( long companyId) { - return _frontendTokenDefinitionsMap.getOrDefault( + return _cetFrontendTokenDefinitions.getOrDefault( companyId, new ConcurrentHashMap<>()); } @@ -355,7 +358,7 @@ public FrontendTokenDefinitionImpl addingBundle( if ((frontendTokenDefinitionImpl != null) && (frontendTokenDefinitionImpl.getThemeId() != null)) { - _frontendTokenDefinitionImpls.put( + _themeFrontendTokenDefinitions.put( frontendTokenDefinitionImpl.getThemeId(), frontendTokenDefinitionImpl); @@ -376,29 +379,30 @@ public void removedBundle( Bundle bundle, BundleEvent bundleEvent, FrontendTokenDefinitionImpl frontendTokenDefinitionImpl) { - _frontendTokenDefinitionImpls.remove( + _themeFrontendTokenDefinitions.remove( frontendTokenDefinitionImpl.getThemeId()); } }; + private final Map> + _cetFrontendTokenDefinitions = new ConcurrentHashMap<>(); + @Reference private ClientExtensionEntryRelLocalService _clientExtensionEntryRelLocalService; - private final Map - _frontendTokenDefinitionImpls = new ConcurrentHashMap<>(); - private final DCLSingleton> - _frontendTokenDefinitionImplsDCLSingleton = new DCLSingleton<>(); private final FrontendTokenDefinitionJSONValidator _frontendTokenDefinitionJSONValidator = new FrontendTokenDefinitionJSONValidator(); - private final Map> - _frontendTokenDefinitionsMap = new ConcurrentHashMap<>(); + private final DCLSingleton> + _frontendTokenDefinitionsDCLSingleton = new DCLSingleton<>(); @Reference private Portal _portal; private ServiceTracker _serviceTracker; + private final Map + _themeFrontendTokenDefinitions = new ConcurrentHashMap<>(); } \ No newline at end of file