Project

General

Profile

« Previous | Next » 

Revision 60509

[Admin Tools | Trunk]: Add get managers method. Delete no needed files.

View differences:

ConnectController.java
1 1
package eu.dnetlib.uoaadmintools.controllers;
2 2

  
3
import eu.dnetlib.uoaadmintools.entities.Layout;
4 3
import eu.dnetlib.uoaadmintools.services.LayoutService;
5 4
import eu.dnetlib.uoaadmintoolslibrary.entities.Portal;
6
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.*;
5
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.PortalResponse;
7 6
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
8 7
import eu.dnetlib.uoaadmintoolslibrary.handlers.MismatchingContentException;
9 8
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
10 9
import org.apache.log4j.Logger;
10
import org.springframework.beans.factory.annotation.Autowired;
11 11
import org.springframework.security.access.prepost.PreAuthorize;
12 12
import org.springframework.web.bind.annotation.*;
13
import org.springframework.beans.factory.annotation.Autowired;
14 13

  
15
import java.util.*;
14
import java.util.List;
16 15

  
17 16
@RestController
18 17
@RequestMapping("/connect")
......
29 28

  
30 29
    @RequestMapping(value = "/update", method = RequestMethod.POST)
31 30
    public PortalResponse updateConnect(@RequestBody Portal portal) {
32
        if(!portal.getType().equals("connect")) {
31
        if (!portal.getType().equals("connect")) {
33 32
            // EXCEPTION - MismatchingContent
34
            throw new MismatchingContentException("Update Connect: Portal with id: "+portal.getId()+" has type: "+portal.getType()+" instead of connect");
33
            throw new MismatchingContentException("Update Connect: Portal with id: " + portal.getId() + " has type: " + portal.getType() + " instead of connect");
35 34
        }
36 35

  
37 36
        PortalResponse portalResponse = portalService.updatePortal(portal);
38 37

  
39 38
        String old_pid = portalResponse.getPid();
40 39
        String new_pid = portal.getPid();
41
        if(!old_pid.equals(new_pid)) {
40
        if (!old_pid.equals(new_pid)) {
42 41
            layoutService.updatePid(old_pid, new_pid);
43 42
        }
44 43

  
......
47 46

  
48 47
    @RequestMapping(value = "/save", method = RequestMethod.POST)
49 48
    public PortalResponse insertConnect(@RequestBody Portal portal) {
50
        if(!portal.getType().equals("connect")) {
49
        if (!portal.getType().equals("connect")) {
51 50
            // EXCEPTION - MismatchingContent
52
            throw new MismatchingContentException("Save Connect: Portal with id: "+portal.getId()+" has type: "+portal.getType()+" instead of connect");
51
            throw new MismatchingContentException("Save Connect: Portal with id: " + portal.getId() + " has type: " + portal.getType() + " instead of connect");
53 52
        }
54 53

  
55 54
        PortalResponse portalResponse = portalService.insertPortal(portal);
......
58 57

  
59 58
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
60 59
    public Boolean deleteConnect(@RequestBody List<String> portals) {
61
        for (String id: portals) {
60
        for (String id : portals) {
62 61
            Portal portal = portalService.getPortalById(id);
63
            if(portal == null) {
62
            if (portal == null) {
64 63
                // EXCEPTION - Entity Not Found
65 64
                throw new ContentNotFoundException("Delete connect: Portal with id: " + id + " not found");
66 65
            }
67
            if(!portal.getType().equals("connect")) {
66
            if (!portal.getType().equals("connect")) {
68 67
                // EXCEPTION - MismatchingContent
69
                throw new MismatchingContentException("Delete Connect: Portal with id: "+id+" has type: "+portal.getType()+" instead of connect");
68
                throw new MismatchingContentException("Delete Connect: Portal with id: " + id + " has type: " + portal.getType() + " instead of connect");
70 69
            }
71 70

  
72 71
            String pid = portalService.deletePortal(id);

Also available in: Unified diff