-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
353 additions
and
395 deletions.
There are no files selected for viewing
293 changes: 145 additions & 148 deletions
293
component/service/src/main/java/org/exoplatform/social/rest/api/EntityBuilder.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
component/service/src/main/java/org/exoplatform/social/rest/impl/site/SiteRest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* Copyright (C) 2023 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.impl.site; | ||
|
||
import java.util.List; | ||
|
||
import javax.annotation.security.RolesAllowed; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.ws.rs.DefaultValue; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.QueryParam; | ||
import javax.ws.rs.core.Context; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
|
||
import org.exoplatform.portal.config.model.PortalConfig; | ||
import org.exoplatform.portal.mop.SiteFilter; | ||
import org.exoplatform.portal.mop.SiteType; | ||
import org.exoplatform.portal.mop.service.LayoutService; | ||
import org.exoplatform.services.log.ExoLogger; | ||
import org.exoplatform.services.log.Log; | ||
import org.exoplatform.services.rest.resource.ResourceContainer; | ||
import org.exoplatform.social.rest.api.EntityBuilder; | ||
import org.exoplatform.social.service.rest.api.VersionResources; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
|
||
@Path(VersionResources.VERSION_ONE + "/social/sites") | ||
@Tag(name = VersionResources.VERSION_ONE + "/social/sites", description = "Manage sites") | ||
public class SiteRest implements ResourceContainer { | ||
|
||
private static final Log LOG = ExoLogger.getLogger(SiteRest.class); | ||
|
||
private LayoutService layoutService; | ||
|
||
public SiteRest(LayoutService layoutService) { | ||
this.layoutService = layoutService; | ||
} | ||
|
||
@GET | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@RolesAllowed("users") | ||
@Operation(summary = "Gets sites", description = "Gets sites", method = "GET") | ||
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Request fulfilled"), | ||
@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) | ||
@QueryParam("siteType") | ||
String siteTypeName, | ||
@Parameter(description = "Site name to be excluded") | ||
@QueryParam("excludedSiteName") | ||
String excludedSiteName, | ||
@Parameter(description = "to include empty site in results in portal type case") | ||
@DefaultValue("true") | ||
@QueryParam("includeEmpty") | ||
boolean includeEmpty, | ||
@Parameter(description = "to expand site navigations nodes") | ||
@DefaultValue("false") | ||
@QueryParam("expandNavigations") | ||
boolean expandNavigations, | ||
@Parameter(description = "to retrieve sites with its displayed status") | ||
@DefaultValue("false") | ||
@QueryParam("displayed") | ||
boolean displayed, | ||
@Parameter(description = "to retrieve all sites") | ||
@DefaultValue("true") | ||
@QueryParam("allSites") | ||
boolean allSites, | ||
@Parameter(description = "to filter sites by view/edit permissions") | ||
@DefaultValue("false") | ||
@QueryParam("filterByPermissions") | ||
boolean filterByPermission, | ||
@Parameter(description = "Offset of results to retrieve") | ||
@QueryParam("offset") | ||
@DefaultValue("0") | ||
int offset, | ||
@Parameter(description = "Limit of results to retrieve") | ||
@QueryParam("limit") | ||
@DefaultValue("0") | ||
int limit) { | ||
try { | ||
SiteFilter siteFilter = new SiteFilter(); | ||
if (siteTypeName != null) { | ||
siteFilter.setSiteType(SiteType.valueOf(siteTypeName.toUpperCase())); | ||
} | ||
siteFilter.setExcludedSiteName(excludedSiteName); | ||
siteFilter.setIncludeEmpty(includeEmpty); | ||
siteFilter.setDisplayed(displayed); | ||
siteFilter.setAllSites(allSites); | ||
siteFilter.setExpandNavigations(expandNavigations); | ||
siteFilter.setFilterByPermission(filterByPermission); | ||
siteFilter.setLimit(limit); | ||
siteFilter.setOffset(offset); | ||
List<PortalConfig> sites = layoutService.getSites(siteFilter); | ||
return Response.ok(EntityBuilder.buildSiteEntities(sites, request, siteFilter)).build(); | ||
} catch (Exception e) { | ||
LOG.warn("Error while retrieving sites", e); | ||
return Response.serverError().build(); | ||
} | ||
} | ||
} |
123 changes: 0 additions & 123 deletions
123
component/service/src/main/java/org/exoplatform/social/rest/impl/site/SiteRestService.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,37 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* Copyright (C) 2023 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.impl.site; | ||
|
||
import java.util.List; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import org.exoplatform.portal.mop.SiteType; | ||
import org.exoplatform.portal.mop.dao.SiteDAO; | ||
import org.exoplatform.portal.rest.services.BaseRestServicesTestCase; | ||
import org.exoplatform.services.rest.impl.ContainerResponse; | ||
import org.exoplatform.services.rest.impl.EnvironmentContext; | ||
import org.exoplatform.services.test.mock.MockHttpServletRequest; | ||
import org.exoplatform.social.rest.entity.SiteEntity; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import java.util.List; | ||
import org.exoplatform.portal.rest.services.BaseRestServicesTestCase; | ||
|
||
public class SiteRestServiceTest extends BaseRestServicesTestCase { | ||
public class SiteRestTest extends BaseRestServicesTestCase { | ||
private SiteDAO siteDAO; | ||
|
||
@Before | ||
|
@@ -33,7 +51,7 @@ public void tearDown() throws Exception { | |
|
||
@Override | ||
protected Class<?> getComponentClass() { | ||
return SiteRestService.class; | ||
return SiteRest.class; | ||
} | ||
|
||
@Test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
webapp/portlet/src/main/webapp/vue-apps/common/js/SiteService.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export function getSites(siteType, displayed, allSites, excludedSiteName, expandNavigations, filterByPermission) { | ||
const formData = new FormData(); | ||
if (siteType) { | ||
formData.append('siteType', siteType); | ||
} | ||
formData.append('displayed', displayed); | ||
formData.append('allSites', allSites); | ||
formData.append('filterByPermission', filterByPermission); | ||
if (excludedSiteName) { | ||
formData.append('excludedSiteName', excludedSiteName); | ||
} | ||
formData.append('expandNavigations', expandNavigations); | ||
const params = new URLSearchParams(formData).toString(); | ||
|
||
return fetch(`${eXo.env.portal.context}/${eXo.env.portal.rest}/v1/social/sites?${params}`, { | ||
method: 'GET', | ||
credentials: 'include', | ||
}).then(resp => { | ||
if (resp?.ok) { | ||
return resp.json(); | ||
} else { | ||
throw new Error('Error while getting sites'); | ||
} | ||
}); | ||
} |
Oops, something went wrong.