diff --git a/modules/apps/object/object-service/src/main/java/com/liferay/object/internal/layout/tab/screen/navigation/ObjectLayoutTabScreenNavigationEntry.java b/modules/apps/object/object-service/src/main/java/com/liferay/object/internal/layout/tab/screen/navigation/ObjectLayoutTabScreenNavigationEntry.java index 20f5dea0115e65..ab926a28d2d10a 100644 --- a/modules/apps/object/object-service/src/main/java/com/liferay/object/internal/layout/tab/screen/navigation/ObjectLayoutTabScreenNavigationEntry.java +++ b/modules/apps/object/object-service/src/main/java/com/liferay/object/internal/layout/tab/screen/navigation/ObjectLayoutTabScreenNavigationEntry.java @@ -31,17 +31,14 @@ public class ObjectLayoutTabScreenNavigationEntry implements ScreenNavigationEntry { public ObjectLayoutTabScreenNavigationEntry( - String categoryKey, ObjectLayoutTab objectLayoutTab, - String screenNavigationKey) { + ObjectLayoutTab objectLayoutTab) { - _categoryKey = categoryKey; _objectLayoutTab = objectLayoutTab; - _screenNavigationKey = screenNavigationKey; } @Override public String getCategoryKey() { - return _categoryKey; + return String.valueOf(_objectLayoutTab.getObjectLayoutTabId()); } @Override @@ -56,7 +53,7 @@ public String getLabel(Locale locale) { @Override public String getScreenNavigationKey() { - return _screenNavigationKey; + return String.valueOf(_objectLayoutTab.getObjectLayoutId()); } @Override @@ -66,8 +63,6 @@ public void render( throws IOException { } - private final String _categoryKey; private final ObjectLayoutTab _objectLayoutTab; - private final String _screenNavigationKey; } \ No newline at end of file diff --git a/modules/apps/object/object-service/src/main/java/com/liferay/object/service/impl/ObjectLayoutLocalServiceImpl.java b/modules/apps/object/object-service/src/main/java/com/liferay/object/service/impl/ObjectLayoutLocalServiceImpl.java index a8d385fc42fc25..c62dcc0791a8d2 100644 --- a/modules/apps/object/object-service/src/main/java/com/liferay/object/service/impl/ObjectLayoutLocalServiceImpl.java +++ b/modules/apps/object/object-service/src/main/java/com/liferay/object/service/impl/ObjectLayoutLocalServiceImpl.java @@ -53,13 +53,16 @@ import com.liferay.portal.kernel.util.Validator; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; @@ -401,24 +404,24 @@ private ObjectLayoutTab _addObjectLayoutTab( user, objectDefinitionId, objectLayoutTab.getObjectLayoutTabId(), objectLayoutBoxes)); - ScreenNavigationCategory screenNavigationCategory = - new ObjectLayoutTabScreenNavigationCategory(objectLayoutTab); - - _bundleContext.registerService( - ScreenNavigationCategory.class, screenNavigationCategory, - HashMapDictionaryBuilder.put( - "screen.navigation.category.order:Integer", - objectLayoutTab.getObjectLayoutTabId() - ).build()); - _bundleContext.registerService( - ScreenNavigationEntry.class, - new ObjectLayoutTabScreenNavigationEntry( - screenNavigationCategory.getCategoryKey(), objectLayoutTab, - screenNavigationCategory.getScreenNavigationKey()), - HashMapDictionaryBuilder.put( - "screen.navigation.entry.order:Integer", - objectLayoutTab.getObjectLayoutTabId() - ).build()); + _serviceRegistrationsMap.put( + String.valueOf(objectLayoutTab.getObjectLayoutTabId()), + Arrays.asList( + _bundleContext.registerService( + ScreenNavigationCategory.class, + new ObjectLayoutTabScreenNavigationCategory( + objectLayoutTab), + HashMapDictionaryBuilder.put( + "screen.navigation.category.order:Integer", + objectLayoutTab.getObjectLayoutTabId() + ).build()), + _bundleContext.registerService( + ScreenNavigationEntry.class, + new ObjectLayoutTabScreenNavigationEntry(objectLayoutTab), + HashMapDictionaryBuilder.put( + "screen.navigation.entry.order:Integer", + objectLayoutTab.getObjectLayoutTabId() + ).build()))); return objectLayoutTab; } @@ -441,14 +444,23 @@ private void _deleteObjectLayoutBoxes( List objectLayoutTabs) { for (ObjectLayoutTab objectLayoutTab : objectLayoutTabs) { - List objectLayoutBoxes = + _deleteObjectLayoutRows( _objectLayoutBoxPersistence.findByObjectLayoutTabId( - objectLayoutTab.getObjectLayoutTabId()); + objectLayoutTab.getObjectLayoutTabId())); _objectLayoutBoxPersistence.removeByObjectLayoutTabId( objectLayoutTab.getObjectLayoutTabId()); - _deleteObjectLayoutRows(objectLayoutBoxes); + for (ServiceRegistration serviceRegistration : + _serviceRegistrationsMap.get( + String.valueOf( + objectLayoutTab.getObjectLayoutTabId()))) { + + serviceRegistration.unregister(); + } + + _serviceRegistrationsMap.remove( + String.valueOf(objectLayoutTab.getObjectLayoutTabId())); } } @@ -661,6 +673,9 @@ private void _validate( @Reference private ObjectLayoutTabPersistence _objectLayoutTabPersistence; + private final Map>> + _serviceRegistrationsMap = new ConcurrentHashMap<>(); + @Reference private UserLocalService _userLocalService;