[Trunk | Admin Tools]:
1. SubscriberController.java & PortalSubscribersController.java: Commented POST/ DELETE methods from controllers related to subscribers (these files will be deleted after migration of roles to AAI). 2. StatisticsController.java: Commented all methods (file and statistics schema in general need update - currently not working).
This commit is contained in:
parent
9389c43ec6
commit
40b7fa40cd
|
@ -1,6 +1,6 @@
|
|||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.configuration.properties.SecurityConfig;
|
||||
//import eu.dnetlib.uoaadmintools.configuration.properties.SecurityConfig;
|
||||
import eu.dnetlib.uoaadmintools.dao.PortalSubscribersDAO;
|
||||
import eu.dnetlib.uoaadmintools.dao.SubscriberDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.subscriber.PortalSubscribers;
|
||||
|
@ -8,7 +8,7 @@ import eu.dnetlib.uoaadmintools.entities.subscriber.Subscriber;
|
|||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||
import eu.dnetlib.uoaadmintools.handlers.utils.AuthorizationUtils;
|
||||
import eu.dnetlib.uoaadmintools.handlers.utils.UserInfo;
|
||||
import eu.dnetlib.uoaadmintools.responses.SingleValueWrapperResponse;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.responses.SingleValueWrapperResponse;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.PortalDAO;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -31,8 +31,8 @@ public class PortalSubscribersController {
|
|||
@Autowired
|
||||
PortalDAO portalDAO;
|
||||
|
||||
@Autowired
|
||||
private SecurityConfig securityConfig;
|
||||
// @Autowired
|
||||
// private SecurityConfig securityConfig;
|
||||
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
|
@ -91,155 +91,155 @@ public class PortalSubscribersController {
|
|||
//
|
||||
// }
|
||||
|
||||
@RequestMapping(value = "/community/{pid}/is-subscriber", method = RequestMethod.GET)
|
||||
public Boolean getIsSubscribedToPortal(@PathVariable(value="pid", required = true) String pid,
|
||||
//@RequestBody String email,
|
||||
@RequestHeader("X-XSRF-TOKEN") String token) throws ContentNotFoundException {
|
||||
AuthorizationUtils helper = new AuthorizationUtils();
|
||||
helper.setUserInfoUrl(securityConfig.getUserInfoUrl());
|
||||
UserInfo userInfo = helper.getUserInfo(token);
|
||||
|
||||
if(userInfo != null) {
|
||||
String email = userInfo.getEmail();
|
||||
PortalSubscribers communitySubscribers = portalSubscribersDAO.findByPid(pid);
|
||||
if (communitySubscribers != null) {
|
||||
if (communitySubscribers.getSubscribers() != null) {
|
||||
for (Subscriber subscriber : communitySubscribers.getSubscribers()) {
|
||||
if (subscriber.getEmail().equals(email)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new ContentNotFoundException("Portal Subscribers not found");
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{pid}/subscriber", method = RequestMethod.POST)
|
||||
public Boolean addSubscriberInPortal(@PathVariable(value="pid", required = true) String pid,
|
||||
@RequestHeader("X-XSRF-TOKEN") String token) throws ContentNotFoundException {
|
||||
AuthorizationUtils helper = new AuthorizationUtils();
|
||||
helper.setUserInfoUrl(securityConfig.getUserInfoUrl());
|
||||
UserInfo userInfo = helper.getUserInfo(token);
|
||||
|
||||
if(userInfo != null) {
|
||||
String email = userInfo.getEmail();
|
||||
Subscriber subscriber = new Subscriber(email);
|
||||
|
||||
PortalSubscribers communitySubscribers = portalSubscribersDAO.findByPid(pid);
|
||||
if (communitySubscribers == null) {
|
||||
throw new ContentNotFoundException("Community Subscribers not found");
|
||||
}
|
||||
|
||||
Subscriber savedSubscriber = subscriberDAO.findByEmail(email);
|
||||
if (savedSubscriber == null) {
|
||||
savedSubscriber = subscriberDAO.save(subscriber);
|
||||
}
|
||||
for (Subscriber sub : communitySubscribers.getSubscribers()) {
|
||||
if (sub.getEmail().equals(subscriber.getEmail())) {
|
||||
//already subscribed
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//not subscribed yet
|
||||
communitySubscribers.getSubscribers().add(savedSubscriber);
|
||||
portalSubscribersDAO.save(communitySubscribers);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
@RequestMapping(value = "/community/{pid}/subscriber/delete", method = RequestMethod.POST)
|
||||
public Boolean deleteSubscriberFromPortal(@PathVariable(value="pid", required = true) String pid,
|
||||
@RequestHeader("X-XSRF-TOKEN") String token) throws ContentNotFoundException {
|
||||
AuthorizationUtils helper = new AuthorizationUtils();
|
||||
helper.setUserInfoUrl(securityConfig.getUserInfoUrl());
|
||||
UserInfo userInfo = helper.getUserInfo(token);
|
||||
|
||||
if(userInfo != null) {
|
||||
String email = userInfo.getEmail();
|
||||
|
||||
PortalSubscribers communitySubscribers = portalSubscribersDAO.findByPid(pid);
|
||||
if (communitySubscribers == null) {
|
||||
throw new ContentNotFoundException("Community Subscribers not found");
|
||||
}
|
||||
|
||||
Iterator<Subscriber> subscriberIterator = communitySubscribers.getSubscribers().iterator();
|
||||
while(subscriberIterator.hasNext()) {
|
||||
Subscriber subscriber = subscriberIterator.next();
|
||||
if(subscriber.getEmail().equals(email)) {
|
||||
subscriberIterator.remove();
|
||||
portalSubscribersDAO.save(communitySubscribers);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{pid}/subscribers", method = RequestMethod.POST)
|
||||
public PortalSubscribers addSubscriberInPortalByEmail(@PathVariable(value="pid", required = true) String pid, @RequestBody Subscriber subscriber) throws ContentNotFoundException {
|
||||
PortalSubscribers communitySubscribers = portalSubscribersDAO.findByPid(pid);
|
||||
if(communitySubscribers == null){
|
||||
throw new ContentNotFoundException("Community Subscribers not found");
|
||||
}
|
||||
|
||||
Subscriber savedSubscriber = subscriberDAO.findByEmail(subscriber.getEmail());
|
||||
if(savedSubscriber==null){
|
||||
savedSubscriber = subscriberDAO.save(subscriber);
|
||||
}
|
||||
for(Subscriber sub:communitySubscribers.getSubscribers()){
|
||||
if(sub.getEmail().equals(subscriber.getEmail())){
|
||||
//already subscribed
|
||||
return communitySubscribers;
|
||||
}
|
||||
}
|
||||
//not subscribed yet
|
||||
communitySubscribers.getSubscribers().add(savedSubscriber);
|
||||
return portalSubscribersDAO.save(communitySubscribers);
|
||||
|
||||
}
|
||||
@RequestMapping(value = "/community/{pid}/subscribers/delete", method = RequestMethod.POST)
|
||||
public PortalSubscribers deleteSubscriberFromPortalByEmail(@PathVariable(value="pid", required = true) String pid, @RequestBody List<String> emails) throws ContentNotFoundException {
|
||||
PortalSubscribers communitySubscribers = portalSubscribersDAO.findByPid(pid);
|
||||
if(communitySubscribers == null){
|
||||
throw new ContentNotFoundException("Community Subscribers not found");
|
||||
}
|
||||
List<Subscriber> list = new ArrayList<>();
|
||||
for(Subscriber s:communitySubscribers.getSubscribers()){
|
||||
if(emails.indexOf(s.getEmail())==-1){
|
||||
list.add(s);
|
||||
}
|
||||
}
|
||||
communitySubscribers.setSubscribers(list);
|
||||
return portalSubscribersDAO.save(communitySubscribers);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/subscriber/communities", method = RequestMethod.GET)
|
||||
public List<String> getPortalsPerSubcriber(//@RequestParam(value="email", required = true) String email,
|
||||
@RequestHeader("X-XSRF-TOKEN") String token) {
|
||||
AuthorizationUtils helper = new AuthorizationUtils();
|
||||
helper.setUserInfoUrl(securityConfig.getUserInfoUrl());
|
||||
UserInfo userInfo = helper.getUserInfo(token);
|
||||
|
||||
List<String> list = new ArrayList<>();
|
||||
|
||||
if (userInfo != null) {
|
||||
String email = userInfo.getEmail();
|
||||
List<PortalSubscribers> communitySubscribers = portalSubscribersDAO.findAll();
|
||||
|
||||
for (PortalSubscribers s : communitySubscribers) {
|
||||
for (Subscriber sub : s.getSubscribers()) {
|
||||
if (sub.getEmail().equals(email)) {
|
||||
list.add(s.getPid());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
// @RequestMapping(value = "/community/{pid}/is-subscriber", method = RequestMethod.GET)
|
||||
// public Boolean getIsSubscribedToPortal(@PathVariable(value="pid", required = true) String pid,
|
||||
// //@RequestBody String email,
|
||||
// @RequestHeader("X-XSRF-TOKEN") String token) throws ContentNotFoundException {
|
||||
// AuthorizationUtils helper = new AuthorizationUtils();
|
||||
// helper.setUserInfoUrl(securityConfig.getUserInfoUrl());
|
||||
// UserInfo userInfo = helper.getUserInfo(token);
|
||||
//
|
||||
// if(userInfo != null) {
|
||||
// String email = userInfo.getEmail();
|
||||
// PortalSubscribers communitySubscribers = portalSubscribersDAO.findByPid(pid);
|
||||
// if (communitySubscribers != null) {
|
||||
// if (communitySubscribers.getSubscribers() != null) {
|
||||
// for (Subscriber subscriber : communitySubscribers.getSubscribers()) {
|
||||
// if (subscriber.getEmail().equals(email)) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// throw new ContentNotFoundException("Portal Subscribers not found");
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(value = "/community/{pid}/subscriber", method = RequestMethod.POST)
|
||||
// public Boolean addSubscriberInPortal(@PathVariable(value="pid", required = true) String pid,
|
||||
// @RequestHeader("X-XSRF-TOKEN") String token) throws ContentNotFoundException {
|
||||
// AuthorizationUtils helper = new AuthorizationUtils();
|
||||
// helper.setUserInfoUrl(securityConfig.getUserInfoUrl());
|
||||
// UserInfo userInfo = helper.getUserInfo(token);
|
||||
//
|
||||
// if(userInfo != null) {
|
||||
// String email = userInfo.getEmail();
|
||||
// Subscriber subscriber = new Subscriber(email);
|
||||
//
|
||||
// PortalSubscribers communitySubscribers = portalSubscribersDAO.findByPid(pid);
|
||||
// if (communitySubscribers == null) {
|
||||
// throw new ContentNotFoundException("Community Subscribers not found");
|
||||
// }
|
||||
//
|
||||
// Subscriber savedSubscriber = subscriberDAO.findByEmail(email);
|
||||
// if (savedSubscriber == null) {
|
||||
// savedSubscriber = subscriberDAO.save(subscriber);
|
||||
// }
|
||||
// for (Subscriber sub : communitySubscribers.getSubscribers()) {
|
||||
// if (sub.getEmail().equals(subscriber.getEmail())) {
|
||||
// //already subscribed
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// //not subscribed yet
|
||||
// communitySubscribers.getSubscribers().add(savedSubscriber);
|
||||
// portalSubscribersDAO.save(communitySubscribers);
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
//
|
||||
// }
|
||||
// @RequestMapping(value = "/community/{pid}/subscriber/delete", method = RequestMethod.POST)
|
||||
// public Boolean deleteSubscriberFromPortal(@PathVariable(value="pid", required = true) String pid,
|
||||
// @RequestHeader("X-XSRF-TOKEN") String token) throws ContentNotFoundException {
|
||||
// AuthorizationUtils helper = new AuthorizationUtils();
|
||||
// helper.setUserInfoUrl(securityConfig.getUserInfoUrl());
|
||||
// UserInfo userInfo = helper.getUserInfo(token);
|
||||
//
|
||||
// if(userInfo != null) {
|
||||
// String email = userInfo.getEmail();
|
||||
//
|
||||
// PortalSubscribers communitySubscribers = portalSubscribersDAO.findByPid(pid);
|
||||
// if (communitySubscribers == null) {
|
||||
// throw new ContentNotFoundException("Community Subscribers not found");
|
||||
// }
|
||||
//
|
||||
// Iterator<Subscriber> subscriberIterator = communitySubscribers.getSubscribers().iterator();
|
||||
// while(subscriberIterator.hasNext()) {
|
||||
// Subscriber subscriber = subscriberIterator.next();
|
||||
// if(subscriber.getEmail().equals(email)) {
|
||||
// subscriberIterator.remove();
|
||||
// portalSubscribersDAO.save(communitySubscribers);
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(value = "/community/{pid}/subscribers", method = RequestMethod.POST)
|
||||
// public PortalSubscribers addSubscriberInPortalByEmail(@PathVariable(value="pid", required = true) String pid, @RequestBody Subscriber subscriber) throws ContentNotFoundException {
|
||||
// PortalSubscribers communitySubscribers = portalSubscribersDAO.findByPid(pid);
|
||||
// if(communitySubscribers == null){
|
||||
// throw new ContentNotFoundException("Community Subscribers not found");
|
||||
// }
|
||||
//
|
||||
// Subscriber savedSubscriber = subscriberDAO.findByEmail(subscriber.getEmail());
|
||||
// if(savedSubscriber==null){
|
||||
// savedSubscriber = subscriberDAO.save(subscriber);
|
||||
// }
|
||||
// for(Subscriber sub:communitySubscribers.getSubscribers()){
|
||||
// if(sub.getEmail().equals(subscriber.getEmail())){
|
||||
// //already subscribed
|
||||
// return communitySubscribers;
|
||||
// }
|
||||
// }
|
||||
// //not subscribed yet
|
||||
// communitySubscribers.getSubscribers().add(savedSubscriber);
|
||||
// return portalSubscribersDAO.save(communitySubscribers);
|
||||
//
|
||||
// }
|
||||
// @RequestMapping(value = "/community/{pid}/subscribers/delete", method = RequestMethod.POST)
|
||||
// public PortalSubscribers deleteSubscriberFromPortalByEmail(@PathVariable(value="pid", required = true) String pid, @RequestBody List<String> emails) throws ContentNotFoundException {
|
||||
// PortalSubscribers communitySubscribers = portalSubscribersDAO.findByPid(pid);
|
||||
// if(communitySubscribers == null){
|
||||
// throw new ContentNotFoundException("Community Subscribers not found");
|
||||
// }
|
||||
// List<Subscriber> list = new ArrayList<>();
|
||||
// for(Subscriber s:communitySubscribers.getSubscribers()){
|
||||
// if(emails.indexOf(s.getEmail())==-1){
|
||||
// list.add(s);
|
||||
// }
|
||||
// }
|
||||
// communitySubscribers.setSubscribers(list);
|
||||
// return portalSubscribersDAO.save(communitySubscribers);
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(value = "/subscriber/communities", method = RequestMethod.GET)
|
||||
// public List<String> getPortalsPerSubcriber(//@RequestParam(value="email", required = true) String email,
|
||||
// @RequestHeader("X-XSRF-TOKEN") String token) {
|
||||
// AuthorizationUtils helper = new AuthorizationUtils();
|
||||
// helper.setUserInfoUrl(securityConfig.getUserInfoUrl());
|
||||
// UserInfo userInfo = helper.getUserInfo(token);
|
||||
//
|
||||
// List<String> list = new ArrayList<>();
|
||||
//
|
||||
// if (userInfo != null) {
|
||||
// String email = userInfo.getEmail();
|
||||
// List<PortalSubscribers> communitySubscribers = portalSubscribersDAO.findAll();
|
||||
//
|
||||
// for (PortalSubscribers s : communitySubscribers) {
|
||||
// for (Subscriber sub : s.getSubscribers()) {
|
||||
// if (sub.getEmail().equals(email)) {
|
||||
// list.add(s.getPid());
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return list;
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -1,123 +1,123 @@
|
|||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.*;
|
||||
import eu.dnetlib.uoaadmintools.entities.statistics.*;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class StatisticsController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private StatisticsDAO statisticsDAO;
|
||||
|
||||
@RequestMapping(value = "/statistics", method = RequestMethod.GET)
|
||||
public List<Statistics> getAllStatistics() throws ContentNotFoundException {
|
||||
log.info("getAllStatistics");
|
||||
List<Statistics> statistics = statisticsDAO.findAll();
|
||||
if(statistics == null){
|
||||
throw new ContentNotFoundException("Statistics not found");
|
||||
}
|
||||
return statistics;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/statistics/{pid}", method = RequestMethod.GET)
|
||||
public Statistics getStatistics(@PathVariable(value = "pid") String pid) throws ContentNotFoundException {
|
||||
Statistics statistics = statisticsDAO.findByPid(pid);
|
||||
if(statistics == null){
|
||||
throw new ContentNotFoundException("Statistics not found");
|
||||
}
|
||||
return statistics;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/statistics/{id}/toggle", method = RequestMethod.POST)
|
||||
public Boolean toggleStatistics(@PathVariable String id) throws Exception {
|
||||
Statistics statistics = statisticsDAO.findById(id);
|
||||
boolean status = statistics.getIsActive();
|
||||
statistics.setIsActive(!status);
|
||||
statisticsDAO.save(statistics);
|
||||
return statistics.getIsActive();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/statistics/save", method = RequestMethod.POST)
|
||||
public Statistics insertStatistics(@RequestBody Statistics statistics) {
|
||||
Statistics savedStatistics = statisticsDAO.save(statistics);
|
||||
return savedStatistics;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/statistics/delete", method = RequestMethod.POST)
|
||||
public Boolean deleteStatistics(@RequestBody List<String> statistics) throws Exception {
|
||||
for (String id: statistics) {
|
||||
statisticsDAO.delete(id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "statistics/{pid}/{entity}/charts", method = RequestMethod.POST)
|
||||
public Statistics toggleCharts(@PathVariable(value = "pid") String pid, @PathVariable(value = "entity") String entity, @RequestBody String key, @RequestParam String status, @RequestParam String monitor) throws ContentNotFoundException {
|
||||
Statistics statistics = statisticsDAO.findByPid(pid);
|
||||
if(statistics == null){
|
||||
throw new ContentNotFoundException("Statistics not found for portal");
|
||||
}
|
||||
StatisticsEntity statisticsEntity = statistics.getEntities().get(entity);
|
||||
if(statisticsEntity == null ){
|
||||
throw new ContentNotFoundException("Statistics not found for entity");
|
||||
}
|
||||
ChartsMap charts = statisticsEntity.getCharts();
|
||||
if(charts == null){
|
||||
throw new ContentNotFoundException("Statistics not found - no charts");
|
||||
}
|
||||
StatisticsStatus statisticsStatus= charts.getMap().get(key);
|
||||
if(statisticsStatus == null){
|
||||
throw new ContentNotFoundException("Statistics not found for key");
|
||||
}
|
||||
if(Boolean.parseBoolean(monitor)){
|
||||
statisticsStatus.setShowInMonitor(Boolean.parseBoolean(status));
|
||||
}else{
|
||||
statisticsStatus.setShowInDashboard(Boolean.parseBoolean(status));
|
||||
}
|
||||
// stats.put(key,statisticsStatus);
|
||||
return statisticsDAO.save(statistics);
|
||||
}
|
||||
@RequestMapping(value = "statistics/{pid}/{entity}/numbers", method = RequestMethod.POST)
|
||||
public Statistics toggleNumber(@PathVariable(value = "pid") String pid, @PathVariable(value = "entity") String entity, @RequestBody String key, @RequestParam String status, @RequestParam String monitor) throws ContentNotFoundException {
|
||||
Statistics statistics = statisticsDAO.findByPid(pid);
|
||||
if(statistics == null){
|
||||
throw new ContentNotFoundException("Statistics not found for portal");
|
||||
}
|
||||
StatisticsEntity statisticsEntity = statistics.getEntities().get(entity);
|
||||
if(statisticsEntity == null ){
|
||||
throw new ContentNotFoundException("Statistics not found for entity");
|
||||
}
|
||||
NumbersMap numbers = statisticsEntity.getNumbers();
|
||||
if(numbers == null){
|
||||
throw new ContentNotFoundException("Statistics not found - no numbers");
|
||||
}
|
||||
StatisticsStatus statisticsStatus= numbers.getMap().get(key);
|
||||
if(statisticsStatus == null){
|
||||
throw new ContentNotFoundException("Statistics not found for key");
|
||||
}
|
||||
if(Boolean.parseBoolean(monitor)){
|
||||
statisticsStatus.setShowInMonitor(Boolean.parseBoolean(status));
|
||||
}else{
|
||||
statisticsStatus.setShowInDashboard(Boolean.parseBoolean(status));
|
||||
}
|
||||
// stats.put(key,statisticsStatus);
|
||||
return statisticsDAO.save(statistics);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//package eu.dnetlib.uoaadmintools.controllers;
|
||||
//
|
||||
//import eu.dnetlib.uoaadmintools.dao.*;
|
||||
//import eu.dnetlib.uoaadmintools.entities.statistics.*;
|
||||
//import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||
//import org.apache.log4j.Logger;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//
|
||||
//import java.util.*;
|
||||
//
|
||||
//@RestController
|
||||
//@CrossOrigin(origins = "*")
|
||||
//public class StatisticsController {
|
||||
// private final Logger log = Logger.getLogger(this.getClass());
|
||||
//
|
||||
// @Autowired
|
||||
// private StatisticsDAO statisticsDAO;
|
||||
//
|
||||
// @RequestMapping(value = "/statistics", method = RequestMethod.GET)
|
||||
// public List<Statistics> getAllStatistics() throws ContentNotFoundException {
|
||||
// log.info("getAllStatistics");
|
||||
// List<Statistics> statistics = statisticsDAO.findAll();
|
||||
// if(statistics == null){
|
||||
// throw new ContentNotFoundException("Statistics not found");
|
||||
// }
|
||||
// return statistics;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// @RequestMapping(value = "/statistics/{pid}", method = RequestMethod.GET)
|
||||
// public Statistics getStatistics(@PathVariable(value = "pid") String pid) throws ContentNotFoundException {
|
||||
// Statistics statistics = statisticsDAO.findByPid(pid);
|
||||
// if(statistics == null){
|
||||
// throw new ContentNotFoundException("Statistics not found");
|
||||
// }
|
||||
// return statistics;
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(value = "/statistics/{id}/toggle", method = RequestMethod.POST)
|
||||
// public Boolean toggleStatistics(@PathVariable String id) throws Exception {
|
||||
// Statistics statistics = statisticsDAO.findById(id);
|
||||
// boolean status = statistics.getIsActive();
|
||||
// statistics.setIsActive(!status);
|
||||
// statisticsDAO.save(statistics);
|
||||
// return statistics.getIsActive();
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(value = "/statistics/save", method = RequestMethod.POST)
|
||||
// public Statistics insertStatistics(@RequestBody Statistics statistics) {
|
||||
// Statistics savedStatistics = statisticsDAO.save(statistics);
|
||||
// return savedStatistics;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// @RequestMapping(value = "/statistics/delete", method = RequestMethod.POST)
|
||||
// public Boolean deleteStatistics(@RequestBody List<String> statistics) throws Exception {
|
||||
// for (String id: statistics) {
|
||||
// statisticsDAO.delete(id);
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// @RequestMapping(value = "statistics/{pid}/{entity}/charts", method = RequestMethod.POST)
|
||||
// public Statistics toggleCharts(@PathVariable(value = "pid") String pid, @PathVariable(value = "entity") String entity, @RequestBody String key, @RequestParam String status, @RequestParam String monitor) throws ContentNotFoundException {
|
||||
// Statistics statistics = statisticsDAO.findByPid(pid);
|
||||
// if(statistics == null){
|
||||
// throw new ContentNotFoundException("Statistics not found for portal");
|
||||
// }
|
||||
// StatisticsEntity statisticsEntity = statistics.getEntities().get(entity);
|
||||
// if(statisticsEntity == null ){
|
||||
// throw new ContentNotFoundException("Statistics not found for entity");
|
||||
// }
|
||||
// ChartsMap charts = statisticsEntity.getCharts();
|
||||
// if(charts == null){
|
||||
// throw new ContentNotFoundException("Statistics not found - no charts");
|
||||
// }
|
||||
// StatisticsStatus statisticsStatus= charts.getMap().get(key);
|
||||
// if(statisticsStatus == null){
|
||||
// throw new ContentNotFoundException("Statistics not found for key");
|
||||
// }
|
||||
// if(Boolean.parseBoolean(monitor)){
|
||||
// statisticsStatus.setShowInMonitor(Boolean.parseBoolean(status));
|
||||
// }else{
|
||||
// statisticsStatus.setShowInDashboard(Boolean.parseBoolean(status));
|
||||
// }
|
||||
//// stats.put(key,statisticsStatus);
|
||||
// return statisticsDAO.save(statistics);
|
||||
// }
|
||||
// @RequestMapping(value = "statistics/{pid}/{entity}/numbers", method = RequestMethod.POST)
|
||||
// public Statistics toggleNumber(@PathVariable(value = "pid") String pid, @PathVariable(value = "entity") String entity, @RequestBody String key, @RequestParam String status, @RequestParam String monitor) throws ContentNotFoundException {
|
||||
// Statistics statistics = statisticsDAO.findByPid(pid);
|
||||
// if(statistics == null){
|
||||
// throw new ContentNotFoundException("Statistics not found for portal");
|
||||
// }
|
||||
// StatisticsEntity statisticsEntity = statistics.getEntities().get(entity);
|
||||
// if(statisticsEntity == null ){
|
||||
// throw new ContentNotFoundException("Statistics not found for entity");
|
||||
// }
|
||||
// NumbersMap numbers = statisticsEntity.getNumbers();
|
||||
// if(numbers == null){
|
||||
// throw new ContentNotFoundException("Statistics not found - no numbers");
|
||||
// }
|
||||
// StatisticsStatus statisticsStatus= numbers.getMap().get(key);
|
||||
// if(statisticsStatus == null){
|
||||
// throw new ContentNotFoundException("Statistics not found for key");
|
||||
// }
|
||||
// if(Boolean.parseBoolean(monitor)){
|
||||
// statisticsStatus.setShowInMonitor(Boolean.parseBoolean(status));
|
||||
// }else{
|
||||
// statisticsStatus.setShowInDashboard(Boolean.parseBoolean(status));
|
||||
// }
|
||||
//// stats.put(key,statisticsStatus);
|
||||
// return statisticsDAO.save(statistics);
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
|
@ -34,18 +34,18 @@ public class SubscriberController {
|
|||
}
|
||||
return subscriber;
|
||||
}
|
||||
@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());
|
||||
|
||||
}
|
||||
// @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());
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue