Skip to content

Commit

Permalink
feat: Adjust get sites query - EXO-66028 - Meeds-io/MIPs#72
Browse files Browse the repository at this point in the history
  • Loading branch information
GouadriaHanen authored and azayati committed Sep 7, 2023
1 parent c424b87 commit a080406
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import org.exoplatform.portal.mop.SiteKey;
import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.mop.navigation.Scope;
import org.exoplatform.portal.mop.rest.model.UserNodeRestEntity;
import org.exoplatform.portal.mop.service.LayoutService;
import org.exoplatform.portal.mop.user.HttpUserPortalContext;
import org.exoplatform.portal.mop.user.UserNavigation;
Expand Down Expand Up @@ -1757,6 +1758,7 @@ public static List<SiteEntity> buildSiteEntities(List<PortalConfig> sites,
}

public static SiteEntity buildSiteEntity(PortalConfig site, HttpServletRequest request, boolean expandNavigations) {
LOG.warn("start computing portal config to siteEntity for site {}", site.getName());
if (site == null) {
return null;
}
Expand Down Expand Up @@ -1798,6 +1800,13 @@ public static SiteEntity buildSiteEntity(PortalConfig site, HttpServletRequest r
LOG.error("Error while getting site {} navigations for user {}", site.getName(), currentUser, e);
}
}

List<UserNodeRestEntity> siteNavigations = rootNode == null ? null
: toUserNodeRestEntity(rootNode.getChildren(),
true,
getOrganizationService(),
getLayoutService(),
getUserACL());
return new SiteEntity(siteType,
site.getName(),
!StringUtils.isBlank(displayName) ? displayName : site.getName(),
Expand All @@ -1807,14 +1816,8 @@ public static SiteEntity buildSiteEntity(PortalConfig site, HttpServletRequest r
site.isDisplayed(),
site.getDisplayOrder(),
isMetaSite(site.getName()),
rootNode == null ? null
: toUserNodeRestEntity(rootNode.getChildren(),
true,
getOrganizationService(),
getLayoutService(),
getUserACL()),
siteNavigations,
getUserACL().hasPermission(site.getEditPermission()));

}

private static List<Map<String, Object>> computePermissions(String[] permissions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,35 @@ public SiteRest(LayoutService layoutService) {
@ApiResponse(responseCode = "500", description = "Internal server error"), })
public Response getSites(@Context
HttpServletRequest request,
@Parameter(description = "Portal site type, possible values: PORTAL, GROUP or USER", required = true)
@Parameter(description = "Portal site types, possible values: PORTAL, GROUP or USER", required = true)
@QueryParam("siteType")
String siteTypeName,
String siteType,
@Parameter(description = "Site type to be excluded")
@QueryParam("excludedSiteType")
String excludedSiteType,
@Parameter(description = "Site name to be excluded")
@QueryParam("excludedSiteName")
String excludedSiteName,
@Parameter(description = "to exclude space sites")
@DefaultValue("false")
@QueryParam("excludeSpaceSites")
boolean excludeSpaceSites,
@Parameter(description = "to expand site navigations nodes")
@DefaultValue("false")
@QueryParam("expandNavigations")
boolean expandNavigations,
@Parameter(description = "to retrieve sites with its displayed status")
@Parameter(description = "to sort with display order")
@DefaultValue("false")
@QueryParam("sortByDisplayOrder")
boolean sortByDisplayOrder,
@Parameter(description = "to filter sites by displayed status")
@DefaultValue("false")
@QueryParam("filterByDisplayed")
boolean filterByDisplayed,
@Parameter(description = "to retrieve sites with displayed status")
@DefaultValue("false")
@QueryParam("displayed")
Boolean displayed,
@Parameter(description = "to retrieve all sites")
@DefaultValue("true")
@QueryParam("allSites")
boolean allSites,
boolean displayed,
@Parameter(description = "to filter sites by view/edit permissions")
@DefaultValue("false")
@QueryParam("filterByPermissions")
Expand All @@ -97,16 +108,20 @@ public Response getSites(@Context
int limit) {
try {
SiteFilter siteFilter = new SiteFilter();
if (siteTypeName != null) {
siteFilter.setSiteType(SiteType.valueOf(siteTypeName.toUpperCase()));
if (siteType != null) {
siteFilter.setSiteType(SiteType.valueOf(siteType.toUpperCase()));
}
if (excludedSiteType != null) {
siteFilter.setExcludedSiteType(SiteType.valueOf(excludedSiteType.toUpperCase()));
}
if (excludedSiteName != null) {
siteFilter.setExcludedSiteName(excludedSiteName);
}
if (displayed != null) {
siteFilter.setExcludeSpaceSites(excludeSpaceSites);
siteFilter.setSortByDisplayOrder(sortByDisplayOrder);
if (filterByDisplayed) {
siteFilter.setDisplayed(displayed);
}
siteFilter.setAllSites(allSites);
siteFilter.setFilterByPermission(filterByPermission);
siteFilter.setLimit(limit);
siteFilter.setOffset(offset);
Expand Down
10 changes: 7 additions & 3 deletions webapp/portlet/src/main/webapp/vue-apps/common/js/SiteService.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
export function getSites(siteType, excludedSiteName, expandNavigations, displayed, allSites, filterByPermissions) {
export function getSites(siteType, excludedSiteType, excludedSiteName, excludeSpaceSites, expandNavigations, filterByDisplayed, sortByDisplayOrder, displayed, filterByPermissions) {
const formData = new FormData();
if (siteType) {
formData.append('siteType', siteType);
}
if (excludedSiteType) {
formData.append('excludedSiteType', excludedSiteType);
}
if (excludedSiteName) {
formData.append('excludedSiteName', excludedSiteName);
}
formData.append('excludeSpaceSites', excludeSpaceSites);
formData.append('expandNavigations', expandNavigations);
if (displayed) {
formData.append('sortByDisplayOrder', sortByDisplayOrder);
if (filterByDisplayed) {
formData.append('displayed', displayed);
}
formData.append('allSites', allSites);
formData.append('filterByPermissions', filterByPermissions);
const params = new URLSearchParams(formData).toString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export default {
},
retrieveSites(){
if (eXo.env.portal.newLeftNavigationDrawer) {
return this.$siteService.getSites('PORTAL', 'global', true, true, false, true)
return this.$siteService.getSites('PORTAL', null, 'global', true, true, true, true, true)
.then(data => this.sites = data || []);
}
},
Expand Down

0 comments on commit a080406

Please sign in to comment.