|
|
@@ -11,6 +11,7 @@ import java.util.Map;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.annotation.Secured;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.security.core.Authentication;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.Model;
|
|
|
@@ -30,7 +31,6 @@ import es.uv.saic.shared.dto.OrganDTO;
|
|
|
import es.uv.saic.shared.dto.ProcedureRequestDTO;
|
|
|
import es.uv.saic.shared.dto.ProcesDTO;
|
|
|
import es.uv.saic.shared.dto.RolDTO;
|
|
|
-import es.uv.saic.shared.dto.TemplateDataDTO;
|
|
|
import es.uv.saic.shared.feign.AdminClient;
|
|
|
import es.uv.saic.shared.feign.DataClient;
|
|
|
import es.uv.saic.shared.feign.IndicadorClient;
|
|
|
@@ -64,7 +64,7 @@ public class AdminController {
|
|
|
|
|
|
// GET para conseguir todas las instancias del sistema en ese momento.
|
|
|
@GetMapping("/admin/instances")
|
|
|
- @Secured({"ROLE_ADMIN"})
|
|
|
+ @PreAuthorize("hasRole('ROLE_INSTS_W')")
|
|
|
public String getInstances(Model model, Authentication auth) {
|
|
|
this.loadInstanceData(model);
|
|
|
return "adminInstances";
|
|
|
@@ -98,7 +98,7 @@ public class AdminController {
|
|
|
|
|
|
// POST que recoge los campos introducidos en los inputs (Proceso, centro y titulación) y busca las instancias relacionadas
|
|
|
@PostMapping("/admin/instances")
|
|
|
- @Secured({"ROLE_ADMIN"})
|
|
|
+ @PreAuthorize("hasRole('ROLE_INSTS_W')")
|
|
|
public String instantiate(Model model, Authentication auth,
|
|
|
@RequestParam("procedure") Integer idProces,
|
|
|
@RequestParam("center") Integer idCentre,
|
|
|
@@ -116,14 +116,14 @@ public class AdminController {
|
|
|
|
|
|
// GET que recoge todos los procedimientos del sistema
|
|
|
@GetMapping("/admin/procedures")
|
|
|
- @Secured({"ROLE_ADMIN"})
|
|
|
+ @PreAuthorize("hasRole('ROLE_PROCS_W')")
|
|
|
public String getProcedures(Model model, Authentication auth) {
|
|
|
this.loadProceduresData(model);
|
|
|
return "adminProcedures";
|
|
|
}
|
|
|
|
|
|
// Función utilizada en el GET que recoge todos los procedimientos
|
|
|
- public void loadProceduresData(Model model) {
|
|
|
+ private void loadProceduresData(Model model) {
|
|
|
List<DummyDataTransfer> procediments = new ArrayList<DummyDataTransfer>();
|
|
|
for(ProcesDTO p : pc.getAll()) {
|
|
|
DummyDataTransfer a = new DummyDataTransfer();
|
|
|
@@ -138,7 +138,7 @@ public class AdminController {
|
|
|
|
|
|
// POST que elimina una instancia concreta
|
|
|
@PostMapping("/admin/instance/delete")
|
|
|
- @Secured({"ROLE_ADMIN"})
|
|
|
+ @PreAuthorize("hasRole('ROLE_INSTS_W')")
|
|
|
public void deleteInstance(Model model, Authentication auth, HttpServletResponse response, @RequestParam BigInteger idInstancia) throws IOException {
|
|
|
ac.deleteInstance(idInstancia);
|
|
|
|
|
|
@@ -147,7 +147,7 @@ public class AdminController {
|
|
|
|
|
|
// POST que reinicia una instancia por completo
|
|
|
@PostMapping("/admin/instance/clear")
|
|
|
- @Secured({"ROLE_ADMIN", "ROLE_MANAGER"})
|
|
|
+ @PreAuthorize("hasRole('ROLE_INSTS_W')")
|
|
|
public void clearInstance(Model model, Authentication auth, HttpServletResponse response, @RequestParam BigInteger idInstancia) throws IOException {
|
|
|
String instanciaid = ac.clearInstance(idInstancia);
|
|
|
|
|
|
@@ -156,7 +156,7 @@ public class AdminController {
|
|
|
|
|
|
// POST que establece que una instancia ha sido cerrada, cambiandole su estado
|
|
|
@PostMapping("/admin/instance/close")
|
|
|
- @Secured({"ROLE_ADMIN", "ROLE_MANAGER"})
|
|
|
+ @PreAuthorize("hasRole('ROLE_INSTS_W')")
|
|
|
public void closeInstance(Model model, Authentication auth, HttpServletResponse response, @RequestParam BigInteger idInstancia) throws IOException {
|
|
|
String instanciaid = ac.closeInstance(idInstancia);
|
|
|
|
|
|
@@ -165,7 +165,7 @@ public class AdminController {
|
|
|
|
|
|
// POST que se encarga de eliminar una tarea concreta de una instancia
|
|
|
@PostMapping("/admin/instance/task/remove")
|
|
|
- @Secured({"ROLE_ADMIN", "ROLE_MANAGER"})
|
|
|
+ @PreAuthorize("hasRole('ROLE_INSTS_W')")
|
|
|
public void removeTask(Model model, Authentication auth, HttpServletResponse response, @RequestParam BigInteger idInstanciaTasca) throws IOException {
|
|
|
String instanciaid = ac.removeTask(idInstanciaTasca);
|
|
|
|
|
|
@@ -174,7 +174,7 @@ public class AdminController {
|
|
|
|
|
|
// POST que se encarga de reiniciar por completo una tarea de una instancia
|
|
|
@PostMapping("/admin/instance/task/clear")
|
|
|
- @Secured({"ROLE_ADMIN", "ROLE_MANAGER"})
|
|
|
+ @PreAuthorize("hasRole('ROLE_W')")
|
|
|
public void clearTask(Model model, Authentication auth, HttpServletResponse response, @RequestParam BigInteger idInstanciaTasca) throws IOException {
|
|
|
String instanciaid = ac.clearTask(idInstanciaTasca);
|
|
|
|
|
|
@@ -183,7 +183,7 @@ public class AdminController {
|
|
|
|
|
|
// POST que reinicia una tarea del procedimiento, eliminando datos anteriores y creando una nueva vesión de esta
|
|
|
@PostMapping("/admin/instance/task/reload")
|
|
|
- @Secured({"ROLE_ADMIN", "ROLE_MANAGER"})
|
|
|
+ @PreAuthorize("hasRole('ROLE_W')")
|
|
|
public void reloadTask(Model model, Authentication auth, HttpServletResponse response, @RequestParam BigInteger idInstanciaTasca) throws IOException {
|
|
|
String instanciaid = ac.reloadTask(idInstanciaTasca);
|
|
|
|
|
|
@@ -192,7 +192,7 @@ public class AdminController {
|
|
|
|
|
|
// POST que tiene como objetivo reactivar una tarea
|
|
|
@PostMapping("/admin/instance/task/reactivate")
|
|
|
- @Secured({"ROLE_ADMIN", "ROLE_MANAGER"})
|
|
|
+ @PreAuthorize("hasRole('ROLE_W')")
|
|
|
public void activateTask(Model model, Authentication auth, HttpServletResponse response, @RequestParam BigInteger idInstanciaTasca) throws IOException {
|
|
|
String instanciaid = ac.activateTask(idInstanciaTasca);
|
|
|
|
|
|
@@ -201,7 +201,7 @@ public class AdminController {
|
|
|
|
|
|
// POST que edita la información de una tarea ya existente
|
|
|
@PostMapping("/admin/instance/task/edit")
|
|
|
- @Secured({"ROLE_ADMIN", "ROLE_MANAGER"})
|
|
|
+ @PreAuthorize("hasRole('ROLE_INSTS_W')")
|
|
|
public void editTask(Model model, Authentication auth, HttpServletResponse response, @RequestParam BigInteger idInstanciaTasca) throws IOException {
|
|
|
String instanciaid = ac.editTask(idInstanciaTasca);
|
|
|
|
|
|
@@ -209,7 +209,7 @@ public class AdminController {
|
|
|
}
|
|
|
|
|
|
@GetMapping("/admin/mailing")
|
|
|
- @Secured({"ROLE_ADMIN"})
|
|
|
+ @Secured({"ROLE_EMAILS"})
|
|
|
public String getMailing(Model model, Authentication auth, HttpServletResponse response) {
|
|
|
List<RolDTO> rols = uc.findAllRols();
|
|
|
List<OrganDTO> centres = oc.getActiveCentres();
|
|
|
@@ -220,7 +220,7 @@ public class AdminController {
|
|
|
}
|
|
|
|
|
|
@PostMapping("/admin/mailing")
|
|
|
- @Secured({"ROLE_ADMIN"})
|
|
|
+ @Secured({"ROLE_EMAILS"})
|
|
|
public String sendMails(Model model, Authentication auth, HttpServletResponse response,
|
|
|
@RequestParam Integer idRol, @RequestParam("centres[]") List<Integer> centres,
|
|
|
@RequestParam String subject, @RequestParam String body) {
|
|
|
@@ -237,7 +237,7 @@ public class AdminController {
|
|
|
|
|
|
// POST para la creación de un procedimiento nuevo
|
|
|
@PostMapping("/admin/procedures/new")
|
|
|
- @Secured({"ROLE_ADMIN"})
|
|
|
+ @Secured({"ROLE_PROCS_W"})
|
|
|
public String newProcedure(Model model, @RequestBody ProcedureRequestDTO request) throws NumberFormatException, ParseException {
|
|
|
|
|
|
ac.newProcedure(request);
|
|
|
@@ -248,7 +248,7 @@ public class AdminController {
|
|
|
}
|
|
|
|
|
|
@PostMapping("/admin/procedures/edit")
|
|
|
- @Secured({"ROLE_ADMIN"})
|
|
|
+ @Secured({"ROLE_PROCS_W"})
|
|
|
public String editProcedure(Model model, @RequestBody ProcedureRequestDTO request) {
|
|
|
// Extraemos los datos del wrapper
|
|
|
ac.editProcedure(request);
|
|
|
@@ -260,7 +260,7 @@ public class AdminController {
|
|
|
|
|
|
// POST que elimina un procedimiento
|
|
|
@PostMapping("/admin/procedures/remove")
|
|
|
- @Secured({"ROLE_ADMIN"})
|
|
|
+ @Secured({"ROLE_PROCS_W"})
|
|
|
public String removeProcedure(Model model, Authentication auth, HttpServletResponse response, @RequestParam("idProces") Integer idProces){
|
|
|
ac.removeProcedure(idProces);
|
|
|
|
|
|
@@ -271,7 +271,7 @@ public class AdminController {
|
|
|
|
|
|
// POST que le eliminar un usuario concreto del sitema
|
|
|
@PostMapping("/admin/userrole/remove")
|
|
|
- @Secured({"ROLE_ADMIN", "ROLE_MANAGER"})
|
|
|
+ @Secured({"ROLE_ADMINS"})
|
|
|
@ResponseBody
|
|
|
public boolean removeUserrole(Model model, Authentication auth, HttpServletResponse response, HttpSession session, @RequestParam("idRol") Integer idRol,
|
|
|
@RequestParam("usuari") String usuari, @RequestParam("lugar") Integer lugar, @RequestParam("tlugar") String tlugar) throws IOException{
|
|
|
@@ -281,7 +281,7 @@ public class AdminController {
|
|
|
|
|
|
// POST para añadir un nuevo usuario al sistema
|
|
|
@PostMapping("/admin/userrole/new")
|
|
|
- @Secured({"ROLE_ADMIN", "ROLE_MANAGER"})
|
|
|
+ @Secured({"ROLE_ADMINS"})
|
|
|
@ResponseBody
|
|
|
public boolean newUserrole(Model model, Authentication auth, HttpServletResponse response, HttpSession session, @RequestParam("idRol") Integer idRol,
|
|
|
@RequestParam(name="usuari", required=false) String usuari, @RequestParam("centre") Integer idCentre,
|
|
|
@@ -292,7 +292,7 @@ public class AdminController {
|
|
|
|
|
|
//¿POSIBLE ELIMINACIÓN?
|
|
|
@GetMapping("/admin/templates2")
|
|
|
- @Secured({"ROLE_ADMIN", "ROLE_TESTER"})
|
|
|
+ @PreAuthorize("hasRole('ROLE_TEMPLATES_W')")
|
|
|
public String getTemplates(Model model, Authentication auth, HttpServletResponse response) {
|
|
|
|
|
|
this.loadInstanceData(model);
|
|
|
@@ -301,7 +301,7 @@ public class AdminController {
|
|
|
|
|
|
// GET que recoge todas las plantillas actuales del sistema
|
|
|
@GetMapping("/admin/templates")
|
|
|
- @Secured({"ROLE_ADMIN", "ROLE_TESTER"})
|
|
|
+ @PreAuthorize("hasRole('ROLE_TEMPLATES_W')")
|
|
|
public String getTemplates2(Model model, Authentication auth, HttpServletResponse response) {
|
|
|
|
|
|
List<String> evs = ac.getTemplates2();
|
|
|
@@ -314,7 +314,7 @@ public class AdminController {
|
|
|
|
|
|
// POST que redefine que indicadores están asociados a una evidencia dentro de un proceso
|
|
|
@PostMapping("/admin/templates/inds/update")
|
|
|
- @Secured({"ROLE_ADMIN"})
|
|
|
+ @PreAuthorize("hasRole('ROLE_TEMPLATES_W')")
|
|
|
public String updateTemplateInds(Model model, Authentication auth, HttpServletResponse response,
|
|
|
@RequestParam(name="indicador[]", required=true) List<String> indicador,
|
|
|
@RequestParam(name="enquesta[]", required=true) List<String> enquesta,
|
|
|
@@ -330,7 +330,7 @@ public class AdminController {
|
|
|
|
|
|
// GET para abrir el editor de plantillas
|
|
|
@GetMapping("/admin/editor")
|
|
|
- @Secured({"ROLE_ADMIN", "ROLE_TESTER"})
|
|
|
+ @PreAuthorize("hasRole('ROLE_TEMPLATES_W')")
|
|
|
public String getTemplateEditor(Model model, Authentication auth, HttpServletResponse response) {
|
|
|
|
|
|
List<String> inds = this.ic.findTypes();
|
|
|
@@ -345,7 +345,7 @@ public class AdminController {
|
|
|
}
|
|
|
|
|
|
@GetMapping("/admin/editor/test")
|
|
|
- @Secured({"ROLE_ADMIN", "ROLE_TESTER"})
|
|
|
+ @PreAuthorize("hasRole('ROLE_TEMPLATES_W')")
|
|
|
public String testTemplateEditor(Model model, Authentication auth, HttpServletResponse response,
|
|
|
@RequestParam Integer idPlantilla, @RequestParam Integer idTitulacio, @RequestParam Integer idCentre, @RequestParam Integer curs) {
|
|
|
|
|
|
@@ -358,7 +358,7 @@ public class AdminController {
|
|
|
|
|
|
// GET para la carga del calendario
|
|
|
@GetMapping("/admin/calendar")
|
|
|
- @Secured({"ROLE_ADMIN"})
|
|
|
+ @PreAuthorize("hasRole('ROLE_INSTS_W')")
|
|
|
public String calendar(Model model, Authentication auth, HttpServletResponse response) {
|
|
|
|
|
|
this.loadInstanceData(model);
|
|
|
@@ -367,7 +367,7 @@ public class AdminController {
|
|
|
|
|
|
@GetMapping("/admin/acredita/{curs}/{grup}/{tambit}")
|
|
|
@ResponseBody
|
|
|
- @Secured({"ROLE_ADMIN", "ROLE_MANAGER"})
|
|
|
+ @Secured({"ROLE_ADMINS"})
|
|
|
public List<AcreditacioTransfer> acreditacionsByCurs(Model model, Authentication auth, HttpServletResponse response,
|
|
|
@PathVariable Integer curs, @PathVariable Integer grup, @PathVariable String tambit) {
|
|
|
|
|
|
@@ -376,7 +376,7 @@ public class AdminController {
|
|
|
|
|
|
@PostMapping("/admin/acredita")
|
|
|
@ResponseBody
|
|
|
- @Secured({"ROLE_ADMIN", "ROLE_MANAGER"})
|
|
|
+ @Secured({"ROLE_ADMINS"})
|
|
|
public Acreditacio UpdateAcreditacio(Model model, Authentication auth, HttpServletResponse response,
|
|
|
@RequestParam String tlugar, @RequestParam Integer lugar,
|
|
|
@RequestParam Integer grupCurs, @RequestParam Integer grupNum, @RequestParam Integer cursImpla,
|
|
|
@@ -387,6 +387,7 @@ public class AdminController {
|
|
|
|
|
|
@GetMapping("/admin/checkProcedureID")
|
|
|
@ResponseBody
|
|
|
+ @PreAuthorize("hasRole('ROLE_PROCS_W')")
|
|
|
public boolean checkProcedureID(@RequestParam String id) {
|
|
|
return pc.findProcesByID(Integer.parseInt(id)) != null;
|
|
|
}
|