diff --git a/component/api/src/main/java/org/exoplatform/social/core/space/Application.java b/component/api/src/main/java/org/exoplatform/social/core/space/Application.java index 154c93fe900..acc9e6c1bca 100644 --- a/component/api/src/main/java/org/exoplatform/social/core/space/Application.java +++ b/component/api/src/main/java/org/exoplatform/social/core/space/Application.java @@ -18,9 +18,6 @@ */ package org.exoplatform.social.core.space; -import org.exoplatform.portal.config.model.ApplicationType; -import org.exoplatform.portal.pom.spi.portlet.Portlet; - import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -38,8 +35,4 @@ public class Application { private String description; - public ApplicationType getType() { - return ApplicationType.PORTLET; - } - } diff --git a/component/core/src/main/java/io/meeds/social/authorization/AuthorizationManager.java b/component/core/src/main/java/io/meeds/social/authorization/AuthorizationManager.java index f0173fe2cfb..56024f45598 100644 --- a/component/core/src/main/java/io/meeds/social/authorization/AuthorizationManager.java +++ b/component/core/src/main/java/io/meeds/social/authorization/AuthorizationManager.java @@ -51,7 +51,9 @@ public AuthorizationManager(InitParams params) { @Override public boolean hasEditPermission(Identity identity, String ownerType, String ownerId, String expression) { - if (isSpaceOwnerId(ownerType, ownerId)) { + if (PortalConfig.GROUP_TEMPLATE.equalsIgnoreCase(ownerType)) { + return isAdministrator(identity); + } else if (isSpaceOwnerId(ownerType, ownerId)) { Space space = getSpaceService().getSpaceByGroupId(ownerId); if (space != null && identity != null) { if (CollectionUtils.isNotEmpty(space.getLayoutPermissions())) { @@ -71,6 +73,9 @@ public boolean hasEditPermission(Identity identity, String ownerType, String own @Override public boolean hasAccessPermission(Identity identity, String ownerType, String ownerId, Stream expressionsStream) { + if (PortalConfig.GROUP_TEMPLATE.equalsIgnoreCase(ownerType)) { + return isAdministrator(identity); + } return isAdministrator(identity, ownerType, ownerId) || super.hasAccessPermission(identity, ownerType, ownerId, expressionsStream); } diff --git a/component/core/src/main/java/io/meeds/social/core/space/listener/SpaceLayoutHandlerPlugin.java b/component/core/src/main/java/io/meeds/social/core/space/listener/SpaceLayoutHandlerPlugin.java index f729b30f644..8c089f8169a 100644 --- a/component/core/src/main/java/io/meeds/social/core/space/listener/SpaceLayoutHandlerPlugin.java +++ b/component/core/src/main/java/io/meeds/social/core/space/listener/SpaceLayoutHandlerPlugin.java @@ -21,6 +21,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.exoplatform.services.log.ExoLogger; +import org.exoplatform.services.log.Log; import org.exoplatform.social.core.space.spi.SpaceLifeCycleEvent; import org.exoplatform.social.core.space.spi.SpaceLifeCycleListener; import org.exoplatform.social.core.space.spi.SpaceService; @@ -32,8 +34,10 @@ @Service public class SpaceLayoutHandlerPlugin implements SpaceLifeCycleListener { + private static final Log LOG = ExoLogger.getLogger(SpaceLayoutHandlerPlugin.class); + @Autowired - private SpaceService spaceService; + private SpaceService spaceService; @Autowired private SpaceLayoutService spaceLayoutService; @@ -45,7 +49,11 @@ public void init() { @Override public void spaceCreated(SpaceLifeCycleEvent event) { - spaceLayoutService.createSpaceSite(event.getPayload()); + try { + spaceLayoutService.createSpaceSite(event.getPayload()); + } catch (Exception e) { + LOG.error("Can't create Site for Space {} width id", event.getPayload().getDisplayName(), event.getPayload().getId(), e); + } } } diff --git a/component/core/src/main/java/io/meeds/social/core/space/service/SpaceLayoutService.java b/component/core/src/main/java/io/meeds/social/core/space/service/SpaceLayoutService.java index 44f9cea32f1..ada66fdaa62 100644 --- a/component/core/src/main/java/io/meeds/social/core/space/service/SpaceLayoutService.java +++ b/component/core/src/main/java/io/meeds/social/core/space/service/SpaceLayoutService.java @@ -74,13 +74,14 @@ public SpaceLayoutService(SpaceService spaceService, * Create a {@link Space} site switch designated templateId characteristics * * @param space + * @throws ObjectNotFoundException */ - public void createSpaceSite(Space space) { + public void createSpaceSite(Space space) throws ObjectNotFoundException { SpaceTemplate spaceTemplate = spaceTemplateService.getSpaceTemplate(space.getTemplateId()); - portalConfigService.createUserPortalConfig(PortalConfig.GROUP_TYPE, - space.getGroupId(), - StringUtils.firstNonBlank(spaceTemplate.getLayout(), DEFAULT_SITE_TEMPLATE), - DEFAULT_SITE_TEMPLATE_PATH); + portalConfigService.createSiteFromTemplate(SiteKey.group(space.getGroupId()), + SiteKey.groupTemplate(StringUtils.firstNonBlank(spaceTemplate.getLayout(), + DEFAULT_SITE_TEMPLATE)), + space.getGroupId()); PortalConfig portalConfig = layoutService.getPortalConfig(PortalConfig.GROUP_TYPE, space.getGroupId()); portalConfig.setEditPermission(StringUtils.join(spaceTemplate.getSpaceLayoutPermissions(), ",")); diff --git a/component/core/src/main/java/io/meeds/social/core/space/service/SpaceServiceImpl.java b/component/core/src/main/java/io/meeds/social/core/space/service/SpaceServiceImpl.java index a522d2ef22f..91cb2f4de3e 100644 --- a/component/core/src/main/java/io/meeds/social/core/space/service/SpaceServiceImpl.java +++ b/component/core/src/main/java/io/meeds/social/core/space/service/SpaceServiceImpl.java @@ -102,7 +102,7 @@ public class SpaceServiceImpl implements SpaceService { - private static final Log LOG = ExoLogger.getLogger(SpaceServiceImpl.class.getName()); + private static final Log LOG = ExoLogger.getLogger(SpaceServiceImpl.class); private static final int MAX_SPACE_NAME_LENGTH = 200; diff --git a/component/core/src/test/resources/conf/exo.social.component.core-configuration.xml b/component/core/src/test/resources/conf/exo.social.component.core-configuration.xml index e22029cbf63..e59451a2354 100644 --- a/component/core/src/test/resources/conf/exo.social.component.core-configuration.xml +++ b/component/core/src/test/resources/conf/exo.social.component.core-configuration.xml @@ -1139,18 +1139,6 @@ - - space.portal.config.listener - addListenerPlugin - org.exoplatform.portal.config.GroupPortalConfigListener - - - group.name.pattern - The group name pattern - /spaces/ - - - @@ -1171,10 +1159,6 @@ In the run method, use try catch or not (value is true/false) true - - page.templates.location - classpath:/portal/template/pages - portal.configuration description diff --git a/component/core/src/test/resources/portal/config/portal/meeds/navigation.xml b/component/core/src/test/resources/portal/config/portal/meeds/navigation.xml index 167a55c81ef..f868fae38e6 100644 --- a/component/core/src/test/resources/portal/config/portal/meeds/navigation.xml +++ b/component/core/src/test/resources/portal/config/portal/meeds/navigation.xml @@ -27,7 +27,6 @@ - node_uri node_name node_icon @@ -37,7 +36,6 @@ portal::meeds::test1 - node_uri1 node_name1 node_icon @@ -47,7 +45,6 @@ portal::meeds::test1 - node_uri2 node_name2 node_icon @@ -56,7 +53,6 @@ portal::meeds::test1 - node_uri3 node_name3 node_icon @@ -65,7 +61,6 @@ portal::meeds::test1 - node_uri4 node_name4 portal::meeds::test1 diff --git a/component/web/src/main/java/io/meeds/social/portlet/CMSPortlet.java b/component/web/src/main/java/io/meeds/social/portlet/CMSPortlet.java index cd7e948fa79..7ceaba20d92 100644 --- a/component/web/src/main/java/io/meeds/social/portlet/CMSPortlet.java +++ b/component/web/src/main/java/io/meeds/social/portlet/CMSPortlet.java @@ -39,7 +39,6 @@ import org.exoplatform.portal.config.UserACL; import org.exoplatform.portal.config.model.Application; import org.exoplatform.portal.config.model.ApplicationState; -import org.exoplatform.portal.config.model.ApplicationType; import org.exoplatform.portal.mop.page.PageKey; import org.exoplatform.portal.mop.service.LayoutService; import org.exoplatform.portal.pom.spi.portlet.Portlet; @@ -160,9 +159,9 @@ protected void postSettingInit(PortletPreferences preferences, String name) { protected void savePreference(String name, String value) { String storageId = UIPortlet.getCurrentUIPortlet().getStorageId(); LayoutService layoutService = ExoContainerContext.getService(LayoutService.class); - Application applicationModel = layoutService.getApplicationModel(storageId); - ApplicationState state = applicationModel.getState(); - Portlet prefs = layoutService.load(state, ApplicationType.PORTLET); + Application applicationModel = layoutService.getApplicationModel(storageId); + ApplicationState state = applicationModel.getState(); + Portlet prefs = layoutService.load(state); prefs.setValue(name, value); layoutService.save(state, prefs); } diff --git a/webapp/src/main/webapp/WEB-INF/jsp/portlet/topbarLogo.jsp b/webapp/src/main/webapp/WEB-INF/jsp/portlet/topbarLogo.jsp index bf2097a74c3..a8d201b947e 100644 --- a/webapp/src/main/webapp/WEB-INF/jsp/portlet/topbarLogo.jsp +++ b/webapp/src/main/webapp/WEB-INF/jsp/portlet/topbarLogo.jsp @@ -55,12 +55,9 @@ if (StringUtils.equals(requestContext.getPortalOwner(), "public")) { portalPath = "/portal/public"; } else { - portalPath = portalConfigService.getUserHomePage(request.getRemoteUser()); + portalPath = portalConfigService.computePortalPath(requestContext.getRequest()); if (portalPath == null) { - portalPath = portalConfigService.computePortalPath(requestContext.getRequest()); - if (portalPath == null) { - portalPath = defaultHomePath; - } + portalPath = defaultHomePath; } } titleClass = "company";