1 |
54525
|
panagiotis
|
package eu.dnetlib.repo.manager.controllers;
|
2 |
49236
|
panagiotis
|
|
3 |
54690
|
panagiotis
|
import eu.dnetlib.repo.manager.service.BrokerServiceImpl;
|
4 |
49763
|
panagiotis
|
import eu.dnetlib.repo.manager.shared.BrokerException;
|
5 |
50319
|
panagiotis
|
import eu.dnetlib.repo.manager.shared.Term;
|
6 |
49868
|
panagiotis
|
import eu.dnetlib.repo.manager.shared.broker.*;
|
7 |
54525
|
panagiotis
|
import io.swagger.annotations.Api;
|
8 |
50686
|
panagiotis
|
import io.swagger.annotations.ApiParam;
|
9 |
49362
|
panagiotis
|
import org.json.JSONException;
|
10 |
49236
|
panagiotis
|
import org.springframework.beans.factory.annotation.Autowired;
|
11 |
54525
|
panagiotis
|
import org.springframework.http.MediaType;
|
12 |
|
|
import org.springframework.http.ResponseEntity;
|
13 |
51656
|
panagiotis
|
import org.springframework.security.access.prepost.PreAuthorize;
|
14 |
54525
|
panagiotis
|
import org.springframework.web.bind.annotation.*;
|
15 |
49236
|
panagiotis
|
|
16 |
49868
|
panagiotis
|
import java.io.IOException;
|
17 |
54525
|
panagiotis
|
import java.util.List;
|
18 |
|
|
import java.util.Map;
|
19 |
49236
|
panagiotis
|
|
20 |
54525
|
panagiotis
|
@RestController
|
21 |
|
|
@RequestMapping(value = "/broker")
|
22 |
|
|
@Api(description = "Broker API", tags = {"broker"})
|
23 |
|
|
public class BrokerController{
|
24 |
49236
|
panagiotis
|
|
25 |
|
|
@Autowired
|
26 |
54690
|
panagiotis
|
BrokerServiceImpl brokerService;
|
27 |
49236
|
panagiotis
|
|
28 |
49868
|
panagiotis
|
|
29 |
54525
|
panagiotis
|
@RequestMapping(value = "/getDatasourcesOfUser" , method = RequestMethod.GET,
|
30 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
31 |
|
|
@ResponseBody
|
32 |
51656
|
panagiotis
|
@PreAuthorize("hasRole('ROLE_USER')")
|
33 |
54525
|
panagiotis
|
DatasourcesBroker getDatasourcesOfUser(@RequestParam("user")
|
34 |
|
|
@ApiParam(value = "User email", required = true) String user,
|
35 |
|
|
@RequestParam("includeShared")
|
36 |
|
|
@ApiParam(value = "Include shared datasources", required = true , defaultValue = "false") String includeShared,
|
37 |
|
|
@RequestParam("includeByOthers")
|
38 |
|
|
@ApiParam(value = "Include datasources of other", required = true,defaultValue = "false") String includeByOthers) throws JSONException {
|
39 |
54690
|
panagiotis
|
return brokerService.getDatasourcesOfUser(user, includeShared, includeByOthers);
|
40 |
49236
|
panagiotis
|
}
|
41 |
|
|
|
42 |
54525
|
panagiotis
|
@RequestMapping(value = "/getTopicsForDatasource/{datasourceName:.+}" ,
|
43 |
|
|
method = RequestMethod.GET,
|
44 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
45 |
|
|
@ResponseBody
|
46 |
|
|
List<BrowseEntry> getTopicsForDatasource(@PathVariable("datasourceName") String datasourceName) throws BrokerException{
|
47 |
54690
|
panagiotis
|
return brokerService.getTopicsForDatasource(datasourceName);
|
48 |
49245
|
panagiotis
|
}
|
49 |
|
|
|
50 |
54525
|
panagiotis
|
@RequestMapping(value = "/advancedShowEvents/{page}/{size}" ,
|
51 |
|
|
method = RequestMethod.POST,
|
52 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
53 |
|
|
@ResponseBody
|
54 |
51656
|
panagiotis
|
@PreAuthorize("hasRole('ROLE_USER')")
|
55 |
54525
|
panagiotis
|
EventsPage advancedShowEvents(@PathVariable("page") String page,
|
56 |
|
|
@PathVariable("size") String size,
|
57 |
|
|
@RequestBody AdvQueryObject advQueryObject) throws BrokerException, JSONException ,IOException{
|
58 |
54690
|
panagiotis
|
return brokerService.advancedShowEvents(page, size, advQueryObject);
|
59 |
49245
|
panagiotis
|
}
|
60 |
|
|
|
61 |
54525
|
panagiotis
|
@RequestMapping(value = "/showEvents/{datasourceName:.+}/{topic}/{page}" ,
|
62 |
|
|
method = RequestMethod.GET,
|
63 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
64 |
|
|
@ResponseBody
|
65 |
51656
|
panagiotis
|
@PreAuthorize("hasRole('ROLE_USER')")
|
66 |
54525
|
panagiotis
|
EventsPage showEvents(@RequestParam("datasourceName") String datasourceName,
|
67 |
|
|
@RequestParam("topic") String topic,
|
68 |
|
|
@RequestParam("page") String page,
|
69 |
|
|
@RequestParam("size") String size) throws BrokerException, JSONException{
|
70 |
54690
|
panagiotis
|
return brokerService.showEvents(datasourceName, topic, page, size);
|
71 |
49852
|
panagiotis
|
}
|
72 |
|
|
|
73 |
54525
|
panagiotis
|
@RequestMapping(value = "/getSimpleSubscriptionsOfUser/{userEmail}" ,
|
74 |
|
|
method = RequestMethod.GET,
|
75 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
76 |
|
|
@ResponseBody
|
77 |
51656
|
panagiotis
|
@PreAuthorize("hasRole('ROLE_USER')")
|
78 |
54525
|
panagiotis
|
Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser(@PathVariable("userEmail") String userEmail) throws BrokerException{
|
79 |
54690
|
panagiotis
|
return brokerService.getSimpleSubscriptionsOfUser(userEmail);
|
80 |
49868
|
panagiotis
|
}
|
81 |
|
|
|
82 |
54525
|
panagiotis
|
@RequestMapping(value = "/subscribe" , method = RequestMethod.POST,
|
83 |
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
84 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
85 |
|
|
@ResponseBody
|
86 |
52781
|
panagiotis
|
@PreAuthorize("hasRole('ROLE_USER') ")
|
87 |
54525
|
panagiotis
|
Subscription subscribe(@RequestBody OpenaireSubscription obj) throws BrokerException{
|
88 |
54690
|
panagiotis
|
return brokerService.subscribe(obj);
|
89 |
49868
|
panagiotis
|
}
|
90 |
|
|
|
91 |
54525
|
panagiotis
|
@RequestMapping(value = "/unsubscribe/{subscriptionId}" , method = RequestMethod.POST,
|
92 |
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
93 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
94 |
|
|
@ResponseBody
|
95 |
51656
|
panagiotis
|
@PreAuthorize("hasRole('ROLE_USER')")
|
96 |
54525
|
panagiotis
|
ResponseEntity<Object> unsubscribe(@PathVariable("subscriptionId") String subscriptionId) throws BrokerException{
|
97 |
54690
|
panagiotis
|
return brokerService.unsubscribe(subscriptionId);
|
98 |
49868
|
panagiotis
|
}
|
99 |
|
|
|
100 |
54525
|
panagiotis
|
@RequestMapping(value = "/getSubscription/{subscriptionId}" , method = RequestMethod.GET,
|
101 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
102 |
|
|
@ResponseBody
|
103 |
51656
|
panagiotis
|
@PreAuthorize("hasRole('ROLE_USER')")
|
104 |
54525
|
panagiotis
|
Subscription getSubscription(@PathVariable("subscriptionId") String subscriptionId) throws BrokerException{
|
105 |
54690
|
panagiotis
|
return brokerService.getSubscription(subscriptionId);
|
106 |
54525
|
panagiotis
|
}
|
107 |
49868
|
panagiotis
|
|
108 |
|
|
|
109 |
54525
|
panagiotis
|
@RequestMapping(value = "/getDnetTopics" , method = RequestMethod.GET,
|
110 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
111 |
|
|
@ResponseBody
|
112 |
|
|
Map<String, Term> getDnetTopics() throws BrokerException{
|
113 |
54690
|
panagiotis
|
return brokerService.getDnetTopics();
|
114 |
49868
|
panagiotis
|
}
|
115 |
|
|
|
116 |
54525
|
panagiotis
|
@RequestMapping(value = "/getNotificationsBySubscriptionId/{subscriptionId}/{page}/{size}" , method = RequestMethod.GET
|
117 |
|
|
,produces = MediaType.APPLICATION_JSON_VALUE)
|
118 |
|
|
@ResponseBody
|
119 |
51656
|
panagiotis
|
@PreAuthorize("hasRole('ROLE_USER')")
|
120 |
54525
|
panagiotis
|
EventsPage getNotificationsBySubscriptionId(@PathVariable("subscriptionId") String subscriptionId,
|
121 |
|
|
@PathVariable("page") String page,
|
122 |
|
|
@PathVariable("size") String size) throws BrokerException{
|
123 |
54690
|
panagiotis
|
return brokerService.getNotificationsBySubscriptionId(subscriptionId, page, size);
|
124 |
50383
|
panagiotis
|
}
|
125 |
|
|
|
126 |
54525
|
panagiotis
|
/*@RequestMapping(value = "/getSubscriptionsOfUser/{userEmail}" , method = RequestMethod.GET
|
127 |
|
|
,produces = MediaType.APPLICATION_JSON_VALUE)
|
128 |
|
|
@ResponseBody*/
|
129 |
|
|
Map<String, List<Subscription>> getSubscriptionsOfUser(String userEmail) throws BrokerException{
|
130 |
54690
|
panagiotis
|
return brokerService.getSubscriptionsOfUser(userEmail);
|
131 |
50409
|
panagiotis
|
}
|
132 |
|
|
|
133 |
|
|
|
134 |
49236
|
panagiotis
|
}
|