[Trunk | Monitor Service]:
1. RolesUtils.java: Comment all contents of this file (should be removed in next commit). This file is added in uoa-admin-tools-library. 2. StakeholderController.java & TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java & IndicatorController.java: Import RolesUtils from uoa-admin-tools-library. 3. StakeholderController.java: In "getAllRealStakeholders()" method, add optional parameter "defaultId", to get Stakeholders based on a default profile.
This commit is contained in:
parent
d6901a49f7
commit
a284d8449a
|
@ -1,11 +1,11 @@
|
|||
package eu.dnetlib.uoamonitorservice.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.utils.RolesUtils;
|
||||
import eu.dnetlib.uoamonitorservice.dao.*;
|
||||
import eu.dnetlib.uoamonitorservice.entities.*;
|
||||
import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException;
|
||||
import eu.dnetlib.uoamonitorservice.handlers.PathNotValidException;
|
||||
import eu.dnetlib.uoamonitorservice.handlers.utils.RolesUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package eu.dnetlib.uoamonitorservice.controllers;
|
||||
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.utils.RolesUtils;
|
||||
import eu.dnetlib.uoamonitorservice.dao.*;
|
||||
import eu.dnetlib.uoamonitorservice.entities.*;
|
||||
import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException;
|
||||
import eu.dnetlib.uoamonitorservice.handlers.PathNotValidException;
|
||||
import eu.dnetlib.uoamonitorservice.handlers.utils.RolesUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package eu.dnetlib.uoamonitorservice.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.utils.RolesUtils;
|
||||
import eu.dnetlib.uoamonitorservice.dao.*;
|
||||
import eu.dnetlib.uoamonitorservice.entities.*;
|
||||
import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException;
|
||||
import eu.dnetlib.uoamonitorservice.handlers.PathNotValidException;
|
||||
import eu.dnetlib.uoamonitorservice.handlers.utils.RolesUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package eu.dnetlib.uoamonitorservice.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.utils.RolesUtils;
|
||||
import eu.dnetlib.uoamonitorservice.dao.*;
|
||||
import eu.dnetlib.uoamonitorservice.entities.*;
|
||||
import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException;
|
||||
import eu.dnetlib.uoamonitorservice.handlers.utils.RolesUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
|
@ -337,14 +337,19 @@ public class StakeholderController {
|
|||
}
|
||||
|
||||
@RequestMapping(value = "/stakeholder", method = RequestMethod.GET)
|
||||
public List<Stakeholder> getAllRealStakeholders(@RequestParam(required = false) String type) {
|
||||
public List<Stakeholder> getAllRealStakeholders(@RequestParam(required = false) String type,
|
||||
@RequestParam(required = false) String defaultId) {
|
||||
// log.debug("get all NOT default stakeholders" + (type != null ? " with type: "+type : ""));
|
||||
|
||||
List<Stakeholder> stakeholders;
|
||||
if(type == null) {
|
||||
stakeholders = stakeholderDAO.findByDefaultIdNot(null);
|
||||
} else {
|
||||
if(type != null && defaultId != null) {
|
||||
stakeholders = stakeholderDAO.findByDefaultIdAndType(defaultId, type);
|
||||
} else if(defaultId != null) {
|
||||
stakeholders = stakeholderDAO.findByDefaultId(defaultId);
|
||||
} else if(type != null) {
|
||||
stakeholders = stakeholderDAO.findByDefaultIdNotAndType(null, type);
|
||||
} else {
|
||||
stakeholders = stakeholderDAO.findByDefaultIdNot(null);
|
||||
}
|
||||
|
||||
//List<Stakeholder> stakeholdersFull = new ArrayList<>();
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package eu.dnetlib.uoamonitorservice.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.utils.RolesUtils;
|
||||
import eu.dnetlib.uoamonitorservice.dao.*;
|
||||
import eu.dnetlib.uoamonitorservice.entities.*;
|
||||
import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException;
|
||||
import eu.dnetlib.uoamonitorservice.handlers.PathNotValidException;
|
||||
import eu.dnetlib.uoamonitorservice.handlers.utils.RolesUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package eu.dnetlib.uoamonitorservice.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.utils.RolesUtils;
|
||||
import eu.dnetlib.uoamonitorservice.dao.*;
|
||||
import eu.dnetlib.uoamonitorservice.entities.*;
|
||||
import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException;
|
||||
import eu.dnetlib.uoamonitorservice.handlers.PathNotValidException;
|
||||
import eu.dnetlib.uoamonitorservice.handlers.utils.RolesUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
|
|
|
@ -1,72 +1,72 @@
|
|||
package eu.dnetlib.uoamonitorservice.handlers.utils;
|
||||
|
||||
import eu.dnetlib.uoaauthorizationlibrary.security.AuthorizationService;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class RolesUtils {
|
||||
@Autowired
|
||||
private AuthorizationService authorizationService;
|
||||
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
public List<String> getRoles() {
|
||||
return authorizationService.getRoles();
|
||||
}
|
||||
|
||||
public boolean isPortalAdmin(List<String> roles) {
|
||||
if(roles == null) {
|
||||
return false;
|
||||
}
|
||||
// log.debug(authorizationService.PORTAL_ADMIN);
|
||||
// log.debug("PortalAdmin: "+roles.contains(authorizationService.PORTAL_ADMIN));
|
||||
return roles.contains(authorizationService.PORTAL_ADMIN);
|
||||
}
|
||||
|
||||
public boolean isCurator(List<String> roles, String type) {
|
||||
if(roles == null) {
|
||||
return false;
|
||||
}
|
||||
// log.debug(authorizationService.curator(type));
|
||||
// log.debug("Curator in "+type+": "+roles.contains(authorizationService.curator(type)));
|
||||
return roles.contains(authorizationService.curator(type));
|
||||
}
|
||||
|
||||
public boolean isManager(List<String> roles, String type, String id) {
|
||||
if(roles == null) {
|
||||
return false;
|
||||
}
|
||||
// log.debug(authorizationService.manager(type, id));
|
||||
// log.debug("Manager in "+type+" - "+id+": "+roles.contains(authorizationService.manager(type, id)));
|
||||
return roles.contains(authorizationService.manager(type, id));
|
||||
}
|
||||
|
||||
public boolean isMember(List<String> roles, String type, String id) {
|
||||
if(roles == null) {
|
||||
return false;
|
||||
}
|
||||
// log.debug(authorizationService.member(type, id));
|
||||
// log.debug("Member in "+type+" - "+id+": "+roles.contains(authorizationService.member(type, id)));
|
||||
return roles.contains(authorizationService.member(type, id));
|
||||
}
|
||||
|
||||
public boolean isLoggedIn(List<String> roles) {
|
||||
if(roles == null || roles.contains(authorizationService.ANONYMOUS_USER)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasUpdateAuthority(List<String> roles, String type, String id) {
|
||||
return isPortalAdmin(roles) || isCurator(roles, type) || isManager(roles, type, id);
|
||||
}
|
||||
|
||||
public boolean hasCreateAndDeleteAuthority(List<String> roles, String type) {
|
||||
return isPortalAdmin(roles) || isCurator(roles, type);
|
||||
}
|
||||
}
|
||||
//package eu.dnetlib.uoamonitorservice.handlers.utils;
|
||||
//
|
||||
//import eu.dnetlib.uoaauthorizationlibrary.security.AuthorizationService;
|
||||
//import org.apache.log4j.Logger;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//@Component
|
||||
//public class RolesUtils {
|
||||
// @Autowired
|
||||
// private AuthorizationService authorizationService;
|
||||
//
|
||||
// private final Logger log = Logger.getLogger(this.getClass());
|
||||
//
|
||||
// public List<String> getRoles() {
|
||||
// return authorizationService.getRoles();
|
||||
// }
|
||||
//
|
||||
// public boolean isPortalAdmin(List<String> roles) {
|
||||
// if(roles == null) {
|
||||
// return false;
|
||||
// }
|
||||
//// log.debug(authorizationService.PORTAL_ADMIN);
|
||||
//// log.debug("PortalAdmin: "+roles.contains(authorizationService.PORTAL_ADMIN));
|
||||
// return roles.contains(authorizationService.PORTAL_ADMIN);
|
||||
// }
|
||||
//
|
||||
// public boolean isCurator(List<String> roles, String type) {
|
||||
// if(roles == null) {
|
||||
// return false;
|
||||
// }
|
||||
//// log.debug(authorizationService.curator(type));
|
||||
//// log.debug("Curator in "+type+": "+roles.contains(authorizationService.curator(type)));
|
||||
// return roles.contains(authorizationService.curator(type));
|
||||
// }
|
||||
//
|
||||
// public boolean isManager(List<String> roles, String type, String id) {
|
||||
// if(roles == null) {
|
||||
// return false;
|
||||
// }
|
||||
//// log.debug(authorizationService.manager(type, id));
|
||||
//// log.debug("Manager in "+type+" - "+id+": "+roles.contains(authorizationService.manager(type, id)));
|
||||
// return roles.contains(authorizationService.manager(type, id));
|
||||
// }
|
||||
//
|
||||
// public boolean isMember(List<String> roles, String type, String id) {
|
||||
// if(roles == null) {
|
||||
// return false;
|
||||
// }
|
||||
//// log.debug(authorizationService.member(type, id));
|
||||
//// log.debug("Member in "+type+" - "+id+": "+roles.contains(authorizationService.member(type, id)));
|
||||
// return roles.contains(authorizationService.member(type, id));
|
||||
// }
|
||||
//
|
||||
// public boolean isLoggedIn(List<String> roles) {
|
||||
// if(roles == null || roles.contains(authorizationService.ANONYMOUS_USER)) {
|
||||
// return false;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// public boolean hasUpdateAuthority(List<String> roles, String type, String id) {
|
||||
// return isPortalAdmin(roles) || isCurator(roles, type) || isManager(roles, type, id);
|
||||
// }
|
||||
//
|
||||
// public boolean hasCreateAndDeleteAuthority(List<String> roles, String type) {
|
||||
// return isPortalAdmin(roles) || isCurator(roles, type);
|
||||
// }
|
||||
//}
|
||||
|
|
Loading…
Reference in New Issue