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>
|
||||
<artifactId>uoa-repository-manager-service</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
||||
<build>
|
||||
|
@ -218,11 +218,11 @@
|
|||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/cz.habarta.typescript-generator/typescript-generator-maven-plugin -->
|
||||
<dependency>
|
||||
<!--<dependency>
|
||||
<groupId>cz.habarta.typescript-generator</groupId>
|
||||
<artifactId>typescript-generator-maven-plugin</artifactId>
|
||||
<version>1.29.366</version>
|
||||
</dependency>
|
||||
</dependency>-->
|
||||
<!-- https://mvnrepository.com/artifact/postgresql/postgresql -->
|
||||
<dependency>
|
||||
<groupId>postgresql</groupId>
|
||||
|
|
|
@ -49,4 +49,9 @@ public interface BrokerApi {
|
|||
@RequestMapping(value = "/getDnetTopics" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
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.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
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.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
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
|
||||
.getLogger(BrokerApiImpl.class);
|
||||
|
||||
private RestTemplate restTemplate = null;
|
||||
|
||||
private HttpHeaders httpHeaders;
|
||||
|
||||
private HashMap<String,Term> topics = new HashMap<String, Term>();
|
||||
|
||||
@PostConstruct
|
||||
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!");
|
||||
InputStream is = null;
|
||||
try {
|
||||
|
@ -104,11 +115,9 @@ public class BrokerApiImpl implements BrokerApi {
|
|||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service)
|
||||
.queryParam("ds", datasourceName);
|
||||
|
||||
RestTemplate template = new RestTemplate();
|
||||
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
||||
ResponseEntity<List<BrowseEntry>> resp;
|
||||
try {
|
||||
resp = template.exchange(
|
||||
resp = restTemplate.exchange(
|
||||
builder.build().encode().toUri(),
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
|
@ -147,11 +156,9 @@ public class BrokerApiImpl implements BrokerApi {
|
|||
|
||||
HttpEntity<AdvQueryObject> entity = new HttpEntity<>(advQueryObject, headers);
|
||||
|
||||
RestTemplate template = new RestTemplate();
|
||||
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
||||
ResponseEntity<EventsPage> resp;
|
||||
try {
|
||||
resp = template.exchange(
|
||||
resp = restTemplate.exchange(
|
||||
builder.buildAndExpand(uriParams).encode().toUri(),
|
||||
HttpMethod.POST,
|
||||
entity,
|
||||
|
@ -231,13 +238,10 @@ public class BrokerApiImpl implements BrokerApi {
|
|||
.queryParam("topic", topic)
|
||||
.queryParam("page", page);
|
||||
|
||||
//create new template engine
|
||||
RestTemplate template = new RestTemplate();
|
||||
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
||||
ResponseEntity<EventsPage> resp;
|
||||
try {
|
||||
//communicate with endpoint
|
||||
resp = template.exchange(
|
||||
resp = restTemplate.exchange(
|
||||
builder.build().encode().toUri(),
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
|
@ -259,12 +263,10 @@ public class BrokerApiImpl implements BrokerApi {
|
|||
.queryParam("email", userEmail);
|
||||
|
||||
//create new template engine
|
||||
RestTemplate template = new RestTemplate();
|
||||
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
||||
ResponseEntity<Map<String, List<SimpleSubscriptionDesc>>> resp;
|
||||
try {
|
||||
//communicate with endpoint
|
||||
resp = template.exchange(
|
||||
resp = restTemplate.exchange(
|
||||
builder.build().encode().toUri(),
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
|
@ -284,10 +286,7 @@ public class BrokerApiImpl implements BrokerApi {
|
|||
//build the uri params
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service);
|
||||
|
||||
//Header info
|
||||
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
|
||||
headers.add("Content-Type", "application/json");
|
||||
HttpEntity<OpenaireSubscription> entity = new HttpEntity<>(obj, headers);
|
||||
HttpEntity<OpenaireSubscription> entity = new HttpEntity<>(obj, httpHeaders);
|
||||
|
||||
//create new template engine
|
||||
RestTemplate template = new RestTemplate();
|
||||
|
@ -295,7 +294,7 @@ public class BrokerApiImpl implements BrokerApi {
|
|||
ResponseEntity<Subscription> resp;
|
||||
try {
|
||||
//communicate with endpoint
|
||||
resp = template.exchange(
|
||||
resp = restTemplate.exchange(
|
||||
builder.build().encode().toUri(),
|
||||
HttpMethod.POST,
|
||||
entity,
|
||||
|
@ -315,12 +314,9 @@ public class BrokerApiImpl implements BrokerApi {
|
|||
//build the uri params
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(apiPath + service);
|
||||
|
||||
//create new template engine
|
||||
RestTemplate template = new RestTemplate();
|
||||
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
||||
try {
|
||||
//communicate with endpoint
|
||||
template.exchange(
|
||||
restTemplate.exchange(
|
||||
builder.build().encode().toUri(),
|
||||
HttpMethod.DELETE,
|
||||
null,
|
||||
|
@ -338,13 +334,10 @@ public class BrokerApiImpl implements BrokerApi {
|
|||
//build the uri params
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(apiPath + service);
|
||||
|
||||
//create new template engine
|
||||
RestTemplate template = new RestTemplate();
|
||||
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
||||
ResponseEntity<Subscription> resp;
|
||||
try {
|
||||
//communicate with endpoint
|
||||
resp = template.exchange(
|
||||
resp = restTemplate.exchange(
|
||||
builder.build().encode().toUri(),
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
|
@ -361,5 +354,30 @@ public class BrokerApiImpl implements BrokerApi {
|
|||
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.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-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-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" />
|
||||
|
||||
<bean class="eu.dnetlib.repo.manager.service.config.CascadingPropertyLoader" id="propertyLoader">
|
||||
|
|
Loading…
Reference in New Issue