exporter-model-classes #14

Merged
michele.artini merged 7 commits from exporter-model-classes into master 2023-04-12 12:03:00 +02:00
33 changed files with 229 additions and 310 deletions
Showing only changes of commit ca382e6b6c - Show all commits

View File

@ -125,12 +125,11 @@
<version>3.4.2</version> <version>3.4.2</version>
</dependency> </dependency>
<!--<dependency> <dependency>
<groupId>eu.dnetlib</groupId> <groupId>eu.dnetlib</groupId>
<artifactId>dnet-datasource-manager-common</artifactId> <artifactId>dnet-datasource-manager-common</artifactId>
<version>[2.0.1,3.0.0)</version> <version>[2.0.1,3.0.0)</version>
</dependency> </dependency>
-->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

View File

@ -16,9 +16,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import eu.dnetlib.openaire.exporter.exceptions.DsmException; import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
import eu.dnetlib.openaire.exporter.exceptions.DsmForbiddenException;
import eu.dnetlib.openaire.exporter.exceptions.DsmNotFoundException;
import eu.dnetlib.openaire.exporter.model.dsm.Response; import eu.dnetlib.openaire.exporter.model.dsm.Response;
/** /**
@ -30,29 +28,13 @@ public abstract class AbstractExporterController {
@ResponseBody @ResponseBody
@ExceptionHandler({ @ExceptionHandler({
DsmException.class DsmApiException.class
}) })
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
public ErrorMessage handleDSMException(final Exception e) { public ErrorMessage handleDSMException(final Exception e) {
return _handleError(e); return _handleError(e);
} }
@ResponseBody
@ExceptionHandler(DsmForbiddenException.class)
@ResponseStatus(value = HttpStatus.FORBIDDEN)
public ErrorMessage handleForbiddenException(final Exception e) {
return _handleError(e);
}
@ResponseBody
@ExceptionHandler({
DsmNotFoundException.class
})
@ResponseStatus(value = HttpStatus.NOT_FOUND)
public ErrorMessage handleNotFoundException(final Exception e) {
return _handleError(e);
}
@ResponseBody @ResponseBody
@ExceptionHandler(MethodArgumentNotValidException.class) @ExceptionHandler(MethodArgumentNotValidException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.BAD_REQUEST)

View File

@ -5,14 +5,13 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo; import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo;
import eu.dnetlib.openaire.exporter.exceptions.DsmException;
import eu.dnetlib.openaire.exporter.model.context.Context; import eu.dnetlib.openaire.exporter.model.context.Context;
public interface ISClient { public interface ISClient {
IndexDsInfo calculateCurrentIndexDsInfo() throws DsmException; IndexDsInfo calculateCurrentIndexDsInfo() throws Exception;
String getObjectStoreId(String dsId) throws DsmException; String getObjectStoreId(String dsId) throws Exception;
Map<String, Context> getFunderContextMap() throws IOException; Map<String, Context> getFunderContextMap() throws IOException;

View File

@ -28,12 +28,12 @@ import com.google.common.escape.Escaper;
import com.google.common.xml.XmlEscapers; import com.google.common.xml.XmlEscapers;
import eu.dnetlib.DnetOpenaireExporterProperties; import eu.dnetlib.DnetOpenaireExporterProperties;
import eu.dnetlib.enabling.datasources.common.DsmException;
import eu.dnetlib.enabling.datasources.common.DsmRuntimeException;
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
import eu.dnetlib.openaire.context.ContextMappingUtils; import eu.dnetlib.openaire.context.ContextMappingUtils;
import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo; import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo;
import eu.dnetlib.openaire.exporter.exceptions.DsmException;
import eu.dnetlib.openaire.exporter.exceptions.DsmRuntimeException;
import eu.dnetlib.openaire.exporter.model.context.Context; import eu.dnetlib.openaire.exporter.model.context.Context;
/** /**
@ -52,7 +52,7 @@ public class ISClientImpl implements ISClient {
@Override @Override
@Cacheable("indexdsinfo-cache") @Cacheable("indexdsinfo-cache")
public IndexDsInfo calculateCurrentIndexDsInfo() throws DsmException { public IndexDsInfo calculateCurrentIndexDsInfo() throws Exception {
log.warn("calculateCurrentIndexDsInfo(): not using cache"); log.warn("calculateCurrentIndexDsInfo(): not using cache");
final String[] arr; final String[] arr;
try { try {
@ -67,7 +67,7 @@ public class ISClientImpl implements ISClient {
@Override @Override
@Cacheable("objectstoreid-cache") @Cacheable("objectstoreid-cache")
public String getObjectStoreId(final String dsId) throws DsmException { public String getObjectStoreId(final String dsId) throws Exception {
log.warn(String.format("getObjectStoreId(%s): not using cache", dsId)); log.warn(String.format("getObjectStoreId(%s): not using cache", dsId));
try { try {
final String xqueryTemplate = _getQuery(config.getFindObjectStore()); final String xqueryTemplate = _getQuery(config.getFindObjectStore());

View File

@ -26,21 +26,19 @@ import org.springframework.web.bind.annotation.RestController;
import eu.dnetlib.openaire.common.AbstractExporterController; import eu.dnetlib.openaire.common.AbstractExporterController;
import eu.dnetlib.openaire.common.OperationManager; import eu.dnetlib.openaire.common.OperationManager;
import eu.dnetlib.openaire.dsm.domain.DatasourceDetailResponse; import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsUpdate;
import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsWithApis;
import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetResponse;
import eu.dnetlib.openaire.dsm.domain.RegisteredDatasourceInfo;
import eu.dnetlib.openaire.dsm.domain.RequestSort;
import eu.dnetlib.openaire.dsm.domain.RequestSortOrder;
import eu.dnetlib.openaire.exporter.exceptions.DsmException;
import eu.dnetlib.openaire.exporter.exceptions.DsmForbiddenException;
import eu.dnetlib.openaire.exporter.exceptions.DsmNotFoundException;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV1; import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV1;
import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails; import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails;
import eu.dnetlib.openaire.exporter.model.dsm.ApiDetailsResponse; import eu.dnetlib.openaire.exporter.model.dsm.ApiDetailsResponse;
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetailResponse;
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails;
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetailsUpdate;
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetailsWithApis;
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceSnippetResponse;
import eu.dnetlib.openaire.exporter.model.dsm.RegisteredDatasourceInfo;
import eu.dnetlib.openaire.exporter.model.dsm.RequestFilter; import eu.dnetlib.openaire.exporter.model.dsm.RequestFilter;
import eu.dnetlib.openaire.exporter.model.dsm.RequestSort;
import eu.dnetlib.openaire.exporter.model.dsm.RequestSortOrder;
import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse; import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse;
import eu.dnetlib.openaire.exporter.model.vocabularies.Country; import eu.dnetlib.openaire.exporter.model.vocabularies.Country;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -69,7 +67,7 @@ public class DsmApiController extends AbstractExporterController {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error") @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public List<Country> listCountries() throws DsmException { public List<Country> listCountries() throws DsmApiException {
return dsmCore.listCountries(); return dsmCore.listCountries();
} }
@ -88,7 +86,7 @@ public class DsmApiController extends AbstractExporterController {
@RequestParam final RequestSortOrder order, @RequestParam final RequestSortOrder order,
@RequestBody final RequestFilter requestFilter, @RequestBody final RequestFilter requestFilter,
@PathVariable final int page, @PathVariable final int page,
@PathVariable final int size) throws DsmException { @PathVariable final int size) throws DsmApiException {
final StopWatch stop = StopWatch.createStarted(); final StopWatch stop = StopWatch.createStarted();
final DatasourceDetailResponse rsp = dsmCore.searchDsDetails(requestSortBy, order, requestFilter, page, size); final DatasourceDetailResponse rsp = dsmCore.searchDsDetails(requestSortBy, order, requestFilter, page, size);
return prepareResponse(page, size, stop, rsp); return prepareResponse(page, size, stop, rsp);
@ -104,7 +102,7 @@ public class DsmApiController extends AbstractExporterController {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error") @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public AggregationHistoryResponseV1 aggregationHistory(@PathVariable final String dsId) throws DsmException { public AggregationHistoryResponseV1 aggregationHistory(@PathVariable final String dsId) throws DsmApiException {
final StopWatch stop = StopWatch.createStarted(); final StopWatch stop = StopWatch.createStarted();
final AggregationHistoryResponseV1 rsp = dsmCore.aggregationhistoryV1(dsId); final AggregationHistoryResponseV1 rsp = dsmCore.aggregationhistoryV1(dsId);
return prepareResponse(0, rsp.getAggregationInfo().size(), stop, rsp); return prepareResponse(0, rsp.getAggregationInfo().size(), stop, rsp);
@ -125,7 +123,7 @@ public class DsmApiController extends AbstractExporterController {
@RequestParam final RequestSortOrder order, @RequestParam final RequestSortOrder order,
@RequestBody final RequestFilter requestFilter, @RequestBody final RequestFilter requestFilter,
@PathVariable final int page, @PathVariable final int page,
@PathVariable final int size) throws DsmException { @PathVariable final int size) throws DsmApiException {
final StopWatch stop = StopWatch.createStarted(); final StopWatch stop = StopWatch.createStarted();
final DatasourceSnippetResponse rsp = dsmCore.searchSnippet(requestSortBy, order, requestFilter, page, size); final DatasourceSnippetResponse rsp = dsmCore.searchSnippet(requestSortBy, order, requestFilter, page, size);
return prepareResponse(page, size, stop, rsp); return prepareResponse(page, size, stop, rsp);
@ -147,7 +145,7 @@ public class DsmApiController extends AbstractExporterController {
@RequestParam final RequestSortOrder order, @RequestParam final RequestSortOrder order,
@RequestBody final RequestFilter requestFilter, @RequestBody final RequestFilter requestFilter,
@PathVariable final int page, @PathVariable final int page,
@PathVariable final int size) throws DsmException { @PathVariable final int size) throws DsmApiException {
final StopWatch stop = StopWatch.createStarted(); final StopWatch stop = StopWatch.createStarted();
final DatasourceSnippetResponse rsp = dsmCore.searchRegistered(requestSortBy, order, requestFilter, page, size); final DatasourceSnippetResponse rsp = dsmCore.searchRegistered(requestSortBy, order, requestFilter, page, size);
return prepareResponse(page, size, stop, rsp); return prepareResponse(page, size, stop, rsp);
@ -198,7 +196,7 @@ public class DsmApiController extends AbstractExporterController {
@ApiResponse(responseCode = "500", description = "unexpected error") @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public ApiDetailsResponse getApi( public ApiDetailsResponse getApi(
@PathVariable final String dsId) throws DsmException { @PathVariable final String dsId) throws DsmApiException {
final StopWatch stop = StopWatch.createStarted(); final StopWatch stop = StopWatch.createStarted();
final ApiDetailsResponse rsp = dsmCore.getApis(dsId); final ApiDetailsResponse rsp = dsmCore.getApis(dsId);
@ -218,7 +216,7 @@ public class DsmApiController extends AbstractExporterController {
public List<String> searchBaseUrls( public List<String> searchBaseUrls(
@RequestBody final RequestFilter requestFilter, @RequestBody final RequestFilter requestFilter,
@PathVariable final int page, @PathVariable final int page,
@PathVariable final int size) throws DsmException { @PathVariable final int size) throws DsmApiException {
return dsmCore.findBaseURLs(requestFilter, page, size); return dsmCore.findBaseURLs(requestFilter, page, size);
} }
@ -233,7 +231,7 @@ public class DsmApiController extends AbstractExporterController {
@ApiResponse(responseCode = "403", description = "Api not removable"), @ApiResponse(responseCode = "403", description = "Api not removable"),
@ApiResponse(responseCode = "500", description = "DSM Server error") @ApiResponse(responseCode = "500", description = "DSM Server error")
}) })
public void deleteApi(@PathVariable final String apiId) throws DsmForbiddenException, DsmNotFoundException { public void deleteApi(@PathVariable final String apiId) throws DsmApiException {
dsmCore.deleteApi(apiId); dsmCore.deleteApi(apiId);
} }
@ -247,7 +245,7 @@ public class DsmApiController extends AbstractExporterController {
}) })
public void setManaged( public void setManaged(
@RequestParam final String id, @RequestParam final String id,
@RequestParam final boolean managed) throws DsmException { @RequestParam final boolean managed) throws DsmApiException {
dsmCore.setManaged(id, managed); dsmCore.setManaged(id, managed);
} }
@ -260,7 +258,7 @@ public class DsmApiController extends AbstractExporterController {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error") @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public boolean isManaged(@PathVariable final String id) throws DsmException { public boolean isManaged(@PathVariable final String id) throws DsmApiException {
return dsmCore.isManaged(id); return dsmCore.isManaged(id);
} }
@ -273,10 +271,10 @@ public class DsmApiController extends AbstractExporterController {
@ApiResponse(responseCode = "400", description = "Malformed request"), @ApiResponse(responseCode = "400", description = "Malformed request"),
@ApiResponse(responseCode = "500", description = "Unexpected error") @ApiResponse(responseCode = "500", description = "Unexpected error")
}) })
public void saveDs(@Valid @RequestBody final DatasourceDetails datasource) throws DsmException { public void saveDs(@Valid @RequestBody final DatasourceDetails datasource) throws DsmApiException {
if (dsmCore.exist(datasource)) { // TODO further check that the DS doesn't have any API if (dsmCore.exist(datasource)) { // TODO further check that the DS doesn't have any API
throw new DsmException(HttpStatus.SC_CONFLICT, String.format("cannot register, datasource already defined '%s'", datasource.getId())); throw new DsmApiException(HttpStatus.SC_CONFLICT, String.format("cannot register, datasource already defined '%s'", datasource.getId()));
} }
dsmCore.save(datasource); dsmCore.save(datasource);
} }
@ -290,10 +288,10 @@ public class DsmApiController extends AbstractExporterController {
@ApiResponse(responseCode = "400", description = "Malformed request"), @ApiResponse(responseCode = "400", description = "Malformed request"),
@ApiResponse(responseCode = "500", description = "Unexpected error") @ApiResponse(responseCode = "500", description = "Unexpected error")
}) })
public void saveDsWithApis(@Valid @RequestBody final DatasourceDetailsWithApis d) throws DsmException { public void saveDsWithApis(@Valid @RequestBody final DatasourceDetailsWithApis d) throws DsmApiException {
if (d.getDatasource() == null) { throw new DsmException(HttpStatus.SC_BAD_REQUEST, "Datasource field is null"); } if (d.getDatasource() == null) { throw new DsmApiException(HttpStatus.SC_BAD_REQUEST, "Datasource field is null"); }
if (dsmCore.exist(d.getDatasource())) { // TODO further check that the DS doesn't have any API if (dsmCore.exist(d.getDatasource())) { // TODO further check that the DS doesn't have any API
throw new DsmException(HttpStatus.SC_CONFLICT, String.format("cannot register, datasource already defined '%s'", d.getDatasource().getId())); throw new DsmApiException(HttpStatus.SC_CONFLICT, String.format("cannot register, datasource already defined '%s'", d.getDatasource().getId()));
} }
dsmCore.save(d); dsmCore.save(d);
} }
@ -307,7 +305,7 @@ public class DsmApiController extends AbstractExporterController {
@ApiResponse(responseCode = "500", description = "unexpected error") @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public void updateDatasource( public void updateDatasource(
@RequestBody final DatasourceDetailsUpdate ds) throws DsmException, DsmNotFoundException { @RequestBody final DatasourceDetailsUpdate ds) throws DsmApiException {
dsmCore.updateDatasource(ds); dsmCore.updateDatasource(ds);
} }
@ -323,7 +321,7 @@ public class DsmApiController extends AbstractExporterController {
public void updateBaseUrl( public void updateBaseUrl(
@RequestParam final String dsId, @RequestParam final String dsId,
@RequestParam final String apiId, @RequestParam final String apiId,
@RequestParam final String baseUrl) throws DsmException { @RequestParam final String baseUrl) throws DsmApiException {
dsmCore.updateApiBaseurl(dsId, apiId, baseUrl); dsmCore.updateApiBaseurl(dsId, apiId, baseUrl);
} }
@ -340,7 +338,7 @@ public class DsmApiController extends AbstractExporterController {
@RequestParam final String dsId, @RequestParam final String dsId,
@RequestParam final String apiId, @RequestParam final String apiId,
@RequestParam final String compliance, @RequestParam final String compliance,
@RequestParam(required = false, defaultValue = "false") final boolean override) throws DsmException { @RequestParam(required = false, defaultValue = "false") final boolean override) throws DsmApiException {
dsmCore.updateApiCompatibility(dsId, apiId, compliance, override); dsmCore.updateApiCompatibility(dsId, apiId, compliance, override);
} }
@ -356,7 +354,7 @@ public class DsmApiController extends AbstractExporterController {
public void updateOaiSetl( public void updateOaiSetl(
@RequestParam final String dsId, @RequestParam final String dsId,
@RequestParam final String apiId, @RequestParam final String apiId,
@RequestParam final String oaiSet) throws DsmException { @RequestParam final String oaiSet) throws DsmApiException {
dsmCore.updateApiOaiSet(dsId, apiId, oaiSet); dsmCore.updateApiOaiSet(dsId, apiId, oaiSet);
} }
@ -369,8 +367,8 @@ public class DsmApiController extends AbstractExporterController {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error") @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public void addApi(@RequestBody final ApiDetails api) throws DsmException { public void addApi(@RequestBody final ApiDetails api) throws DsmApiException {
if (StringUtils.isBlank(api.getDatasource())) { throw new DsmException(HttpStatus.SC_BAD_REQUEST, "missing datasource id"); } if (StringUtils.isBlank(api.getDatasource())) { throw new DsmApiException(HttpStatus.SC_BAD_REQUEST, "missing datasource id"); }
dsmCore.addApi(api); dsmCore.addApi(api);
} }
@ -387,7 +385,7 @@ public class DsmApiController extends AbstractExporterController {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error") @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public int getOps() throws DsmException { public int getOps() throws DsmApiException {
return operationManager.getOpSize(); return operationManager.getOpSize();
} }
@ -399,7 +397,7 @@ public class DsmApiController extends AbstractExporterController {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error") @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public int killOps() throws DsmException { public int killOps() throws DsmApiException {
return operationManager.dropAll(); return operationManager.dropAll();
} }
@ -411,7 +409,7 @@ public class DsmApiController extends AbstractExporterController {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error") @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public void dropCache() throws DsmException { public void dropCache() throws DsmApiException {
dsmCore.dropCaches(); dsmCore.dropCaches();
} }

View File

@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
import eu.dnetlib.openaire.common.AbstractExporterController; import eu.dnetlib.openaire.common.AbstractExporterController;
import eu.dnetlib.openaire.dsm.dao.ResponseUtils; import eu.dnetlib.openaire.dsm.dao.ResponseUtils;
import eu.dnetlib.openaire.exporter.exceptions.DsmException; import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV2; import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV2;
import eu.dnetlib.openaire.exporter.model.dsm.SimpleDatasourceInfo; import eu.dnetlib.openaire.exporter.model.dsm.SimpleDatasourceInfo;
import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse; import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse;
@ -95,7 +95,7 @@ public class DsmApiControllerV2 extends AbstractExporterController {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error") @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public AggregationHistoryResponseV2 aggregationHistory(@PathVariable final String dsId) throws DsmException { public AggregationHistoryResponseV2 aggregationHistory(@PathVariable final String dsId) throws DsmApiException {
final StopWatch stop = StopWatch.createStarted(); final StopWatch stop = StopWatch.createStarted();
final AggregationHistoryResponseV2 rsp = dsmCore.aggregationhistoryV2(dsId); final AggregationHistoryResponseV2 rsp = dsmCore.aggregationhistoryV2(dsId);
return prepareResponse(0, rsp.getAggregationInfo().size(), stop, rsp); return prepareResponse(0, rsp.getAggregationInfo().size(), stop, rsp);

View File

@ -9,6 +9,7 @@ import java.nio.charset.Charset;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -29,37 +30,42 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.google.common.collect.Lists;
import eu.dnetlib.enabling.datasources.common.DsmException;
import eu.dnetlib.enabling.datasources.common.DsmForbiddenException;
import eu.dnetlib.enabling.datasources.common.DsmNotFoundException;
import eu.dnetlib.openaire.common.ISClient; import eu.dnetlib.openaire.common.ISClient;
import eu.dnetlib.openaire.community.CommunityClient; import eu.dnetlib.openaire.community.CommunityClient;
import eu.dnetlib.openaire.dsm.dao.CountryTermRepository;
import eu.dnetlib.openaire.dsm.dao.DatasourceDao; import eu.dnetlib.openaire.dsm.dao.DatasourceDao;
import eu.dnetlib.openaire.dsm.dao.MongoLoggerClient; import eu.dnetlib.openaire.dsm.dao.MongoLoggerClient;
import eu.dnetlib.openaire.dsm.dao.ResponseUtils; import eu.dnetlib.openaire.dsm.dao.ResponseUtils;
import eu.dnetlib.openaire.dsm.dao.VocabularyClient; import eu.dnetlib.openaire.dsm.dao.VocabularyClient;
import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils; import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils;
import eu.dnetlib.openaire.dsm.domain.DatasourceDetailResponse;
import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsUpdate;
import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsWithApis;
import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetResponse;
import eu.dnetlib.openaire.dsm.domain.RegisteredDatasourceInfo;
import eu.dnetlib.openaire.dsm.domain.RequestSort;
import eu.dnetlib.openaire.dsm.domain.RequestSortOrder;
import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry; import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry;
import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry; import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry;
import eu.dnetlib.openaire.dsm.domain.db.IdentityDbEntry; import eu.dnetlib.openaire.dsm.domain.db.IdentityDbEntry;
import eu.dnetlib.openaire.exporter.exceptions.DsmException; import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
import eu.dnetlib.openaire.exporter.exceptions.DsmForbiddenException;
import eu.dnetlib.openaire.exporter.exceptions.DsmNotFoundException;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV1; import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV1;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV2; import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV2;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo; import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfoV1; import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfoV1;
import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails; import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails;
import eu.dnetlib.openaire.exporter.model.dsm.ApiDetailsResponse; import eu.dnetlib.openaire.exporter.model.dsm.ApiDetailsResponse;
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetailResponse;
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails;
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetailsUpdate;
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetailsWithApis;
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceSnippetResponse;
import eu.dnetlib.openaire.exporter.model.dsm.RegisteredDatasourceInfo;
import eu.dnetlib.openaire.exporter.model.dsm.RequestFilter; import eu.dnetlib.openaire.exporter.model.dsm.RequestFilter;
import eu.dnetlib.openaire.exporter.model.dsm.RequestSort;
import eu.dnetlib.openaire.exporter.model.dsm.RequestSortOrder;
import eu.dnetlib.openaire.exporter.model.dsm.SimpleDatasourceInfo; import eu.dnetlib.openaire.exporter.model.dsm.SimpleDatasourceInfo;
import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse; import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse;
import eu.dnetlib.openaire.exporter.model.vocabularies.Country; import eu.dnetlib.openaire.exporter.model.vocabularies.Country;
import eu.dnetlib.openaire.exporter.model.vocabularies.Vocabulary;
@Component @Component
@ConditionalOnProperty(value = "openaire.exporter.enable.dsm", havingValue = "true") @ConditionalOnProperty(value = "openaire.exporter.enable.dsm", havingValue = "true")
@ -79,19 +85,24 @@ public class DsmCore {
@Autowired @Autowired
private DatasourceDao<DatasourceDbEntry, ApiDbEntry> dsDao; private DatasourceDao<DatasourceDbEntry, ApiDbEntry> dsDao;
@Autowired
private CountryTermRepository countryTermRepository;
@Autowired @Autowired
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
@Autowired @Autowired
private CommunityClient communityClient; private CommunityClient communityClient;
public List<Country> listCountries() throws DsmException { public List<Country> listCountries() throws DsmApiException {
try { final List<Country> countries = Lists.newArrayList();
return dsDao.listCountries(); final Vocabulary v = vocabularyClient.getCountries();
} catch (final Throwable e) { countries.addAll(countryTermRepository.findAll()
log.error("error listing countries", e); .stream()
throw e; .filter(Objects::nonNull)
} .map(t -> new Country(t.getTerm(), v.getEnglishName(t.getTerm())))
.collect(Collectors.toList()));
return countries;
} }
public DatasourceDetailResponse searchDsDetails(final RequestSort requestSortBy, public DatasourceDetailResponse searchDsDetails(final RequestSort requestSortBy,
@ -99,14 +110,14 @@ public class DsmCore {
final RequestFilter requestFilter, final RequestFilter requestFilter,
final int page, final int page,
final int size) final int size)
throws DsmException { throws DsmApiException {
try { try {
final Page<DatasourceDbEntry> dsPage = dsDao.search(requestSortBy, order, requestFilter, page, size); final Page<DatasourceDbEntry> dsPage = dsDao.search(requestSortBy, order, requestFilter, page, size);
return ResponseUtils.detailsResponse(dsPage.map(d -> asDetails(d)).getContent(), dsPage.getTotalElements()); return ResponseUtils.detailsResponse(dsPage.map(d -> asDetails(d)).getContent(), dsPage.getTotalElements());
} catch (final Throwable e) { } catch (final DsmException e) {
log.error("error searching datasources", e); log.error("error searching datasources", e);
throw e; throw new DsmApiException(e.getCode(), "error searching datasources", e);
} }
} }
@ -115,13 +126,13 @@ public class DsmCore {
final RequestFilter requestFilter, final RequestFilter requestFilter,
final int page, final int page,
final int size) final int size)
throws DsmException { throws DsmApiException {
try { try {
final Page<DatasourceDbEntry> dsPage = dsDao.search(requestSortBy, order, requestFilter, page, size); final Page<DatasourceDbEntry> dsPage = dsDao.search(requestSortBy, order, requestFilter, page, size);
return ResponseUtils.snippetResponse(dsPage.map(DsmMappingUtils::asSnippetExtended).getContent(), dsPage.getTotalElements()); return ResponseUtils.snippetResponse(dsPage.map(DsmMappingUtils::asSnippetExtended).getContent(), dsPage.getTotalElements());
} catch (final Throwable e) { } catch (final DsmException e) {
log.error("error searching datasources", e); log.error("error searching datasources", e);
throw e; throw new DsmApiException(e.getCode(), "error searching datasources", e);
} }
} }
@ -130,26 +141,26 @@ public class DsmCore {
final RequestFilter requestFilter, final RequestFilter requestFilter,
final int page, final int page,
final int size) final int size)
throws DsmException { throws DsmApiException {
try { try {
final Page<DatasourceDbEntry> dsPage = dsDao.searchRegistered(requestSortBy, order, requestFilter, page, size); final Page<DatasourceDbEntry> dsPage = dsDao.searchRegistered(requestSortBy, order, requestFilter, page, size);
return ResponseUtils.snippetResponse(dsPage.map(DsmMappingUtils::asSnippetExtended).getContent(), dsPage.getTotalElements()); return ResponseUtils.snippetResponse(dsPage.map(DsmMappingUtils::asSnippetExtended).getContent(), dsPage.getTotalElements());
} catch (final Throwable e) { } catch (final DsmException e) {
log.error("error searching datasources", e); log.error("error searching datasources", e);
throw e; throw new DsmApiException(e.getCode(), "error searching datasources", e);
} }
} }
public List<String> findBaseURLs(final RequestFilter requestFilter, final int page, final int size) throws DsmException { public List<String> findBaseURLs(final RequestFilter requestFilter, final int page, final int size) throws DsmApiException {
try { try {
return dsDao.findApiBaseURLs(requestFilter, page, size); return dsDao.findApiBaseURLs(requestFilter, page, size);
} catch (final Throwable e) { } catch (final DsmException e) {
log.error("error searching datasource base urls", e); log.error("error searching datasource base urls", e);
throw e; throw new DsmApiException(e.getCode(), "error searching datasource base urls", e);
} }
} }
public ApiDetailsResponse getApis(final String dsId) throws DsmException { public ApiDetailsResponse getApis(final String dsId) throws DsmApiException {
try { try {
final DatasourceDbEntry ds = dsDao.getDs(dsId); final DatasourceDbEntry ds = dsDao.getDs(dsId);
final List<? extends ApiDbEntry> apis = dsDao.getApis(dsId); final List<? extends ApiDbEntry> apis = dsDao.getApis(dsId);
@ -159,37 +170,49 @@ public class DsmCore {
.map(a -> a.setTypology(ds.getTypology())) .map(a -> a.setTypology(ds.getTypology()))
.collect(Collectors.toList()); .collect(Collectors.toList());
return ResponseUtils.apiResponse(api, api.size()); return ResponseUtils.apiResponse(api, api.size());
} catch (final Throwable e) { } catch (final DsmException e) {
log.error(String.format("error searching datasource api %s", dsId), e); log.error(String.format("error searching datasource api %s", dsId), e);
throw e; throw new DsmApiException(e.getCode(), String.format("error searching datasource api %s", dsId), e);
} }
} }
public void setManaged(final String dsId, final boolean managed) throws DsmException { public void setManaged(final String dsId, final boolean managed) throws DsmApiException {
log.info(String.format("updated ds '%s' managed with '%s'", dsId, managed)); log.info(String.format("updated ds '%s' managed with '%s'", dsId, managed));
try {
dsDao.setManaged(dsId, managed); dsDao.setManaged(dsId, managed);
} catch (final DsmException e) {
throw new DsmApiException(e.getCode(), e.getMessage(), e);
}
} }
public boolean isManaged(final String dsId) throws DsmException { public boolean isManaged(final String dsId) throws DsmApiException {
try {
return dsDao.isManaged(dsId); return dsDao.isManaged(dsId);
} catch (final DsmException e) {
throw new DsmApiException(e.getCode(), e.getMessage(), e);
}
} }
public boolean exist(final DatasourceDetails d) throws DsmException { public boolean exist(final DatasourceDetails d) throws DsmApiException {
try {
return dsDao.existDs(d.getId()); return dsDao.existDs(d.getId());
} catch (final DsmException e) {
throw new DsmApiException(e.getCode(), e.getMessage(), e);
}
} }
public void save(final DatasourceDetails d) throws DsmException { public void save(final DatasourceDetails d) throws DsmApiException {
try { try {
dsDao.saveDs(asDbEntry(d)); dsDao.saveDs(asDbEntry(d));
log.info("DS saved, " + d.getId()); log.info("DS saved, " + d.getId());
} catch (final Throwable e) { } catch (final DsmException e) {
log.error(ExceptionUtils.getStackTrace(e)); log.error(ExceptionUtils.getStackTrace(e));
throw e; throw new DsmApiException(e.getCode(), e.getMessage(), e);
} }
} }
@Transactional @Transactional
public void save(final DatasourceDetailsWithApis d) throws DsmException { public void save(final DatasourceDetailsWithApis d) throws DsmApiException {
try { try {
dsDao.saveDs(asDbEntry(d.getDatasource())); dsDao.saveDs(asDbEntry(d.getDatasource()));
final List<ApiDetails> apis = d.getApis(); final List<ApiDetails> apis = d.getApis();
@ -199,15 +222,13 @@ public class DsmCore {
addApi(api); addApi(api);
} }
} }
} catch ( } catch (final DsmException e) {
final Throwable e) {
log.error(ExceptionUtils.getStackTrace(e)); log.error(ExceptionUtils.getStackTrace(e));
throw e; throw new DsmApiException(e.getCode(), e.getMessage(), e);
} }
} }
public void updateDatasource(final DatasourceDetailsUpdate d) throws DsmException, DsmNotFoundException { public void updateDatasource(final DatasourceDetailsUpdate d) throws DsmApiException {
try { try {
// initialize with current values from DB // initialize with current values from DB
final DatasourceDbEntry ds = dsDao.getDs(d.getId()); final DatasourceDbEntry ds = dsDao.getDs(d.getId());
@ -228,46 +249,72 @@ public class DsmCore {
} }
dsDao.saveDs(ds); dsDao.saveDs(ds);
} catch (final Throwable e) { } catch (final DsmException e) {
log.error(ExceptionUtils.getStackTrace(e)); log.error(ExceptionUtils.getStackTrace(e));
throw e; throw new DsmApiException(e.getCode(), e.getMessage(), e);
} }
} }
// TODO remove if unused // TODO remove if unused
public void deleteDs(final String dsId) throws DsmException { public void deleteDs(final String dsId) throws DsmApiException {
log.info(String.format("deleted datasource '%s'", dsId)); log.info(String.format("deleted datasource '%s'", dsId));
try {
dsDao.deleteDs(dsId); dsDao.deleteDs(dsId);
} catch (final DsmException e) {
throw new DsmApiException(e.getCode(), e.getMessage(), e);
}
} }
// API // API
public void updateApiOaiSet(final String dsId, final String apiId, final String oaiSet) throws DsmException { public void updateApiOaiSet(final String dsId, final String apiId, final String oaiSet) throws DsmApiException {
try {
dsDao.upsertApiOaiSet(apiId, oaiSet); dsDao.upsertApiOaiSet(apiId, oaiSet);
} catch (final DsmException e) {
throw new DsmApiException(e.getCode(), e.getMessage(), e);
}
} }
public void updateApiBaseurl(final String dsId, final String apiId, final String baseUrl) throws DsmException { public void updateApiBaseurl(final String dsId, final String apiId, final String baseUrl) throws DsmApiException {
log.info(String.format("updated api '%s' baseurl with '%s'", apiId, baseUrl)); log.info(String.format("updated api '%s' baseurl with '%s'", apiId, baseUrl));
try {
dsDao.updateApiBaseUrl(apiId, baseUrl); dsDao.updateApiBaseUrl(apiId, baseUrl);
} catch (final DsmException e) {
throw new DsmApiException(e.getCode(), e.getMessage(), e);
}
} }
public void updateApiCompatibility(final String dsId, final String apiId, final String compliance, final boolean override) throws DsmException { public void updateApiCompatibility(final String dsId, final String apiId, final String compliance, final boolean override) throws DsmApiException {
log.info(String.format("updated api '%s' compliance with '%s'", apiId, compliance)); log.info(String.format("updated api '%s' compliance with '%s'", apiId, compliance));
try {
dsDao.updateCompliance(null, apiId, compliance, override); dsDao.updateCompliance(null, apiId, compliance, override);
} catch (final DsmException e) {
throw new DsmApiException(e.getCode(), e.getMessage(), e);
}
} }
public void addApi(final ApiDetails api) throws DsmException { public void addApi(final ApiDetails api) throws DsmApiException {
if (StringUtils.isBlank(api.getId())) { if (StringUtils.isBlank(api.getId())) {
api.setId(createId(api)); api.setId(createId(api));
log.info(String.format("missing api id, created '%s'", api.getId())); log.info(String.format("missing api id, created '%s'", api.getId()));
} }
try {
dsDao.addApi(asDbEntry(api)); dsDao.addApi(asDbEntry(api));
log.info("API saved, id: " + api.getId()); log.info("API saved, id: " + api.getId());
} catch (final DsmException e) {
throw new DsmApiException(e.getCode(), e.getMessage(), e);
}
} }
public void deleteApi(final String apiId) throws DsmForbiddenException, DsmNotFoundException { public void deleteApi(final String apiId) throws DsmApiException {
// TODO handle the api removal in case of associated workflows. // TODO handle the api removal in case of associated workflows.
try {
dsDao.deleteApi(null, apiId); dsDao.deleteApi(null, apiId);
} catch (final DsmForbiddenException e) {
throw new DsmApiException(e.getCode(), e.getMessage(), e);
} catch (final DsmNotFoundException e) {
throw new DsmApiException(e.getCode(), e.getMessage(), e);
}
} }
public void dropCaches() { public void dropCaches() {
@ -316,14 +363,14 @@ public class DsmCore {
} }
@Deprecated @Deprecated
public AggregationHistoryResponseV1 aggregationhistoryV1(final String dsId) throws DsmException { public AggregationHistoryResponseV1 aggregationhistoryV1(final String dsId) throws DsmApiException {
final List<AggregationInfoV1> history = mongoLoggerClient.getAggregationHistoryV1(dsId); final List<AggregationInfoV1> history = mongoLoggerClient.getAggregationHistoryV1(dsId);
final AggregationHistoryResponseV1 rsp = new AggregationHistoryResponseV1(history); final AggregationHistoryResponseV1 rsp = new AggregationHistoryResponseV1(history);
rsp.setHeader(ResponseUtils.header(history.size())); rsp.setHeader(ResponseUtils.header(history.size()));
return rsp; return rsp;
} }
public AggregationHistoryResponseV2 aggregationhistoryV2(final String dsId) throws DsmException { public AggregationHistoryResponseV2 aggregationhistoryV2(final String dsId) throws DsmApiException {
final List<AggregationInfo> history = mongoLoggerClient.getAggregationHistoryV2(dsId); final List<AggregationInfo> history = mongoLoggerClient.getAggregationHistoryV2(dsId);
final AggregationHistoryResponseV2 rsp = new AggregationHistoryResponseV2(history); final AggregationHistoryResponseV2 rsp = new AggregationHistoryResponseV2(history);
rsp.setHeader(ResponseUtils.header(history.size())); rsp.setHeader(ResponseUtils.header(history.size()));

View File

@ -5,18 +5,17 @@ import java.util.List;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import eu.dnetlib.enabling.datasources.common.Api; import eu.dnetlib.enabling.datasources.common.Api;
import eu.dnetlib.openaire.dsm.domain.RequestSort; import eu.dnetlib.enabling.datasources.common.Datasource;
import eu.dnetlib.openaire.dsm.domain.RequestSortOrder; import eu.dnetlib.enabling.datasources.common.DatasourceManagerCommon;
import eu.dnetlib.openaire.exporter.exceptions.DsmException; import eu.dnetlib.enabling.datasources.common.DsmException;
import eu.dnetlib.openaire.exporter.model.dsm.RequestFilter; import eu.dnetlib.openaire.exporter.model.dsm.RequestFilter;
import eu.dnetlib.openaire.exporter.model.vocabularies.Country; import eu.dnetlib.openaire.exporter.model.dsm.RequestSort;
import eu.dnetlib.openaire.exporter.model.dsm.RequestSortOrder;
public interface DatasourceDao<DS extends Datasource<?, ?, ?>, API extends Api<?>> extends DatasourceManagerCommon<DS, API> { public interface DatasourceDao<DS extends Datasource<?, ?, ?>, API extends Api<?>> extends DatasourceManagerCommon<DS, API> {
// DATASOURCE // DATASOURCE
List<Country> listCountries() throws DsmException;
boolean existDs(final String dsId) throws DsmException; boolean existDs(final String dsId) throws DsmException;
Page<DS> search(RequestSort requestSortBy, RequestSortOrder order, RequestFilter requestFilter, int page, int size) throws DsmException; Page<DS> search(RequestSort requestSortBy, RequestSortOrder order, RequestFilter requestFilter, int page, int size) throws DsmException;
@ -53,6 +52,4 @@ public interface DatasourceDao<DS extends Datasource<?, ?, ?>, API extends Api<?
void updateApiBaseUrl(String apiId, String baseUrl) throws DsmException; void updateApiBaseUrl(String apiId, String baseUrl) throws DsmException;
@Override
void addApi(final API api) throws DsmException;
} }

View File

@ -9,7 +9,6 @@ import static eu.dnetlib.openaire.dsm.dao.DatasourceSpecs.dsSpec;
import java.sql.Date; import java.sql.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -30,18 +29,16 @@ import org.springframework.transaction.annotation.Transactional;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import eu.dnetlib.DnetOpenaireExporterProperties; import eu.dnetlib.DnetOpenaireExporterProperties;
import eu.dnetlib.openaire.dsm.domain.RequestSort; import eu.dnetlib.enabling.datasources.common.DsmException;
import eu.dnetlib.openaire.dsm.domain.RequestSortOrder; import eu.dnetlib.enabling.datasources.common.DsmForbiddenException;
import eu.dnetlib.enabling.datasources.common.DsmNotFoundException;
import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry; import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry;
import eu.dnetlib.openaire.dsm.domain.db.ApiParamDbEntry; import eu.dnetlib.openaire.dsm.domain.db.ApiParamDbEntry;
import eu.dnetlib.openaire.dsm.domain.db.DatasourceApiDbEntry; import eu.dnetlib.openaire.dsm.domain.db.DatasourceApiDbEntry;
import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry; import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry;
import eu.dnetlib.openaire.exporter.exceptions.DsmException;
import eu.dnetlib.openaire.exporter.exceptions.DsmForbiddenException;
import eu.dnetlib.openaire.exporter.exceptions.DsmNotFoundException;
import eu.dnetlib.openaire.exporter.model.dsm.RequestFilter; import eu.dnetlib.openaire.exporter.model.dsm.RequestFilter;
import eu.dnetlib.openaire.exporter.model.vocabularies.Country; import eu.dnetlib.openaire.exporter.model.dsm.RequestSort;
import eu.dnetlib.openaire.exporter.model.vocabularies.Vocabulary; import eu.dnetlib.openaire.exporter.model.dsm.RequestSortOrder;
/** /**
* Created by claudio on 20/10/2016. * Created by claudio on 20/10/2016.
@ -55,9 +52,6 @@ public class DatasourceDaoImpl implements DatasourceDao<DatasourceDbEntry, ApiDb
@Autowired @Autowired
private DnetOpenaireExporterProperties config; private DnetOpenaireExporterProperties config;
@Autowired
private CountryTermRepository countryTermRepository;
@Autowired @Autowired
private DatasourceDbEntryRepository dsRepository; private DatasourceDbEntryRepository dsRepository;
@ -67,20 +61,8 @@ public class DatasourceDaoImpl implements DatasourceDao<DatasourceDbEntry, ApiDb
@Autowired @Autowired
private DatasourceApiDbEntryRepository dsApiRepository; private DatasourceApiDbEntryRepository dsApiRepository;
@Autowired // @Autowired
private VocabularyClient vocabularyClient; // private VocabularyClient vocabularyClient;
@Override
public List<Country> listCountries() throws DsmException {
final List<Country> countries = Lists.newArrayList();
final Vocabulary v = vocabularyClient.getCountries();
countries.addAll(countryTermRepository.findAll()
.stream()
.filter(Objects::nonNull)
.map(t -> new Country(t.getTerm(), v.getEnglishName(t.getTerm())))
.collect(Collectors.toList()));
return countries;
}
@Override @Override
public Page<DatasourceDbEntry> search(final RequestSort requestSortBy, public Page<DatasourceDbEntry> search(final RequestSort requestSortBy,
@ -239,13 +221,11 @@ public class DatasourceDaoImpl implements DatasourceDao<DatasourceDbEntry, ApiDb
@Override @Override
public void updateEoscDatasourceType(final String dsId, final String type) throws DsmException { public void updateEoscDatasourceType(final String dsId, final String type) throws DsmException {
final Vocabulary typologies = vocabularyClient.getDatasourceTypologies(); /*
if (!typologies.hasCode(type)) { * final Vocabulary typologies = vocabularyClient.getDatasourceTypologies(); if (!typologies.hasCode(type)) { throw new
throw new DsmException( * DsmException( HttpStatus.SC_BAD_REQUEST, String.format("invalid datasource type '%s', provide one according to vocabulary %s",
HttpStatus.SC_BAD_REQUEST, * type, config.getVocabularies() .getDatasourceTypologiesEndpoint())); }
String.format("invalid datasource type '%s', provide one according to vocabulary %s", type, config.getVocabularies() */
.getDatasourceTypologiesEndpoint()));
}
dsRepository.setEoscDatasourceType(dsId, type); dsRepository.setEoscDatasourceType(dsId, type);
} }

