1. Add a get notifications method by subscription id
This commit is contained in:
parent
f3e55be459
commit
aba8bcf807
6
pom.xml
6
pom.xml
|
@ -12,7 +12,7 @@
|
||||||
<groupId>eu.dnetlib</groupId>
|
<groupId>eu.dnetlib</groupId>
|
||||||
<artifactId>uoa-repository-manager-service</artifactId>
|
<artifactId>uoa-repository-manager-service</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
<packaging>war</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -218,11 +218,11 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/cz.habarta.typescript-generator/typescript-generator-maven-plugin -->
|
<!-- https://mvnrepository.com/artifact/cz.habarta.typescript-generator/typescript-generator-maven-plugin -->
|
||||||
<dependency>
|
<!--<dependency>
|
||||||
<groupId>cz.habarta.typescript-generator</groupId>
|
<groupId>cz.habarta.typescript-generator</groupId>
|
||||||
<artifactId>typescript-generator-maven-plugin</artifactId>
|
<artifactId>typescript-generator-maven-plugin</artifactId>
|
||||||
<version>1.29.366</version>
|
<version>1.29.366</version>
|
||||||
</dependency>
|
</dependency>-->
|
||||||
<!-- https://mvnrepository.com/artifact/postgresql/postgresql -->
|
<!-- https://mvnrepository.com/artifact/postgresql/postgresql -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>postgresql</groupId>
|
<groupId>postgresql</groupId>
|
||||||
|
|
|
@ -49,4 +49,9 @@ public interface BrokerApi {
|
||||||
@RequestMapping(value = "/getDnetTopics" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/getDnetTopics" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
Map<String, Term> getDnetTopics() throws BrokerException;
|
Map<String, Term> getDnetTopics() throws BrokerException;
|
||||||
|
|
||||||
|
@RequestMapping(value = "/getNotificationsBySubscriptionId/{subscriptionId}/{page}/{size}" , method = RequestMethod.GET
|
||||||
|
,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
@ResponseBody
|
||||||
|
EventsPage getNotificationsBySubscriptionId(String subscriptionId,String page,String size) throws BrokerException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.core.ParameterizedTypeReference;
|
import org.springframework.core.ParameterizedTypeReference;
|
||||||
import org.springframework.http.HttpEntity;
|
import org.springframework.http.HttpEntity;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||||
|
@ -22,6 +23,7 @@ import org.springframework.util.MultiValueMap;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.client.RestClientException;
|
import org.springframework.web.client.RestClientException;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
import org.springframework.web.util.UriComponents;
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
@ -45,12 +47,21 @@ public class BrokerApiImpl implements BrokerApi {
|
||||||
private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger
|
private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger
|
||||||
.getLogger(BrokerApiImpl.class);
|
.getLogger(BrokerApiImpl.class);
|
||||||
|
|
||||||
|
private RestTemplate restTemplate = null;
|
||||||
|
|
||||||
|
private HttpHeaders httpHeaders;
|
||||||
|
|
||||||
private HashMap<String,Term> topics = new HashMap<String, Term>();
|
private HashMap<String,Term> topics = new HashMap<String, Term>();
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
private void initDnetTopicsMap() {
|
private void initDnetTopicsMap() {
|
||||||
|
|
||||||
|
restTemplate = new RestTemplate();
|
||||||
|
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
||||||
|
|
||||||
|
httpHeaders = new HttpHeaders();
|
||||||
|
httpHeaders.set("Content-Type", "application/json");
|
||||||
|
|
||||||
LOGGER.debug("Init dnet topics!");
|
LOGGER.debug("Init dnet topics!");
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
try {
|
try {
|
||||||
|
@ -104,11 +115,9 @@ public class BrokerApiImpl implements BrokerApi {
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service)
|
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service)
|
||||||
.queryParam("ds", datasourceName);
|
.queryParam("ds", datasourceName);
|
||||||
|
|
||||||
RestTemplate template = new RestTemplate();
|
|
||||||
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
|
||||||
ResponseEntity<List<BrowseEntry>> resp;
|
ResponseEntity<List<BrowseEntry>> resp;
|
||||||
try {
|
try {
|
||||||
resp = template.exchange(
|
resp = restTemplate.exchange(
|
||||||
builder.build().encode().toUri(),
|
builder.build().encode().toUri(),
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
null,
|
null,
|
||||||
|
@ -147,11 +156,9 @@ public class BrokerApiImpl implements BrokerApi {
|
||||||
|
|
||||||
HttpEntity<AdvQueryObject> entity = new HttpEntity<>(advQueryObject, headers);
|
HttpEntity<AdvQueryObject> entity = new HttpEntity<>(advQueryObject, headers);
|
||||||
|
|
||||||
RestTemplate template = new RestTemplate();
|
|
||||||
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
|
||||||
ResponseEntity<EventsPage> resp;
|
ResponseEntity<EventsPage> resp;
|
||||||
try {
|
try {
|
||||||
resp = template.exchange(
|
resp = restTemplate.exchange(
|
||||||
builder.buildAndExpand(uriParams).encode().toUri(),
|
builder.buildAndExpand(uriParams).encode().toUri(),
|
||||||
HttpMethod.POST,
|
HttpMethod.POST,
|
||||||
entity,
|
entity,
|
||||||
|
@ -231,13 +238,10 @@ public class BrokerApiImpl implements BrokerApi {
|
||||||
.queryParam("topic", topic)
|
.queryParam("topic", topic)
|
||||||
.queryParam("page", page);
|
.queryParam("page", page);
|
||||||
|
|
||||||
//create new template engine
|
|
||||||
RestTemplate template = new RestTemplate();
|
|
||||||
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
|
||||||
ResponseEntity<EventsPage> resp;
|
ResponseEntity<EventsPage> resp;
|
||||||
try {
|
try {
|
||||||
//communicate with endpoint
|
//communicate with endpoint
|
||||||
resp = template.exchange(
|
resp = restTemplate.exchange(
|
||||||
builder.build().encode().toUri(),
|
builder.build().encode().toUri(),
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
null,
|
null,
|
||||||
|
@ -259,12 +263,10 @@ public class BrokerApiImpl implements BrokerApi {
|
||||||
.queryParam("email", userEmail);
|
.queryParam("email", userEmail);
|
||||||
|
|
||||||
//create new template engine
|
//create new template engine
|
||||||
RestTemplate template = new RestTemplate();
|
|
||||||
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
|
||||||
ResponseEntity<Map<String, List<SimpleSubscriptionDesc>>> resp;
|
ResponseEntity<Map<String, List<SimpleSubscriptionDesc>>> resp;
|
||||||
try {
|
try {
|
||||||
//communicate with endpoint
|
//communicate with endpoint
|
||||||
resp = template.exchange(
|
resp = restTemplate.exchange(
|
||||||
builder.build().encode().toUri(),
|
builder.build().encode().toUri(),
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
null,
|
null,
|
||||||
|
@ -284,10 +286,7 @@ public class BrokerApiImpl implements BrokerApi {
|
||||||
//build the uri params
|
//build the uri params
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service);
|
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service);
|
||||||
|
|
||||||
//Header info
|
HttpEntity<OpenaireSubscription> entity = new HttpEntity<>(obj, httpHeaders);
|
||||||
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
|
|
||||||
headers.add("Content-Type", "application/json");
|
|
||||||
HttpEntity<OpenaireSubscription> entity = new HttpEntity<>(obj, headers);
|
|
||||||
|
|
||||||
//create new template engine
|
//create new template engine
|
||||||
RestTemplate template = new RestTemplate();
|
RestTemplate template = new RestTemplate();
|
||||||
|
@ -295,7 +294,7 @@ public class BrokerApiImpl implements BrokerApi {
|
||||||
ResponseEntity<Subscription> resp;
|
ResponseEntity<Subscription> resp;
|
||||||
try {
|
try {
|
||||||
//communicate with endpoint
|
//communicate with endpoint
|
||||||
resp = template.exchange(
|
resp = restTemplate.exchange(
|
||||||
builder.build().encode().toUri(),
|
builder.build().encode().toUri(),
|
||||||
HttpMethod.POST,
|
HttpMethod.POST,
|
||||||
entity,
|
entity,
|
||||||
|
@ -315,12 +314,9 @@ public class BrokerApiImpl implements BrokerApi {
|
||||||
//build the uri params
|
//build the uri params
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(apiPath + service);
|
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(apiPath + service);
|
||||||
|
|
||||||
//create new template engine
|
|
||||||
RestTemplate template = new RestTemplate();
|
|
||||||
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
|
||||||
try {
|
try {
|
||||||
//communicate with endpoint
|
//communicate with endpoint
|
||||||
template.exchange(
|
restTemplate.exchange(
|
||||||
builder.build().encode().toUri(),
|
builder.build().encode().toUri(),
|
||||||
HttpMethod.DELETE,
|
HttpMethod.DELETE,
|
||||||
null,
|
null,
|
||||||
|
@ -338,13 +334,10 @@ public class BrokerApiImpl implements BrokerApi {
|
||||||
//build the uri params
|
//build the uri params
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(apiPath + service);
|
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(apiPath + service);
|
||||||
|
|
||||||
//create new template engine
|
|
||||||
RestTemplate template = new RestTemplate();
|
|
||||||
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
|
||||||
ResponseEntity<Subscription> resp;
|
ResponseEntity<Subscription> resp;
|
||||||
try {
|
try {
|
||||||
//communicate with endpoint
|
//communicate with endpoint
|
||||||
resp = template.exchange(
|
resp = restTemplate.exchange(
|
||||||
builder.build().encode().toUri(),
|
builder.build().encode().toUri(),
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
null,
|
null,
|
||||||
|
@ -361,5 +354,30 @@ public class BrokerApiImpl implements BrokerApi {
|
||||||
return topics;
|
return topics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EventsPage getNotificationsBySubscriptionId(@PathVariable("subscriptionId") String subscriptionId,
|
||||||
|
@PathVariable("page") String page,
|
||||||
|
@PathVariable("size") String size
|
||||||
|
) throws BrokerException {
|
||||||
|
|
||||||
|
UriComponents uriComponents = UriComponentsBuilder
|
||||||
|
.fromHttpUrl(apiPath + "/openaireBroker/notifications/")
|
||||||
|
.path("/{id}/{page}/{size}/")
|
||||||
|
.build().expand(subscriptionId,page, size).encode();
|
||||||
|
|
||||||
|
ResponseEntity<EventsPage> resp;
|
||||||
|
try {
|
||||||
|
resp = restTemplate.exchange(
|
||||||
|
uriComponents.toUri(),
|
||||||
|
HttpMethod.GET,
|
||||||
|
null,
|
||||||
|
new ParameterizedTypeReference<EventsPage>() {
|
||||||
|
});
|
||||||
|
} catch (RestClientException e) {
|
||||||
|
throw new BrokerException(e);
|
||||||
|
}
|
||||||
|
return resp.getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
<!-- <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>-->
|
<!-- <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>-->
|
||||||
|
|
||||||
<import resource="classpath:META-INF/cxf/cxf.xml"/>
|
<!--<import resource="classpath:META-INF/cxf/cxf.xml"/>
|
||||||
|
|
||||||
<import resource="classpath:META-INF/cxf/cxf-extension-jaxws.xml"/>
|
<import resource="classpath:META-INF/cxf/cxf-extension-jaxws.xml"/>
|
||||||
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
|
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
<import resource="classpath*:/gr/uoa/di/driver/app/springContext-commons.xml"/>
|
<import resource="classpath*:/gr/uoa/di/driver/app/springContext-commons.xml"/>
|
||||||
<import resource="classpath*:/gr/uoa/di/driver/app/springContext-registrator.xml"/>
|
<import resource="classpath*:/gr/uoa/di/driver/app/springContext-registrator.xml"/>
|
||||||
|
|
||||||
<import resource="classpath*:/eu/dnetlib/repos/springContext-repos-dms-cached.xml"/>
|
<import resource="classpath*:/eu/dnetlib/repos/springContext-repos-dms-cached.xml"/>-->
|
||||||
<context:property-placeholder location="classpath*:/eu/**/application.properties" />
|
<context:property-placeholder location="classpath*:/eu/**/application.properties" />
|
||||||
|
|
||||||
<bean class="eu.dnetlib.repo.manager.service.config.CascadingPropertyLoader" id="propertyLoader">
|
<bean class="eu.dnetlib.repo.manager.service.config.CascadingPropertyLoader" id="propertyLoader">
|
||||||
|
|
Loading…
Reference in New Issue