2022-02-04 10:12:15 +01:00
package eu.dnetlib.openaire.community ;
2022-08-19 15:21:40 +02:00
import static eu.dnetlib.openaire.common.ExporterConstants.C ;
import static eu.dnetlib.openaire.common.ExporterConstants.C_CP ;
import static eu.dnetlib.openaire.common.ExporterConstants.C_O ;
import static eu.dnetlib.openaire.common.ExporterConstants.C_PJ ;
2023-10-18 12:05:56 +02:00
import static eu.dnetlib.openaire.common.ExporterConstants.C_SUB ;
2022-08-19 15:21:40 +02:00
import static eu.dnetlib.openaire.common.ExporterConstants.C_ZC ;
import static eu.dnetlib.openaire.common.ExporterConstants.R ;
import static eu.dnetlib.openaire.common.ExporterConstants.W ;
2022-02-04 10:12:15 +01:00
import java.util.List ;
2023-06-28 12:29:59 +02:00
import java.util.Map ;
import java.util.Set ;
2023-10-18 12:05:56 +02:00
import java.util.stream.Collectors ;
2022-02-04 10:12:15 +01:00
2023-06-12 14:47:27 +02:00
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty ;
2023-06-20 09:10:14 +02:00
import org.springframework.data.domain.Page ;
2023-06-12 14:47:27 +02:00
import org.springframework.web.bind.annotation.CrossOrigin ;
2024-02-27 10:36:55 +01:00
import org.springframework.web.bind.annotation.DeleteMapping ;
import org.springframework.web.bind.annotation.GetMapping ;
2023-06-12 14:47:27 +02:00
import org.springframework.web.bind.annotation.PathVariable ;
2024-02-27 10:36:55 +01:00
import org.springframework.web.bind.annotation.PostMapping ;
2023-06-12 14:47:27 +02:00
import org.springframework.web.bind.annotation.RequestBody ;
2023-06-20 09:10:14 +02:00
import org.springframework.web.bind.annotation.RequestParam ;
2023-06-12 14:47:27 +02:00
import org.springframework.web.bind.annotation.RestController ;
2023-10-10 15:51:00 +02:00
import eu.dnetlib.openaire.common.AbstractExporterController ;
2024-02-27 12:05:20 +01:00
import eu.dnetlib.openaire.community.model.DepositionInfo ;
2023-03-31 14:53:52 +02:00
import eu.dnetlib.openaire.exporter.exceptions.CommunityException ;
2023-10-10 15:51:00 +02:00
import eu.dnetlib.openaire.exporter.exceptions.ResourceNotFoundException ;
2023-03-31 14:53:52 +02:00
import eu.dnetlib.openaire.exporter.model.community.CommunityContentprovider ;
import eu.dnetlib.openaire.exporter.model.community.CommunityDetails ;
import eu.dnetlib.openaire.exporter.model.community.CommunityOpenAIRECommunities ;
import eu.dnetlib.openaire.exporter.model.community.CommunityOrganization ;
import eu.dnetlib.openaire.exporter.model.community.CommunityProject ;
import eu.dnetlib.openaire.exporter.model.community.CommunitySummary ;
import eu.dnetlib.openaire.exporter.model.community.CommunityWritableProperties ;
2023-10-18 12:05:56 +02:00
import eu.dnetlib.openaire.exporter.model.community.SubCommunity ;
2023-03-31 14:53:52 +02:00
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria ;
2022-08-19 15:21:40 +02:00
import io.swagger.v3.oas.annotations.Operation ;
import io.swagger.v3.oas.annotations.responses.ApiResponse ;
import io.swagger.v3.oas.annotations.responses.ApiResponses ;
import io.swagger.v3.oas.annotations.tags.Tag ;
2022-02-04 10:12:15 +01:00
@RestController
2022-08-19 15:21:40 +02:00
@CrossOrigin ( origins = {
2024-02-26 14:59:57 +01:00
" * "
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
@ConditionalOnProperty ( value = " openaire.exporter.enable.community " , havingValue = " true " )
2022-08-19 15:21:40 +02:00
@Tag ( name = " OpenAIRE Communities API " , description = " the OpenAIRE Community API " )
2023-10-10 15:51:00 +02:00
public class CommunityApiController extends AbstractExporterController {
2022-02-04 10:12:15 +01:00
@Autowired
2023-06-12 14:47:27 +02:00
private CommunityService communityService ;
2022-02-04 10:12:15 +01:00
2024-02-27 10:36:55 +01:00
@GetMapping ( " /community/communities " )
2022-08-19 15:21:40 +02:00
@Operation ( summary = " get all community profiles " , description = " get all community profiles " , tags = {
2024-02-26 14:59:57 +01:00
C , R
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
public List < CommunitySummary > listCommunities ( ) throws CommunityException {
2023-10-10 15:51:00 +02:00
try {
return communityService . listCommunities ( ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-02-04 10:12:15 +01:00
}
2024-02-27 10:36:55 +01:00
@PostMapping ( " /community/ " )
2023-07-10 10:42:11 +02:00
@Operation ( summary = " add a new community profile " , description = " add a new community profile " , tags = {
2024-02-26 14:59:57 +01:00
C , W
2023-07-10 10:42:11 +02:00
} )
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-07-10 10:42:11 +02:00
} )
public CommunityDetails getCommunity ( @RequestBody final CommunityDetails details ) throws CommunityException {
2023-10-10 15:51:00 +02:00
try {
return communityService . newCommunity ( details ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2023-07-10 10:42:11 +02:00
}
2024-02-28 15:02:26 +01:00
@GetMapping ( " /community/{id} " )
2022-08-19 15:21:40 +02:00
@Operation ( summary = " get community profile " , description = " get community profile " , tags = {
2024-02-26 14:59:57 +01:00
C , R
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-08-19 15:21:40 +02:00
} )
2023-07-04 11:36:44 +02:00
public CommunityDetails getCommunity ( @PathVariable final String id ) throws CommunityException {
2023-10-10 15:51:00 +02:00
try {
return communityService . getCommunity ( id ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-02-04 10:12:15 +01:00
}
2024-02-27 10:36:55 +01:00
@PostMapping ( " /community/{id} " )
2022-08-19 15:21:40 +02:00
@Operation ( summary = " update community details " , description = " update community details " , tags = {
2024-02-26 14:59:57 +01:00
C , W
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
public void setCommunity (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestBody final CommunityWritableProperties properties ) throws CommunityException {
2023-10-10 15:51:00 +02:00
try {
communityService . setCommunity ( id , properties ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-02-04 10:12:15 +01:00
}
2024-02-27 10:36:55 +01:00
@DeleteMapping ( " /community/{id} " )
2023-07-12 09:49:08 +02:00
@Operation ( summary = " delete a community " , description = " delete a community " , tags = {
2024-02-26 14:59:57 +01:00
C , W
2023-07-12 09:49:08 +02:00
} )
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-07-12 09:49:08 +02:00
} )
public void deleteCommunity ( @PathVariable final String id , @RequestParam ( required = false , defaultValue = " false " ) final boolean recursive )
2024-02-26 14:59:57 +01:00
throws CommunityException {
2023-10-10 15:51:00 +02:00
try {
communityService . deleteCommunity ( id , recursive ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2023-07-12 09:49:08 +02:00
}
2024-02-27 10:36:55 +01:00
@GetMapping ( " /community/{id}/projects/{page}/{size} " )
2022-08-19 15:21:40 +02:00
@Operation ( summary = " get community projects " , description = " get community projects " , tags = {
2024-02-26 14:59:57 +01:00
C_PJ , R
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-08-19 15:21:40 +02:00
} )
2023-07-12 11:16:00 +02:00
public Page < CommunityProject > getCommunityProjects ( @PathVariable final String id ,
2024-02-26 14:59:57 +01:00
@PathVariable final Integer page ,
@PathVariable final Integer size ,
@RequestParam ( required = false ) final String funder ,
@RequestParam ( required = false ) final String searchFilter ,
@RequestParam ( required = false ) final String orderBy )
throws CommunityException {
2023-10-10 15:51:00 +02:00
try {
return communityService . getCommunityProjects ( id , funder , searchFilter , page , size , orderBy ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-02-04 10:12:15 +01:00
}
2024-02-27 10:36:55 +01:00
@PostMapping ( " /community/{id}/projects " )
2024-02-28 15:02:26 +01:00
@Operation ( summary = " associate a project to the community, provide all the fields or the method will overwrite with nulls the fields that are missing " , description = " associate a project to the community, provide all the fields or the method will overwrite with nulls the fields that are missing " , tags = {
2024-02-26 14:59:57 +01:00
C_PJ , W
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
public CommunityProject addCommunityProject (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestBody final CommunityProject project ) throws CommunityException {
2022-02-04 10:12:15 +01:00
2023-10-10 15:51:00 +02:00
try {
return communityService . addCommunityProject ( id , project ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-02-04 10:12:15 +01:00
}
2024-02-27 10:36:55 +01:00
@DeleteMapping ( " /community/{id}/projects " )
2022-08-19 15:21:40 +02:00
@Operation ( summary = " remove a project from the community " , description = " remove a project from the community " , tags = {
2024-02-26 14:59:57 +01:00
C_PJ , W
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
public void deleteCommunityProject (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestParam final String projectId ) throws CommunityException {
2023-10-10 15:51:00 +02:00
try {
communityService . removeCommunityProjects ( id , projectId ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-02-04 10:12:15 +01:00
}
2024-02-27 10:36:55 +01:00
@PostMapping ( " /community/{id}/projectList " )
2023-06-12 14:47:27 +02:00
@Operation ( summary = " associate a list of project to the community " , description = " associate a list of project to the community " , tags = {
2024-02-26 14:59:57 +01:00
C_PJ , W
2022-09-26 12:15:39 +02:00
} )
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-09-26 12:15:39 +02:00
} )
2023-07-04 11:36:44 +02:00
public CommunityProject [ ] addCommunityProjectList (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestBody final CommunityProject [ ] projects ) throws CommunityException {
2023-10-10 15:51:00 +02:00
try {
communityService . addCommunityProjects ( id , projects ) ;
return projects ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-09-26 12:15:39 +02:00
}
2024-02-27 10:36:55 +01:00
@DeleteMapping ( " /community/{id}/projectList " )
2023-06-12 14:47:27 +02:00
@Operation ( summary = " remove a list of projects from the community " , description = " remove a list of projects from the community " , tags = {
2024-02-26 14:59:57 +01:00
C_PJ , W
2022-09-26 12:15:39 +02:00
} )
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-09-26 12:15:39 +02:00
} )
public void deleteCommunityProjectList (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestBody final String [ ] projectIdList ) throws CommunityException {
2023-10-10 15:51:00 +02:00
try {
communityService . removeCommunityProjects ( id , projectIdList ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-09-26 12:15:39 +02:00
}
2024-02-27 10:36:55 +01:00
@GetMapping ( " /community/{id}/funders " )
2023-10-02 08:38:19 +02:00
@Operation ( summary = " get the funders of the projects of a community " , description = " get the funders of the projects of a community " , tags = {
2024-02-26 14:59:57 +01:00
C_PJ , R
2023-10-02 08:38:19 +02:00
} )
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-10-02 08:38:19 +02:00
} )
public List < String > getCommunityFunders ( @PathVariable final String id )
2024-02-26 14:59:57 +01:00
throws CommunityException {
2023-10-10 15:51:00 +02:00
try {
return communityService . getCommunityFunders ( id ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2023-10-02 08:38:19 +02:00
}
2024-02-27 14:57:57 +01:00
// Datasources
@GetMapping ( " /community/{id}/datasources " )
@Operation ( summary = " get the list of datasources associated to a given community " , description = " get the list of content providers associated to a given community " , tags = {
2024-02-26 14:59:57 +01:00
C_CP , R
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-08-19 15:21:40 +02:00
} )
2024-02-27 14:57:57 +01:00
public List < CommunityContentprovider > getCommunityDatasources ( @PathVariable final String id , @RequestParam ( required = false ) final Boolean deposit )
2024-02-27 10:36:55 +01:00
throws CommunityException {
2023-10-10 15:51:00 +02:00
try {
2024-02-27 10:36:55 +01:00
return deposit = = null ? communityService . getCommunityDatasources ( id ) : communityService . getCommunityDatasourcesWithDeposit ( id , deposit ) ;
2023-10-10 15:51:00 +02:00
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-02-04 10:12:15 +01:00
}
2024-02-27 14:57:57 +01:00
@PostMapping ( " /community/{id}/datasources " )
2024-02-28 15:02:26 +01:00
@Operation ( summary = " associate a datasource to the community, provide all the fields or the method will overwrite with nulls the fields that are missing " , description = " associate a datasource to the community, provide all the fields or the method will overwrite with nulls the fields that are missing " , tags = {
2024-02-26 14:59:57 +01:00
C_CP , W
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-08-19 15:21:40 +02:00
} )
2024-02-27 14:57:57 +01:00
public CommunityContentprovider addCommunityDatasource (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
2024-02-27 14:57:57 +01:00
@RequestBody final CommunityContentprovider datasource ) throws CommunityException {
2023-07-04 11:36:44 +02:00
2023-10-10 15:51:00 +02:00
try {
2024-02-27 14:57:57 +01:00
communityService . addCommunityDatasources ( id , datasource ) ;
return datasource ;
2023-10-10 15:51:00 +02:00
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-02-04 10:12:15 +01:00
}
2024-02-27 12:05:20 +01:00
@PostMapping ( " /community/{id}/datasources/deposit " )
2024-02-28 15:02:26 +01:00
@Operation ( summary = " update the deposit and message filelds of a datasource associated to the community " , description = " update the deposit and message filelds of a datasource associated to the community " , tags = {
2024-02-27 12:05:20 +01:00
C_CP , W
} )
@ApiResponses ( value = {
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2024-02-27 14:57:57 +01:00
public CommunityContentprovider addCommunityDatasourceDeposit (
2024-02-27 12:05:20 +01:00
@PathVariable final String id ,
@RequestBody final DepositionInfo info ) throws CommunityException {
try {
return communityService . updateCommunityDatasourcesDeposit ( id , info . getOpenaireId ( ) , info . getDeposit ( ) , info . getMessage ( ) ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
}
2024-02-27 14:57:57 +01:00
@DeleteMapping ( " /community/{id}/datasources " )
@Operation ( summary = " remove the association between a datasource and the community " , description = " remove the association between a datasource and the community " , tags = {
C_CP , W
} )
@ApiResponses ( value = {
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
public void removeCommunityDatasource (
@PathVariable final String id ,
@RequestParam final String dsId ) throws CommunityException {
try {
communityService . removeCommunityDatasources ( id , dsId ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
}
@PostMapping ( " /community/{id}/datasourcesList " )
2024-02-28 15:02:26 +01:00
@Operation ( summary = " associate a list of datasources to the community, provide all the fields or the method will overwrite with nulls the fields that are missing " , description = " associate a list of datasources to the community, provide all the fields or the method will overwrite with nulls the fields that are missing " , tags = {
2024-02-27 14:57:57 +01:00
C_CP , W
} )
@ApiResponses ( value = {
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
public CommunityContentprovider [ ] addCommunityDatasourcesList (
@PathVariable final String id ,
@RequestBody final CommunityContentprovider [ ] dsList ) throws CommunityException {
try {
communityService . addCommunityDatasources ( id , dsList ) ;
return dsList ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
}
@DeleteMapping ( " /community/{id}/datasourcesList " )
@Operation ( summary = " remove a list of datasources from the community " , description = " remove a list of datasources from the community " , tags = {
C_CP , W
} )
@ApiResponses ( value = {
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
public void deleteCommunityDatasourcesList (
@PathVariable final String id ,
@RequestBody final String [ ] dsIdList ) throws CommunityException {
try {
communityService . removeCommunityDatasources ( id , dsIdList ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
}
// Content Providers (DEPRECATED)
@Deprecated
@GetMapping ( " /community/{id}/contentproviders " )
@Operation ( summary = " get the list of datasources associated to a given community " , description = " get the list of content providers associated to a given community " , tags = {
C_CP , R
} )
@ApiResponses ( value = {
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
public List < CommunityContentprovider > getCommunityContentproviders ( @PathVariable final String id , @RequestParam ( required = false ) final Boolean deposit )
throws CommunityException {
2024-02-27 15:03:02 +01:00
return getCommunityDatasources ( id , deposit ) ;
2024-02-27 14:57:57 +01:00
}
@Deprecated
@PostMapping ( " /community/{id}/contentproviders " )
2024-02-28 15:02:26 +01:00
@Operation ( summary = " associate a datasource to the community, provide all the fields or the method will overwrite with nulls the fields that are missing " , description = " associate a datasource to the community, provide all the fields or the method will overwrite with nulls the fields that are missing " , tags = {
2024-02-27 14:57:57 +01:00
C_CP , W
} )
@ApiResponses ( value = {
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
public CommunityContentprovider addCommunityContentprovider (
@PathVariable final String id ,
@RequestBody final CommunityContentprovider contentprovider ) throws CommunityException {
2024-02-27 15:03:02 +01:00
return addCommunityDatasource ( id , contentprovider ) ;
2024-02-27 14:57:57 +01:00
}
@Deprecated
@DeleteMapping ( " /community/{id}/contentproviders " )
@Operation ( summary = " remove the association between a datasource and the community " , description = " remove the association between a datasource and the community " , tags = {
2024-02-26 14:59:57 +01:00
C_CP , W
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-08-19 15:21:40 +02:00
} )
2024-02-27 15:03:02 +01:00
public void removeCommunityContentprovider ( @PathVariable final String id , @RequestParam final String contentproviderId ) throws CommunityException {
removeCommunityDatasource ( id , contentproviderId ) ;
2022-02-04 10:12:15 +01:00
}
2024-02-27 14:57:57 +01:00
@Deprecated
@PostMapping ( " /community/{id}/contentprovidersList " )
2024-02-28 15:02:26 +01:00
@Operation ( summary = " associate a list of datasources to the community, provide all the fields or the method will overwrite with nulls the fields that are missing " , description = " associate a list of datasources to the community, provide all the fields or the method will overwrite with nulls the fields that are missing " , tags = {
2024-02-26 14:59:57 +01:00
C_CP , W
2022-09-27 16:06:31 +02:00
} )
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-09-27 16:06:31 +02:00
} )
2023-07-04 11:36:44 +02:00
public CommunityContentprovider [ ] addCommunityContentProvidersList (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestBody final CommunityContentprovider [ ] contentprovidersList ) throws CommunityException {
2024-02-27 15:03:02 +01:00
return addCommunityDatasourcesList ( id , contentprovidersList ) ;
2022-09-27 16:06:31 +02:00
}
2024-02-27 14:57:57 +01:00
@Deprecated
@DeleteMapping ( " /community/{id}/contentprovidersList " )
@Operation ( summary = " remove a list of datasources from the community " , description = " remove a list of datasources from the community " , tags = {
2024-02-26 14:59:57 +01:00
C_CP , W
2022-09-27 16:06:31 +02:00
} )
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-09-27 16:06:31 +02:00
} )
public void deleteCommunityContentProvidersList (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestBody final String [ ] contentProviderIdList ) throws CommunityException {
2024-02-27 15:03:02 +01:00
deleteCommunityDatasourcesList ( id , contentProviderIdList ) ;
2022-09-27 16:06:31 +02:00
}
2024-02-27 14:57:57 +01:00
// ORGANIZATIONS
2022-02-04 10:12:15 +01:00
2024-02-27 10:36:55 +01:00
@GetMapping ( " /community/{id}/organizations " )
2022-08-19 15:21:40 +02:00
@Operation ( summary = " get the list of organizations for a given community " , description = " get the list of organizations for a given community " , tags = {
2024-02-26 14:59:57 +01:00
C_O , R
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-08-19 15:21:40 +02:00
} )
2023-07-04 11:36:44 +02:00
public List < CommunityOrganization > getCommunityOrganizations ( @PathVariable final String id ) throws CommunityException {
2023-10-10 15:51:00 +02:00
try {
return communityService . getCommunityOrganizations ( id ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-02-04 10:12:15 +01:00
}
2024-02-27 10:36:55 +01:00
@PostMapping ( " /community/{id}/organizations " )
2024-02-28 15:02:26 +01:00
@Operation ( summary = " associate an organization to the community, provide all the fields or the method will overwrite with nulls the fields that are missing " , description = " associate an organization to the community, provide all the fields or the method will overwrite with nulls the fields that are missing " , tags = {
2024-02-26 14:59:57 +01:00
C_O , W
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
public CommunityOrganization addCommunityOrganization (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestBody final CommunityOrganization organization ) throws CommunityException {
2023-10-10 15:51:00 +02:00
try {
communityService . addCommunityOrganizations ( id , organization ) ;
return organization ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2023-07-04 11:36:44 +02:00
}
2024-02-27 10:36:55 +01:00
@PostMapping ( " /community/{id}/organizationList " )
2024-02-28 15:02:26 +01:00
@Operation ( summary = " associate a list of organizations to the community, provide all the fields or the method will overwrite with nulls the fields that are missing " , description = " associate a list of organizations to the community, provide all the fields or the method will overwrite with nulls the fields that are missing " , tags = {
2024-02-26 14:59:57 +01:00
C_O , W
2023-07-04 11:36:44 +02:00
} )
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-07-04 11:36:44 +02:00
} )
public CommunityOrganization [ ] addCommunityOrganizationList (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestBody final CommunityOrganization [ ] orgs ) throws CommunityException {
2022-02-04 10:12:15 +01:00
2023-10-10 15:51:00 +02:00
try {
communityService . addCommunityOrganizations ( id , orgs ) ;
return orgs ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-02-04 10:12:15 +01:00
}
2024-02-27 10:36:55 +01:00
@DeleteMapping ( " /community/{id}/organizations " )
2022-08-19 15:21:40 +02:00
@Operation ( summary = " remove the association between an organization and the community " , description = " remove the association between an organization and the community " , tags = {
2024-02-26 14:59:57 +01:00
C_O , W
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
public void removeCommunityOrganization (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestParam final String organizationName ) throws CommunityException {
2023-10-10 15:51:00 +02:00
try {
communityService . removeCommunityOrganizations ( id , organizationName ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2023-07-04 11:36:44 +02:00
}
2024-02-27 10:36:55 +01:00
@DeleteMapping ( " /community/{id}/organizationList " )
2023-07-04 11:36:44 +02:00
@Operation ( summary = " remove a list of associations between some organizations and the community " , description = " remove a list of associations between some organizations and the community " , tags = {
2024-02-26 14:59:57 +01:00
C_O , W
2023-07-04 11:36:44 +02:00
} )
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-07-04 11:36:44 +02:00
} )
public void removeCommunityOrganizationList (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestBody final String [ ] orgNames ) throws CommunityException {
2023-10-10 15:51:00 +02:00
try {
communityService . removeCommunityOrganizations ( id , orgNames ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-02-04 10:12:15 +01:00
}
2023-07-04 11:36:44 +02:00
2022-08-19 15:21:40 +02:00
// **********************
2024-02-27 10:36:55 +01:00
@PostMapping ( " /community/{id}/subjects " )
2022-08-19 15:21:40 +02:00
@Operation ( summary = " associate a subject to the community " , description = " associate a subject to the community " , tags = {
2024-02-26 14:59:57 +01:00
C , W
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
public CommunityDetails addCommunitySubjects (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestBody final String [ ] subjects ) throws CommunityException {
2022-02-04 10:12:15 +01:00
2023-10-10 15:51:00 +02:00
try {
return communityService . addCommunitySubjects ( id , subjects ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-02-04 10:12:15 +01:00
}
2024-02-27 10:36:55 +01:00
@DeleteMapping ( " /community/{id}/subjects " )
2022-08-19 15:21:40 +02:00
@Operation ( summary = " remove subjects from a community " , description = " remove subjects from a community " , tags = {
2024-02-26 14:59:57 +01:00
C , W
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
public CommunityDetails removeCommunitySubjects (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestBody final String [ ] subjects ) throws CommunityException {
2022-02-04 10:12:15 +01:00
2023-10-10 15:51:00 +02:00
try {
return communityService . removeCommunitySubjects ( id , subjects ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-02-04 10:12:15 +01:00
}
2023-06-12 14:47:27 +02:00
2024-02-27 10:36:55 +01:00
@PostMapping ( " /community/{id}/fos " )
2023-06-12 14:47:27 +02:00
@Operation ( summary = " associate a fos to the community " , description = " associate a fos to the community " , tags = {
2024-02-26 14:59:57 +01:00
C , W
2023-06-12 14:47:27 +02:00
} )
2022-09-26 12:15:39 +02:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-06-12 14:47:27 +02:00
} )
2022-09-26 12:15:39 +02:00
public CommunityDetails addCommunityFOS (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestBody final String [ ] subjects ) throws CommunityException {
2022-09-26 12:15:39 +02:00
2023-10-10 15:51:00 +02:00
try {
return communityService . addCommunityFOS ( id , subjects ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-09-26 12:15:39 +02:00
}
2024-02-27 10:36:55 +01:00
@DeleteMapping ( " /community/{id}/fos " )
2023-06-12 14:47:27 +02:00
@Operation ( summary = " remove fos from a community " , description = " remove fos from a community " , tags = {
2024-02-26 14:59:57 +01:00
C , W
2023-06-12 14:47:27 +02:00
} )
2022-09-26 12:15:39 +02:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-06-12 14:47:27 +02:00
} )
2022-09-26 12:15:39 +02:00
public CommunityDetails removeCommunityFOS (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestBody final String [ ] subjects ) throws CommunityException {
2022-09-26 12:15:39 +02:00
2023-10-10 15:51:00 +02:00
try {
return communityService . removeCommunityFOS ( id , subjects ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-09-26 12:15:39 +02:00
}
2024-02-27 10:36:55 +01:00
@PostMapping ( " /community/{id}/sdg " )
2023-06-12 14:47:27 +02:00
@Operation ( summary = " associate a sdg to the community " , description = " associate a sdg to the community " , tags = {
2024-02-26 14:59:57 +01:00
C , W
2023-06-12 14:47:27 +02:00
} )
2022-09-26 12:15:39 +02:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-06-12 14:47:27 +02:00
} )
2022-09-26 12:15:39 +02:00
public CommunityDetails addCommunitySDG (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestBody final String [ ] subjects ) throws CommunityException {
2022-09-26 12:15:39 +02:00
2023-10-10 15:51:00 +02:00
try {
return communityService . addCommunitySDG ( id , subjects ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-09-26 12:15:39 +02:00
}
2024-02-27 10:36:55 +01:00
@DeleteMapping ( " /community/{id}/sdg " )
2023-06-12 14:47:27 +02:00
@Operation ( summary = " remove sdg from a community " , description = " remove sdg from a community " , tags = {
2024-02-26 14:59:57 +01:00
C , W
2023-06-12 14:47:27 +02:00
} )
2022-09-26 12:15:39 +02:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-06-12 14:47:27 +02:00
} )
2022-09-26 12:15:39 +02:00
public CommunityDetails removeCommunitySDG (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestBody final String [ ] subjects ) throws CommunityException {
2022-09-26 12:15:39 +02:00
2023-10-10 15:51:00 +02:00
try {
return communityService . removeCommunitySDG ( id , subjects ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-09-26 12:15:39 +02:00
}
2024-02-27 10:36:55 +01:00
@PostMapping ( " /community/{id}/advancedConstraint " )
2023-06-12 14:47:27 +02:00
@Operation ( summary = " the set of constraints to be used to extend the association between result and community " , description = " the set of constraints to be used to extend the association between result and community " , tags = {
2024-02-26 14:59:57 +01:00
C , W
2023-06-12 14:47:27 +02:00
} )
2022-09-26 12:15:39 +02:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-06-12 14:47:27 +02:00
} )
2022-09-26 12:15:39 +02:00
public CommunityDetails addAdvancedConstraint (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestBody final SelectionCriteria advancedConstraint ) throws CommunityException {
2022-09-26 12:15:39 +02:00
2023-10-10 15:51:00 +02:00
try {
return communityService . addCommunityAdvancedConstraint ( id , advancedConstraint ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-09-26 12:15:39 +02:00
}
2024-02-27 10:36:55 +01:00
@DeleteMapping ( " /community/{id}/advancedConstraint " )
2023-06-12 14:47:27 +02:00
@Operation ( summary = " remove the constraints to extend the association result community from a community " , description = " remove the constraints to extend the association result community from a community " , tags = {
2024-02-26 14:59:57 +01:00
C , W
2023-06-12 14:47:27 +02:00
} )
2022-09-26 12:15:39 +02:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-06-12 14:47:27 +02:00
} )
2022-09-26 12:15:39 +02:00
public CommunityDetails removeAdvancedConstraint (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ) throws CommunityException {
2022-09-26 12:15:39 +02:00
2023-10-10 15:51:00 +02:00
try {
return communityService . removeCommunityAdvancedConstraint ( id ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-09-26 12:15:39 +02:00
}
2022-02-04 10:12:15 +01:00
2024-02-27 10:36:55 +01:00
@PostMapping ( " /community/{id}/removeConstraint " )
2023-07-05 11:20:53 +02:00
@Operation ( summary = " the set of constraints to be used to remove the association between result and community " , description = " the set of constraints to be used to remove the association between result and community " , tags = {
2024-02-26 14:59:57 +01:00
C , W
2023-07-05 11:20:53 +02:00
} )
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-07-05 11:20:53 +02:00
} )
public CommunityDetails addRemoveConstraint (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestBody final SelectionCriteria removeConstraint ) throws CommunityException {
2023-07-05 11:20:53 +02:00
2023-10-10 15:51:00 +02:00
try {
return communityService . addCommunityRemoveConstraint ( id , removeConstraint ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2023-07-05 11:20:53 +02:00
}
2024-02-27 10:36:55 +01:00
@DeleteMapping ( " /community/{id}/removeConstraint " )
2023-07-05 11:20:53 +02:00
@Operation ( summary = " remove the constraints to remove the association beetween result and community " , description = " remove the constraints to remove the association beetween result and community " , tags = {
2024-02-26 14:59:57 +01:00
C , W
2023-07-05 11:20:53 +02:00
} )
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-07-05 11:20:53 +02:00
} )
public CommunityDetails removeRemoveConstraint ( @PathVariable final String id ) throws CommunityException {
2023-10-10 15:51:00 +02:00
try {
return communityService . removeCommunityRemoveConstraint ( id ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2023-07-05 11:20:53 +02:00
}
2024-02-27 10:36:55 +01:00
@PostMapping ( " /community/{id}/zenodocommunities " )
2022-08-19 15:21:40 +02:00
@Operation ( summary = " associate a Zenodo community to the community " , description = " associate a Zenodo community to the community " , tags = {
2024-02-26 14:59:57 +01:00
C_ZC , W
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-08-19 15:21:40 +02:00
} )
2023-06-19 15:47:48 +02:00
public CommunityDetails addCommunityZenodoCommunity (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestParam ( required = false , defaultValue = " false " ) final boolean main ,
@RequestParam final String zenodocommunity ) throws CommunityException {
2022-02-04 10:12:15 +01:00
2023-10-10 15:51:00 +02:00
try {
return communityService . addCommunityZenodoCommunity ( id , zenodocommunity , main ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-02-04 10:12:15 +01:00
}
2024-02-27 10:36:55 +01:00
@DeleteMapping ( " /community/{id}/zenodocommunities " )
2022-08-19 15:21:40 +02:00
@Operation ( summary = " remove a Zenodo community from a community " , description = " remove a Zenodo community from a community " , tags = {
2024-02-26 14:59:57 +01:00
C_ZC , W
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
public void removeCommunityZenodoCommunity (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestParam ( required = false , defaultValue = " false " ) final boolean main ,
@RequestParam final String zenodocommunity ) throws CommunityException {
2023-10-10 15:51:00 +02:00
try {
communityService . removeCommunityZenodoCommunity ( id , zenodocommunity , main ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-02-04 10:12:15 +01:00
}
2024-02-27 10:36:55 +01:00
@GetMapping ( " /community/{zenodoId}/openairecommunities " )
2022-08-19 15:21:40 +02:00
@Operation ( summary = " get the list of OpenAIRE communities associated to a given Zenodo community " , description = " get the list of OpenAIRE communities associated to a given Zenodo community " , tags = {
2024-02-26 14:59:57 +01:00
C_ZC , R
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-08-19 15:21:40 +02:00
} )
2023-07-04 11:36:44 +02:00
public CommunityOpenAIRECommunities getOpenAireCommunities ( @PathVariable final String zenodoId ) throws CommunityException {
2023-10-10 15:51:00 +02:00
try {
final CommunityOpenAIRECommunities res = new CommunityOpenAIRECommunities ( ) ;
res . setZenodoid ( zenodoId ) ;
res . setOpenAirecommunitylist ( communityService . getOpenAIRECommunitiesByZenodoId ( zenodoId ) ) ;
return res ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2022-02-04 10:12:15 +01:00
}
2023-06-28 12:29:59 +02:00
// APIs to manage the propagationOrganizationCommunityMap
2024-02-27 10:36:55 +01:00
@GetMapping ( " /propagationOrganizationCommunityMap " )
2023-06-28 12:29:59 +02:00
@Operation ( summary = " Get the propagationOrganizationCommunityMap " , description = " propagationOrganizationCommunityMap " , tags = {
2024-02-26 14:59:57 +01:00
C_O , R
2023-06-28 12:29:59 +02:00
} )
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-06-28 12:29:59 +02:00
} )
2023-06-30 10:46:20 +02:00
public Map < String , Set < String > > getPropagationOrganizationCommunityMap ( ) throws CommunityException {
2023-10-10 15:51:00 +02:00
try {
return communityService . getPropagationOrganizationCommunityMap ( ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2023-06-28 12:29:59 +02:00
}
2024-02-27 10:36:55 +01:00
@GetMapping ( " /community/{id}/propagationOrganizations " )
2023-10-10 15:51:00 +02:00
@Operation ( summary = " try { return the propagation organizations of a community " , description = " try { return the propagation organizations of a community " , tags = {
2024-02-26 14:59:57 +01:00
C_O , R
2023-06-28 12:29:59 +02:00
} )
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-06-28 12:29:59 +02:00
} )
2023-06-30 11:27:14 +02:00
public Set < String > getPropagationOrganizationsForCommunity ( @PathVariable final String id ) throws CommunityException {
2023-10-10 15:51:00 +02:00
try {
return communityService . getPropagationOrganizationsForCommunity ( id ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2023-06-28 12:29:59 +02:00
}
2024-02-27 10:36:55 +01:00
@PostMapping ( " /community/{id}/propagationOrganizations " )
2023-06-28 12:29:59 +02:00
@Operation ( summary = " add an organization to the propagationOrganizationCommunityMap " , description = " add an organization to the propagationOrganizationCommunityMap " , tags = {
2024-02-26 14:59:57 +01:00
C_O , W
2023-06-28 12:29:59 +02:00
} )
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-06-28 12:29:59 +02:00
} )
2023-06-30 11:27:14 +02:00
public Set < String > addPropagationOrganizationForCommunity ( @PathVariable final String id ,
2024-02-26 14:59:57 +01:00
@RequestParam final String organizationId ) throws CommunityException {
2023-07-11 13:33:12 +02:00
2023-10-10 15:51:00 +02:00
try {
return communityService . addPropagationOrganizationForCommunity ( id , organizationId . split ( " , " ) ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2023-06-28 12:29:59 +02:00
}
2024-02-27 10:36:55 +01:00
@DeleteMapping ( " /community/{id}/propagationOrganizations " )
2023-06-28 12:29:59 +02:00
@Operation ( summary = " delete an organization to the propagationOrganizationCommunityMap " , description = " delete an organization to the propagationOrganizationCommunityMap " , tags = {
2024-02-26 14:59:57 +01:00
C_O , W
2023-06-28 12:29:59 +02:00
} )
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-06-28 12:29:59 +02:00
} )
2023-06-30 11:27:14 +02:00
public Set < String > removePropagationOrganizationForCommunity ( @PathVariable final String id ,
2024-02-26 14:59:57 +01:00
@RequestParam final String organizationId ) throws CommunityException {
2023-07-11 13:33:12 +02:00
2023-10-10 15:51:00 +02:00
try {
return communityService . removePropagationOrganizationForCommunity ( id , organizationId . split ( " , " ) ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
2023-06-28 12:29:59 +02:00
}
2023-10-18 12:05:56 +02:00
// APIs to manage the sub communities
2024-02-27 10:36:55 +01:00
@GetMapping ( " /community/{id}/subcommunities " )
2023-10-18 12:05:56 +02:00
@Operation ( summary = " get the list of subcommunities for a given community " , description = " get the list of subcommunities for a given community " , tags = {
2024-02-26 14:59:57 +01:00
C_SUB , R
2023-10-18 12:05:56 +02:00
} )
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-10-18 12:05:56 +02:00
} )
public List < SubCommunity > getSubCommunities ( @PathVariable final String id , @RequestParam ( required = false , defaultValue = " false " ) final boolean all )
2024-02-26 14:59:57 +01:00
throws CommunityException {
2023-10-18 12:05:56 +02:00
try {
return communityService . getSubCommunities ( id )
2024-02-26 14:59:57 +01:00
. stream ( )
. filter ( sc - > all | | sc . isBrowsable ( ) )
. collect ( Collectors . toList ( ) ) ;
2023-10-18 12:05:56 +02:00
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
}
2024-02-27 10:36:55 +01:00
@PostMapping ( " /community/{id}/subcommunities " )
2024-02-28 15:02:26 +01:00
@Operation ( summary = " associate a subcommunity to the community, provide all the fields or the method will overwrite with nulls the fields that are missing " , description = " associate a subcommunity to the community, provide all the fields or the method will overwrite with nulls the fields that are missing " , tags = {
2024-02-26 14:59:57 +01:00
C_SUB , W
2023-10-18 12:05:56 +02:00
} )
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-10-18 12:05:56 +02:00
} )
public SubCommunity addSubCommunity (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestBody final SubCommunity subcommunity ) throws CommunityException {
2023-10-18 12:05:56 +02:00
try {
communityService . addSubCommunities ( id , subcommunity ) ;
return subcommunity ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
}
2024-02-27 10:36:55 +01:00
@PostMapping ( " /community/{id}/subcommunitiesList " )
2024-02-28 15:02:26 +01:00
@Operation ( summary = " associate a list of subcommunities to the community, provide all the fields or the method will overwrite with nulls the fields that are missing " , description = " associate a list of subcommunities to the community, provide all the fields or the method will overwrite with nulls the fields that are missing " , tags = {
2024-02-26 14:59:57 +01:00
C_SUB , W
2023-10-18 12:05:56 +02:00
} )
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-10-18 12:05:56 +02:00
} )
public SubCommunity [ ] addSubCommunityList (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestBody final SubCommunity [ ] subcommunities ) throws CommunityException {
2023-10-18 12:05:56 +02:00
try {
communityService . addSubCommunities ( id , subcommunities ) ;
return subcommunities ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
}
2024-02-27 10:36:55 +01:00
@DeleteMapping ( " /community/{id}/subcommunities " )
2023-10-18 12:05:56 +02:00
@Operation ( summary = " remove the association between a subcommunity and the community " , description = " remove the association between a subcommunity and the community " , tags = {
2024-02-26 14:59:57 +01:00
C_SUB , W
2023-10-18 12:05:56 +02:00
} )
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-10-18 12:05:56 +02:00
} )
public void removeSubCommunity (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestParam final String subCommunityId ) throws CommunityException {
2023-10-18 12:05:56 +02:00
try {
communityService . removeSubCommunities ( id , subCommunityId ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
}
2024-02-27 10:36:55 +01:00
@DeleteMapping ( " /community/{id}/subcommunitiesList " )
2023-10-18 12:05:56 +02:00
@Operation ( summary = " remove a list of associations between some subcommunities and the community " , description = " remove a list of associations between some subcommunities and the community " , tags = {
2024-02-26 14:59:57 +01:00
C_SUB , W
2023-10-18 12:05:56 +02:00
} )
@ApiResponses ( value = {
2024-02-26 14:59:57 +01:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2023-10-18 12:05:56 +02:00
} )
public void removeSubcommunities (
2024-02-26 14:59:57 +01:00
@PathVariable final String id ,
@RequestBody final String [ ] subCommunityIdList ) throws CommunityException {
2023-10-18 12:05:56 +02:00
try {
communityService . removeSubCommunities ( id , subCommunityIdList ) ;
} catch ( final ResourceNotFoundException e ) {
throw e ;
} catch ( final Throwable e ) {
throw new CommunityException ( e ) ;
}
}
2022-02-04 10:12:15 +01:00
}