Add getSubscriptionsOfUser method. Rename old one to getSimpleSubscriptionsOfUser

This commit is contained in:
Panagiotis Kanakakis 2018-01-25 15:14:19 +00:00
parent aba8bcf807
commit bfed3f0d8c
2 changed files with 27 additions and 3 deletions

View File

@ -29,9 +29,9 @@ public interface BrokerApi {
@RequestMapping(value = "/showEvents" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
EventsPage showEvents(@RequestBody String params) throws BrokerException, JSONException;
@RequestMapping(value = "/getSubscriptionsOfUser/{userEmail}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/getSimpleSubscriptionsOfUser/{userEmail}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
Map<String, List<SimpleSubscriptionDesc>> getSubscriptionsOfUser(String userEmail) throws BrokerException;
Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser(String userEmail) throws BrokerException;
@RequestMapping(value = "/subscribe" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@ -54,4 +54,9 @@ public interface BrokerApi {
,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
EventsPage getNotificationsBySubscriptionId(String subscriptionId,String page,String size) throws BrokerException;
@RequestMapping(value = "/getSubscriptionsOfUser/{userEmail}" , method = RequestMethod.GET
,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
Map<String, List<Subscription>> getSubscriptionsOfUser(String userEmail) throws BrokerException;
}

View File

@ -254,7 +254,7 @@ public class BrokerApiImpl implements BrokerApi {
}
@Override
public Map<String, List<SimpleSubscriptionDesc>> getSubscriptionsOfUser(@PathVariable("userEmail") String userEmail) throws BrokerException {
public Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser(@PathVariable("userEmail") String userEmail) throws BrokerException {
final String service = "/subscriptions";
@ -379,5 +379,24 @@ public class BrokerApiImpl implements BrokerApi {
return resp.getBody();
}
@Override
public Map<String, List<Subscription>> getSubscriptionsOfUser(@PathVariable("userEmail") String userEmail)
throws BrokerException {
Map<String, List<SimpleSubscriptionDesc>> simpleSubs = getSimpleSubscriptionsOfUser(userEmail);
Map<String,List<Subscription>> subs = new HashMap<>();
List<Subscription> subscriptions = null;
for(String s:simpleSubs.keySet()){
List<SimpleSubscriptionDesc> simpleSubscriptionDescs = simpleSubs.get(s);
for(SimpleSubscriptionDesc simpleSubscriptionDesc : simpleSubscriptionDescs) {
subscriptions = new ArrayList<>();
subscriptions.add(getSubscription(simpleSubscriptionDesc.getId()));
}
subs.put(s,subscriptions);
}
return subs;
}
}