View File

@ -4,12 +4,12 @@ import java.util.Queue;
import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo; import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo;
import eu.dnetlib.openaire.dsm.dao.utils.IndexRecordsInfo; import eu.dnetlib.openaire.dsm.dao.utils.IndexRecordsInfo;
import eu.dnetlib.openaire.exporter.exceptions.DsmException; import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
public interface DatasourceIndexClient { public interface DatasourceIndexClient {
IndexRecordsInfo getIndexInfo(final String dsId, final IndexDsInfo info, final Queue<Throwable> errors) throws DsmException; IndexRecordsInfo getIndexInfo(final String dsId, final IndexDsInfo info, final Queue<Throwable> errors) throws DsmApiException;
String getLastIndexingDate(final IndexDsInfo info) throws DsmException; String getLastIndexingDate(final IndexDsInfo info) throws DsmApiException;
} }

View File

@ -38,11 +38,12 @@ import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.common.util.concurrent.ThreadFactoryBuilder;
import eu.dnetlib.DnetOpenaireExporterProperties; import eu.dnetlib.DnetOpenaireExporterProperties;
import eu.dnetlib.enabling.datasources.common.DsmException;
import eu.dnetlib.miscutils.functional.hash.Hashing; import eu.dnetlib.miscutils.functional.hash.Hashing;
import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils; import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils;
import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo; import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo;
import eu.dnetlib.openaire.dsm.dao.utils.IndexRecordsInfo; import eu.dnetlib.openaire.dsm.dao.utils.IndexRecordsInfo;
import eu.dnetlib.openaire.exporter.exceptions.DsmException; import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
/** /**
* Created by claudio on 20/10/2016. * Created by claudio on 20/10/2016.
@ -81,7 +82,7 @@ public class DatasourceIndexClientImpl implements DatasourceIndexClient {
} }
@Override @Override
public IndexRecordsInfo getIndexInfo(final String dsId, final IndexDsInfo info, final Queue<Throwable> errors) throws DsmException { public IndexRecordsInfo getIndexInfo(final String dsId, final IndexDsInfo info, final Queue<Throwable> errors) throws DsmApiException {
try { try {
final String collectedFrom = StringUtils.substringBefore(dsId, SEPARATOR) + SEPARATOR + Hashing.md5(StringUtils.substringAfter(dsId, SEPARATOR)); final String collectedFrom = StringUtils.substringBefore(dsId, SEPARATOR) + SEPARATOR + Hashing.md5(StringUtils.substringAfter(dsId, SEPARATOR));
final CloudSolrClient indexClient = getIndexClient(info); final CloudSolrClient indexClient = getIndexClient(info);
@ -123,12 +124,12 @@ public class DatasourceIndexClientImpl implements DatasourceIndexClient {
waitLatch(latch, errors, config.getRequestTimeout()); waitLatch(latch, errors, config.getRequestTimeout());
return indexRecordInfo; return indexRecordInfo;
} catch (final Throwable e) { } catch (final Throwable e) {
throw new DsmException(HttpStatus.INTERNAL_SERVER_ERROR.value(), String.format("error reading index info", dsId), e); throw new DsmApiException(HttpStatus.INTERNAL_SERVER_ERROR.value(), String.format("error reading index info", dsId), e);
} }
} }
@Override @Override
public String getLastIndexingDate(final IndexDsInfo info) throws DsmException { public String getLastIndexingDate(final IndexDsInfo info) throws DsmApiException {
try { try {
final SolrQuery query = new SolrQuery("oaftype:datasource").setRows(1); final SolrQuery query = new SolrQuery("oaftype:datasource").setRows(1);
final QueryResponse rsp = getIndexClient(info).query(query); final QueryResponse rsp = getIndexClient(info).query(query);
@ -136,7 +137,7 @@ public class DatasourceIndexClientImpl implements DatasourceIndexClient {
final String dsversion = doc.get("__dsversion").toString(); final String dsversion = doc.get("__dsversion").toString();
return StringUtils.substringBefore(dsversion, "T"); return StringUtils.substringBefore(dsversion, "T");
} catch (SolrServerException | IOException e) { } catch (SolrServerException | IOException e) {
throw new DsmException(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Error querying index DS profile: " + info, e); throw new DsmApiException(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Error querying index DS profile: " + info, e);
} }
} }

View File

@ -16,13 +16,13 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import eu.dnetlib.openaire.dsm.domain.RequestSort; import eu.dnetlib.enabling.datasources.common.DsmRuntimeException;
import eu.dnetlib.openaire.dsm.domain.RequestSortOrder;
import eu.dnetlib.openaire.dsm.domain.db.DatasourceApiDbEntry; import eu.dnetlib.openaire.dsm.domain.db.DatasourceApiDbEntry;
import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry; import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry;
import eu.dnetlib.openaire.exporter.exceptions.DsmRuntimeException;
import eu.dnetlib.openaire.exporter.model.dsm.FilterName; import eu.dnetlib.openaire.exporter.model.dsm.FilterName;
import eu.dnetlib.openaire.exporter.model.dsm.RequestFilter; import eu.dnetlib.openaire.exporter.model.dsm.RequestFilter;
import eu.dnetlib.openaire.exporter.model.dsm.RequestSort;
import eu.dnetlib.openaire.exporter.model.dsm.RequestSortOrder;
public class DatasourceSpecs { public class DatasourceSpecs {

View File

@ -2,14 +2,15 @@ package eu.dnetlib.openaire.dsm.dao;
import java.util.List; import java.util.List;
import eu.dnetlib.openaire.exporter.exceptions.DsmException; import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfoV1; import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfoV1;
public interface MongoLoggerClient { public interface MongoLoggerClient {
List<AggregationInfoV1> getAggregationHistoryV1(final String dsId) throws DsmException; List<AggregationInfoV1> getAggregationHistoryV1(final String dsId) throws DsmApiException;
List<AggregationInfo> getAggregationHistoryV2(final String dsId) throws DsmException; List<AggregationInfo> getAggregationHistoryV2(final String dsId) throws DsmApiException;
void dropCache(); void dropCache();

View File

@ -41,13 +41,13 @@ import com.mongodb.client.MongoCollection;
import eu.dnetlib.DnetOpenaireExporterProperties; import eu.dnetlib.DnetOpenaireExporterProperties;
import eu.dnetlib.DnetOpenaireExporterProperties.Datasource; import eu.dnetlib.DnetOpenaireExporterProperties.Datasource;
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
import eu.dnetlib.enabling.datasources.common.AggregationStage;
import eu.dnetlib.miscutils.datetime.DateUtils; import eu.dnetlib.miscutils.datetime.DateUtils;
import eu.dnetlib.openaire.common.Utils; import eu.dnetlib.openaire.common.Utils;
import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils; import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils;
import eu.dnetlib.openaire.exporter.exceptions.DsmException; import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfoV1; import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfoV1;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationStage;
import eu.dnetlib.openaire.exporter.model.dsm.CollectionInfoV1; import eu.dnetlib.openaire.exporter.model.dsm.CollectionInfoV1;
import eu.dnetlib.openaire.exporter.model.dsm.CollectionInfoV2; import eu.dnetlib.openaire.exporter.model.dsm.CollectionInfoV2;
import eu.dnetlib.openaire.exporter.model.dsm.CollectionMode; import eu.dnetlib.openaire.exporter.model.dsm.CollectionMode;
@ -93,19 +93,19 @@ public class MongoLoggerClientImpl implements MongoLoggerClient {
@Override @Override
@Cacheable("dsm-aggregationhistory-cache-v1") @Cacheable("dsm-aggregationhistory-cache-v1")
@Deprecated @Deprecated
public List<AggregationInfoV1> getAggregationHistoryV1(final String dsId) throws DsmException { public List<AggregationInfoV1> getAggregationHistoryV1(final String dsId) throws DsmApiException {
return getAggregationHistory(dsId, queryForAggregationHistoryV1(dsId, "(collect|transform)"), getMapperV1()); return getAggregationHistory(dsId, queryForAggregationHistoryV1(dsId, "(collect|transform)"), getMapperV1());
} }
@Override @Override
@Cacheable("dsm-aggregationhistory-cache-v2") @Cacheable("dsm-aggregationhistory-cache-v2")
public List<AggregationInfo> getAggregationHistoryV2(final String dsId) throws DsmException { public List<AggregationInfo> getAggregationHistoryV2(final String dsId) throws DsmApiException {
return getAggregationHistory(dsId, queryForAggregationHistoryV2(dsId, "(collect|transform)"), getMapperV2()); return getAggregationHistory(dsId, queryForAggregationHistoryV2(dsId, "(collect|transform)"), getMapperV2());
} }
private <T extends AggregationInfo> List<T> getAggregationHistory(final String dsId, private <T extends AggregationInfo> List<T> getAggregationHistory(final String dsId,
final Bson queryForAggregationHistory, final Bson queryForAggregationHistory,
final Function<Document, T> mapper) throws DsmException { final Function<Document, T> mapper) throws DsmApiException {
log.warn(String.format("getAggregationHistory(dsId = %s): not using cache", dsId)); log.warn(String.format("getAggregationHistory(dsId = %s): not using cache", dsId));
final Datasource conf = config.getDatasource(); final Datasource conf = config.getDatasource();
try { try {
@ -132,7 +132,7 @@ public class MongoLoggerClientImpl implements MongoLoggerClient {
return aggregationInfos; return aggregationInfos;
} catch (final Throwable e) { } catch (final Throwable e) {
throw new DsmException(HttpStatus.SC_INTERNAL_SERVER_ERROR, String.format("error reading aggregation history for '%s'", dsId), e); throw new DsmApiException(HttpStatus.SC_INTERNAL_SERVER_ERROR, String.format("error reading aggregation history for '%s'", dsId), e);
} }
} }

View File

@ -1,9 +1,9 @@
package eu.dnetlib.openaire.dsm.dao; package eu.dnetlib.openaire.dsm.dao;
import eu.dnetlib.openaire.exporter.exceptions.DsmException; import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
public interface ObjectStoreClient { public interface ObjectStoreClient {
Long getObjectStoreSize(final String objectStoreId) throws DsmException; Long getObjectStoreSize(final String objectStoreId) throws DsmApiException;
} }

View File

@ -9,7 +9,7 @@ import org.springframework.stereotype.Component;
import eu.dnetlib.data.objectstore.rmi.ObjectStoreService; import eu.dnetlib.data.objectstore.rmi.ObjectStoreService;
import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException; import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
import eu.dnetlib.openaire.exporter.exceptions.DsmException; import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
@Component @Component
@ConditionalOnProperty(value = "openaire.exporter.enable.dsm", havingValue = "true") @ConditionalOnProperty(value = "openaire.exporter.enable.dsm", havingValue = "true")
@ -21,7 +21,7 @@ public class ObjectStoreClientImpl implements ObjectStoreClient {
private ObjectStoreService objectStoreService; private ObjectStoreService objectStoreService;
@Override @Override
public Long getObjectStoreSize(final String objectStoreId) throws DsmException { public Long getObjectStoreSize(final String objectStoreId) throws DsmApiException {
log.debug("get size for objectStore " + objectStoreId); log.debug("get size for objectStore " + objectStoreId);
if (StringUtils.isBlank(objectStoreId)) { return 0L; } if (StringUtils.isBlank(objectStoreId)) { return 0L; }
try { try {
@ -29,7 +29,7 @@ public class ObjectStoreClientImpl implements ObjectStoreClient {
log.debug("got objectStore size: " + size); log.debug("got objectStore size: " + size);
return size; return size;
} catch (final ObjectStoreServiceException e) { } catch (final ObjectStoreServiceException e) {
throw new DsmException("unable to get size for objectStore " + objectStoreId); throw new DsmApiException("unable to get size for objectStore " + objectStoreId);
} }
} }

View File

@ -5,14 +5,14 @@ import java.util.Queue;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import eu.dnetlib.openaire.dsm.domain.DatasourceDetailResponse;
import eu.dnetlib.openaire.dsm.domain.DatasourceSearchResponse; import eu.dnetlib.openaire.dsm.domain.DatasourceSearchResponse;
import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetExtended;
import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetResponse;
import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails; import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails;
import eu.dnetlib.openaire.exporter.model.dsm.ApiDetailsResponse; import eu.dnetlib.openaire.exporter.model.dsm.ApiDetailsResponse;
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetailResponse;
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails;
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceInfo; import eu.dnetlib.openaire.exporter.model.dsm.DatasourceInfo;
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceSnippetExtended;
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceSnippetResponse;
import eu.dnetlib.openaire.exporter.model.dsm.Header; import eu.dnetlib.openaire.exporter.model.dsm.Header;
import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse; import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse;

View File

@ -1,12 +1,13 @@
package eu.dnetlib.openaire.dsm.dao; package eu.dnetlib.openaire.dsm.dao;
import eu.dnetlib.openaire.exporter.exceptions.DsmException; import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
import eu.dnetlib.openaire.exporter.model.vocabularies.Vocabulary;
public interface VocabularyClient { public interface VocabularyClient {
Vocabulary getCountries() throws DsmException; Vocabulary getCountries() throws DsmApiException;
Vocabulary getDatasourceTypologies() throws DsmException; Vocabulary getDatasourceTypologies() throws DsmApiException;
void dropCache(); void dropCache();

View File

@ -1,9 +1,5 @@
package eu.dnetlib.openaire.dsm.dao; package eu.dnetlib.openaire.dsm.dao;
import eu.dnetlib.DnetOpenaireExporterProperties;
import eu.dnetlib.enabling.datasources.common.DsmException;
import eu.dnetlib.openaire.exporter.model.vocabularies.Vocabulary;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -14,6 +10,10 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import eu.dnetlib.DnetOpenaireExporterProperties;
import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
import eu.dnetlib.openaire.exporter.model.vocabularies.Vocabulary;
/** /**
* Created by claudio on 15/09/2017. * Created by claudio on 15/09/2017.
*/ */
@ -27,24 +27,22 @@ public class VocabularyClientImpl implements VocabularyClient {
@Override @Override
@Cacheable("vocabularies-cache") @Cacheable("vocabularies-cache")
public Vocabulary getCountries() throws DsmException { public Vocabulary getCountries() throws DsmApiException {
return _getVocabulary(config.getVocabularies().getCountriesEndpoint(), Vocabulary.class); return _getVocabulary(config.getVocabularies().getCountriesEndpoint(), Vocabulary.class);
} }
@Override @Override
@Cacheable("vocabularies-cache") @Cacheable("vocabularies-cache")
public Vocabulary getDatasourceTypologies() throws DsmException { public Vocabulary getDatasourceTypologies() throws DsmApiException {
return _getVocabulary(config.getVocabularies().getDatasourceTypologiesEndpoint(), Vocabulary.class); return _getVocabulary(config.getVocabularies().getDatasourceTypologiesEndpoint(), Vocabulary.class);
} }
private <T> T _getVocabulary(final String endpoint, Class<T> clazz) throws DsmException { private <T> T _getVocabulary(final String endpoint, final Class<T> clazz) throws DsmApiException {
final RestTemplate rt = new RestTemplate(); final RestTemplate rt = new RestTemplate();
log.info("get vocabulary from " + endpoint); log.info("get vocabulary from " + endpoint);
final ResponseEntity<T> rsp = rt.getForEntity(endpoint, clazz); final ResponseEntity<T> rsp = rt.getForEntity(endpoint, clazz);
if (!rsp.getStatusCode().is2xxSuccessful()) { if (!rsp.getStatusCode().is2xxSuccessful()) { throw new DsmApiException(rsp.getStatusCodeValue(), "unable to read content from " + endpoint); }
throw new DsmException(rsp.getStatusCodeValue(), "unable to read content from " + endpoint);
}
return rsp.getBody(); return rsp.getBody();
} }

View File

@ -14,13 +14,13 @@ import org.springframework.beans.BeanWrapperImpl;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import eu.dnetlib.data.transform.xml.AbstractDNetXsltFunctions; import eu.dnetlib.data.transform.xml.AbstractDNetXsltFunctions;
import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsUpdate;
import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetExtended;
import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry; import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry;
import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry; import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry;
import eu.dnetlib.openaire.dsm.domain.db.OrganizationDbEntry; import eu.dnetlib.openaire.dsm.domain.db.OrganizationDbEntry;
import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails; import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails;
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails; import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails;
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetailsUpdate;
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceSnippetExtended;
import eu.dnetlib.openaire.exporter.model.dsm.OrganizationDetails; import eu.dnetlib.openaire.exporter.model.dsm.OrganizationDetails;
public class DsmMappingUtils { public class DsmMappingUtils {

View File

@ -1,6 +0,0 @@
DsmApiController
DatasourceSnippetResponse
RegisteredDatasourceInfo
DatasourceDetailsWithApis
DatasourceDetailsUpdate

View File

@ -1,27 +1,27 @@
package eu.dnetlib.openaire.exporter.exceptions; package eu.dnetlib.openaire.exporter.exceptions;
public class DsmException extends Exception { public class DsmApiException extends Exception {
private static final long serialVersionUID = -8173126561260106405L; private static final long serialVersionUID = -8173126561260106405L;
private int code; private int code;
public DsmException(final int code, final String msg) { public DsmApiException(final int code, final String msg) {
super(msg); super(msg);
this.code = code; this.code = code;
} }
public DsmException(final int code, final Throwable e) { public DsmApiException(final int code, final Throwable e) {
super(e); super(e);
this.code = code; this.code = code;
} }
public DsmException(final int code, final String msg, final Throwable e) { public DsmApiException(final int code, final String msg, final Throwable e) {
super(msg, e); super(msg, e);
this.code = code; this.code = code;
} }
public DsmException(final String msg) { public DsmApiException(final String msg) {
this(500, msg); this(500, msg);
} }

View File

@ -1,23 +0,0 @@
package eu.dnetlib.openaire.exporter.exceptions;
public class DsmForbiddenException extends DsmException {
private static final long serialVersionUID = -6538032715005339181L;
public DsmForbiddenException(final int code, final String msg) {
super(code, msg);
}
public DsmForbiddenException(final int code, final Throwable e) {
super(code, e);
}
public DsmForbiddenException(final int code, final String msg, final Throwable e) {
super(code, msg, e);
}
public DsmForbiddenException(final String msg) {
this(403, msg);
}
}

View File

@ -1,23 +0,0 @@
package eu.dnetlib.openaire.exporter.exceptions;
public class DsmNotFoundException extends DsmException {
private static final long serialVersionUID = 1327980530652540728L;
public DsmNotFoundException(final int code, final String msg) {
super(code, msg);
}
public DsmNotFoundException(final int code, final Throwable e) {
super(code, e);
}
public DsmNotFoundException(final int code, final String msg, final Throwable e) {
super(code, msg, e);
}
public DsmNotFoundException(final String msg) {
this(404, msg);
}
}

View File

@ -1,23 +0,0 @@
package eu.dnetlib.openaire.exporter.exceptions;
public class DsmRuntimeException extends RuntimeException {
private static final long serialVersionUID = 6755159618210324144L;
public DsmRuntimeException() {
super();
}
public DsmRuntimeException(final String message, final Throwable cause) {
super(message, cause);
}
public DsmRuntimeException(final String message) {
super(message);
}
public DsmRuntimeException(final Throwable cause) {
super(cause);
}
}

View File

@ -1,12 +1,9 @@
package eu.dnetlib.openaire.dsm.domain; package eu.dnetlib.openaire.exporter.model.dsm;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails;
import eu.dnetlib.openaire.exporter.model.dsm.Response;
@JsonAutoDetect @JsonAutoDetect
public class DatasourceDetailResponse extends Response { public class DatasourceDetailResponse extends Response {

View File

@ -1,4 +1,4 @@
package eu.dnetlib.openaire.dsm.domain; package eu.dnetlib.openaire.exporter.model.dsm;
import java.sql.Date; import java.sql.Date;
import java.util.Set; import java.util.Set;
@ -8,7 +8,6 @@ import javax.validation.constraints.NotBlank;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import eu.dnetlib.openaire.exporter.model.dsm.IdentitiesDetails;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
/** /**

View File

@ -1,12 +1,10 @@
package eu.dnetlib.openaire.dsm.domain; package eu.dnetlib.openaire.exporter.model.dsm;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails;
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
/** /**

View File

@ -1,4 +1,4 @@
package eu.dnetlib.openaire.dsm.domain; package eu.dnetlib.openaire.exporter.model.dsm;
import java.util.Date; import java.util.Date;
import java.util.Set; import java.util.Set;
@ -8,7 +8,6 @@ import javax.validation.constraints.NotBlank;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import eu.dnetlib.openaire.exporter.model.dsm.OrganizationDetails;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect @JsonAutoDetect

View File

@ -1,11 +1,9 @@
package eu.dnetlib.openaire.dsm.domain; package eu.dnetlib.openaire.exporter.model.dsm;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import eu.dnetlib.openaire.exporter.model.dsm.Response;
@JsonAutoDetect @JsonAutoDetect
public class DatasourceSnippetResponse extends Response { public class DatasourceSnippetResponse extends Response {

View File

@ -1,4 +1,4 @@
package eu.dnetlib.openaire.dsm.domain; package eu.dnetlib.openaire.exporter.model.dsm;
public class RegisteredDatasourceInfo { public class RegisteredDatasourceInfo {

View File

@ -1,4 +1,4 @@
package eu.dnetlib.openaire.dsm.domain; package eu.dnetlib.openaire.exporter.model.dsm;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.openaire.dsm.domain; package eu.dnetlib.openaire.exporter.model.dsm;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;