2020-03-31 14:02:29 +02:00
|
|
|
package eu.dnetlib.uoaadmintools.controllers;
|
|
|
|
|
|
|
|
import eu.dnetlib.uoaadmintools.dao.SubscriberDAO;
|
2020-09-24 14:02:39 +02:00
|
|
|
import eu.dnetlib.uoaadmintools.entities.subscriber.Subscriber;
|
|
|
|
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
2022-10-07 12:38:56 +02:00
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
import org.apache.logging.log4j.Logger;
|
2020-03-31 14:02:29 +02:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by argirok on 2/3/2018.
|
|
|
|
*/
|
|
|
|
@RestController
|
|
|
|
@CrossOrigin(origins = "*")
|
|
|
|
public class SubscriberController {
|
2022-10-07 12:38:56 +02:00
|
|
|
private final Logger log = LogManager.getLogger(this.getClass());
|
2020-03-31 14:02:29 +02:00
|
|
|
@Autowired
|
|
|
|
private SubscriberDAO subscriberDAO;
|
|
|
|
@RequestMapping(value = "/subscriber", method = RequestMethod.GET)
|
|
|
|
public List<Subscriber> getSubscriber() throws ContentNotFoundException {
|
|
|
|
List<Subscriber> list = subscriberDAO.findAll();
|
|
|
|
if(list == null){
|
|
|
|
throw new ContentNotFoundException("Subscribers not found");
|
|
|
|
}
|
|
|
|
return subscriberDAO.findAll();
|
|
|
|
}
|
|
|
|
@RequestMapping(value = "/subscriber/{email}", method = RequestMethod.GET)
|
|
|
|
public Subscriber getSubscriber(@PathVariable(value="email", required = true) String email) throws ContentNotFoundException {
|
|
|
|
Subscriber subscriber = subscriberDAO.findByEmail(email);
|
|
|
|
if(subscriber == null){
|
|
|
|
throw new ContentNotFoundException("Subscribers not found");
|
|
|
|
}
|
|
|
|
return subscriber;
|
|
|
|
}
|
2021-02-25 11:43:53 +01:00
|
|
|
// @RequestMapping(value = "/subscriber", method = RequestMethod.POST)
|
|
|
|
// public Subscriber saveSubscriber(@RequestBody Subscriber subscriber) {
|
|
|
|
// return subscriberDAO.save(subscriber);
|
|
|
|
// }
|
|
|
|
// @RequestMapping(value = "/subscriber/{email}", method = RequestMethod.DELETE)
|
|
|
|
// public void deleteSubscriber(@PathVariable(value="email", required = true) String email) throws ContentNotFoundException {
|
|
|
|
// Subscriber subscriber = subscriberDAO.findByEmail(email);
|
|
|
|
// if(subscriber == null){
|
|
|
|
// throw new ContentNotFoundException("Subscribers not found");
|
|
|
|
// }
|
|
|
|
// subscriberDAO.delete(subscriber.getId());
|
|
|
|
//
|
|
|
|
// }
|
2020-03-31 14:02:29 +02:00
|
|
|
|
|
|
|
}
|