Skip to content

Commit

Permalink
feat: Create Space Site from Stored Group Site Template - MEED-7669 - M…
Browse files Browse the repository at this point in the history
  • Loading branch information
boubaker committed Oct 26, 2024
1 parent f5a332a commit 1ee524f
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -38,8 +35,4 @@ public class Application {

private String description;

public ApplicationType<Portlet> getType() {
return ApplicationType.PORTLET;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand All @@ -71,6 +73,9 @@ public boolean hasEditPermission(Identity identity, String ownerType, String own

@Override
public boolean hasAccessPermission(Identity identity, String ownerType, String ownerId, Stream<String> expressionsStream) {
if (PortalConfig.GROUP_TEMPLATE.equalsIgnoreCase(ownerType)) {
return isAdministrator(identity);
}
return isAdministrator(identity, ownerType, ownerId)
|| super.hasAccessPermission(identity, ownerType, ownerId, expressionsStream);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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(), ","));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1139,18 +1139,6 @@
</object-param>
</init-params>
</component-plugin>
<component-plugin>
<name>space.portal.config.listener</name>
<set-method>addListenerPlugin</set-method>
<type>org.exoplatform.portal.config.GroupPortalConfigListener</type>
<init-params>
<value-param>
<name>group.name.pattern</name>
<description>The group name pattern</description>
<value>/spaces/</value>
</value-param>
</init-params>
</component-plugin>
</external-component-plugins>

<external-component-plugins>
Expand All @@ -1171,10 +1159,6 @@
<description>In the run method, use try catch or not (value is true/false)</description>
<value>true</value>
</value-param>
<value-param>
<name>page.templates.location</name>
<value>classpath:/portal/template/pages</value>
</value-param>
<object-param>
<name>portal.configuration</name>
<description>description</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

<page-nodes>
<node>
<uri>node_uri</uri>
<name>node_name</name>
<label>node_label</label>
<icon>node_icon</icon>
Expand All @@ -37,7 +36,6 @@
<page-reference>portal::meeds::test1</page-reference>
</node>
<node>
<uri>node_uri1</uri>
<name>node_name1</name>
<label>node_label</label>
<icon>node_icon</icon>
Expand All @@ -47,7 +45,6 @@
<page-reference>portal::meeds::test1</page-reference>
</node>
<node>
<uri>node_uri2</uri>
<name>node_name2</name>
<label>node_label</label>
<icon>node_icon</icon>
Expand All @@ -56,7 +53,6 @@
<page-reference>portal::meeds::test1</page-reference>
</node>
<node>
<uri>node_uri3</uri>
<name>node_name3</name>
<label>node_label</label>
<icon>node_icon</icon>
Expand All @@ -65,7 +61,6 @@
<page-reference>portal::meeds::test1</page-reference>
</node>
<node>
<uri>node_uri4</uri>
<name>node_name4</name>
<label>node_label4</label>
<page-reference>portal::meeds::test1</page-reference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Portlet> applicationModel = layoutService.getApplicationModel(storageId);
ApplicationState<Portlet> 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);
}
Expand Down
7 changes: 2 additions & 5 deletions webapp/src/main/webapp/WEB-INF/jsp/portlet/topbarLogo.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 1ee524f

Please sign in to comment.