Revision 60495
Added by Konstantina Galouni about 3 years ago
PortalService.java | ||
---|---|---|
77 | 77 |
|
78 | 78 |
private void setEnabledPagesForPortalByType(Portal portal, PortalResponse portalResponse) { |
79 | 79 |
List<PortalPage> pages = this.getPagesForPortalByType(portal.getPid(), null, null, null, null); |
80 |
log.debug("PAGES number="+pages.size()); |
|
80 |
// log.debug("PAGES number="+pages.size());
|
|
81 | 81 |
Iterator<PortalPage> iteratorPages = pages.iterator(); |
82 | 82 |
while(iteratorPages.hasNext()) { |
83 | 83 |
PortalPage page = iteratorPages.next(); |
... | ... | |
86 | 86 |
} |
87 | 87 |
} |
88 | 88 |
portalResponse.setPages(pages); |
89 |
log.debug("PAGES set"); |
|
89 |
// log.debug("PAGES set");
|
|
90 | 90 |
} |
91 | 91 |
|
92 | 92 |
private void setEnabledEntitiesForPortalByType(Portal portal, PortalResponse portalResponse) { |
93 | 93 |
List<PortalEntity> entities = this.getEntitiesForPortal(portal.getPid(), null); |
94 |
log.debug("ENTITIES number="+entities.size()); |
|
94 |
// log.debug("ENTITIES number="+entities.size());
|
|
95 | 95 |
Iterator<PortalEntity> iteratorEntities = entities.iterator(); |
96 | 96 |
while(iteratorEntities.hasNext()) { |
97 | 97 |
PortalEntity entity = iteratorEntities.next(); |
... | ... | |
100 | 100 |
} |
101 | 101 |
} |
102 | 102 |
portalResponse.setEntities(entities); |
103 |
log.debug("ENTITIES set"); |
|
103 |
// log.debug("ENTITIES set");
|
|
104 | 104 |
} |
105 | 105 |
|
106 | 106 |
public PortalResponse getPortalFull(String pid) { |
... | ... | |
176 | 176 |
Portal savedPortal = portalDAO.save(portal); |
177 | 177 |
PortalResponse portalResponse = this.getPortalFull(savedPortal.getPid()); |
178 | 178 |
|
179 |
log.debug("pid of saved portal: "+ savedPortal.getPid()); |
|
179 |
// log.debug("pid of saved portal: "+ savedPortal.getPid());
|
|
180 | 180 |
|
181 | 181 |
String id = savedPortal.getId(); |
182 | 182 |
|
... | ... | |
298 | 298 |
} |
299 | 299 |
|
300 | 300 |
public Portal getPortalById(String id) { |
301 |
log.debug("ID: "+ id); |
|
301 |
// log.debug("ID: "+ id);
|
|
302 | 302 |
return portalDAO.findById(id); |
303 | 303 |
} |
304 | 304 |
|
305 | 305 |
public Portal getPortal(String pid) { |
306 |
log.debug("PID: "+ pid); |
|
306 |
// log.debug("PID: "+ pid);
|
|
307 | 307 |
return portalDAO.findByPid(pid); |
308 | 308 |
} |
309 | 309 |
|
... | ... | |
391 | 391 |
return portalDAO.save(portal); |
392 | 392 |
} |
393 | 393 |
|
394 |
public Portal togglePage(String pid, List<String> pageIds, String status) throws Exception { |
|
394 |
public Portal togglePage(String pid, String portalType, List<String> pageIds, String status) throws Exception {
|
|
395 | 395 |
Portal portal = portalDAO.findByPid(pid); |
396 |
checkPortalInfo(pid, portalType, portal, pid, "pid"); |
|
396 | 397 |
Map<String, Boolean> pages = portal.getPages(); |
397 | 398 |
|
398 | 399 |
for (String pageId: pageIds) { |
399 |
log.debug("Toggle portal page: " + pageId + " of portal: " + pid + " to " + status); |
|
400 |
Page page = pageService.getPage(pageId); |
|
401 |
if(page == null) { |
|
402 |
throw new ContentNotFoundException("Page with id: " + pageId + " not found"); |
|
403 |
} |
|
404 |
if(!page.getPortalType().equals(portalType)) { |
|
405 |
throw new MismatchingContentException("["+portalType+ " - "+ pid+"] Conflicting page type: "+page.getPortalType()); |
|
406 |
} |
|
407 |
// log.debug("Toggle portal page: " + pageId + " of portal: " + pid + " to " + status); |
|
400 | 408 |
pages.put(pageId, Boolean.parseBoolean(status)); |
401 | 409 |
} |
402 | 410 |
|
... | ... | |
410 | 418 |
Map<String, Boolean> pages = portal.getPages(); |
411 | 419 |
|
412 | 420 |
for (String entityId: entityIds) { |
413 |
log.debug("Toggle portal entity: " + entityId + " of portal: " + pid + " to " + status); |
|
421 |
// log.debug("Toggle portal entity: " + entityId + " of portal: " + pid + " to " + status);
|
|
414 | 422 |
|
415 | 423 |
entities.put(entityId, Boolean.parseBoolean(status)); |
416 | 424 |
|
... | ... | |
512 | 520 |
return divHelpContentResponses; |
513 | 521 |
} |
514 | 522 |
|
515 |
public void checkPortalInfo(String pid, String portalType, Portal portal, String portalId) { |
|
523 |
public void checkPortalInfo(String pid, String portalType, Portal portal, String portalId, String getBy) {
|
|
516 | 524 |
if(portal == null) { |
517 |
throw new ContentNotFoundException("Portal with id: "+portalId+" not found"); |
|
525 |
if(portalId != null) { |
|
526 |
throw new ContentNotFoundException("Portal with "+getBy+": " + portalId + " not found"); |
|
527 |
} |
|
518 | 528 |
} |
519 | 529 |
if(!portal.getType().equals(portalType)) { |
520 | 530 |
throw new MismatchingContentException("["+portalType+ " - "+ pid+"] Conflicting portal info: type: "+portal.getType()); |
Also available in: Unified diff
[Trunk | Admin Tools Library]:
1. pom.xml: Added in dependency for spring security and and for uoa-authorization-library.
2. UoaAdminToolsLibraryApplication.java: import "AuthorizationConfiguration.class".
3. RolesUtils.java: Added folder handlers/utils and file handlers/utils/RolesUtils.java to get roles and info of user from authorization library.
4. AdminToolsLibraryExceptionsHandler.java: call setStatus of ExceptionResponse in handlers that status was not set | Use log.error instead of log.debug.
5. DivHelpContentService.java: Added checks and throw Exceptions in methods "deleteDivHelpContents()" and "toggleDivHelpContent()".
6. PageHelpContentService.java: Added checks and throw Exceptions in methods "deletePageHelpContents()" and "togglePageHelpContent()".
7. PortalService.java: Added checks and throw Exceptions in method "togglePage()".
8. EntityController.java: Added @PreAuthorize
Portal Admins: methods "insertEntity()" (/entity/save), "updateEntity()" (/entity/update), "deleteEntities()" (/entity/delete).
9. DivIdController.java: Added @PreAuthorize
Portal Admins: methods "insertDivId()" (/div/save), "updateDivId()" (/div/update), "deleteDivIds()" (/div/delete).
10. PageController.java: Added @PreAuthorize
Portal Admins: methods "insertPage()" (/page/save), "updatePage()" (/page/update), "deletePages()" (/page/delete).
11. AdminPortalRelationsController.java:
a. Added checks and throw Exceptions in methods "getEntitiesForCommunity()",
"getDivHelpContent()", "saveDivHelpContent()", "updateDivHelpContent()", "deleteDivHelpContents()", "toggleDivHelpContent()",
"togglePage()",
"getPageHelpContent()", "savePageHelpContent()", "updatePageHelpContent()", "deletePageHelpContents()", "togglePageHelpContent()"
b. Added @PreAuthorize
Portals Admin - Curators - Managers: "toggleEntity()" (/{portalType}/{pid}/entity/toggle),
"saveDivHelpContent()" (/{portalType}/{pid}/divhelpcontent/save), "updateDivHelpContent()" (/{portalType}/{pid}/divhelpcontent/update),
"deleteDivHelpContents()" (/{portalType}/{pid|/divhelpcontent/delete), "toggleDivHelpContent()" (/{portalType}/{pid|/divhelpcontent/toggle),
"togglePage()" (/{portalType}/{pid}/page/toggle),
"savePageHelpContent()" (/{portalType}/{pid}/pagehelpcontent/save), "updatePageHelpContent()" (/{portalType}/{pid}/pagehelpcontent/update),
"deletePageHelpContents()" (/{portalType}/{pid|/pagehelpcontent/delete), "togglePageHelpContent()" (/{portalType}/{pid|/pagehelpcontent/toggle)