Merge pull request 'exporter-model-classes' (#14) from exporter-model-classes into master
Reviewed-on: #14
This commit is contained in:
commit
dfca500b31
|
@ -26,6 +26,11 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-cache</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eu.dnetlib.dhp</groupId>
|
||||
<artifactId>dnet-exporter-model</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>cnr-rmi-api</artifactId>
|
||||
|
@ -125,7 +130,7 @@
|
|||
<artifactId>dnet-datasource-manager-common</artifactId>
|
||||
<version>[2.0.1,3.0.0)</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
|
|
@ -16,10 +16,8 @@ import org.springframework.web.bind.annotation.ResponseStatus;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
|
||||
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.dsm.domain.Response;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.Response;
|
||||
|
||||
/**
|
||||
* Created by claudio on 18/07/2017.
|
||||
|
@ -30,29 +28,13 @@ public abstract class AbstractExporterController {
|
|||
|
||||
@ResponseBody
|
||||
@ExceptionHandler({
|
||||
DsmException.class
|
||||
DsmApiException.class
|
||||
})
|
||||
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
public ErrorMessage handleDSMException(final Exception 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
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
|
|
|
@ -4,15 +4,14 @@ import java.io.IOException;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import eu.dnetlib.enabling.datasources.common.DsmException;
|
||||
import eu.dnetlib.openaire.context.Context;
|
||||
import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo;
|
||||
import eu.dnetlib.openaire.exporter.model.context.Context;
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -32,9 +32,9 @@ 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.ISLookUpService;
|
||||
import eu.dnetlib.openaire.context.Context;
|
||||
import eu.dnetlib.openaire.context.ContextMappingUtils;
|
||||
import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo;
|
||||
import eu.dnetlib.openaire.exporter.model.context.Context;
|
||||
|
||||
/**
|
||||
* Created by claudio on 20/10/2016.
|
||||
|
@ -52,7 +52,7 @@ public class ISClientImpl implements ISClient {
|
|||
|
||||
@Override
|
||||
@Cacheable("indexdsinfo-cache")
|
||||
public IndexDsInfo calculateCurrentIndexDsInfo() throws DsmException {
|
||||
public IndexDsInfo calculateCurrentIndexDsInfo() throws Exception {
|
||||
log.warn("calculateCurrentIndexDsInfo(): not using cache");
|
||||
final String[] arr;
|
||||
try {
|
||||
|
@ -67,7 +67,7 @@ public class ISClientImpl implements ISClient {
|
|||
|
||||
@Override
|
||||
@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));
|
||||
try {
|
||||
final String xqueryTemplate = _getQuery(config.getFindObjectStore());
|
||||
|
@ -105,35 +105,34 @@ public class ISClientImpl implements ISClient {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = {
|
||||
"context-cache", "context-cache-funder"
|
||||
}, allEntries = true)
|
||||
public void updateContextParam(final String id, final String name, final String value, boolean toEscape) {
|
||||
if(getSize(id, name) > 0){
|
||||
public void updateContextParam(final String id, final String name, final String value, final boolean toEscape) {
|
||||
if (getSize(id, name) > 0) {
|
||||
try {
|
||||
_quickSeachProfile(getXQuery(id, name, value, toEscape));
|
||||
} catch (final ISLookUpException e) {
|
||||
throw new DsmRuntimeException(String.format("unable to update context param [id: %s, name: %s, value: %s]", id, name, value), e);
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
try {
|
||||
_quickSeachProfile(getInsertXQuery(id, name, value,toEscape));
|
||||
_quickSeachProfile(getInsertXQuery(id, name, value, toEscape));
|
||||
} catch (final ISLookUpException e) {
|
||||
throw new DsmRuntimeException(String.format("unable to insert context param [id: %s, name: %s, value: %s]", id, name, value), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private int getSize(String id, String name) {
|
||||
private int getSize(final String id, final String name) {
|
||||
int size = 0;
|
||||
try {
|
||||
size = _quickSeachProfile(String.format("for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType') where $x//context[@id='%s']/param[@name='%s'] return $x", id, name)).size();
|
||||
} catch (ISLookUpException e) {
|
||||
size = _quickSeachProfile(String
|
||||
.format("for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType') where $x//context[@id='%s']/param[@name='%s'] return $x", id, name))
|
||||
.size();
|
||||
} catch (final ISLookUpException e) {
|
||||
throw new DsmRuntimeException("unable to execute search query", e);
|
||||
}
|
||||
return size;
|
||||
|
@ -222,26 +221,27 @@ public class ISClientImpl implements ISClient {
|
|||
|
||||
/// HELPERS
|
||||
|
||||
|
||||
private String getInsertXQuery(final String id, final String paramName, final String paramValue, final boolean toEscape) {
|
||||
String value;
|
||||
if(toEscape)
|
||||
if (toEscape) {
|
||||
value = escape(XmlEscapers.xmlContentEscaper(), paramValue);
|
||||
else
|
||||
} else {
|
||||
value = paramValue;
|
||||
}
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
return String.format("update insert <param name='%s'>%s</param> into collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" +
|
||||
"/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']", paramName, value, id);
|
||||
"/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']", paramName, value, id);
|
||||
} else {
|
||||
return String.format("update insert <param name='%s'/> into collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" +
|
||||
"/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']", paramName, id);
|
||||
"/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']", paramName, id);
|
||||
}
|
||||
}
|
||||
|
||||
private String getXQuery(final String id, final String name, final String paramValue, final boolean toEscape) {
|
||||
String value = paramValue;
|
||||
if (toEscape)
|
||||
if (toEscape) {
|
||||
value = escape(XmlEscapers.xmlContentEscaper(), paramValue);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
return String.format("update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" +
|
||||
|
@ -252,15 +252,16 @@ public class ISClientImpl implements ISClient {
|
|||
}
|
||||
}
|
||||
|
||||
// private String getXQueryNoEscape(final String id, final String name, final String value) {
|
||||
// if (StringUtils.isNotBlank(value)) {
|
||||
// return String.format("update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" +
|
||||
// "/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']/param[./@name = '%s'] with <param name='%s'>%s</param>", id, name, name, value);
|
||||
// } else {
|
||||
// return String.format("update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" +
|
||||
// "/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']/param[./@name = '%s'] with <param name='%s'/>", id, name, name);
|
||||
// }
|
||||
// }
|
||||
// private String getXQueryNoEscape(final String id, final String name, final String value) {
|
||||
// if (StringUtils.isNotBlank(value)) {
|
||||
// return String.format("update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" +
|
||||
// "/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']/param[./@name = '%s'] with <param name='%s'>%s</param>", id, name, name,
|
||||
// value);
|
||||
// } else {
|
||||
// return String.format("update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" +
|
||||
// "/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']/param[./@name = '%s'] with <param name='%s'/>", id, name, name);
|
||||
// }
|
||||
// }
|
||||
|
||||
private String getConceptXQuery(final String id, final String name, final String value) {
|
||||
final Escaper esc = XmlEscapers.xmlContentEscaper();
|
||||
|
|
|
@ -10,7 +10,18 @@ import static eu.dnetlib.openaire.common.ExporterConstants.W;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import eu.dnetlib.openaire.community.selectioncriteria.SelectionCriteria;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.CommunityException;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.CommunityNotFoundException;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityContentprovider;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityDetails;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityOpenAIRECommunities;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityOrganization;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityProject;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunitySummary;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityWritableProperties;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityZenodoCommunity;
|
||||
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
|
|
|
@ -4,7 +4,19 @@ import java.util.*;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import eu.dnetlib.openaire.community.selectioncriteria.SelectionCriteria;
|
||||
|
||||
import eu.dnetlib.openaire.exporter.exceptions.CommunityException;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.CommunityNotFoundException;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityContentprovider;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityDetails;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityOpenAIRECommunities;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityOrganization;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityProject;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunitySummary;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityWritableProperties;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityZenodoCommunity;
|
||||
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
|
|
@ -3,6 +3,9 @@ package eu.dnetlib.openaire.community;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import eu.dnetlib.openaire.exporter.exceptions.CommunityException;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.CommunityNotFoundException;
|
||||
|
||||
public interface CommunityClient {
|
||||
|
||||
Map<String, Set<String>> getInverseZenodoCommunityMap() throws CommunityException, CommunityNotFoundException;
|
||||
|
|
|
@ -8,6 +8,11 @@ import org.springframework.cache.annotation.Cacheable;
|
|||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import eu.dnetlib.openaire.exporter.exceptions.CommunityException;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.CommunityNotFoundException;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunitySummary;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityZenodoCommunity;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
|
|
|
@ -4,11 +4,21 @@ import com.google.common.base.Joiner;
|
|||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.Gson;
|
||||
import eu.dnetlib.openaire.common.ISClient;
|
||||
import eu.dnetlib.openaire.community.selectioncriteria.SelectionCriteria;
|
||||
import eu.dnetlib.openaire.context.Category;
|
||||
import eu.dnetlib.openaire.context.Concept;
|
||||
import eu.dnetlib.openaire.context.Context;
|
||||
import eu.dnetlib.openaire.context.Param;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.CommunityException;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.CommunityNotFoundException;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityContentprovider;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityDetails;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityOrganization;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityProject;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunitySummary;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityWritableProperties;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityZenodoCommunity;
|
||||
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria;
|
||||
import eu.dnetlib.openaire.exporter.model.context.Category;
|
||||
import eu.dnetlib.openaire.exporter.model.context.Concept;
|
||||
import eu.dnetlib.openaire.exporter.model.context.Context;
|
||||
import eu.dnetlib.openaire.exporter.model.context.Param;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
|
@ -7,10 +7,19 @@ import java.util.stream.Stream;
|
|||
|
||||
import com.google.common.escape.Escaper;
|
||||
import com.google.common.xml.XmlEscapers;
|
||||
import eu.dnetlib.openaire.community.selectioncriteria.SelectionCriteria;
|
||||
import eu.dnetlib.openaire.context.Concept;
|
||||
import eu.dnetlib.openaire.context.Context;
|
||||
import eu.dnetlib.openaire.context.Param;
|
||||
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityContentprovider;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityDetails;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityOrganization;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityProject;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityStatus;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunitySummary;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityZenodoCommunity;
|
||||
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria;
|
||||
import eu.dnetlib.openaire.exporter.model.context.Concept;
|
||||
import eu.dnetlib.openaire.exporter.model.context.Context;
|
||||
import eu.dnetlib.openaire.exporter.model.context.Param;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
|
|
@ -12,6 +12,10 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import eu.dnetlib.openaire.exporter.exceptions.ContextException;
|
||||
import eu.dnetlib.openaire.exporter.model.context.CategorySummary;
|
||||
import eu.dnetlib.openaire.exporter.model.context.ConceptSummary;
|
||||
import eu.dnetlib.openaire.exporter.model.context.ContextSummary;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
|
|
|
@ -15,6 +15,13 @@ import com.google.common.base.Splitter;
|
|||
import com.google.common.collect.Lists;
|
||||
|
||||
import eu.dnetlib.openaire.common.ISClient;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.ContextException;
|
||||
import eu.dnetlib.openaire.exporter.model.context.Category;
|
||||
import eu.dnetlib.openaire.exporter.model.context.CategorySummary;
|
||||
import eu.dnetlib.openaire.exporter.model.context.Concept;
|
||||
import eu.dnetlib.openaire.exporter.model.context.ConceptSummary;
|
||||
import eu.dnetlib.openaire.exporter.model.context.Context;
|
||||
import eu.dnetlib.openaire.exporter.model.context.ContextSummary;
|
||||
|
||||
@Component
|
||||
@ConditionalOnProperty(value = "openaire.exporter.enable.context", havingValue = "true")
|
||||
|
|
|
@ -20,7 +20,11 @@ import org.dom4j.Node;
|
|||
import com.google.common.base.Functions;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import eu.dnetlib.openaire.funders.domain.FunderDetails;
|
||||
import eu.dnetlib.openaire.exporter.model.context.Category;
|
||||
import eu.dnetlib.openaire.exporter.model.context.Concept;
|
||||
import eu.dnetlib.openaire.exporter.model.context.Context;
|
||||
import eu.dnetlib.openaire.exporter.model.context.Param;
|
||||
import eu.dnetlib.openaire.exporter.model.funders.FunderDetails;
|
||||
|
||||
public class ContextMappingUtils {
|
||||
|
||||
|
|
|
@ -24,25 +24,23 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
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.AbstractExporterController;
|
||||
import eu.dnetlib.openaire.common.OperationManager;
|
||||
import eu.dnetlib.openaire.dsm.domain.AggregationHistoryResponseV1;
|
||||
import eu.dnetlib.openaire.dsm.domain.ApiDetails;
|
||||
import eu.dnetlib.openaire.dsm.domain.ApiDetailsResponse;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceDetailResponse;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceDetails;
|
||||
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.RequestFilter;
|
||||
import eu.dnetlib.openaire.dsm.domain.RequestSort;
|
||||
import eu.dnetlib.openaire.dsm.domain.RequestSortOrder;
|
||||
import eu.dnetlib.openaire.dsm.domain.SimpleResponse;
|
||||
import eu.dnetlib.openaire.vocabularies.Country;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV1;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails;
|
||||
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.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.RequestSort;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.RequestSortOrder;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse;
|
||||
import eu.dnetlib.openaire.exporter.model.vocabularies.Country;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
|
@ -69,7 +67,7 @@ public class DsmApiController extends AbstractExporterController {
|
|||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "500", description = "unexpected error")
|
||||
})
|
||||
public List<Country> listCountries() throws DsmException {
|
||||
public List<Country> listCountries() throws DsmApiException {
|
||||
return dsmCore.listCountries();
|
||||
}
|
||||
|
||||
|
@ -88,7 +86,7 @@ public class DsmApiController extends AbstractExporterController {
|
|||
@RequestParam final RequestSortOrder order,
|
||||
@RequestBody final RequestFilter requestFilter,
|
||||
@PathVariable final int page,
|
||||
@PathVariable final int size) throws DsmException {
|
||||
@PathVariable final int size) throws DsmApiException {
|
||||
final StopWatch stop = StopWatch.createStarted();
|
||||
final DatasourceDetailResponse rsp = dsmCore.searchDsDetails(requestSortBy, order, requestFilter, page, size);
|
||||
return prepareResponse(page, size, stop, rsp);
|
||||
|
@ -104,7 +102,7 @@ public class DsmApiController extends AbstractExporterController {
|
|||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@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 AggregationHistoryResponseV1 rsp = dsmCore.aggregationhistoryV1(dsId);
|
||||
return prepareResponse(0, rsp.getAggregationInfo().size(), stop, rsp);
|
||||
|
@ -125,7 +123,7 @@ public class DsmApiController extends AbstractExporterController {
|
|||
@RequestParam final RequestSortOrder order,
|
||||
@RequestBody final RequestFilter requestFilter,
|
||||
@PathVariable final int page,
|
||||
@PathVariable final int size) throws DsmException {
|
||||
@PathVariable final int size) throws DsmApiException {
|
||||
final StopWatch stop = StopWatch.createStarted();
|
||||
final DatasourceSnippetResponse rsp = dsmCore.searchSnippet(requestSortBy, order, requestFilter, page, size);
|
||||
return prepareResponse(page, size, stop, rsp);
|
||||
|
@ -147,7 +145,7 @@ public class DsmApiController extends AbstractExporterController {
|
|||
@RequestParam final RequestSortOrder order,
|
||||
@RequestBody final RequestFilter requestFilter,
|
||||
@PathVariable final int page,
|
||||
@PathVariable final int size) throws DsmException {
|
||||
@PathVariable final int size) throws DsmApiException {
|
||||
final StopWatch stop = StopWatch.createStarted();
|
||||
final DatasourceSnippetResponse rsp = dsmCore.searchRegistered(requestSortBy, order, requestFilter, page, size);
|
||||
return prepareResponse(page, size, stop, rsp);
|
||||
|
@ -198,7 +196,7 @@ public class DsmApiController extends AbstractExporterController {
|
|||
@ApiResponse(responseCode = "500", description = "unexpected error")
|
||||
})
|
||||
public ApiDetailsResponse getApi(
|
||||
@PathVariable final String dsId) throws DsmException {
|
||||
@PathVariable final String dsId) throws DsmApiException {
|
||||
|
||||
final StopWatch stop = StopWatch.createStarted();
|
||||
final ApiDetailsResponse rsp = dsmCore.getApis(dsId);
|
||||
|
@ -218,7 +216,7 @@ public class DsmApiController extends AbstractExporterController {
|
|||
public List<String> searchBaseUrls(
|
||||
@RequestBody final RequestFilter requestFilter,
|
||||
@PathVariable final int page,
|
||||
@PathVariable final int size) throws DsmException {
|
||||
@PathVariable final int size) throws DsmApiException {
|
||||
|
||||
return dsmCore.findBaseURLs(requestFilter, page, size);
|
||||
}
|
||||
|
@ -233,7 +231,7 @@ public class DsmApiController extends AbstractExporterController {
|
|||
@ApiResponse(responseCode = "403", description = "Api not removable"),
|
||||
@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);
|
||||
}
|
||||
|
||||
|
@ -247,7 +245,7 @@ public class DsmApiController extends AbstractExporterController {
|
|||
})
|
||||
public void setManaged(
|
||||
@RequestParam final String id,
|
||||
@RequestParam final boolean managed) throws DsmException {
|
||||
@RequestParam final boolean managed) throws DsmApiException {
|
||||
|
||||
dsmCore.setManaged(id, managed);
|
||||
}
|
||||
|
@ -260,7 +258,7 @@ public class DsmApiController extends AbstractExporterController {
|
|||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@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);
|
||||
}
|
||||
|
||||
|
@ -273,10 +271,10 @@ public class DsmApiController extends AbstractExporterController {
|
|||
@ApiResponse(responseCode = "400", description = "Malformed request"),
|
||||
@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
|
||||
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);
|
||||
}
|
||||
|
@ -290,10 +288,10 @@ public class DsmApiController extends AbstractExporterController {
|
|||
@ApiResponse(responseCode = "400", description = "Malformed request"),
|
||||
@ApiResponse(responseCode = "500", description = "Unexpected error")
|
||||
})
|
||||
public void saveDsWithApis(@Valid @RequestBody final DatasourceDetailsWithApis d) throws DsmException {
|
||||
if (d.getDatasource() == null) { throw new DsmException(HttpStatus.SC_BAD_REQUEST, "Datasource field is null"); }
|
||||
public void saveDsWithApis(@Valid @RequestBody final DatasourceDetailsWithApis d) throws DsmApiException {
|
||||
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
|
||||
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);
|
||||
}
|
||||
|
@ -307,7 +305,7 @@ public class DsmApiController extends AbstractExporterController {
|
|||
@ApiResponse(responseCode = "500", description = "unexpected error")
|
||||
})
|
||||
public void updateDatasource(
|
||||
@RequestBody final DatasourceDetailsUpdate ds) throws DsmException, DsmNotFoundException {
|
||||
@RequestBody final DatasourceDetailsUpdate ds) throws DsmApiException {
|
||||
|
||||
dsmCore.updateDatasource(ds);
|
||||
}
|
||||
|
@ -323,7 +321,7 @@ public class DsmApiController extends AbstractExporterController {
|
|||
public void updateBaseUrl(
|
||||
@RequestParam final String dsId,
|
||||
@RequestParam final String apiId,
|
||||
@RequestParam final String baseUrl) throws DsmException {
|
||||
@RequestParam final String baseUrl) throws DsmApiException {
|
||||
|
||||
dsmCore.updateApiBaseurl(dsId, apiId, baseUrl);
|
||||
}
|
||||
|
@ -340,7 +338,7 @@ public class DsmApiController extends AbstractExporterController {
|
|||
@RequestParam final String dsId,
|
||||
@RequestParam final String apiId,
|
||||
@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);
|
||||
}
|
||||
|
@ -356,7 +354,7 @@ public class DsmApiController extends AbstractExporterController {
|
|||
public void updateOaiSetl(
|
||||
@RequestParam final String dsId,
|
||||
@RequestParam final String apiId,
|
||||
@RequestParam final String oaiSet) throws DsmException {
|
||||
@RequestParam final String oaiSet) throws DsmApiException {
|
||||
|
||||
dsmCore.updateApiOaiSet(dsId, apiId, oaiSet);
|
||||
}
|
||||
|
@ -369,8 +367,8 @@ public class DsmApiController extends AbstractExporterController {
|
|||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "500", description = "unexpected error")
|
||||
})
|
||||
public void addApi(@RequestBody final ApiDetails api) throws DsmException {
|
||||
if (StringUtils.isBlank(api.getDatasource())) { throw new DsmException(HttpStatus.SC_BAD_REQUEST, "missing datasource id"); }
|
||||
public void addApi(@RequestBody final ApiDetails api) throws DsmApiException {
|
||||
if (StringUtils.isBlank(api.getDatasource())) { throw new DsmApiException(HttpStatus.SC_BAD_REQUEST, "missing datasource id"); }
|
||||
dsmCore.addApi(api);
|
||||
}
|
||||
|
||||
|
@ -387,7 +385,7 @@ public class DsmApiController extends AbstractExporterController {
|
|||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "500", description = "unexpected error")
|
||||
})
|
||||
public int getOps() throws DsmException {
|
||||
public int getOps() throws DsmApiException {
|
||||
return operationManager.getOpSize();
|
||||
}
|
||||
|
||||
|
@ -399,7 +397,7 @@ public class DsmApiController extends AbstractExporterController {
|
|||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "500", description = "unexpected error")
|
||||
})
|
||||
public int killOps() throws DsmException {
|
||||
public int killOps() throws DsmApiException {
|
||||
return operationManager.dropAll();
|
||||
}
|
||||
|
||||
|
@ -411,7 +409,7 @@ public class DsmApiController extends AbstractExporterController {
|
|||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "500", description = "unexpected error")
|
||||
})
|
||||
public void dropCache() throws DsmException {
|
||||
public void dropCache() throws DsmApiException {
|
||||
dsmCore.dropCaches();
|
||||
}
|
||||
|
||||
|
|
|
@ -15,12 +15,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import eu.dnetlib.enabling.datasources.common.DsmException;
|
||||
import eu.dnetlib.openaire.common.AbstractExporterController;
|
||||
import eu.dnetlib.openaire.dsm.dao.ResponseUtils;
|
||||
import eu.dnetlib.openaire.dsm.domain.AggregationHistoryResponseV2;
|
||||
import eu.dnetlib.openaire.dsm.domain.SimpleDatasourceInfo;
|
||||
import eu.dnetlib.openaire.dsm.domain.SimpleResponse;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV2;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.SimpleDatasourceInfo;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
|
@ -95,7 +95,7 @@ public class DsmApiControllerV2 extends AbstractExporterController {
|
|||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@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 AggregationHistoryResponseV2 rsp = dsmCore.aggregationhistoryV2(dsId);
|
||||
return prepareResponse(0, rsp.getAggregationInfo().size(), stop, rsp);
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.nio.charset.Charset;
|
|||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -29,37 +30,42 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
|
||||
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.community.CommunityClient;
|
||||
import eu.dnetlib.openaire.dsm.dao.CountryTermRepository;
|
||||
import eu.dnetlib.openaire.dsm.dao.DatasourceDao;
|
||||
import eu.dnetlib.openaire.dsm.dao.MongoLoggerClient;
|
||||
import eu.dnetlib.openaire.dsm.dao.ResponseUtils;
|
||||
import eu.dnetlib.openaire.dsm.dao.VocabularyClient;
|
||||
import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils;
|
||||
import eu.dnetlib.openaire.dsm.domain.AggregationHistoryResponseV1;
|
||||
import eu.dnetlib.openaire.dsm.domain.AggregationHistoryResponseV2;
|
||||
import eu.dnetlib.openaire.dsm.domain.AggregationInfoV1;
|
||||
import eu.dnetlib.openaire.dsm.domain.ApiDetails;
|
||||
import eu.dnetlib.openaire.dsm.domain.ApiDetailsResponse;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceDetailResponse;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceDetails;
|
||||
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.RequestFilter;
|
||||
import eu.dnetlib.openaire.dsm.domain.RequestSort;
|
||||
import eu.dnetlib.openaire.dsm.domain.RequestSortOrder;
|
||||
import eu.dnetlib.openaire.dsm.domain.SimpleDatasourceInfo;
|
||||
import eu.dnetlib.openaire.dsm.domain.SimpleResponse;
|
||||
import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry;
|
||||
import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry;
|
||||
import eu.dnetlib.openaire.dsm.domain.db.IdentityDbEntry;
|
||||
import eu.dnetlib.openaire.vocabularies.Country;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV1;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV2;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfoV1;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails;
|
||||
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.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.RequestSort;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.RequestSortOrder;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.SimpleDatasourceInfo;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.SimpleResponse;
|
||||
import eu.dnetlib.openaire.exporter.model.vocabularies.Country;
|
||||
import eu.dnetlib.openaire.exporter.model.vocabularies.Vocabulary;
|
||||
|
||||
@Component
|
||||
@ConditionalOnProperty(value = "openaire.exporter.enable.dsm", havingValue = "true")
|
||||
|
@ -79,19 +85,24 @@ public class DsmCore {
|
|||
@Autowired
|
||||
private DatasourceDao<DatasourceDbEntry, ApiDbEntry> dsDao;
|
||||
|
||||
@Autowired
|
||||
private CountryTermRepository countryTermRepository;
|
||||
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
private CommunityClient communityClient;
|
||||
|
||||
public List<Country> listCountries() throws DsmException {
|
||||
try {
|
||||
return dsDao.listCountries();
|
||||
} catch (final Throwable e) {
|
||||
log.error("error listing countries", e);
|
||||
throw e;
|
||||
}
|
||||
public List<Country> listCountries() throws DsmApiException {
|
||||
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;
|
||||
}
|
||||
|
||||
public DatasourceDetailResponse searchDsDetails(final RequestSort requestSortBy,
|
||||
|
@ -99,14 +110,14 @@ public class DsmCore {
|
|||
final RequestFilter requestFilter,
|
||||
final int page,
|
||||
final int size)
|
||||
throws DsmException {
|
||||
throws DsmApiException {
|
||||
|
||||
try {
|
||||
final Page<DatasourceDbEntry> dsPage = dsDao.search(requestSortBy, order, requestFilter, page, size);
|
||||
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);
|
||||
throw e;
|
||||
throw new DsmApiException(e.getCode(), "error searching datasources", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,13 +126,13 @@ public class DsmCore {
|
|||
final RequestFilter requestFilter,
|
||||
final int page,
|
||||
final int size)
|
||||
throws DsmException {
|
||||
throws DsmApiException {
|
||||
try {
|
||||
final Page<DatasourceDbEntry> dsPage = dsDao.search(requestSortBy, order, requestFilter, page, size);
|
||||
return ResponseUtils.snippetResponse(dsPage.map(DsmMappingUtils::asSnippetExtended).getContent(), dsPage.getTotalElements());
|
||||
} catch (final Throwable e) {
|
||||
} catch (final DsmException 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 int page,
|
||||
final int size)
|
||||
throws DsmException {
|
||||
throws DsmApiException {
|
||||
try {
|
||||
final Page<DatasourceDbEntry> dsPage = dsDao.searchRegistered(requestSortBy, order, requestFilter, page, size);
|
||||
return ResponseUtils.snippetResponse(dsPage.map(DsmMappingUtils::asSnippetExtended).getContent(), dsPage.getTotalElements());
|
||||
} catch (final Throwable e) {
|
||||
} catch (final DsmException 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 {
|
||||
return dsDao.findApiBaseURLs(requestFilter, page, size);
|
||||
} catch (final Throwable e) {
|
||||
} catch (final DsmException 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 {
|
||||
final DatasourceDbEntry ds = dsDao.getDs(dsId);
|
||||
final List<? extends ApiDbEntry> apis = dsDao.getApis(dsId);
|
||||
|
@ -159,37 +170,49 @@ public class DsmCore {
|
|||
.map(a -> a.setTypology(ds.getTypology()))
|
||||
.collect(Collectors.toList());
|
||||
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);
|
||||
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));
|
||||
dsDao.setManaged(dsId, managed);
|
||||
try {
|
||||
dsDao.setManaged(dsId, managed);
|
||||
} catch (final DsmException e) {
|
||||
throw new DsmApiException(e.getCode(), e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isManaged(final String dsId) throws DsmException {
|
||||
return dsDao.isManaged(dsId);
|
||||
public boolean isManaged(final String dsId) throws DsmApiException {
|
||||
try {
|
||||
return dsDao.isManaged(dsId);
|
||||
} catch (final DsmException e) {
|
||||
throw new DsmApiException(e.getCode(), e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean exist(final DatasourceDetails d) throws DsmException {
|
||||
return dsDao.existDs(d.getId());
|
||||
public boolean exist(final DatasourceDetails d) throws DsmApiException {
|
||||
try {
|
||||
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 {
|
||||
dsDao.saveDs(asDbEntry(d));
|
||||
log.info("DS saved, " + d.getId());
|
||||
} catch (final Throwable e) {
|
||||
} catch (final DsmException e) {
|
||||
log.error(ExceptionUtils.getStackTrace(e));
|
||||
throw e;
|
||||
throw new DsmApiException(e.getCode(), e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void save(final DatasourceDetailsWithApis d) throws DsmException {
|
||||
public void save(final DatasourceDetailsWithApis d) throws DsmApiException {
|
||||
try {
|
||||
dsDao.saveDs(asDbEntry(d.getDatasource()));
|
||||
final List<ApiDetails> apis = d.getApis();
|
||||
|
@ -199,15 +222,13 @@ public class DsmCore {
|
|||
addApi(api);
|
||||
}
|
||||
}
|
||||
} catch (
|
||||
|
||||
final Throwable e) {
|
||||
} catch (final DsmException 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 {
|
||||
// initialize with current values from DB
|
||||
final DatasourceDbEntry ds = dsDao.getDs(d.getId());
|
||||
|
@ -228,46 +249,72 @@ public class DsmCore {
|
|||
}
|
||||
|
||||
dsDao.saveDs(ds);
|
||||
} catch (final Throwable e) {
|
||||
} catch (final DsmException e) {
|
||||
log.error(ExceptionUtils.getStackTrace(e));
|
||||
throw e;
|
||||
throw new DsmApiException(e.getCode(), e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
// 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));
|
||||
dsDao.deleteDs(dsId);
|
||||
try {
|
||||
dsDao.deleteDs(dsId);
|
||||
} catch (final DsmException e) {
|
||||
throw new DsmApiException(e.getCode(), e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
// API
|
||||
|
||||
public void updateApiOaiSet(final String dsId, final String apiId, final String oaiSet) throws DsmException {
|
||||
dsDao.upsertApiOaiSet(apiId, oaiSet);
|
||||
public void updateApiOaiSet(final String dsId, final String apiId, final String oaiSet) throws DsmApiException {
|
||||
try {
|
||||
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));
|
||||
dsDao.updateApiBaseUrl(apiId, baseUrl);
|
||||
try {
|
||||
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));
|
||||
dsDao.updateCompliance(null, apiId, compliance, override);
|
||||
try {
|
||||
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())) {
|
||||
api.setId(createId(api));
|
||||
log.info(String.format("missing api id, created '%s'", api.getId()));
|
||||
}
|
||||
dsDao.addApi(asDbEntry(api));
|
||||
log.info("API saved, id: " + api.getId());
|
||||
try {
|
||||
dsDao.addApi(asDbEntry(api));
|
||||
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.
|
||||
dsDao.deleteApi(null, apiId);
|
||||
try {
|
||||
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() {
|
||||
|
@ -316,14 +363,14 @@ public class DsmCore {
|
|||
}
|
||||
|
||||
@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 AggregationHistoryResponseV1 rsp = new AggregationHistoryResponseV1(history);
|
||||
rsp.setHeader(ResponseUtils.header(history.size()));
|
||||
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 AggregationHistoryResponseV2 rsp = new AggregationHistoryResponseV2(history);
|
||||
rsp.setHeader(ResponseUtils.header(history.size()));
|
||||
|
|
|
@ -8,17 +8,14 @@ import eu.dnetlib.enabling.datasources.common.Api;
|
|||
import eu.dnetlib.enabling.datasources.common.Datasource;
|
||||
import eu.dnetlib.enabling.datasources.common.DatasourceManagerCommon;
|
||||
import eu.dnetlib.enabling.datasources.common.DsmException;
|
||||
import eu.dnetlib.openaire.dsm.domain.RequestFilter;
|
||||
import eu.dnetlib.openaire.dsm.domain.RequestSort;
|
||||
import eu.dnetlib.openaire.dsm.domain.RequestSortOrder;
|
||||
import eu.dnetlib.openaire.vocabularies.Country;
|
||||
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 interface DatasourceDao<DS extends Datasource<?, ?, ?>, API extends Api<?>> extends DatasourceManagerCommon<DS, API> {
|
||||
|
||||
// DATASOURCE
|
||||
|
||||
List<Country> listCountries() throws DsmException;
|
||||
|
||||
boolean existDs(final String dsId) throws DsmException;
|
||||
|
||||
Page<DS> search(RequestSort requestSortBy, RequestSortOrder order, RequestFilter requestFilter, int page, int size) throws DsmException;
|
||||
|
@ -55,6 +52,4 @@ public interface DatasourceDao<DS extends Datasource<?, ?, ?>, API extends Api<?
|
|||
|
||||
void updateApiBaseUrl(String apiId, String baseUrl) throws DsmException;
|
||||
|
||||
@Override
|
||||
void addApi(final API api) throws DsmException;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import static eu.dnetlib.openaire.dsm.dao.DatasourceSpecs.dsSpec;
|
|||
import java.sql.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -33,15 +32,13 @@ import eu.dnetlib.DnetOpenaireExporterProperties;
|
|||
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.dsm.domain.RequestFilter;
|
||||
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.ApiParamDbEntry;
|
||||
import eu.dnetlib.openaire.dsm.domain.db.DatasourceApiDbEntry;
|
||||
import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry;
|
||||
import eu.dnetlib.openaire.vocabularies.Country;
|
||||
import eu.dnetlib.openaire.vocabularies.Vocabulary;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.RequestFilter;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.RequestSort;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.RequestSortOrder;
|
||||
|
||||
/**
|
||||
* Created by claudio on 20/10/2016.
|
||||
|
@ -55,9 +52,6 @@ public class DatasourceDaoImpl implements DatasourceDao<DatasourceDbEntry, ApiDb
|
|||
@Autowired
|
||||
private DnetOpenaireExporterProperties config;
|
||||
|
||||
@Autowired
|
||||
private CountryTermRepository countryTermRepository;
|
||||
|
||||
@Autowired
|
||||
private DatasourceDbEntryRepository dsRepository;
|
||||
|
||||
|
@ -67,20 +61,8 @@ public class DatasourceDaoImpl implements DatasourceDao<DatasourceDbEntry, ApiDb
|
|||
@Autowired
|
||||
private DatasourceApiDbEntryRepository dsApiRepository;
|
||||
|
||||
@Autowired
|
||||
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;
|
||||
}
|
||||
// @Autowired
|
||||
// private VocabularyClient vocabularyClient;
|
||||
|
||||
@Override
|
||||
public Page<DatasourceDbEntry> search(final RequestSort requestSortBy,
|
||||
|
@ -239,13 +221,11 @@ public class DatasourceDaoImpl implements DatasourceDao<DatasourceDbEntry, ApiDb
|
|||
|
||||
@Override
|
||||
public void updateEoscDatasourceType(final String dsId, final String type) throws DsmException {
|
||||
final Vocabulary typologies = vocabularyClient.getDatasourceTypologies();
|
||||
if (!typologies.hasCode(type)) {
|
||||
throw new DsmException(
|
||||
HttpStatus.SC_BAD_REQUEST,
|
||||
String.format("invalid datasource type '%s', provide one according to vocabulary %s", type, config.getVocabularies()
|
||||
.getDatasourceTypologiesEndpoint()));
|
||||
}
|
||||
/*
|
||||
* final Vocabulary typologies = vocabularyClient.getDatasourceTypologies(); if (!typologies.hasCode(type)) { throw new
|
||||
* DsmException( HttpStatus.SC_BAD_REQUEST, String.format("invalid datasource type '%s', provide one according to vocabulary %s",
|
||||
* type, config.getVocabularies() .getDatasourceTypologiesEndpoint())); }
|
||||
*/
|
||||
dsRepository.setEoscDatasourceType(dsId, type);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,16 +2,14 @@ package eu.dnetlib.openaire.dsm.dao;
|
|||
|
||||
import java.util.Queue;
|
||||
|
||||
import eu.dnetlib.enabling.datasources.common.DsmException;
|
||||
import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo;
|
||||
import eu.dnetlib.openaire.dsm.dao.utils.IndexRecordsInfo;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
|
||||
|
||||
public interface DatasourceIndexClient {
|
||||
|
||||
IndexRecordsInfo getIndexInfo(final String dsId, final IndexDsInfo info, final Queue<Throwable> errors) throws DsmException;
|
||||
|
||||
String getLastIndexingDate(final IndexDsInfo info) throws DsmException;
|
||||
|
||||
IndexRecordsInfo getIndexInfo(final String dsId, final IndexDsInfo info, final Queue<Throwable> errors) throws DsmApiException;
|
||||
|
||||
String getLastIndexingDate(final IndexDsInfo info) throws DsmApiException;
|
||||
|
||||
}
|
||||
|
|
|
@ -5,19 +5,15 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.util.concurrent.*;
|
||||
import eu.dnetlib.DnetOpenaireExporterProperties;
|
||||
import eu.dnetlib.enabling.datasources.common.DsmException;
|
||||
import eu.dnetlib.miscutils.functional.hash.Hashing;
|
||||
import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils;
|
||||
import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo;
|
||||
import eu.dnetlib.openaire.dsm.dao.utils.IndexRecordsInfo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -33,6 +29,22 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
|
||||
import eu.dnetlib.DnetOpenaireExporterProperties;
|
||||
import eu.dnetlib.enabling.datasources.common.DsmException;
|
||||
import eu.dnetlib.miscutils.functional.hash.Hashing;
|
||||
import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils;
|
||||
import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo;
|
||||
import eu.dnetlib.openaire.dsm.dao.utils.IndexRecordsInfo;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
|
||||
|
||||
/**
|
||||
* Created by claudio on 20/10/2016.
|
||||
*/
|
||||
|
@ -54,9 +66,8 @@ public class DatasourceIndexClientImpl implements DatasourceIndexClient {
|
|||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
executor = MoreExecutors.listeningDecorator(
|
||||
new ScheduledThreadPoolExecutor(5,
|
||||
new ThreadFactoryBuilder().setNameFormat("datasource-index-client-%d").build()));
|
||||
executor = MoreExecutors.listeningDecorator(new ScheduledThreadPoolExecutor(5,
|
||||
new ThreadFactoryBuilder().setNameFormat("datasource-index-client-%d").build()));
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
|
@ -64,65 +75,61 @@ public class DatasourceIndexClientImpl implements DatasourceIndexClient {
|
|||
indexClientMap.forEach((name, client) -> {
|
||||
try {
|
||||
client.close();
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
log.warn(String.format("unable to gracefully shutdown client for index %s", name));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@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 {
|
||||
final String collectedFrom = StringUtils.substringBefore(dsId, SEPARATOR) + SEPARATOR + Hashing.md5(StringUtils.substringAfter(dsId, SEPARATOR));
|
||||
final CloudSolrClient indexClient = getIndexClient(info);
|
||||
final CountDownLatch latch = new CountDownLatch(2);
|
||||
final IndexRecordsInfo indexRecordInfo = new IndexRecordsInfo();
|
||||
|
||||
Futures.addCallback(
|
||||
executor.submit(() -> setDateAndTotal(dsId, collectedFrom, indexClient)),
|
||||
new FutureCallback<IndexRecordsInfo>() {
|
||||
Futures.addCallback(executor.submit(() -> setDateAndTotal(dsId, collectedFrom, indexClient)), new FutureCallback<IndexRecordsInfo>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(final IndexRecordsInfo info) {
|
||||
indexRecordInfo
|
||||
.setTotal(info.getTotal())
|
||||
.setDate(info.getDate());
|
||||
latch.countDown();
|
||||
}
|
||||
@Override
|
||||
public void onSuccess(final IndexRecordsInfo info) {
|
||||
indexRecordInfo
|
||||
.setTotal(info.getTotal())
|
||||
.setDate(info.getDate());
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(final Throwable e) {
|
||||
errors.offer(e);
|
||||
latch.countDown();
|
||||
}
|
||||
}, executor);
|
||||
@Override
|
||||
public void onFailure(final Throwable e) {
|
||||
errors.offer(e);
|
||||
latch.countDown();
|
||||
}
|
||||
}, executor);
|
||||
|
||||
Futures.addCallback(
|
||||
executor.submit(() -> setFunded(dsId, collectedFrom, indexClient)),
|
||||
new FutureCallback<Long>() {
|
||||
Futures.addCallback(executor.submit(() -> setFunded(dsId, collectedFrom, indexClient)), new FutureCallback<Long>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(final Long numFound) {
|
||||
indexRecordInfo.setFunded(numFound);
|
||||
latch.countDown();
|
||||
}
|
||||
@Override
|
||||
public void onSuccess(final Long numFound) {
|
||||
indexRecordInfo.setFunded(numFound);
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(final Throwable e) {
|
||||
errors.offer(e);
|
||||
latch.countDown();
|
||||
}
|
||||
}, executor);
|
||||
@Override
|
||||
public void onFailure(final Throwable e) {
|
||||
errors.offer(e);
|
||||
latch.countDown();
|
||||
}
|
||||
}, executor);
|
||||
|
||||
waitLatch(latch, errors, config.getRequestTimeout());
|
||||
return indexRecordInfo;
|
||||
} 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
|
||||
public String getLastIndexingDate(final IndexDsInfo info) throws DsmException {
|
||||
public String getLastIndexingDate(final IndexDsInfo info) throws DsmApiException {
|
||||
try {
|
||||
final SolrQuery query = new SolrQuery("oaftype:datasource").setRows(1);
|
||||
final QueryResponse rsp = getIndexClient(info).query(query);
|
||||
|
@ -130,28 +137,28 @@ public class DatasourceIndexClientImpl implements DatasourceIndexClient {
|
|||
final String dsversion = doc.get("__dsversion").toString();
|
||||
return StringUtils.substringBefore(dsversion, "T");
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
private Long setFunded(
|
||||
final String dsId,
|
||||
final String collectedFrom,
|
||||
final CloudSolrClient indexClient) throws DsmException {
|
||||
final String dsId,
|
||||
final String collectedFrom,
|
||||
final CloudSolrClient indexClient) throws DsmException {
|
||||
final String query =
|
||||
String.format("oaftype:result AND deletedbyinference:false AND collectedfromdatasourceid:\"%s\" AND relprojectid:*", collectedFrom);
|
||||
String.format("oaftype:result AND deletedbyinference:false AND collectedfromdatasourceid:\"%s\" AND relprojectid:*", collectedFrom);
|
||||
log.debug(String.format("query: %s", query));
|
||||
try {
|
||||
return indexClient.query(new SolrQuery(query).setRows(0)).getResults().getNumFound();
|
||||
} catch (Throwable e) {
|
||||
} catch (final Throwable e) {
|
||||
throw new DsmException(HttpStatus.INTERNAL_SERVER_ERROR.value(), String.format("Error querying index for funded results '%s'", dsId), e);
|
||||
}
|
||||
}
|
||||
|
||||
private IndexRecordsInfo setDateAndTotal(
|
||||
final String dsId,
|
||||
final String collectedFrom,
|
||||
final CloudSolrClient indexClient) throws DsmException {
|
||||
final String dsId,
|
||||
final String collectedFrom,
|
||||
final CloudSolrClient indexClient) throws DsmException {
|
||||
try {
|
||||
final String query = String.format("oaftype:result AND deletedbyinference:false AND collectedfromdatasourceid:\"%s\"", collectedFrom);
|
||||
log.debug(String.format("query: %s", query));
|
||||
|
@ -166,9 +173,9 @@ public class DatasourceIndexClientImpl implements DatasourceIndexClient {
|
|||
// query: %s", queryTotal));
|
||||
// }
|
||||
return new IndexRecordsInfo()
|
||||
.setDate(getDate(doc))
|
||||
.setTotal(rsp.getResults().getNumFound());
|
||||
} catch (Throwable e) {
|
||||
.setDate(getDate(doc))
|
||||
.setTotal(rsp.getResults().getNumFound());
|
||||
} catch (final Throwable e) {
|
||||
throw new DsmException(HttpStatus.INTERNAL_SERVER_ERROR.value(), String.format("Error querying index for date and total '%s'", dsId), e);
|
||||
}
|
||||
}
|
||||
|
@ -176,8 +183,10 @@ public class DatasourceIndexClientImpl implements DatasourceIndexClient {
|
|||
@SuppressWarnings("unchecked")
|
||||
private String getDate(final SolrDocument doc) throws DsmException {
|
||||
final List<Date> dsversion = (List<Date>) doc.get(DSVERSION);
|
||||
if (dsversion == null || dsversion.isEmpty()) { throw new DsmException(HttpStatus.INTERNAL_SERVER_ERROR.value(),
|
||||
String.format("cannot find %s in matched solr document", DSVERSION)); }
|
||||
if (dsversion == null || dsversion.isEmpty()) {
|
||||
throw new DsmException(HttpStatus.INTERNAL_SERVER_ERROR.value(),
|
||||
String.format("cannot find %s in matched solr document", DSVERSION));
|
||||
}
|
||||
final Date date = Iterables.getLast(dsversion);
|
||||
|
||||
return DateFormatUtils.format(date, DsmMappingUtils.DATE_FORMAT);
|
||||
|
|
|
@ -17,12 +17,12 @@ import org.apache.commons.logging.LogFactory;
|
|||
import org.springframework.data.jpa.domain.Specification;
|
||||
|
||||
import eu.dnetlib.enabling.datasources.common.DsmRuntimeException;
|
||||
import eu.dnetlib.openaire.dsm.domain.FilterName;
|
||||
import eu.dnetlib.openaire.dsm.domain.RequestFilter;
|
||||
import eu.dnetlib.openaire.dsm.domain.RequestSort;
|
||||
import eu.dnetlib.openaire.dsm.domain.RequestSortOrder;
|
||||
import eu.dnetlib.openaire.dsm.domain.db.DatasourceApiDbEntry;
|
||||
import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.FilterName;
|
||||
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 {
|
||||
|
||||
|
|
|
@ -2,15 +2,15 @@ package eu.dnetlib.openaire.dsm.dao;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
|
||||
import eu.dnetlib.enabling.datasources.common.DsmException;
|
||||
import eu.dnetlib.openaire.dsm.domain.AggregationInfoV1;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfoV1;
|
||||
|
||||
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();
|
||||
|
||||
|
|
|
@ -41,18 +41,18 @@ import com.mongodb.client.MongoCollection;
|
|||
|
||||
import eu.dnetlib.DnetOpenaireExporterProperties;
|
||||
import eu.dnetlib.DnetOpenaireExporterProperties.Datasource;
|
||||
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
|
||||
import eu.dnetlib.enabling.datasources.common.AggregationStage;
|
||||
import eu.dnetlib.enabling.datasources.common.DsmException;
|
||||
import eu.dnetlib.miscutils.datetime.DateUtils;
|
||||
import eu.dnetlib.openaire.common.Utils;
|
||||
import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils;
|
||||
import eu.dnetlib.openaire.dsm.domain.AggregationInfoV1;
|
||||
import eu.dnetlib.openaire.dsm.domain.CollectionInfoV1;
|
||||
import eu.dnetlib.openaire.dsm.domain.CollectionInfoV2;
|
||||
import eu.dnetlib.openaire.dsm.domain.CollectionMode;
|
||||
import eu.dnetlib.openaire.dsm.domain.TransformationInfoV1;
|
||||
import eu.dnetlib.openaire.dsm.domain.TransformationInfoV2;
|
||||
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.AggregationStage;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.CollectionInfoV1;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.CollectionInfoV2;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.CollectionMode;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.TransformationInfoV1;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.TransformationInfoV2;
|
||||
import eu.dnetlib.openaire.info.JdbcInfoDao;
|
||||
|
||||
/**
|
||||
|
@ -93,19 +93,19 @@ public class MongoLoggerClientImpl implements MongoLoggerClient {
|
|||
@Override
|
||||
@Cacheable("dsm-aggregationhistory-cache-v1")
|
||||
@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());
|
||||
}
|
||||
|
||||
@Override
|
||||
@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());
|
||||
}
|
||||
|
||||
private <T extends AggregationInfo> List<T> getAggregationHistory(final String dsId,
|
||||
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));
|
||||
final Datasource conf = config.getDatasource();
|
||||
try {
|
||||
|
@ -132,7 +132,7 @@ public class MongoLoggerClientImpl implements MongoLoggerClient {
|
|||
|
||||
return aggregationInfos;
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package eu.dnetlib.openaire.dsm.dao;
|
||||
|
||||
import eu.dnetlib.enabling.datasources.common.DsmException;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
|
||||
|
||||
public interface ObjectStoreClient {
|
||||
|
||||
Long getObjectStoreSize(final String objectStoreId) throws DsmException;
|
||||
Long getObjectStoreSize(final String objectStoreId) throws DsmApiException;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package eu.dnetlib.openaire.dsm.dao;
|
||||
|
||||
import eu.dnetlib.data.objectstore.rmi.ObjectStoreService;
|
||||
import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
|
||||
import eu.dnetlib.enabling.datasources.common.DsmException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -10,6 +7,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import eu.dnetlib.data.objectstore.rmi.ObjectStoreService;
|
||||
import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
|
||||
|
||||
@Component
|
||||
@ConditionalOnProperty(value = "openaire.exporter.enable.dsm", havingValue = "true")
|
||||
public class ObjectStoreClientImpl implements ObjectStoreClient {
|
||||
|
@ -20,17 +21,15 @@ public class ObjectStoreClientImpl implements ObjectStoreClient {
|
|||
private ObjectStoreService objectStoreService;
|
||||
|
||||
@Override
|
||||
public Long getObjectStoreSize(final String objectStoreId) throws DsmException {
|
||||
public Long getObjectStoreSize(final String objectStoreId) throws DsmApiException {
|
||||
log.debug("get size for objectStore " + objectStoreId);
|
||||
if (StringUtils.isBlank(objectStoreId)) {
|
||||
return 0L;
|
||||
}
|
||||
if (StringUtils.isBlank(objectStoreId)) { return 0L; }
|
||||
try {
|
||||
final long size = objectStoreService.getSize(objectStoreId);
|
||||
log.debug("got objectStore size: " + size);
|
||||
return size;
|
||||
} catch (ObjectStoreServiceException e) {
|
||||
throw new DsmException("unable to get size for objectStore " + objectStoreId);
|
||||
} catch (final ObjectStoreServiceException e) {
|
||||
throw new DsmApiException("unable to get size for objectStore " + objectStoreId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,16 +5,16 @@ import java.util.Queue;
|
|||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import eu.dnetlib.openaire.dsm.domain.ApiDetails;
|
||||
import eu.dnetlib.openaire.dsm.domain.ApiDetailsResponse;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceDetailResponse;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceDetails;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceInfo;
|
||||
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.dsm.domain.Header;
|
||||
import eu.dnetlib.openaire.dsm.domain.SimpleResponse;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails;
|
||||
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.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.SimpleResponse;
|
||||
|
||||
public class ResponseUtils {
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package eu.dnetlib.openaire.dsm.dao;
|
||||
|
||||
import eu.dnetlib.enabling.datasources.common.DsmException;
|
||||
import eu.dnetlib.openaire.vocabularies.Vocabulary;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.DsmApiException;
|
||||
import eu.dnetlib.openaire.exporter.model.vocabularies.Vocabulary;
|
||||
|
||||
public interface VocabularyClient {
|
||||
|
||||
Vocabulary getCountries() throws DsmException;
|
||||
Vocabulary getCountries() throws DsmApiException;
|
||||
|
||||
Vocabulary getDatasourceTypologies() throws DsmException;
|
||||
Vocabulary getDatasourceTypologies() throws DsmApiException;
|
||||
|
||||
void dropCache();
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package eu.dnetlib.openaire.dsm.dao;
|
||||
|
||||
import eu.dnetlib.DnetOpenaireExporterProperties;
|
||||
import eu.dnetlib.enabling.datasources.common.DsmException;
|
||||
import eu.dnetlib.openaire.vocabularies.Vocabulary;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -13,6 +10,10 @@ import org.springframework.scheduling.annotation.Scheduled;
|
|||
import org.springframework.stereotype.Component;
|
||||
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.
|
||||
*/
|
||||
|
@ -26,24 +27,22 @@ public class VocabularyClientImpl implements VocabularyClient {
|
|||
|
||||
@Override
|
||||
@Cacheable("vocabularies-cache")
|
||||
public Vocabulary getCountries() throws DsmException {
|
||||
public Vocabulary getCountries() throws DsmApiException {
|
||||
return _getVocabulary(config.getVocabularies().getCountriesEndpoint(), Vocabulary.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable("vocabularies-cache")
|
||||
public Vocabulary getDatasourceTypologies() throws DsmException {
|
||||
public Vocabulary getDatasourceTypologies() throws DsmApiException {
|
||||
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();
|
||||
log.info("get vocabulary from " + endpoint);
|
||||
final ResponseEntity<T> rsp = rt.getForEntity(endpoint, clazz);
|
||||
|
||||
if (!rsp.getStatusCode().is2xxSuccessful()) {
|
||||
throw new DsmException(rsp.getStatusCodeValue(), "unable to read content from " + endpoint);
|
||||
}
|
||||
if (!rsp.getStatusCode().is2xxSuccessful()) { throw new DsmApiException(rsp.getStatusCodeValue(), "unable to read content from " + endpoint); }
|
||||
|
||||
return rsp.getBody();
|
||||
}
|
||||
|
|
|
@ -14,14 +14,14 @@ import org.springframework.beans.BeanWrapperImpl;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import eu.dnetlib.data.transform.xml.AbstractDNetXsltFunctions;
|
||||
import eu.dnetlib.openaire.dsm.domain.ApiDetails;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceDetails;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsUpdate;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetExtended;
|
||||
import eu.dnetlib.openaire.dsm.domain.OrganizationDetails;
|
||||
import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry;
|
||||
import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry;
|
||||
import eu.dnetlib.openaire.dsm.domain.db.OrganizationDbEntry;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails;
|
||||
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;
|
||||
|
||||
public class DsmMappingUtils {
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ import java.util.List;
|
|||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.Response;
|
||||
|
||||
@JsonAutoDetect
|
||||
public class DatasourceResponse<T> extends Response {
|
||||
|
||||
|
|
|
@ -4,6 +4,9 @@ import java.util.List;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceInfo;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.Response;
|
||||
|
||||
@JsonAutoDetect
|
||||
public class DatasourceSearchResponse extends Response {
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package eu.dnetlib.openaire.funders.domain;
|
||||
package eu.dnetlib.openaire.funders;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import eu.dnetlib.openaire.exporter.model.funders.ExtendedFunderDetails;
|
||||
import eu.dnetlib.openaire.exporter.model.funders.FunderDetails;
|
||||
import eu.dnetlib.openaire.exporter.model.funders.FundingStream;
|
||||
import eu.dnetlib.openaire.funders.domain.db.FunderDbEntry;
|
||||
import eu.dnetlib.openaire.funders.domain.db.FundingPathDbEntry;
|
||||
import org.dom4j.Document;
|
|
@ -8,9 +8,9 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import eu.dnetlib.openaire.funders.domain.ConversionUtils;
|
||||
import eu.dnetlib.openaire.funders.domain.ExtendedFunderDetails;
|
||||
import eu.dnetlib.openaire.funders.domain.FunderDetails;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.FundersApiException;
|
||||
import eu.dnetlib.openaire.exporter.model.funders.ExtendedFunderDetails;
|
||||
import eu.dnetlib.openaire.exporter.model.funders.FunderDetails;
|
||||
|
||||
@Component
|
||||
@ConditionalOnProperty(value = "openaire.exporter.enable.funders", havingValue = "true")
|
||||
|
|
|
@ -13,8 +13,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import eu.dnetlib.openaire.common.AbstractExporterController;
|
||||
import eu.dnetlib.openaire.funders.domain.ExtendedFunderDetails;
|
||||
import eu.dnetlib.openaire.funders.domain.FunderDetails;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.FundersApiException;
|
||||
import eu.dnetlib.openaire.exporter.model.funders.ExtendedFunderDetails;
|
||||
import eu.dnetlib.openaire.exporter.model.funders.FunderDetails;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
|
|
|
@ -22,7 +22,6 @@ management.endpoints.web.base-path = /
|
|||
management.endpoints.web.path-mapping.prometheus = metrics
|
||||
management.endpoints.web.path-mapping.health = health
|
||||
|
||||
apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiController.java
|
||||
# ENABLE / DISABLE CONTROLLERS
|
||||
openaire.exporter.enable.dsm = true
|
||||
openaire.exporter.enable.community = true
|
||||
|
|
|
@ -19,6 +19,8 @@ import org.springframework.boot.test.mock.mockito.MockBean;
|
|||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunitySummary;
|
||||
|
||||
/**
|
||||
* Created by Alessia Bardi on 2019-04-04.
|
||||
*
|
||||
|
|
|
@ -2,6 +2,10 @@ package eu.dnetlib.openaire.community.selectioncriteria;
|
|||
|
||||
import com.google.gson.Gson;
|
||||
import eu.dnetlib.data.bulktag.selectioncriteria.Selection;
|
||||
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.Constraint;
|
||||
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.Constraints;
|
||||
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
|
@ -13,6 +13,8 @@ import org.junit.jupiter.api.Test;
|
|||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import eu.dnetlib.openaire.exporter.model.context.Context;
|
||||
|
||||
/**
|
||||
* Created by Alessia Bardi on 2019-04-04.
|
||||
*
|
||||
|
|
|
@ -21,9 +21,9 @@ import org.springframework.test.web.servlet.MockMvc;
|
|||
|
||||
import eu.dnetlib.enabling.datasources.common.DsmException;
|
||||
import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceDetails;
|
||||
import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry;
|
||||
import eu.dnetlib.openaire.vocabularies.Country;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.DatasourceDetails;
|
||||
import eu.dnetlib.openaire.exporter.model.vocabularies.Country;
|
||||
|
||||
@SpringBootTest
|
||||
@WebMvcTest(DsmApiController.class)
|
||||
|
|
|
@ -5,8 +5,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import eu.dnetlib.openaire.dsm.domain.ApiDetails;
|
||||
import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry;
|
||||
import eu.dnetlib.openaire.exporter.model.dsm.ApiDetails;
|
||||
|
||||
class DsmMappingUtilsTest {
|
||||
|
||||
|
|
|
@ -14,9 +14,9 @@ import org.junit.jupiter.api.Test;
|
|||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import eu.dnetlib.openaire.context.Context;
|
||||
import eu.dnetlib.openaire.context.ContextMappingUtils;
|
||||
import eu.dnetlib.openaire.funders.domain.FunderDetails;
|
||||
import eu.dnetlib.openaire.exporter.model.context.Context;
|
||||
import eu.dnetlib.openaire.exporter.model.funders.FunderDetails;
|
||||
|
||||
public class FunderContextClientTest {
|
||||
|
||||
|
|
|
@ -0,0 +1,233 @@
|
|||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven2 Start Up Batch script
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "`uname`" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
#
|
||||
# Look for the Apple JDKs first to preserve the existing behaviour, and then look
|
||||
# for the new JDKs provided by Oracle.
|
||||
#
|
||||
if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
|
||||
#
|
||||
# Apple JDKs
|
||||
#
|
||||
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
|
||||
#
|
||||
# Apple JDKs
|
||||
#
|
||||
export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
|
||||
#
|
||||
# Oracle JDKs
|
||||
#
|
||||
export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
|
||||
#
|
||||
# Apple JDKs
|
||||
#
|
||||
export JAVA_HOME=`/usr/libexec/java_home`
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=`java-config --jre-home`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# For Migwn, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||
# TODO classpath?
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
javaExecutable="`which javac`"
|
||||
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=`which readlink`
|
||||
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||
else
|
||||
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||
fi
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="`which java`"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
local basedir=$(pwd)
|
||||
local wdir=$(pwd)
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
wdir=$(cd "$wdir/.."; pwd)
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$(tr -s '\n' ' ' < "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# Provide a "standardized" way to retrieve the CLI args that will
|
||||
# work with both Windows and non-Windows executions.
|
||||
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
|
||||
export MAVEN_CMD_LINE_ARGS
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} "$@"
|
|
@ -0,0 +1,145 @@
|
|||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM http://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven2 Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
set MAVEN_CMD_LINE_ARGS=%*
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
|
||||
set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar""
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%" == "on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
|
||||
|
||||
exit /B %ERROR_CODE%
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>eu.dnetlib.dhp</groupId>
|
||||
<artifactId>libs</artifactId>
|
||||
<version>3.3.4-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>dnet-exporter-model</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>dnet-exporter-model</name>
|
||||
<description>Model classes for D-Net Exporter API</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-common</artifactId>
|
||||
<version>1.6.10</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>jakarta.persistence</groupId>
|
||||
<artifactId>jakarta.persistence-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,13 +1,7 @@
|
|||
package eu.dnetlib.openaire.community;
|
||||
package eu.dnetlib.openaire.exporter.exceptions;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ResponseBody
|
||||
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
public class CommunityException extends Exception {
|
||||
|
||||
/**
|
|
@ -1,11 +1,5 @@
|
|||
package eu.dnetlib.openaire.community;
|
||||
package eu.dnetlib.openaire.exporter.exceptions;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ResponseBody
|
||||
@ResponseStatus(value = HttpStatus.NOT_FOUND)
|
||||
public class CommunityNotFoundException extends Exception {
|
||||
|
||||
/**
|
|
@ -1,13 +1,7 @@
|
|||
package eu.dnetlib.openaire.context;
|
||||
package eu.dnetlib.openaire.exporter.exceptions;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ResponseBody
|
||||
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
public class ContextException extends Exception {
|
||||
|
||||
/**
|
|
@ -1,11 +1,5 @@
|
|||
package eu.dnetlib.openaire.context;
|
||||
package eu.dnetlib.openaire.exporter.exceptions;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ResponseBody
|
||||
@ResponseStatus(value = HttpStatus.NOT_FOUND)
|
||||
public class ContextNotFoundException extends Exception {
|
||||
|
||||
/**
|
|
@ -0,0 +1,36 @@
|
|||
package eu.dnetlib.openaire.exporter.exceptions;
|
||||
|
||||
public class DsmApiException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -8173126561260106405L;
|
||||
|
||||
private int code;
|
||||
|
||||
public DsmApiException(final int code, final String msg) {
|
||||
super(msg);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public DsmApiException(final int code, final Throwable e) {
|
||||
super(e);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public DsmApiException(final int code, final String msg, final Throwable e) {
|
||||
super(msg, e);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public DsmApiException(final String msg) {
|
||||
this(500, msg);
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(final int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.funders;
|
||||
package eu.dnetlib.openaire.exporter.exceptions;
|
||||
|
||||
public class FundersApiException extends Exception {
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
package eu.dnetlib.openaire.community;
|
||||
package eu.dnetlib.openaire.exporter.model.community;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.google.gson.Gson;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import eu.dnetlib.openaire.community.selectioncriteria.SelectionCriteria;
|
||||
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
@JsonAutoDetect
|
||||
|
@ -90,7 +91,11 @@ public class CommunityContentprovider {
|
|||
|
||||
public String toJson() {
|
||||
if (selectioncriteria == null) { return ""; }
|
||||
return new Gson().toJson(selectioncriteria);
|
||||
try {
|
||||
return new ObjectMapper().writeValueAsString(selectioncriteria);
|
||||
} catch (final JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String toXML() {
|
|
@ -1,11 +1,11 @@
|
|||
package eu.dnetlib.openaire.community;
|
||||
package eu.dnetlib.openaire.exporter.model.community;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
|
||||
import eu.dnetlib.openaire.community.selectioncriteria.SelectionCriteria;
|
||||
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
@JsonAutoDetect
|
||||
|
@ -29,7 +29,6 @@ public class CommunityDetails extends CommunitySummary {
|
|||
@Schema(description = "list of advanced criteria to associate results to this community")
|
||||
private SelectionCriteria advancedConstraint;
|
||||
|
||||
|
||||
public CommunityDetails() {}
|
||||
|
||||
public CommunityDetails(final CommunitySummary summary) {
|
||||
|
@ -68,7 +67,7 @@ public class CommunityDetails extends CommunitySummary {
|
|||
return fos;
|
||||
}
|
||||
|
||||
public void setFos(List<String> fos) {
|
||||
public void setFos(final List<String> fos) {
|
||||
this.fos = fos;
|
||||
}
|
||||
|
||||
|
@ -76,7 +75,7 @@ public class CommunityDetails extends CommunitySummary {
|
|||
return sdg;
|
||||
}
|
||||
|
||||
public void setSdg(List<String> sdg) {
|
||||
public void setSdg(final List<String> sdg) {
|
||||
this.sdg = sdg;
|
||||
}
|
||||
|
||||
|
@ -84,7 +83,7 @@ public class CommunityDetails extends CommunitySummary {
|
|||
return advancedConstraint;
|
||||
}
|
||||
|
||||
public void setAdvancedConstraint(SelectionCriteria advancedConstraint) {
|
||||
public void setAdvancedConstraint(final SelectionCriteria advancedConstraint) {
|
||||
this.advancedConstraint = advancedConstraint;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.community;
|
||||
package eu.dnetlib.openaire.exporter.model.community;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.community;
|
||||
package eu.dnetlib.openaire.exporter.model.community;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.community;
|
||||
package eu.dnetlib.openaire.exporter.model.community;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.community;
|
||||
package eu.dnetlib.openaire.exporter.model.community;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.community;
|
||||
package eu.dnetlib.openaire.exporter.model.community;
|
||||
|
||||
import java.util.Date;
|
||||
|
|
@ -1,14 +1,12 @@
|
|||
package eu.dnetlib.openaire.community;
|
||||
package eu.dnetlib.openaire.exporter.model.community;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
|
||||
import eu.dnetlib.openaire.community.selectioncriteria.SelectionCriteria;
|
||||
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import javax.persistence.criteria.Selection;
|
||||
|
||||
@JsonAutoDetect
|
||||
public class CommunityWritableProperties {
|
||||
|
||||
|
@ -36,7 +34,6 @@ public class CommunityWritableProperties {
|
|||
@Schema(description = "Advanced constraint for the association of results to the community")
|
||||
private SelectionCriteria advancedConstraint;
|
||||
|
||||
|
||||
@Schema(description = "status of the community, drives its visibility")
|
||||
private CommunityStatus status;
|
||||
|
||||
|
@ -62,7 +59,7 @@ public class CommunityWritableProperties {
|
|||
return fos;
|
||||
}
|
||||
|
||||
public void setFos(List<String> fos) {
|
||||
public void setFos(final List<String> fos) {
|
||||
this.fos = fos;
|
||||
}
|
||||
|
||||
|
@ -70,7 +67,7 @@ public class CommunityWritableProperties {
|
|||
return sdg;
|
||||
}
|
||||
|
||||
public void setSdg(List<String> sdg) {
|
||||
public void setSdg(final List<String> sdg) {
|
||||
this.sdg = sdg;
|
||||
}
|
||||
|
||||
|
@ -78,7 +75,7 @@ public class CommunityWritableProperties {
|
|||
return advancedConstraint;
|
||||
}
|
||||
|
||||
public void setAdvancedConstraint(SelectionCriteria advancedConstraint) {
|
||||
public void setAdvancedConstraint(final SelectionCriteria advancedConstraint) {
|
||||
this.advancedConstraint = advancedConstraint;
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.community;
|
||||
package eu.dnetlib.openaire.exporter.model.community;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.community.selectioncriteria;
|
||||
package eu.dnetlib.openaire.exporter.model.community.selectioncriteria;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.community.selectioncriteria;
|
||||
package eu.dnetlib.openaire.exporter.model.community.selectioncriteria;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
|
@ -1,10 +1,11 @@
|
|||
package eu.dnetlib.openaire.community.selectioncriteria;
|
||||
package eu.dnetlib.openaire.exporter.model.community.selectioncriteria;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.google.gson.Gson;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
@JsonAutoDetect
|
||||
public class SelectionCriteria implements Serializable {
|
||||
|
@ -27,7 +28,11 @@ public class SelectionCriteria implements Serializable {
|
|||
}
|
||||
|
||||
public static SelectionCriteria fromJson(final String json) {
|
||||
return new Gson().fromJson(json, SelectionCriteria.class);
|
||||
|
||||
try {
|
||||
return new ObjectMapper().readValue(json, SelectionCriteria.class);
|
||||
} catch (final JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.context;
|
||||
package eu.dnetlib.openaire.exporter.model.context;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.context;
|
||||
package eu.dnetlib.openaire.exporter.model.context;
|
||||
|
||||
public class CategorySummary {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.context;
|
||||
package eu.dnetlib.openaire.exporter.model.context;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.context;
|
||||
package eu.dnetlib.openaire.exporter.model.context;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.context;
|
||||
package eu.dnetlib.openaire.exporter.model.context;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -44,8 +44,6 @@ public class Context {
|
|||
return categories;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Context setId(final String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
|
@ -66,17 +64,15 @@ public class Context {
|
|||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Date getLastUpdateDate() {
|
||||
return lastUpdateDate;
|
||||
}
|
||||
|
||||
public Context setLastUpdateDate(Date lastUpdateDate) {
|
||||
public Context setLastUpdateDate(final Date lastUpdateDate) {
|
||||
this.lastUpdateDate = lastUpdateDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Context setParams(final Map<String, List<Param>> params) {
|
||||
this.params = params;
|
||||
return this;
|
||||
|
@ -88,4 +84,3 @@ public class Context {
|
|||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.context;
|
||||
package eu.dnetlib.openaire.exporter.model.context;
|
||||
|
||||
public class ContextSummary {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.context;
|
||||
package eu.dnetlib.openaire.exporter.model.context;
|
||||
|
||||
public class Param {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -1,11 +1,9 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
|
||||
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
|
||||
|
||||
@JsonAutoDetect
|
||||
public class AggregationHistoryResponseV2 extends Response {
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
public abstract class AggregationInfo {
|
||||
|
||||
private int numberOfRecords;
|
||||
|
||||
private String date;
|
||||
|
||||
private AggregationStage aggregationStage;
|
||||
|
||||
private boolean indexedVersion = false;
|
||||
|
||||
private boolean completedSuccessfully = true;
|
||||
|
||||
public AggregationInfo() {}
|
||||
|
||||
public int getNumberOfRecords() {
|
||||
return numberOfRecords;
|
||||
}
|
||||
|
||||
public void setNumberOfRecords(final int numberOfRecords) {
|
||||
this.numberOfRecords = numberOfRecords;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(final String date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public AggregationStage getAggregationStage() {
|
||||
return aggregationStage;
|
||||
}
|
||||
|
||||
public void setAggregationStage(final AggregationStage aggregationStage) {
|
||||
this.aggregationStage = aggregationStage;
|
||||
}
|
||||
|
||||
public boolean isIndexedVersion() {
|
||||
return indexedVersion;
|
||||
}
|
||||
|
||||
public void setIndexedVersion(final boolean indexedVersion) {
|
||||
this.indexedVersion = indexedVersion;
|
||||
}
|
||||
|
||||
public boolean isCompletedSuccessfully() {
|
||||
return completedSuccessfully;
|
||||
}
|
||||
|
||||
public void setCompletedSuccessfully(final boolean completedSuccessfully) {
|
||||
this.completedSuccessfully = completedSuccessfully;
|
||||
}
|
||||
}
|
|
@ -1,9 +1,7 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
|
||||
|
||||
public class AggregationInfoV1 extends AggregationInfo {
|
||||
|
||||
@Override
|
|
@ -0,0 +1,25 @@
|
|||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
public enum AggregationStage {
|
||||
|
||||
COLLECT,
|
||||
TRANSFORM;
|
||||
|
||||
public static AggregationStage parse(final String s) {
|
||||
switch (s) {
|
||||
case "collect":
|
||||
case "collection":
|
||||
case "COLLECT":
|
||||
case "COLLECTION":
|
||||
return AggregationStage.COLLECT;
|
||||
case "transform":
|
||||
case "transformation":
|
||||
case "TRANSFORM":
|
||||
case "TRANSFORMATION":
|
||||
case "transformDatasets":
|
||||
case "transformPublications":
|
||||
return AggregationStage.TRANSFORM;
|
||||
}
|
||||
throw new IllegalArgumentException("invalid AggregationStage: " + s);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.util.Set;
|
|
@ -1,12 +1,9 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
|
||||
@JsonAutoDetect
|
||||
public class ApiDetailsResponse extends Response {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
public class ApiParamDetails {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
|
|
@ -1,10 +1,7 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
|
||||
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
/**
|
||||
* Created by claudio on 29/11/2016.
|
||||
*/
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.util.Set;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.util.Set;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import java.sql.Date;
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
|
||||
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
@JsonAutoDetect
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
public enum FilterType {
|
||||
exact,
|
|
@ -1,13 +1,14 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
@JsonAutoDetect
|
||||
public class Header {
|
||||
|
@ -22,10 +23,8 @@ public class Header {
|
|||
|
||||
private int statusCode;
|
||||
|
||||
private List<String> errors = Lists.newArrayList();
|
||||
|
||||
@JsonIgnore
|
||||
private Queue<Throwable> exceptions = Lists.newLinkedList();
|
||||
private Queue<Throwable> exceptions = new LinkedList<>();
|
||||
|
||||
public static Header newInsance() {
|
||||
return new Header();
|
||||
|
@ -93,13 +92,12 @@ public class Header {
|
|||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Header setErrors(final List<String> errors) {
|
||||
this.errors = errors;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return new GsonBuilder().setPrettyPrinting().create().toJson(this);
|
||||
try {
|
||||
return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this);
|
||||
} catch (final JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
public class RegisteredDatasourceInfo {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.dsm.domain;
|
||||
package eu.dnetlib.openaire.exporter.model.dsm;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue