From 07cd4dda85baf92f218a27294d3a20c783c4a2f9 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Tue, 27 Feb 2024 15:03:02 +0100 Subject: [PATCH] simplified deprecated methods --- .../community/CommunityApiController.java | 47 +++---------------- 1 file changed, 6 insertions(+), 41 deletions(-) diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiController.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiController.java index 8801e8b9..828ebe33 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiController.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiController.java @@ -431,13 +431,7 @@ public class CommunityApiController extends AbstractExporterController { }) public List getCommunityContentproviders(@PathVariable final String id, @RequestParam(required = false) final Boolean deposit) throws CommunityException { - try { - return deposit == null ? communityService.getCommunityDatasources(id) : communityService.getCommunityDatasourcesWithDeposit(id, deposit); - } catch (final ResourceNotFoundException e) { - throw e; - } catch (final Throwable e) { - throw new CommunityException(e); - } + return getCommunityDatasources(id, deposit); } @Deprecated @@ -454,14 +448,7 @@ public class CommunityApiController extends AbstractExporterController { @PathVariable final String id, @RequestBody final CommunityContentprovider contentprovider) throws CommunityException { - try { - communityService.addCommunityDatasources(id, contentprovider); - return contentprovider; - } catch (final ResourceNotFoundException e) { - throw e; - } catch (final Throwable e) { - throw new CommunityException(e); - } + return addCommunityDatasource(id, contentprovider); } @Deprecated @@ -474,16 +461,8 @@ public class CommunityApiController extends AbstractExporterController { @ApiResponse(responseCode = "404", description = "not found"), @ApiResponse(responseCode = "500", description = "unexpected error") }) - public void removeCommunityContentprovider( - @PathVariable final String id, - @RequestParam final String contentproviderId) throws CommunityException { - try { - communityService.removeCommunityDatasources(id, contentproviderId); - } catch (final ResourceNotFoundException e) { - throw e; - } catch (final Throwable e) { - throw new CommunityException(e); - } + public void removeCommunityContentprovider(@PathVariable final String id, @RequestParam final String contentproviderId) throws CommunityException { + removeCommunityDatasource(id, contentproviderId); } @Deprecated @@ -499,15 +478,7 @@ public class CommunityApiController extends AbstractExporterController { public CommunityContentprovider[] addCommunityContentProvidersList( @PathVariable final String id, @RequestBody final CommunityContentprovider[] contentprovidersList) throws CommunityException { - - try { - communityService.addCommunityDatasources(id, contentprovidersList); - return contentprovidersList; - } catch (final ResourceNotFoundException e) { - throw e; - } catch (final Throwable e) { - throw new CommunityException(e); - } + return addCommunityDatasourcesList(id, contentprovidersList); } @Deprecated @@ -523,13 +494,7 @@ public class CommunityApiController extends AbstractExporterController { public void deleteCommunityContentProvidersList( @PathVariable final String id, @RequestBody final String[] contentProviderIdList) throws CommunityException { - try { - communityService.removeCommunityDatasources(id, contentProviderIdList); - } catch (final ResourceNotFoundException e) { - throw e; - } catch (final Throwable e) { - throw new CommunityException(e); - } + deleteCommunityDatasourcesList(id, contentProviderIdList); } // ORGANIZATIONS