removed dependency to cnr-api
This commit is contained in:
parent
81da6cfd58
commit
99b8fbfdfb
12
pom.xml
12
pom.xml
|
@ -144,18 +144,6 @@
|
|||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- DNET RMI API -->
|
||||
<dependency>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>cnr-rmi-api</artifactId>
|
||||
<version>${cnr-rmi-api.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-transports-http</artifactId>
|
||||
<version>3.1.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- DHP SCHEMAS -->
|
||||
<dependency>
|
||||
<groupId>eu.dnetlib.dhp</groupId>
|
||||
|
|
|
@ -7,11 +7,6 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.cxf.endpoint.Client;
|
||||
import org.apache.cxf.frontend.ClientProxy;
|
||||
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
|
||||
import org.apache.cxf.transport.http.HTTPConduit;
|
||||
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
|
@ -26,7 +21,6 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
|
||||
import io.micrometer.core.instrument.ImmutableTag;
|
||||
import io.micrometer.core.instrument.Metrics;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
|
@ -123,28 +117,4 @@ public class DirectIndexApplication {
|
|||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ISLookUpService lookupServiceStub() {
|
||||
|
||||
log.info(String.format("creating stub for ISLookUpService from %s", isLookupUrl));
|
||||
|
||||
final JaxWsProxyFactoryBean jaxWsProxyFactory = new JaxWsProxyFactoryBean();
|
||||
jaxWsProxyFactory.setServiceClass(ISLookUpService.class);
|
||||
jaxWsProxyFactory.setAddress(isLookupUrl);
|
||||
final ISLookUpService service = (ISLookUpService) jaxWsProxyFactory.create();
|
||||
|
||||
final Client client = ClientProxy.getClient(service);
|
||||
if (client != null) {
|
||||
final HTTPConduit conduit = (HTTPConduit) client.getConduit();
|
||||
final HTTPClientPolicy policy = new HTTPClientPolicy();
|
||||
|
||||
policy.setConnectionTimeout(isLookupConnectTimeout);
|
||||
policy.setReceiveTimeout(isLookupRequestTimeout);
|
||||
|
||||
conduit.setClient(policy);
|
||||
}
|
||||
|
||||
return service;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package eu.dnetlib.app.directindex.clients;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -14,7 +16,6 @@ import org.springframework.web.client.RestClientException;
|
|||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import eu.dnetlib.app.directindex.errors.DirectIndexApiException;
|
||||
import eu.dnetlib.app.directindex.input.ZenodoContextList;
|
||||
|
||||
@Component
|
||||
public class CommunityClient {
|
||||
|
@ -23,23 +24,53 @@ public class CommunityClient {
|
|||
|
||||
private static final Log log = LogFactory.getLog(CommunityClient.class);
|
||||
|
||||
@Value("${dnet.directindex.community.url")
|
||||
@Value("${dnet.directindex.community.url}")
|
||||
private String communityApiUrl;
|
||||
|
||||
@Cacheable("communities")
|
||||
public Collection<String> translateZenodoCommunity(final String community) throws DirectIndexApiException {
|
||||
if (!community.contains(ZENODO_COMMUNITY)) { return Arrays.asList(community); }
|
||||
|
||||
final String context = community.substring(community.lastIndexOf("/") + 1);
|
||||
final RestTemplate rt = new RestTemplate();
|
||||
|
||||
final String url = communityApiUrl + "/" + context + "/openairecommunities";
|
||||
try {
|
||||
return new HashSet<>(rt.getForObject(communityApiUrl + context + "/openairecommunities", ZenodoContextList.class)
|
||||
.getOpenAirecommunitylist());
|
||||
return new HashSet<>(rt.getForObject(url, ZenodoContextList.class).getOpenAirecommunitylist());
|
||||
} catch (final RestClientException e) {
|
||||
log.error("Unable to get object for " + communityApiUrl + context + "/openairecommunities", e);
|
||||
throw new DirectIndexApiException("Unable to get object for " + communityApiUrl + context + "/openairecommunities", e);
|
||||
log.error("Unable to get object for url: " + url, e);
|
||||
throw new DirectIndexApiException("Unable to get object for url: " + url, e);
|
||||
}
|
||||
}
|
||||
|
||||
@CacheEvict(value = "communities", allEntries = true)
|
||||
public void clearCache() {}
|
||||
|
||||
public class ZenodoContextList implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8575901008472098218L;
|
||||
|
||||
private String zenodoid;
|
||||
|
||||
private List<String> openAirecommunitylist;
|
||||
|
||||
public List<String> getOpenAirecommunitylist() {
|
||||
return openAirecommunitylist;
|
||||
}
|
||||
|
||||
public void setOpenAirecommunitylist(final List<String> openAirecommunitylist) {
|
||||
this.openAirecommunitylist = openAirecommunitylist;
|
||||
|
||||
}
|
||||
|
||||
public String getZenodoid() {
|
||||
return zenodoid;
|
||||
}
|
||||
|
||||
public void setZenodoid(final String zenodoid) {
|
||||
this.zenodoid = zenodoid;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import eu.dnetlib.app.directindex.input.DatasourceEntry;
|
|||
@Component
|
||||
public class DatasourceManagerClient {
|
||||
|
||||
@Value("${dnet.directindex.dsm.url")
|
||||
@Value("${dnet.directindex.dsm.url}")
|
||||
private String dsmApiUrl;
|
||||
|
||||
private static final Log log = LogFactory.getLog(DatasourceManagerClient.class);
|
||||
|
@ -40,7 +40,7 @@ public class DatasourceManagerClient {
|
|||
.orElse(DatasourceEntry.UNKNOWN_DATASOURCE);
|
||||
|
||||
} catch (final RestClientException rce) {
|
||||
log.warn("Unable to obtainn datasource: " + dsId, rce);
|
||||
log.warn("Unable to obtain datasource: " + dsId, rce);
|
||||
throw new DirectIndexApiException("Unable to obtainn datasource: " + dsId, rce);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,52 +1,149 @@
|
|||
package eu.dnetlib.app.directindex.clients;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import eu.dnetlib.app.directindex.errors.DirectIndexApiException;
|
||||
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
|
||||
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
|
||||
|
||||
@Component
|
||||
public class VocabularyClient {
|
||||
|
||||
private static final Log log = LogFactory.getLog(VocabularyClient.class);
|
||||
|
||||
@Autowired
|
||||
private ISLookUpService lookupService;
|
||||
@Value("${dnet.directindex.vocabulary.url}")
|
||||
private String vocApiUrl;
|
||||
|
||||
@Cacheable("vocabularies")
|
||||
public Map<String, String> findVocabulary(final String voc) throws DirectIndexApiException {
|
||||
|
||||
final String query = "collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType')[.//VOCABULARY_NAME/@code='" + voc
|
||||
+ "']//TERM/concat(@code, ' @@@ ', @english_name)";
|
||||
final String url = vocApiUrl + "/" + voc + ".json";
|
||||
|
||||
final Map<String, String> map = new HashMap<>();
|
||||
for (final String s : find(query)) {
|
||||
final String[] arr = s.split("@@@");
|
||||
map.put(arr[0].trim(), arr[1].trim());
|
||||
final RestTemplate rt = new RestTemplate();
|
||||
try {
|
||||
final Map<String, String> map = new HashMap<>();
|
||||
for (final VocTerm term : rt.getForObject(url, Vocabulary.class).getTerms()) {
|
||||
map.put(term.getCode(), term.getEnglishName());
|
||||
}
|
||||
return map;
|
||||
} catch (final RestClientException e) {
|
||||
log.error("Unable to get vocabulary, url: " + url, e);
|
||||
throw new DirectIndexApiException("Unable to get vocabulary, url: " + url, e);
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@CacheEvict(value = "vocabularies", allEntries = true)
|
||||
public void clearCache() {}
|
||||
|
||||
private List<String> find(final String query) throws DirectIndexApiException {
|
||||
try {
|
||||
return lookupService.quickSearchProfile(query);
|
||||
} catch (final ISLookUpException e) {
|
||||
log.error("Error executing xquery: " + query, e);
|
||||
throw new DirectIndexApiException("Error executing xquery: " + query, e);
|
||||
public class Vocabulary implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -865664758603896385L;
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String description;
|
||||
private String code;
|
||||
private List<VocTerm> terms;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(final String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(final String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(final String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public List<VocTerm> getTerms() {
|
||||
return terms;
|
||||
}
|
||||
|
||||
public void setTerms(final List<VocTerm> terms) {
|
||||
this.terms = terms;
|
||||
}
|
||||
}
|
||||
|
||||
public class VocTerm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1618105318956602387L;
|
||||
|
||||
private String englishName;
|
||||
private String nativeName;
|
||||
private String encoding;
|
||||
private String code;
|
||||
private List<?> synonyms;
|
||||
|
||||
public String getEnglishName() {
|
||||
return englishName;
|
||||
}
|
||||
|
||||
public void setEnglishName(final String englishName) {
|
||||
this.englishName = englishName;
|
||||
}
|
||||
|
||||
public String getNativeName() {
|
||||
return nativeName;
|
||||
}
|
||||
|
||||
public void setNativeName(final String nativeName) {
|
||||
this.nativeName = nativeName;
|
||||
}
|
||||
|
||||
public String getEncoding() {
|
||||
return encoding;
|
||||
}
|
||||
|
||||
public void setEncoding(final String encoding) {
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(final String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public List<?> getSynonyms() {
|
||||
return synonyms;
|
||||
}
|
||||
|
||||
public void setSynonyms(final List<?> synonyms) {
|
||||
this.synonyms = synonyms;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,18 +31,14 @@ public class ResultEntry implements Serializable {
|
|||
private String language;
|
||||
private List<PidEntry> pids = new ArrayList<>();
|
||||
|
||||
@Schema(requiredMode = RequiredMode.REQUIRED, allowableValues = {
|
||||
"OPEN", "CLOSED", "RESTRICTED", "EMBARGO", "UNKNOWN", "OTHER", "OPEN SOURCE"
|
||||
})
|
||||
@Schema(requiredMode = RequiredMode.REQUIRED, allowableValues = { "OPEN", "CLOSED", "RESTRICTED", "EMBARGO", "UNKNOWN", "OTHER", "OPEN SOURCE" })
|
||||
private String accessRightCode;
|
||||
private String embargoEndDate;
|
||||
|
||||
/**
|
||||
* One of publication, dataset, software, other. Default value is publication.
|
||||
*/
|
||||
@Schema(allowableValues = {
|
||||
"publication", "dataset", "software", "other"
|
||||
})
|
||||
@Schema(allowableValues = { "publication", "dataset", "software", "other" })
|
||||
private String type = "publication";
|
||||
|
||||
@Schema(requiredMode = RequiredMode.REQUIRED, description = "Use 001 for articles, 021 for datasets, 0029 for software. See: http://api.openaire.eu/vocabularies/dnet:publication_resource for all the available resource types.")
|
||||
|
@ -133,11 +129,6 @@ public class ResultEntry implements Serializable {
|
|||
this.pids = pids;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set required = true when the deprecated licenseCode is not used anymore by our client and it is removed
|
||||
*
|
||||
* @return access rights code
|
||||
*/
|
||||
public String getAccessRightCode() {
|
||||
return accessRightCode;
|
||||
}
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
package eu.dnetlib.app.directindex.input;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ZenodoContextList implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8575901008472098218L;
|
||||
|
||||
private String zenodoid;
|
||||
|
||||
private List<String> openAirecommunitylist;
|
||||
|
||||
public List<String> getOpenAirecommunitylist() {
|
||||
return openAirecommunitylist;
|
||||
}
|
||||
|
||||
public void setOpenAirecommunitylist(final List<String> openAirecommunitylist) {
|
||||
this.openAirecommunitylist = openAirecommunitylist;
|
||||
|
||||
}
|
||||
|
||||
public String getZenodoid() {
|
||||
return zenodoid;
|
||||
}
|
||||
|
||||
public void setZenodoid(final String zenodoid) {
|
||||
this.zenodoid = zenodoid;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,21 +1,19 @@
|
|||
server.port=8080
|
||||
|
||||
dnet.directindex.baseurl = http://localhost:8280
|
||||
|
||||
dnet.directindex.scheduling.enabled}")
|
||||
|
||||
dnet.directindex.baseurl = http://localhost:8080
|
||||
dnet.directindex.title = D-Net Direct Index Service
|
||||
dnet.directindex.description = Service that permits the indexing according to the SWORD v.3 protocol
|
||||
|
||||
dnet.directindex.scheduling.enabled = false
|
||||
dnet.directindex.legacy.enabled=true
|
||||
dnet.directindex.sword.enabled=false
|
||||
dnet.directindex.legacy.enabled = true
|
||||
dnet.directindex.sword.enabled = false
|
||||
|
||||
dnet.directindex.solr.collection =
|
||||
dnet.directindex.solr.url =
|
||||
dnet.directindex.community.url =
|
||||
dnet.directindex.dsm.url =
|
||||
|
||||
dnet.directindex.solr.collection =
|
||||
|
||||
dnet.directindex.community.url = https://services.openaire.eu/openaire/community
|
||||
dnet.directindex.dsm.url = https://services.openaire.eu/openaire/ds
|
||||
dnet.directindex.vocabulary.url = https://services.openaire.eu/provision/mvc/vocabularies
|
||||
|
||||
spring.profiles.active=dev
|
||||
|
||||
|
|
Loading…
Reference in New Issue