fixed some methods
This commit is contained in:
parent
fc1417d629
commit
1b6ffc22ae
|
@ -294,9 +294,7 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
@RequestParam(required = false) final String subCommunityId,
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestBody final String[] subjects) throws CommunityException {
|
@RequestBody final String[] subjects) throws CommunityException {
|
||||||
|
|
||||||
if (subCommunityId != null && !id.equals(CommunityMappingUtils.calculateMainCommunityId(subCommunityId))) {
|
verifyIdParameters(id, subCommunityId);
|
||||||
throw new CommunityException("The sub-collection id does not start with " + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.addCommunitySubjects(ObjectUtils.firstNonNull(subCommunityId, id), subjects);
|
communityService.addCommunitySubjects(ObjectUtils.firstNonNull(subCommunityId, id), subjects);
|
||||||
|
@ -323,9 +321,7 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
@RequestParam(required = false) final String subCommunityId,
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestBody final String[] subjects) throws CommunityException {
|
@RequestBody final String[] subjects) throws CommunityException {
|
||||||
|
|
||||||
if (subCommunityId != null && !id.equals(CommunityMappingUtils.calculateMainCommunityId(subCommunityId))) {
|
verifyIdParameters(id, subCommunityId);
|
||||||
throw new CommunityException("The sub-collection id does not start with " + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.removeCommunitySubjects(ObjectUtils.firstNonNull(subCommunityId, id), subjects);
|
communityService.removeCommunitySubjects(ObjectUtils.firstNonNull(subCommunityId, id), subjects);
|
||||||
|
@ -352,9 +348,7 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
@RequestParam(required = false) final String subCommunityId,
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestBody final String[] subjects) throws CommunityException {
|
@RequestBody final String[] subjects) throws CommunityException {
|
||||||
|
|
||||||
if (subCommunityId != null && !id.equals(CommunityMappingUtils.calculateMainCommunityId(subCommunityId))) {
|
verifyIdParameters(id, subCommunityId);
|
||||||
throw new CommunityException("The sub-collection id does not start with " + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.addCommunityFOS(ObjectUtils.firstNonNull(subCommunityId, id), subjects);
|
communityService.addCommunityFOS(ObjectUtils.firstNonNull(subCommunityId, id), subjects);
|
||||||
|
@ -381,9 +375,7 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
@RequestParam(required = false) final String subCommunityId,
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestBody final String[] subjects) throws CommunityException {
|
@RequestBody final String[] subjects) throws CommunityException {
|
||||||
|
|
||||||
if (subCommunityId != null && !id.equals(CommunityMappingUtils.calculateMainCommunityId(subCommunityId))) {
|
verifyIdParameters(id, subCommunityId);
|
||||||
throw new CommunityException("The sub-collection id does not start with " + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.removeCommunityFOS(ObjectUtils.firstNonNull(subCommunityId, id), subjects);
|
communityService.removeCommunityFOS(ObjectUtils.firstNonNull(subCommunityId, id), subjects);
|
||||||
|
@ -410,9 +402,7 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
@RequestParam(required = false) final String subCommunityId,
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestBody final String[] subjects) throws CommunityException {
|
@RequestBody final String[] subjects) throws CommunityException {
|
||||||
|
|
||||||
if (subCommunityId != null && !id.equals(CommunityMappingUtils.calculateMainCommunityId(subCommunityId))) {
|
verifyIdParameters(id, subCommunityId);
|
||||||
throw new CommunityException("The sub-collection id does not start with " + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.addCommunitySDG(ObjectUtils.firstNonNull(subCommunityId, id), subjects);
|
communityService.addCommunitySDG(ObjectUtils.firstNonNull(subCommunityId, id), subjects);
|
||||||
|
@ -439,9 +429,7 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
@RequestParam(required = false) final String subCommunityId,
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestBody final String[] subjects) throws CommunityException {
|
@RequestBody final String[] subjects) throws CommunityException {
|
||||||
|
|
||||||
if (subCommunityId != null && !id.equals(CommunityMappingUtils.calculateMainCommunityId(subCommunityId))) {
|
verifyIdParameters(id, subCommunityId);
|
||||||
throw new CommunityException("The sub-collection id does not start with " + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.removeCommunitySDG(ObjectUtils.firstNonNull(subCommunityId, id), subjects);
|
communityService.removeCommunitySDG(ObjectUtils.firstNonNull(subCommunityId, id), subjects);
|
||||||
|
@ -468,9 +456,7 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
@RequestParam(required = false) final String subCommunityId,
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestBody final SelectionCriteria advancedConstraint) throws CommunityException {
|
@RequestBody final SelectionCriteria advancedConstraint) throws CommunityException {
|
||||||
|
|
||||||
if (subCommunityId != null && !id.equals(CommunityMappingUtils.calculateMainCommunityId(subCommunityId))) {
|
verifyIdParameters(id, subCommunityId);
|
||||||
throw new CommunityException("The sub-collection id does not start with " + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.addCommunityAdvancedConstraint(ObjectUtils.firstNonNull(subCommunityId, id), advancedConstraint);
|
communityService.addCommunityAdvancedConstraint(ObjectUtils.firstNonNull(subCommunityId, id), advancedConstraint);
|
||||||
|
@ -496,9 +482,7 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
@PathVariable final String id,
|
@PathVariable final String id,
|
||||||
@RequestParam(required = false) final String subCommunityId) throws CommunityException {
|
@RequestParam(required = false) final String subCommunityId) throws CommunityException {
|
||||||
|
|
||||||
if (subCommunityId != null && !id.equals(CommunityMappingUtils.calculateMainCommunityId(subCommunityId))) {
|
verifyIdParameters(id, subCommunityId);
|
||||||
throw new CommunityException("The sub-collection id does not start with " + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.removeCommunityAdvancedConstraint(ObjectUtils.firstNonNull(subCommunityId, id));
|
communityService.removeCommunityAdvancedConstraint(ObjectUtils.firstNonNull(subCommunityId, id));
|
||||||
|
@ -525,9 +509,7 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
@RequestParam(required = false) final String subCommunityId,
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestBody final SelectionCriteria removeConstraint) throws CommunityException {
|
@RequestBody final SelectionCriteria removeConstraint) throws CommunityException {
|
||||||
|
|
||||||
if (subCommunityId != null && !id.equals(CommunityMappingUtils.calculateMainCommunityId(subCommunityId))) {
|
verifyIdParameters(id, subCommunityId);
|
||||||
throw new CommunityException("The sub-collection id does not start with " + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.addCommunityRemoveConstraint(ObjectUtils.firstNonNull(subCommunityId, id), removeConstraint);
|
communityService.addCommunityRemoveConstraint(ObjectUtils.firstNonNull(subCommunityId, id), removeConstraint);
|
||||||
|
@ -552,9 +534,7 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
public Object removeRemoveConstraint(@PathVariable final String id, @RequestParam(required = false) final String subCommunityId)
|
public Object removeRemoveConstraint(@PathVariable final String id, @RequestParam(required = false) final String subCommunityId)
|
||||||
throws CommunityException {
|
throws CommunityException {
|
||||||
|
|
||||||
if (subCommunityId != null && !id.equals(CommunityMappingUtils.calculateMainCommunityId(subCommunityId))) {
|
verifyIdParameters(id, subCommunityId);
|
||||||
throw new CommunityException("The sub-collection id does not start with " + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.removeCommunityRemoveConstraint(ObjectUtils.firstNonNull(subCommunityId, id));
|
communityService.removeCommunityRemoveConstraint(ObjectUtils.firstNonNull(subCommunityId, id));
|
||||||
|
@ -582,9 +562,7 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
@RequestParam(required = false, defaultValue = "false") final boolean main,
|
@RequestParam(required = false, defaultValue = "false") final boolean main,
|
||||||
@RequestParam final String zenodocommunity) throws CommunityException {
|
@RequestParam final String zenodocommunity) throws CommunityException {
|
||||||
|
|
||||||
if (subCommunityId != null && !id.equals(CommunityMappingUtils.calculateMainCommunityId(subCommunityId))) {
|
verifyIdParameters(id, subCommunityId);
|
||||||
throw new CommunityException("The sub-collection id does not start with " + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.addCommunityZenodoCommunity(ObjectUtils.firstNonNull(subCommunityId, id), zenodocommunity, main);
|
communityService.addCommunityZenodoCommunity(ObjectUtils.firstNonNull(subCommunityId, id), zenodocommunity, main);
|
||||||
|
@ -612,9 +590,7 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
@RequestParam(required = false) final String subCommunityId,
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestParam(required = false, defaultValue = "false") final boolean main,
|
@RequestParam(required = false, defaultValue = "false") final boolean main,
|
||||||
@RequestParam final String zenodocommunity) throws CommunityException {
|
@RequestParam final String zenodocommunity) throws CommunityException {
|
||||||
if (subCommunityId != null && !id.equals(CommunityMappingUtils.calculateMainCommunityId(subCommunityId))) {
|
verifyIdParameters(id, subCommunityId);
|
||||||
throw new CommunityException("The sub-collection id does not start with " + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.removeCommunityZenodoCommunity(ObjectUtils.firstNonNull(subCommunityId, id), zenodocommunity, main);
|
communityService.removeCommunityZenodoCommunity(ObjectUtils.firstNonNull(subCommunityId, id), zenodocommunity, main);
|
||||||
|
@ -641,12 +617,16 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
public Page<CommunityProject> getCommunityProjects(@PathVariable final String id,
|
public Page<CommunityProject> getCommunityProjects(@PathVariable final String id,
|
||||||
@PathVariable final Integer page,
|
@PathVariable final Integer page,
|
||||||
@PathVariable final Integer size,
|
@PathVariable final Integer size,
|
||||||
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestParam(required = false) final String funder,
|
@RequestParam(required = false) final String funder,
|
||||||
@RequestParam(required = false) final String searchFilter,
|
@RequestParam(required = false) final String searchFilter,
|
||||||
@RequestParam(required = false) final String orderBy)
|
@RequestParam(required = false) final String orderBy)
|
||||||
throws CommunityException {
|
throws CommunityException {
|
||||||
|
|
||||||
|
verifyIdParameters(id, subCommunityId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return communityService.getCommunityProjects(id, funder, searchFilter, page, size, orderBy);
|
return communityService.getCommunityProjects(ObjectUtils.firstNonNull(subCommunityId, id), funder, searchFilter, page, size, orderBy);
|
||||||
} catch (final ResourceNotFoundException e) {
|
} catch (final ResourceNotFoundException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
|
@ -665,10 +645,13 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
})
|
})
|
||||||
public CommunityProject addCommunityProject(
|
public CommunityProject addCommunityProject(
|
||||||
@PathVariable final String id,
|
@PathVariable final String id,
|
||||||
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestBody final CommunityProject project) throws CommunityException {
|
@RequestBody final CommunityProject project) throws CommunityException {
|
||||||
|
|
||||||
|
verifyIdParameters(id, subCommunityId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return communityService.addCommunityProject(id, project);
|
return communityService.addCommunityProject(ObjectUtils.firstNonNull(subCommunityId, id), project);
|
||||||
} catch (final ResourceNotFoundException e) {
|
} catch (final ResourceNotFoundException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
|
@ -687,9 +670,13 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
})
|
})
|
||||||
public void deleteCommunityProject(
|
public void deleteCommunityProject(
|
||||||
@PathVariable final String id,
|
@PathVariable final String id,
|
||||||
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestParam final String projectId) throws CommunityException {
|
@RequestParam final String projectId) throws CommunityException {
|
||||||
|
|
||||||
|
verifyIdParameters(id, subCommunityId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.removeCommunityProjects(id, projectId);
|
communityService.removeCommunityProjects(ObjectUtils.firstNonNull(subCommunityId, id), projectId);
|
||||||
} catch (final ResourceNotFoundException e) {
|
} catch (final ResourceNotFoundException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
|
@ -708,9 +695,13 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
})
|
})
|
||||||
public CommunityProject[] addCommunityProjectList(
|
public CommunityProject[] addCommunityProjectList(
|
||||||
@PathVariable final String id,
|
@PathVariable final String id,
|
||||||
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestBody final CommunityProject[] projects) throws CommunityException {
|
@RequestBody final CommunityProject[] projects) throws CommunityException {
|
||||||
|
|
||||||
|
verifyIdParameters(id, subCommunityId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.addCommunityProjects(id, projects);
|
communityService.addCommunityProjects(ObjectUtils.firstNonNull(subCommunityId, id), projects);
|
||||||
return projects;
|
return projects;
|
||||||
} catch (final ResourceNotFoundException e) {
|
} catch (final ResourceNotFoundException e) {
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -730,9 +721,13 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
})
|
})
|
||||||
public void deleteCommunityProjectList(
|
public void deleteCommunityProjectList(
|
||||||
@PathVariable final String id,
|
@PathVariable final String id,
|
||||||
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestBody final String[] projectIdList) throws CommunityException {
|
@RequestBody final String[] projectIdList) throws CommunityException {
|
||||||
|
|
||||||
|
verifyIdParameters(id, subCommunityId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.removeCommunityProjects(id, projectIdList);
|
communityService.removeCommunityProjects(ObjectUtils.firstNonNull(subCommunityId, id), projectIdList);
|
||||||
} catch (final ResourceNotFoundException e) {
|
} catch (final ResourceNotFoundException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
|
@ -749,10 +744,13 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
@ApiResponse(responseCode = "404", description = "not found"),
|
@ApiResponse(responseCode = "404", description = "not found"),
|
||||||
@ApiResponse(responseCode = "500", description = "unexpected error")
|
@ApiResponse(responseCode = "500", description = "unexpected error")
|
||||||
})
|
})
|
||||||
public List<String> getCommunityFunders(@PathVariable final String id)
|
public List<String> getCommunityFunders(@PathVariable final String id, @RequestParam(required = false) final String subCommunityId)
|
||||||
throws CommunityException {
|
throws CommunityException {
|
||||||
|
|
||||||
|
verifyIdParameters(id, subCommunityId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return communityService.getCommunityFunders(id);
|
return communityService.getCommunityFunders(ObjectUtils.firstNonNull(subCommunityId, id));
|
||||||
} catch (final ResourceNotFoundException e) {
|
} catch (final ResourceNotFoundException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
|
@ -771,10 +769,16 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
@ApiResponse(responseCode = "404", description = "not found"),
|
@ApiResponse(responseCode = "404", description = "not found"),
|
||||||
@ApiResponse(responseCode = "500", description = "unexpected error")
|
@ApiResponse(responseCode = "500", description = "unexpected error")
|
||||||
})
|
})
|
||||||
public List<CommunityContentprovider> getCommunityDatasources(@PathVariable final String id, @RequestParam(required = false) final Boolean deposit)
|
public List<CommunityContentprovider> getCommunityDatasources(@PathVariable final String id,
|
||||||
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
|
@RequestParam(required = false) final Boolean deposit)
|
||||||
throws CommunityException {
|
throws CommunityException {
|
||||||
|
|
||||||
|
verifyIdParameters(id, subCommunityId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return deposit == null ? communityService.getCommunityDatasources(id) : communityService.getCommunityDatasourcesWithDeposit(id, deposit);
|
return deposit == null ? communityService.getCommunityDatasources(ObjectUtils.firstNonNull(subCommunityId, id))
|
||||||
|
: communityService.getCommunityDatasourcesWithDeposit(id, deposit);
|
||||||
} catch (final ResourceNotFoundException e) {
|
} catch (final ResourceNotFoundException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
|
@ -793,10 +797,13 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
})
|
})
|
||||||
public CommunityContentprovider addCommunityDatasource(
|
public CommunityContentprovider addCommunityDatasource(
|
||||||
@PathVariable final String id,
|
@PathVariable final String id,
|
||||||
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestBody final CommunityContentprovider datasource) throws CommunityException {
|
@RequestBody final CommunityContentprovider datasource) throws CommunityException {
|
||||||
|
|
||||||
|
verifyIdParameters(id, subCommunityId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.addCommunityDatasources(id, datasource);
|
communityService.addCommunityDatasources(ObjectUtils.firstNonNull(subCommunityId, id), datasource);
|
||||||
return datasource;
|
return datasource;
|
||||||
} catch (final ResourceNotFoundException e) {
|
} catch (final ResourceNotFoundException e) {
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -816,9 +823,14 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
})
|
})
|
||||||
public CommunityContentprovider addCommunityDatasourceDeposit(
|
public CommunityContentprovider addCommunityDatasourceDeposit(
|
||||||
@PathVariable final String id,
|
@PathVariable final String id,
|
||||||
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestBody final DepositionInfo info) throws CommunityException {
|
@RequestBody final DepositionInfo info) throws CommunityException {
|
||||||
|
|
||||||
|
verifyIdParameters(id, subCommunityId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return communityService.updateCommunityDatasourcesDeposit(id, info.getOpenaireId(), info.getDeposit(), info.getMessage());
|
return communityService.updateCommunityDatasourcesDeposit(ObjectUtils.firstNonNull(subCommunityId, id), info.getOpenaireId(), info
|
||||||
|
.getDeposit(), info.getMessage());
|
||||||
} catch (final ResourceNotFoundException e) {
|
} catch (final ResourceNotFoundException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
|
@ -837,9 +849,13 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
})
|
})
|
||||||
public void removeCommunityDatasource(
|
public void removeCommunityDatasource(
|
||||||
@PathVariable final String id,
|
@PathVariable final String id,
|
||||||
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestParam final String dsId) throws CommunityException {
|
@RequestParam final String dsId) throws CommunityException {
|
||||||
|
|
||||||
|
verifyIdParameters(id, subCommunityId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.removeCommunityDatasources(id, dsId);
|
communityService.removeCommunityDatasources(ObjectUtils.firstNonNull(subCommunityId, id), dsId);
|
||||||
} catch (final ResourceNotFoundException e) {
|
} catch (final ResourceNotFoundException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
|
@ -858,10 +874,13 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
})
|
})
|
||||||
public CommunityContentprovider[] addCommunityDatasourcesList(
|
public CommunityContentprovider[] addCommunityDatasourcesList(
|
||||||
@PathVariable final String id,
|
@PathVariable final String id,
|
||||||
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestBody final CommunityContentprovider[] dsList) throws CommunityException {
|
@RequestBody final CommunityContentprovider[] dsList) throws CommunityException {
|
||||||
|
|
||||||
|
verifyIdParameters(id, subCommunityId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.addCommunityDatasources(id, dsList);
|
communityService.addCommunityDatasources(ObjectUtils.firstNonNull(subCommunityId, id), dsList);
|
||||||
return dsList;
|
return dsList;
|
||||||
} catch (final ResourceNotFoundException e) {
|
} catch (final ResourceNotFoundException e) {
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -881,9 +900,13 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
})
|
})
|
||||||
public void deleteCommunityDatasourcesList(
|
public void deleteCommunityDatasourcesList(
|
||||||
@PathVariable final String id,
|
@PathVariable final String id,
|
||||||
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestBody final String[] dsIdList) throws CommunityException {
|
@RequestBody final String[] dsIdList) throws CommunityException {
|
||||||
|
|
||||||
|
verifyIdParameters(id, subCommunityId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.removeCommunityDatasources(id, dsIdList);
|
communityService.removeCommunityDatasources(ObjectUtils.firstNonNull(subCommunityId, id), dsIdList);
|
||||||
} catch (final ResourceNotFoundException e) {
|
} catch (final ResourceNotFoundException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
|
@ -891,86 +914,6 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 {
|
|
||||||
return getCommunityDatasources(id, deposit);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@PostMapping("/community/{id}/contentproviders")
|
|
||||||
@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 = {
|
|
||||||
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 {
|
|
||||||
|
|
||||||
return addCommunityDatasource(id, contentprovider);
|
|
||||||
}
|
|
||||||
|
|
||||||
@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 = {
|
|
||||||
C_CP, W
|
|
||||||
})
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(responseCode = "200", description = "OK"),
|
|
||||||
@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 {
|
|
||||||
removeCommunityDatasource(id, contentproviderId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@PostMapping("/community/{id}/contentprovidersList")
|
|
||||||
@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 = {
|
|
||||||
C_CP, W
|
|
||||||
})
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(responseCode = "200", description = "OK"),
|
|
||||||
@ApiResponse(responseCode = "404", description = "not found"),
|
|
||||||
@ApiResponse(responseCode = "500", description = "unexpected error")
|
|
||||||
})
|
|
||||||
public CommunityContentprovider[] addCommunityContentProvidersList(
|
|
||||||
@PathVariable final String id,
|
|
||||||
@RequestBody final CommunityContentprovider[] contentprovidersList) throws CommunityException {
|
|
||||||
return addCommunityDatasourcesList(id, contentprovidersList);
|
|
||||||
}
|
|
||||||
|
|
||||||
@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 = {
|
|
||||||
C_CP, W
|
|
||||||
})
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(responseCode = "200", description = "OK"),
|
|
||||||
@ApiResponse(responseCode = "404", description = "not found"),
|
|
||||||
@ApiResponse(responseCode = "500", description = "unexpected error")
|
|
||||||
})
|
|
||||||
public void deleteCommunityContentProvidersList(
|
|
||||||
@PathVariable final String id,
|
|
||||||
@RequestBody final String[] contentProviderIdList) throws CommunityException {
|
|
||||||
deleteCommunityDatasourcesList(id, contentProviderIdList);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ORGANIZATIONS
|
// ORGANIZATIONS
|
||||||
|
|
||||||
@GetMapping("/community/{id}/organizations")
|
@GetMapping("/community/{id}/organizations")
|
||||||
|
@ -982,9 +925,12 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
@ApiResponse(responseCode = "404", description = "not found"),
|
@ApiResponse(responseCode = "404", description = "not found"),
|
||||||
@ApiResponse(responseCode = "500", description = "unexpected error")
|
@ApiResponse(responseCode = "500", description = "unexpected error")
|
||||||
})
|
})
|
||||||
public List<CommunityOrganization> getCommunityOrganizations(@PathVariable final String id) throws CommunityException {
|
public List<CommunityOrganization> getCommunityOrganizations(@PathVariable final String id, @RequestParam(required = false) final String subCommunityId)
|
||||||
|
throws CommunityException {
|
||||||
|
verifyIdParameters(id, subCommunityId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return communityService.getCommunityOrganizations(id);
|
return communityService.getCommunityOrganizations(ObjectUtils.firstNonNull(subCommunityId, id));
|
||||||
} catch (final ResourceNotFoundException e) {
|
} catch (final ResourceNotFoundException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
|
@ -1003,9 +949,13 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
})
|
})
|
||||||
public CommunityOrganization addCommunityOrganization(
|
public CommunityOrganization addCommunityOrganization(
|
||||||
@PathVariable final String id,
|
@PathVariable final String id,
|
||||||
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestBody final CommunityOrganization organization) throws CommunityException {
|
@RequestBody final CommunityOrganization organization) throws CommunityException {
|
||||||
|
|
||||||
|
verifyIdParameters(id, subCommunityId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.addCommunityOrganizations(id, organization);
|
communityService.addCommunityOrganizations(ObjectUtils.firstNonNull(subCommunityId, id), organization);
|
||||||
return organization;
|
return organization;
|
||||||
} catch (final ResourceNotFoundException e) {
|
} catch (final ResourceNotFoundException e) {
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -1025,10 +975,13 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
})
|
})
|
||||||
public CommunityOrganization[] addCommunityOrganizationList(
|
public CommunityOrganization[] addCommunityOrganizationList(
|
||||||
@PathVariable final String id,
|
@PathVariable final String id,
|
||||||
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestBody final CommunityOrganization[] orgs) throws CommunityException {
|
@RequestBody final CommunityOrganization[] orgs) throws CommunityException {
|
||||||
|
|
||||||
|
verifyIdParameters(id, subCommunityId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.addCommunityOrganizations(id, orgs);
|
communityService.addCommunityOrganizations(ObjectUtils.firstNonNull(subCommunityId, id), orgs);
|
||||||
return orgs;
|
return orgs;
|
||||||
} catch (final ResourceNotFoundException e) {
|
} catch (final ResourceNotFoundException e) {
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -1048,9 +1001,13 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
})
|
})
|
||||||
public void removeCommunityOrganization(
|
public void removeCommunityOrganization(
|
||||||
@PathVariable final String id,
|
@PathVariable final String id,
|
||||||
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestParam final String organizationName) throws CommunityException {
|
@RequestParam final String organizationName) throws CommunityException {
|
||||||
|
|
||||||
|
verifyIdParameters(id, subCommunityId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.removeCommunityOrganizations(id, organizationName);
|
communityService.removeCommunityOrganizations(ObjectUtils.firstNonNull(subCommunityId, id), organizationName);
|
||||||
} catch (final ResourceNotFoundException e) {
|
} catch (final ResourceNotFoundException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
|
@ -1069,9 +1026,13 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
})
|
})
|
||||||
public void removeCommunityOrganizationList(
|
public void removeCommunityOrganizationList(
|
||||||
@PathVariable final String id,
|
@PathVariable final String id,
|
||||||
|
@RequestParam(required = false) final String subCommunityId,
|
||||||
@RequestBody final String[] orgNames) throws CommunityException {
|
@RequestBody final String[] orgNames) throws CommunityException {
|
||||||
|
|
||||||
|
verifyIdParameters(id, subCommunityId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
communityService.removeCommunityOrganizations(id, orgNames);
|
communityService.removeCommunityOrganizations(ObjectUtils.firstNonNull(subCommunityId, id), orgNames);
|
||||||
} catch (final ResourceNotFoundException e) {
|
} catch (final ResourceNotFoundException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
|
@ -1184,4 +1145,16 @@ public class CommunityApiController extends AbstractExporterController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void verifyIdParameters(final String id, final String subCommunityId) throws CommunityException {
|
||||||
|
if (!CommunityMappingUtils.isValidCommunityId(id)) { throw new CommunityException("Invalid community id: " + id); }
|
||||||
|
|
||||||
|
if (subCommunityId != null && CommunityMappingUtils.isValidSubCommunityId(subCommunityId)) {
|
||||||
|
throw new CommunityException("Invalid sub-collection id: " + subCommunityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subCommunityId != null && !id.equals(CommunityMappingUtils.calculateMainCommunityId(subCommunityId))) {
|
||||||
|
throw new CommunityException("The sub-collection id does not start with " + id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -338,4 +338,11 @@ public class CommunityMappingUtils {
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isValidCommunityId(final String id) {
|
||||||
|
return StringUtils.isNotBlank(id) && !StringUtils.contains(id, COMMUNITY_ID_PARTS_SEPARATOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isValidSubCommunityId(final String subcommunityId) {
|
||||||
|
return StringUtils.isNotBlank(subcommunityId) && StringUtils.split(subcommunityId, COMMUNITY_ID_PARTS_SEPARATOR).length > 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue