Project

General

Profile

« Previous | Next » 

Revision 60517

[Trunk | Admin Tools Library]:
1. PageHelpContentDAO.java & MongoDBPageHelpContentDAO.java: Added method "findByPortalAndPageOrderByPlacementAscOrderAsc()" to get page help contents for a specific portal and page.
2. PageHelpContentService.java: Added method "getPageHelpContentsBasic()".
3. DivHelpContentDAO.java & MongoDBDivHelpContentDAO.java: Added method "findByPortalAndPage()" to get div help contents for a specific portal and page.
4. DivHelpContentService.java: Added method "getDivHelpContentsBasic()".
5. AdminPortalRelationsController.java:
a. Added methods
"public List<PageHelpContent> getPageHelpContentsByPageId()" (/{portalType}/{pid}/{pageId}/pagehelpcontent),
"public Map<String, Integer> countPageHelpContentsForPages()" (/{portalType}/{pid}/pagehelpcontent/page/count),
"public List<DivHelpContent> getDivHelpContentsByPageId()" (/{portalType}/{pid}/{pageId}/divhelpcontent),
"public Map<String, Integer> countDivHelpContentsForPages()" (/{portalType}/{pid}/divhelpcontent/page/count)
b. Added @PreAuthorize("hasAnyAuthority(@AuthorizationService.PORTAL_ADMIN)") in methods:
"public List<PageHelpContentResponse> getPageHelpContents()" and "public List<DivHelpContentResponse> getDivHelpContents()".
6. RolesUtils.java: [Bug fix] In method "getEmail()" call authorizationService.getEmail().

View differences:

AdminPortalRelationsController.java
4 4
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.*;
5 5
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
6 6
import eu.dnetlib.uoaadmintoolslibrary.handlers.MismatchingContentException;
7
import eu.dnetlib.uoaadmintoolslibrary.responses.SingleValueWrapperResponse;
7 8
import eu.dnetlib.uoaadmintoolslibrary.services.*;
8 9
import org.apache.log4j.Logger;
9 10
import org.springframework.beans.factory.annotation.Autowired;
10 11
import org.springframework.web.bind.annotation.*;
11 12
import org.springframework.security.access.prepost.PreAuthorize;
12 13

  
14
import java.util.HashMap;
13 15
import java.util.List;
16
import java.util.Map;
14 17
import java.util.Set;
15 18

  
16 19
@RestController
......
67 70
//        return portalService.getDivHelpContentsByPosition(pid, page, active);
68 71
//    }
69 72

  
73
    // not used by portals
74
    @PreAuthorize("hasAnyAuthority(@AuthorizationService.PORTAL_ADMIN)")
70 75
    @RequestMapping(value = "/{pid}/divhelpcontent", method = RequestMethod.GET)
71 76
    public List<DivHelpContentResponse> getDivHelpContents(@PathVariable PortalType portalType,
72 77
                                                           @PathVariable(value = "pid") String pid) {
73 78
        return divHelpContentService.getDivHelpContents(pid, null, null, null);
74 79
    }
75 80

  
76
    @RequestMapping(value = "/{pid}/divhelpcontent/{id}", method = RequestMethod.GET)
77
    public DivHelpContent getDivHelpContent(@PathVariable PortalType portalType,
78
                                            @PathVariable(value = "pid") String pid,
79
                                            @PathVariable(value = "id") String id) {
80
        DivHelpContent divHelpContent = divHelpContentService.getDivHelpContent(id);
81
        if(divHelpContent == null) {
82
            throw new ContentNotFoundException("DivHelpContent with id: "+id+" not found");
83
        }
81
//    @RequestMapping(value = "/{pid}/divhelpcontent/{id}", method = RequestMethod.GET)
82
//    public DivHelpContent getDivHelpContent(@PathVariable PortalType portalType,
83
//                                            @PathVariable(value = "pid") String pid,
84
//                                            @PathVariable(value = "id") String id) {
85
//        DivHelpContent divHelpContent = divHelpContentService.getDivHelpContent(id);
86
//        if(divHelpContent == null) {
87
//            throw new ContentNotFoundException("DivHelpContent with id: "+id+" not found");
88
//        }
89
//
90
//        Portal portal = portalService.getPortalById(divHelpContent.getPortal());
91
//        portalService.checkPortalInfo(pid, portalType.name(), portal, divHelpContent.getPortal(), "id");
92
//        return divHelpContent;
93
//    }
84 94

  
85
        Portal portal = portalService.getPortalById(divHelpContent.getPortal());
86
        portalService.checkPortalInfo(pid, portalType.name(), portal, divHelpContent.getPortal(), "id");
87
        return divHelpContent;
95
    @RequestMapping(value = "/{pid}/{pageId}/divhelpcontent", method = RequestMethod.GET)
96
    public List<DivHelpContent> getDivHelpContentsByPageId(@PathVariable PortalType portalType,
97
                                                             @PathVariable(value = "pid") String pid,
98
                                                             @PathVariable(value =  "pageId") String pageId) {
99
        return divHelpContentService.getDivHelpContentsBasic(pid, portalType.name(), pageId);
88 100
    }
89 101

  
102
    @RequestMapping(value = "/{pid}/divhelpcontent/page/count", method = RequestMethod.GET)
103
    public Map<String, Integer> countDivHelpContentsForPages(@PathVariable PortalType portalType,
104
                                                              @PathVariable(value = "pid") String pid) {
105
        Map<String, Integer> mapCount = new HashMap<String, Integer>();
106

  
107
        List<Page> pages = pageService.getAllPages(pid, null, null);
108
        for(Page page : pages){
109
            List<DivHelpContent> divHelpContents = divHelpContentService.getDivHelpContentsBasic(pid, portalType.name(), page.getId());
110
            if (divHelpContents == null) {
111
                mapCount.put(page.getId(), 0);
112
            } else {
113
                mapCount.put(page.getId(), divHelpContents.size());
114
            }
115
        }
116
        return mapCount;
117
    }
118

  
90 119
    @PreAuthorize("hasAnyAuthority(" +
91 120
            "@AuthorizationService.PORTAL_ADMIN, " +
92 121
            "@AuthorizationService.curator(#portalType), @AuthorizationService.manager(#portalType, #pid))")
......
240 269
//        return portalService.getPageHelpContentsByPosition(pid, page, active);
241 270
//    }
242 271

  
272
    // not used by portals
273
    @PreAuthorize("hasAnyAuthority(@AuthorizationService.PORTAL_ADMIN)")
243 274
    @RequestMapping(value = "/{pid}/pagehelpcontent", method = RequestMethod.GET)
244 275
    public List<PageHelpContentResponse> getPageHelpContents(@PathVariable PortalType portalType,
245 276
                                                             @PathVariable(value = "pid") String pid) {
246 277
        return pageHelpContentService.getPageHelpContents(pid, null, null, null, null, null);
247 278
    }
248 279

  
249
    @RequestMapping(value = "/{pid}/pagehelpcontent/{id}", method = RequestMethod.GET)
250
    public PageHelpContent getPageHelpContent(@PathVariable PortalType portalType,
251
                                              @PathVariable(value = "pid") String pid,
252
                                              @PathVariable(value = "id") String id) {
253
        PageHelpContent pageHelpContent = pageHelpContentService.getPageHelpContent(id);
254
        if(pageHelpContent == null) {
255
            throw new ContentNotFoundException("PageHelpContent with id: "+id+" not found");
280
    // used
281
    @RequestMapping(value = "/{pid}/{pageId}/pagehelpcontent", method = RequestMethod.GET)
282
    public List<PageHelpContent> getPageHelpContentsByPageId(@PathVariable PortalType portalType,
283
                                                             @PathVariable(value = "pid") String pid,
284
                                                             @PathVariable(value =  "pageId") String pageId) {
285
        return pageHelpContentService.getPageHelpContentsBasic(pid, portalType.name(), pageId);
286
    }
287

  
288
    // used
289
    @RequestMapping(value = "/{pid}/pagehelpcontent/page/count", method = RequestMethod.GET)
290
    public Map<String, Integer> countPageHelpContentsForPages(@PathVariable PortalType portalType,
291
                                                              @PathVariable(value = "pid") String pid) {
292
        Map<String, Integer> mapCount = new HashMap<String, Integer>();
293

  
294
        List<Page> pages = pageService.getAllPages(pid, null, null);
295
        for(Page page : pages){
296
            List<PageHelpContent> pageHelpContents = pageHelpContentService.getPageHelpContentsBasic(pid, portalType.name(), page.getId());
297
            if (pageHelpContents == null) {
298
                mapCount.put(page.getId(), 0);
299
            } else {
300
                mapCount.put(page.getId(), pageHelpContents.size());
301
            }
256 302
        }
257

  
258
        Portal portal = portalService.getPortalById(pageHelpContent.getPortal());
259
        portalService.checkPortalInfo(pid, portalType.name(), portal, pageHelpContent.getPortal(), "id");
260
        return pageHelpContent;
303
        return mapCount;
261 304
    }
262 305

  
306
//    @RequestMapping(value = "/{pid}/pagehelpcontent/{id}", method = RequestMethod.GET)
307
//    public PageHelpContent getPageHelpContent(@PathVariable PortalType portalType,
308
//                                              @PathVariable(value = "pid") String pid,
309
//                                              @PathVariable(value = "id") String id) {
310
//        PageHelpContent pageHelpContent = pageHelpContentService.getPageHelpContent(id);
311
//        if(pageHelpContent == null) {
312
//            throw new ContentNotFoundException("PageHelpContent with id: "+id+" not found");
313
//        }
314
//
315
//        Portal portal = portalService.getPortalById(pageHelpContent.getPortal());
316
//        portalService.checkPortalInfo(pid, portalType.name(), portal, pageHelpContent.getPortal(), "id");
317
//        return pageHelpContent;
318
//    }
319

  
263 320
    @PreAuthorize("hasAnyAuthority(" +
264 321
            "@AuthorizationService.PORTAL_ADMIN, " +
265 322
            "@AuthorizationService.curator(#portalType), @AuthorizationService.manager(#portalType, #pid))")

Also available in: Unified diff