Skip to content

Commit

Permalink
LPD-35069 review #1
Browse files Browse the repository at this point in the history
  • Loading branch information
algobob authored and brianchandotcom committed Oct 11, 2024
1 parent cdd7029 commit dd3004b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
*/
public interface FrontendTokenDefinitionRegistry {

public List<FrontendTokenDefinition> getAllFrontendTokenDefinition(
long companyId);

public FrontendTokenDefinition getFrontendTokenDefinition(
LayoutSet layoutSet);

public List<FrontendTokenDefinition> getFrontendTokenDefinitions(
long companyId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,35 @@ public class FrontendTokenDefinitionRegistryImpl
implements FrontendTokenDefinitionRegistry {

@Override
public List<FrontendTokenDefinition> getAllFrontendTokenDefinition(
public FrontendTokenDefinition getFrontendTokenDefinition(
LayoutSet layoutSet) {

return _getFrontendTokenDefinition(
layoutSet.getCompanyId(),
_getCETExternalReferenceCode(layoutSet.getLayoutSetId()),
layoutSet.getThemeId());
}

@Override
public List<FrontendTokenDefinition> getFrontendTokenDefinitions(
long companyId) {

List<FrontendTokenDefinition> themesFrontendTokenDefinitions =
(List<FrontendTokenDefinition>)
_frontendTokenDefinitionImpls.values();
_themeFrontendTokenDefinitions.values();

Map<String, FrontendTokenDefinition>
companyCETFrontendTokenDefinitions =
_cetFrontendTokenDefinitions.get(companyId);

List<FrontendTokenDefinition> cetFrontendTokenDefinitions =
(List<FrontendTokenDefinition>)_frontendTokenDefinitionsMap.get(
companyId
).values();
(List<FrontendTokenDefinition>)
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<>(
Expand Down Expand Up @@ -242,7 +245,7 @@ private void _addingService(ThemeCSSCET themeCSSCET) {
themeCSSCET.getFrontendTokenDefinitionJSON());

Map<String, FrontendTokenDefinition> frontendTokenDefinitions =
_frontendTokenDefinitionsMap.computeIfAbsent(
_cetFrontendTokenDefinitions.computeIfAbsent(
themeCSSCET.getCompanyId(),
entry -> new ConcurrentHashMap<>());

Expand Down Expand Up @@ -292,11 +295,11 @@ private FrontendTokenDefinition _getFrontendTokenDefinition(
}

Map<String, FrontendTokenDefinition> frontendTokenDefinitionImpls =
_frontendTokenDefinitionImplsDCLSingleton.getSingleton(
_frontendTokenDefinitionsDCLSingleton.getSingleton(
() -> {
_bundleTracker.open();

return _frontendTokenDefinitionImpls;
return _themeFrontendTokenDefinitions;
});

return frontendTokenDefinitionImpls.get(themeId);
Expand All @@ -322,7 +325,7 @@ private String _getFrontendTokenDefinitionJSON(Bundle bundle) {
private Map<String, FrontendTokenDefinition> _getFrontendTokenDefinitions(
long companyId) {

return _frontendTokenDefinitionsMap.getOrDefault(
return _cetFrontendTokenDefinitions.getOrDefault(
companyId, new ConcurrentHashMap<>());
}

Expand Down Expand Up @@ -355,7 +358,7 @@ public FrontendTokenDefinitionImpl addingBundle(
if ((frontendTokenDefinitionImpl != null) &&
(frontendTokenDefinitionImpl.getThemeId() != null)) {

_frontendTokenDefinitionImpls.put(
_themeFrontendTokenDefinitions.put(
frontendTokenDefinitionImpl.getThemeId(),
frontendTokenDefinitionImpl);

Expand All @@ -376,29 +379,30 @@ public void removedBundle(
Bundle bundle, BundleEvent bundleEvent,
FrontendTokenDefinitionImpl frontendTokenDefinitionImpl) {

_frontendTokenDefinitionImpls.remove(
_themeFrontendTokenDefinitions.remove(
frontendTokenDefinitionImpl.getThemeId());
}

};

private final Map<Long, Map<String, FrontendTokenDefinition>>
_cetFrontendTokenDefinitions = new ConcurrentHashMap<>();

@Reference
private ClientExtensionEntryRelLocalService
_clientExtensionEntryRelLocalService;

private final Map<String, FrontendTokenDefinition>
_frontendTokenDefinitionImpls = new ConcurrentHashMap<>();
private final DCLSingleton<Map<String, FrontendTokenDefinition>>
_frontendTokenDefinitionImplsDCLSingleton = new DCLSingleton<>();
private final FrontendTokenDefinitionJSONValidator
_frontendTokenDefinitionJSONValidator =
new FrontendTokenDefinitionJSONValidator();
private final Map<Long, Map<String, FrontendTokenDefinition>>
_frontendTokenDefinitionsMap = new ConcurrentHashMap<>();
private final DCLSingleton<Map<String, FrontendTokenDefinition>>
_frontendTokenDefinitionsDCLSingleton = new DCLSingleton<>();

@Reference
private Portal _portal;

private ServiceTracker<ThemeCSSCET, ThemeCSSCET> _serviceTracker;
private final Map<String, FrontendTokenDefinition>
_themeFrontendTokenDefinitions = new ConcurrentHashMap<>();

}

0 comments on commit dd3004b

Please sign in to comment.