Skip to content

Commit

Permalink
Merge Spaces Directory - Meeds-io/MIPs#158 (#4093)
Browse files Browse the repository at this point in the history
  • Loading branch information
boubaker authored Oct 9, 2024
2 parents e0c5e61 + baee6c2 commit 4af1f9a
Show file tree
Hide file tree
Showing 75 changed files with 2,541 additions and 2,092 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;
import org.exoplatform.commons.utils.ListAccess;
Expand Down Expand Up @@ -261,7 +260,7 @@ public Space[] load(int offset, int limit) throws Exception, IllegalArgumentExce
break;
case PUBLIC_FILTER: listSpaces = spaceStorage.getPublicSpacesByFilter(this.userId, this.spaceFilter, offset, limit);
break;
case PUBLIC_SUPER_USER: listSpaces = new ArrayList<Space> ();
case PUBLIC_SUPER_USER: listSpaces = new ArrayList<> ();
break;
case SETTING: listSpaces = spaceStorage.getEditableSpaces(this.userId, offset, limit);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ public Identity[] load(int offset, int limit) throws Exception, IllegalArgumentE
Iterator<? extends Identity> iterator = identities.iterator();
while (iterator.hasNext()) {
Identity identity = iterator.next();
if (identity.equals(profileFilter.getViewerIdentity())) {
if (identity == null || (profileFilter.getViewerIdentity() != null
&& identity.getId().equals(profileFilter.getViewerIdentity().getId()))) {
iterator.remove();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@
package org.exoplatform.social.core.space;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -441,6 +438,9 @@ public static void removePagesAndGroupNavigation(Space space) throws Exception {
*/

public static void changeAppPageTitle(UserNode spacePageNode, String newSpaceName) throws Exception {
if (spacePageNode == null || spacePageNode.getPageRef() == null) {
return;
}
LayoutService layoutService = getLayoutService();
Page page = layoutService.getPage(spacePageNode.getPageRef().format());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import io.meeds.social.link.model.Link;
import io.meeds.social.link.model.LinkSetting;
import io.meeds.social.link.rest.model.LinkSettingRestEntity;
import io.meeds.social.link.rest.util.EntityBuilder;
import io.meeds.social.link.rest.util.LinkEntityBuilder;
import io.meeds.social.link.service.LinkService;

import io.swagger.v3.oas.annotations.Operation;
Expand Down Expand Up @@ -130,8 +130,8 @@ public Response getLinkSetting(
@ApiResponse(responseCode = "401", description = "Unauthorized"), })
public Response saveLinkSetting(LinkSettingRestEntity linkSettingEntity) {
try {
LinkSetting linkSetting = EntityBuilder.toLinkSetting(linkSettingEntity);
List<Link> linksToSave = EntityBuilder.toLinks(linkSettingEntity);
LinkSetting linkSetting = LinkEntityBuilder.toLinkSetting(linkSettingEntity);
List<Link> linksToSave = LinkEntityBuilder.toLinks(linkSettingEntity);
linkSetting = linkService.saveLinkSetting(linkSetting, linksToSave, RestUtils.getCurrentUserAclIdentity());
return Response.ok(getLinkSettingEntity(linkSetting, null)).build();
} catch (IllegalAccessException e) {
Expand Down Expand Up @@ -190,7 +190,7 @@ public Response getLinkIcon(

private LinkSettingRestEntity getLinkSettingEntity(LinkSetting linkSetting, String lang) {
List<Link> links = linkService.getLinks(linkSetting.getName(), lang, true);
return EntityBuilder.build(linkSetting, links);
return LinkEntityBuilder.build(linkSetting, links);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
import io.meeds.social.link.rest.model.LinkRestEntity;
import io.meeds.social.link.rest.model.LinkSettingRestEntity;

public class EntityBuilder {
public class LinkEntityBuilder {

private EntityBuilder() {
private LinkEntityBuilder() {
// Utils class
}

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,28 @@
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;

import lombok.EqualsAndHashCode;
import lombok.EqualsAndHashCode.Exclude;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@EqualsAndHashCode
@NoArgsConstructor
public class BaseEntity implements Serializable {
private static final long serialVersionUID = -7245526640639649852L;
private DataEntity dataEntity = new DataEntity();
private long lastUpdatedTime;

public BaseEntity() {
private DataEntity dataEntity = new DataEntity();

@Exclude
@Getter
@Setter
private long lastUpdatedTime;

public BaseEntity(String id) {
if (!StringUtils.isEmpty(id)) {
setId(id);
}
}

public BaseEntity setProperty(String name, Object value) {
Expand All @@ -47,12 +63,6 @@ protected String getString(String name) {
return String.valueOf(o);
}

public BaseEntity(String id) {
if (!StringUtils.isEmpty(id)) {
setId(id);
}
}

public BaseEntity setId(String id) {
setProperty("id", id);
return this;
Expand All @@ -66,7 +76,7 @@ public BaseEntity setHref(String href) {
setProperty("href", href);
return this;
}

public String getHref() {
return (String) dataEntity.get("href");
}
Expand All @@ -88,11 +98,4 @@ public JSONObject toJSONObject() {
return new JSONObject(this);
}

public void setLastUpdatedTime(long lastUpdatedTime) {
this.lastUpdatedTime = lastUpdatedTime;
}

public long getLastUpdatedTime() {
return lastUpdatedTime;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@
import java.util.Map;

import org.exoplatform.social.rest.api.RestUtils;

import lombok.EqualsAndHashCode;

import org.json.JSONObject;

@EqualsAndHashCode(callSuper = true)
public class CollectionEntity extends LinkedHashMap<String, Object> {

private static final long serialVersionUID = 5157400162426650346L;

private final String key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;

import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
public class DataEntity extends LinkedHashMap<String, Object> {
private static final long serialVersionUID = -7245526640639649852L;

public DataEntity() {
}
private static final long serialVersionUID = -7245526640639649852L;

public DataEntity setProperty(String name, Object value) {
if (value != null && StringUtils.isNotEmpty(String.valueOf(value))) {
Expand All @@ -43,4 +44,5 @@ public String toString() {
public JSONObject toJSONObject() {
return new JSONObject(this);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

import org.exoplatform.social.core.identity.model.Identity;

import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
public class SpaceEntity extends BaseEntity {
private static final long serialVersionUID = -5407676622915680099L;

Expand Down Expand Up @@ -114,6 +117,15 @@ public Long getPublicSiteId() {
return (Long) getProperty("publicSiteId");
}

public SpaceEntity setPublicSiteName(String publicSiteName) {
setProperty("publicSiteName", publicSiteName);
return this;
}

public String getPublicSiteName() {
return (String) getProperty("publicSiteName");
}

public SpaceEntity setPublicSiteVisibility(String publicSiteVisibility) {
setProperty("publicSiteVisibility", publicSiteVisibility);
return this;
Expand Down Expand Up @@ -236,6 +248,15 @@ public Boolean getCanEdit() {
return (Boolean) getProperty("canEdit");
}

public SpaceEntity setCanRedactOnSpace(boolean canRedactOnSpace) {
setProperty("canRedactOnSpace", canRedactOnSpace);
return this;
}

public Boolean getCanRedactOnSpace() {
return (Boolean) getProperty("canRedactOnSpace");
}

public SpaceEntity setCanEditNavigations(boolean canEditNavigations) {
setProperty("canEditNavigations", canEditNavigations);
return this;
Expand Down Expand Up @@ -298,7 +319,7 @@ public SpaceEntity setPublishers(LinkEntity publishers) {
public String getPublishers() {
return getString("publishers");
}

public SpaceEntity setPublishersCount(int publishersCount) {
setProperty("publishersCount", publishersCount);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@ public SpaceMembershipEntity setDataUser(LinkEntity user) {
return this;
}

public void setUser(String user) {
setProperty("user", user);
public void setUsername(String username) {
setProperty("username", username);
}

public String getUser() {
return getString("user");
public String getUsername() {
return getString("username");
}

public SpaceMembershipEntity setDataSpace(LinkEntity space) {
setProperty("space", space.getData());
return this;
}

public void setSpace(String space) {
setProperty("space", space);
public void setSpaceId(String spaceId) {
setProperty("spaceId", spaceId);
}

public String getSpace() {
return getString("space");
public String getSpaceId() {
return getString("spaceId");
}

public SpaceMembershipEntity setRole(String role) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2020 - 2024 Meeds Association [email protected]
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.exoplatform.social.rest.entity;

import lombok.Data;

@Data
public class SpaceMembershipUpdateEntity {

private String user;

private String space;

private String status;

private String role;

}
Loading

0 comments on commit 4af1f9a

Please sign in to comment.