[Trunk | Admin Tools Library]:
1. DivHelpContentController.java & PageHelpContentController.java: Comment every method (not used anymore by portals) (changed and moved to AdminPortalRelationsController.java - portal specific). 2. DivIdController.java & EntityController.java & PageController.java: Comment methods not used by portals (some of them changed and moved to AdminPortalRelationsController.java - portal specific). 3. PortalController.java: a. Comment methods not used by portals (some of them changed and moved to AdminPortalRelationsController.java - entities portal specific). b. Methods to get portal (basic and full response) by pid. c. In path of methods "getPageHelpContentsByPosition()" and "getDivHelpContentsByPosition()" add "/grouped" (without it, methods in AdminPortalRelationsController.java return simple lists). 4. DivId.java & DivIdResponse.java & Page.java & PageResponse.java & Portal.java & PortalResponse.java: Change type of field "portalType" (type for Portal.java) from "String" to "PortalType" (enum). 5. VerifyRecaptcha.java: log error before throwing exception. 6. PageHelpContentService.java: a. Replace methods "insertPageHelpContent()" and "updatePageHelpContent()" with "insertOrUpdatePageHelpContent()". b. In "addPageHelpContentsInPortal()" call DAO instead of insert. 7. PageService.java: Use method "getAllPortalsByType()" with portalType parameter, instead of "getAllPortals()". 8. PortalService.java: a. Add methods "getAllPortalsByType()" and "getAllPortalsFullByType()". b. In method "getPagesForPortalByType()" add parameter "with_positions". c. Add method "checkPortalInfo()", which checks if pid and portalType matches, otherwise throws exception. 9. AdminPortalRelationsController.java: [NEW] controller to handle actions (get, delete, save, update, toggle) for portal specific entities. 10. PortalType.java: [NEW] Enumeration for acceptable portal types. 11. AdminToolsLibraryExceptionsHandler.java & ContentNotFoundException.java & MismatchingContentException.java & ExceptionResponse.java: [NEW] Exception handling for specific error cases.
This commit is contained in:
parent
b12d839964
commit
1f0fb6df28
|
@ -0,0 +1,308 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.*;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.*;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.MismatchingContentException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.services.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "{portalType}")
|
||||
@CrossOrigin(origins = "*")
|
||||
public class AdminPortalRelationsController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private PortalService portalService;
|
||||
|
||||
@Autowired
|
||||
private DivHelpContentService divHelpContentService;
|
||||
|
||||
@Autowired
|
||||
private DivIdService divIdService;
|
||||
|
||||
@Autowired
|
||||
private PageService pageService;
|
||||
|
||||
@Autowired
|
||||
private PageHelpContentService pageHelpContentService;
|
||||
|
||||
// ENTITIES
|
||||
|
||||
@RequestMapping(value = {"/{pid}/entities"}, method = RequestMethod.GET)
|
||||
public List<PortalEntity> getEntitiesForCommunity(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid) {
|
||||
//@RequestParam(value="entity", required=false) String entity) {
|
||||
return portalService.getEntitiesForPortal(pid, null);
|
||||
}
|
||||
|
||||
// cannot handle MismatchingContent
|
||||
// @PreAuthorize("hasAnyAuthority(" +
|
||||
// "@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN, " +
|
||||
// "@AuthorizationService.curator(#portalType), @AuthorizationService.manager(#portalType, #pid))")
|
||||
@RequestMapping(value = {"/{pid}/entity/toggle"}, method = RequestMethod.POST)
|
||||
public Portal toggleEntity(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid,
|
||||
@RequestBody List<String> entityIds, @RequestParam String status) throws Exception {
|
||||
return portalService.toggleEntity(pid, entityIds, status);
|
||||
}
|
||||
|
||||
// DIV HELP CONTENTS
|
||||
|
||||
// not used by portals
|
||||
// // @RequestMapping(value = {"/community/{pid}/divhelpcontent", "/explore/{pid}/divhelpcontent", "/connect/{pid}/divhelpcontent"}, method = RequestMethod.GET)
|
||||
// @RequestMapping(value = {"/{pid}/divhelpcontent/test"}, method = RequestMethod.GET)
|
||||
// public Map<String, List<DivHelpContentResponse>> getDivHelpContentsByPositionAdmin(@PathVariable PortalType portalType,
|
||||
// @PathVariable(value = "pid") String pid,
|
||||
// @RequestParam(required=false) String page,
|
||||
// @RequestParam(required=false) String active) {
|
||||
// return portalService.getDivHelpContentsByPosition(pid, page, active);
|
||||
// }
|
||||
|
||||
@RequestMapping(value = "/{pid}/divhelpcontent", method = RequestMethod.GET)
|
||||
public List<DivHelpContentResponse> getDivHelpContents(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid) {
|
||||
return divHelpContentService.getDivHelpContents(pid, null, null, null);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{pid}/divhelpcontent/{id}", method = RequestMethod.GET)
|
||||
public DivHelpContent getDivHelpContent(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid,
|
||||
@PathVariable(value = "id") String id) {
|
||||
DivHelpContent divHelpContent = divHelpContentService.getDivHelpContent(id);
|
||||
if(divHelpContent == null) {
|
||||
throw new ContentNotFoundException("DivHelpContent with id: "+id+" not found");
|
||||
}
|
||||
|
||||
Portal portal = portalService.getPortalById(divHelpContent.getPortal());
|
||||
portalService.checkPortalInfo(pid, portalType.name(), portal, divHelpContent.getPortal());
|
||||
return divHelpContent;
|
||||
}
|
||||
|
||||
// @PreAuthorize("hasAnyAuthority(" +
|
||||
// "@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN, " +
|
||||
// "@AuthorizationService.curator(#portalType), @AuthorizationService.manager(#portalType, #pid))")
|
||||
@RequestMapping(value = "/{pid}/divhelpcontent/save", method = RequestMethod.POST)
|
||||
public DivHelpContent saveDivHelpContent(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid,
|
||||
@RequestBody DivHelpContent divHelpContent) {
|
||||
Portal portal = portalService.getPortal(divHelpContent.getPortal());
|
||||
portalService.checkPortalInfo(pid, portalType.name(), portal, divHelpContent.getPortal());
|
||||
divHelpContent.setPortal(portal.getId());
|
||||
return divHelpContentService.insertOrUpdateDivHelpContent(divHelpContent);
|
||||
}
|
||||
|
||||
// @PreAuthorize("hasAnyAuthority(" +
|
||||
// "@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN, " +
|
||||
// "@AuthorizationService.curator(#portalType), @AuthorizationService.manager(#portalType, #pid))")
|
||||
@RequestMapping(value = "/{pid}/divhelpcontent/update", method = RequestMethod.POST)
|
||||
public DivHelpContent updateDivHelpContent(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid,
|
||||
@RequestBody DivHelpContent divHelpContent) {
|
||||
Portal portal = portalService.getPortalById(divHelpContent.getPortal());
|
||||
portalService.checkPortalInfo(pid, portalType.name(), portal, divHelpContent.getPortal());
|
||||
return divHelpContentService.insertOrUpdateDivHelpContent(divHelpContent);
|
||||
}
|
||||
|
||||
// cannot handle MismatchingContent
|
||||
// @PreAuthorize("hasAnyAuthority(" +
|
||||
// "@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN, " +
|
||||
// "@AuthorizationService.curator(#portalType), @AuthorizationService.manager(#portalType, #pid))")
|
||||
@RequestMapping(value = "/{pid}/divhelpcontent/delete", method = RequestMethod.POST)
|
||||
public Boolean deleteDivHelpContents(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid,
|
||||
@RequestBody List<String> divHelpContents) throws Exception {
|
||||
return divHelpContentService.deleteDivHelpContents(divHelpContents);
|
||||
}
|
||||
|
||||
// cannot handle MismatchingContent
|
||||
// @PreAuthorize("hasAnyAuthority(" +
|
||||
// "@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN, " +
|
||||
// "@AuthorizationService.curator(#portalType), @AuthorizationService.manager(#portalType, #pid))")
|
||||
@RequestMapping(value = "/{pid}/divhelpcontent/toggle", method = RequestMethod.POST)
|
||||
public List<String> toggleDivHelpContent(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid,
|
||||
@RequestBody List<String> divHelpContents, @RequestParam String status) throws Exception {
|
||||
return divHelpContentService.toggleDivHelpContent(divHelpContents, status);
|
||||
}
|
||||
|
||||
|
||||
// DIVIDS
|
||||
|
||||
@RequestMapping(value = "/{pid}/div/full", method = RequestMethod.GET)
|
||||
public List<DivIdResponse> getDivIdsFull(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid,
|
||||
@RequestParam(required = true) String page) {
|
||||
return divIdService.getDivIdsFull(page, null, pid);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{pid}/div/{id}/full", method = RequestMethod.GET)
|
||||
public DivIdResponse getDivIdFull(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid,
|
||||
@PathVariable(value = "id") String id) {
|
||||
DivIdResponse divIdResponse = divIdService.getDivIdFull(id);
|
||||
if(divIdResponse == null) {
|
||||
throw new ContentNotFoundException("DivId with id: "+id+" not found");
|
||||
}
|
||||
if(!divIdResponse.getPortalType().equals(portalType.name())) {
|
||||
throw new MismatchingContentException("["+portalType+ " - "+ pid+"] Conflicting portal info: type: "+divIdResponse.getPortalType());
|
||||
}
|
||||
return divIdResponse;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{pid}/div/pages", method = RequestMethod.GET)
|
||||
public Set<String> getDivIdsPages(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid) {
|
||||
return divIdService.getDivIdsPages(pid);
|
||||
}
|
||||
|
||||
// PAGES
|
||||
|
||||
// used
|
||||
@RequestMapping(value = {"/{pid}/pages"}, method = RequestMethod.GET)
|
||||
public List<PortalPage> getPagesForPortalByType(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid,
|
||||
@RequestParam(value="page_type", required=false) String page_type,
|
||||
//@RequestParam(value="page_route", required=false) String page_route,
|
||||
@RequestParam(value="div", required = false) String div,
|
||||
@RequestParam(value="with_positions", required = false) String with_positions) {
|
||||
return portalService.getPagesForPortalByType(pid, page_type, null, div, with_positions);
|
||||
}
|
||||
|
||||
// not used by portals
|
||||
// @RequestMapping(value = "/{pid}/page", method = RequestMethod.GET)
|
||||
// public List<Page> getAllPages(@PathVariable PortalType portalType,
|
||||
// @PathVariable(value = "pid") String pid,
|
||||
// @RequestParam(value="page_route", required=false) String page_route,
|
||||
// @RequestParam(value="with_positions", required=false) String with_positions) {
|
||||
// return pageService.getAllPages(pid, page_route, with_positions);
|
||||
// }
|
||||
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = {"/{id}/page"}, method = RequestMethod.POST)
|
||||
// public Portal insertOrUpdatePage(@PathVariable PortalType portalType,
|
||||
// @PathVariable(value = "id") String id, @RequestBody PortalPage page) {
|
||||
// return portalService.insertOrUpdatePage(id, page);
|
||||
// }
|
||||
|
||||
// used
|
||||
// @PreAuthorize("hasAnyAuthority(" +
|
||||
// "@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN, " +
|
||||
// "@AuthorizationService.curator(#portalType), @AuthorizationService.manager(#portalType, #pid))")
|
||||
@RequestMapping(value = {"/{pid}/page/toggle"}, method = RequestMethod.POST)
|
||||
public Portal togglePage(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid,
|
||||
@RequestBody List<String> pageIds, @RequestParam String status) throws Exception {
|
||||
return portalService.togglePage(pid, pageIds, status);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{pid}/page", method = RequestMethod.GET)
|
||||
public Page getPageByRoute(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid,
|
||||
@RequestParam(value="page_route", required=true) String page_route) {
|
||||
List<Page> pageInArray = pageService.getAllPages(pid, page_route, null);
|
||||
if(pageInArray == null || pageInArray.size() == 0) {
|
||||
throw new ContentNotFoundException("No page with route: "+page_route + " found for portal with pid: "+pid);
|
||||
}
|
||||
return pageInArray.get(0);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{pid}/page/{id}", method = RequestMethod.GET)
|
||||
public Page getPage(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid,
|
||||
@PathVariable(value = "id") String id) {
|
||||
Page page = pageService.getPage(id);
|
||||
if(page == null) {
|
||||
throw new ContentNotFoundException("Page with id: "+id+" not found");
|
||||
}
|
||||
if(!page.getPortalType().equals(portalType.name())) {
|
||||
throw new MismatchingContentException("["+portalType+ " - "+ pid+"] Conflicting portal info: type: "+page.getPortalType());
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
// PAGE HELP CONTENTS
|
||||
|
||||
// not used by portals
|
||||
// @RequestMapping(value = {"/{pid}/pagehelpcontent/test"}, method = RequestMethod.GET)
|
||||
// public Map<String, List<PageHelpContentResponse>> getPageHelpContentsByPositionAdmin(@PathVariable PortalType portalType,
|
||||
// @PathVariable(value = "pid") String pid,
|
||||
// @RequestParam(required=false) String page,
|
||||
// @RequestParam(required=false) String active) {
|
||||
// return portalService.getPageHelpContentsByPosition(pid, page, active);
|
||||
// }
|
||||
|
||||
@RequestMapping(value = "/{pid}/pagehelpcontent", method = RequestMethod.GET)
|
||||
public List<PageHelpContentResponse> getPageHelpContents(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid) {
|
||||
return pageHelpContentService.getPageHelpContents(pid, null, null, null, null, null);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{pid}/pagehelpcontent/{id}", method = RequestMethod.GET)
|
||||
public PageHelpContent getPageHelpContent(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid,
|
||||
@PathVariable(value = "id") String id) {
|
||||
PageHelpContent pageHelpContent = pageHelpContentService.getPageHelpContent(id);
|
||||
if(pageHelpContent == null) {
|
||||
throw new ContentNotFoundException("PageHelpContent with id: "+id+" not found");
|
||||
}
|
||||
|
||||
Portal portal = portalService.getPortalById(pageHelpContent.getPortal());
|
||||
portalService.checkPortalInfo(pid, portalType.name(), portal, pageHelpContent.getPortal());
|
||||
return pageHelpContent;
|
||||
}
|
||||
|
||||
// @PreAuthorize("hasAnyAuthority(" +
|
||||
// "@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN, " +
|
||||
// "@AuthorizationService.curator(#portalType), @AuthorizationService.manager(#portalType, #pid))")
|
||||
@RequestMapping(value = "/{pid}/pagehelpcontent/save", method = RequestMethod.POST)
|
||||
public PageHelpContent insertPageHelpContent(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid,
|
||||
@RequestBody PageHelpContent pageHelpContent) {
|
||||
Portal portal = portalService.getPortal(pageHelpContent.getPortal());
|
||||
portalService.checkPortalInfo(pid, portalType.name(), portal, pageHelpContent.getPortal());
|
||||
pageHelpContent.setPortal(portal.getId());
|
||||
return pageHelpContentService.insertOrUpdatePageHelpContent(pageHelpContent);
|
||||
}
|
||||
|
||||
// @PreAuthorize("hasAnyAuthority(" +
|
||||
// "@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN, " +
|
||||
// "@AuthorizationService.curator(#portalType), @AuthorizationService.manager(#portalType, #pid))")
|
||||
@RequestMapping(value = "/{pid}/pagehelpcontent/update", method = RequestMethod.POST)
|
||||
public PageHelpContent updatePageHelpContent(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid,
|
||||
@RequestBody PageHelpContent pageHelpContent) {
|
||||
Portal portal = portalService.getPortalById(pageHelpContent.getPortal());
|
||||
portalService.checkPortalInfo(pid, portalType.name(), portal, pageHelpContent.getPortal());
|
||||
return pageHelpContentService.insertOrUpdatePageHelpContent(pageHelpContent);
|
||||
}
|
||||
|
||||
// cannot handle MismatchingContent
|
||||
// @PreAuthorize("hasAnyAuthority(" +
|
||||
// "@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN, " +
|
||||
// "@AuthorizationService.curator(#portalType), @AuthorizationService.manager(#portalType, #pid))")
|
||||
@RequestMapping(value = "/{pid}/pagehelpcontent/delete", method = RequestMethod.POST)
|
||||
public Boolean deletePageHelpContents(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid,
|
||||
@RequestBody List<String> pageHelpContents) throws Exception {
|
||||
return pageHelpContentService.deletePageHelpContents(pageHelpContents);
|
||||
}
|
||||
|
||||
// cannot handle MismatchingContent
|
||||
// @PreAuthorize("hasAnyAuthority(" +
|
||||
// "@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN, " +
|
||||
// "@AuthorizationService.curator(#portalType), @AuthorizationService.manager(#portalType, #pid))")
|
||||
@RequestMapping(value = "/{pid}/pagehelpcontent/toggle", method = RequestMethod.POST)
|
||||
public List<String> togglePageHelpContent(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid,
|
||||
@RequestBody List<String> pageHelpContents, @RequestParam String status) throws Exception {
|
||||
return pageHelpContentService.togglePageHelpContent(pageHelpContents, status);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,9 +1,12 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.DivHelpContent;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Portal;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.DivHelpContentResponse;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.services.DivHelpContentService;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -18,38 +21,47 @@ public class DivHelpContentController {
|
|||
@Autowired
|
||||
private DivHelpContentService divHelpContentService;
|
||||
|
||||
@RequestMapping(value = "/divhelpcontent", method = RequestMethod.GET)
|
||||
public List<DivHelpContentResponse> getDivHelpContents(@RequestParam(value = "portal", required = false) String pid,
|
||||
@RequestParam(required = false) String page,
|
||||
@RequestParam(required = false) String divId,
|
||||
@RequestParam(required = false) String active) {
|
||||
@Autowired
|
||||
private PortalService portalService;
|
||||
|
||||
return divHelpContentService.getDivHelpContents(pid, page, divId, active);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/divhelpcontent/{id}", method = RequestMethod.GET)
|
||||
public DivHelpContent getDivHelpContent(@PathVariable(value = "id") String id) {
|
||||
return divHelpContentService.getDivHelpContent(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/divhelpcontent", method = RequestMethod.POST)
|
||||
public DivHelpContent insertOrUpdateDivHelpContent(@RequestBody DivHelpContent divHelpContent) {
|
||||
return divHelpContentService.insertOrUpdateDivHelpContent(divHelpContent);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/divhelpcontent/{id}", method = RequestMethod.DELETE)
|
||||
public void deleteDivHelpContent(@PathVariable(value = "id") String id) {
|
||||
divHelpContentService.deleteDivHelpContent(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/divhelpcontent/delete", method = RequestMethod.POST)
|
||||
public Boolean deleteDivHelpContents(@RequestBody List<String> divHelpContents) throws Exception {
|
||||
return divHelpContentService.deleteDivHelpContents(divHelpContents);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/divhelpcontent/toggle", method = RequestMethod.POST)
|
||||
public List<String> toggleDivHelpContent(@RequestBody List<String> divHelpContents, @RequestParam String status) throws Exception {
|
||||
return divHelpContentService.toggleDivHelpContent(divHelpContents, status);
|
||||
}
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/divhelpcontent", method = RequestMethod.GET)
|
||||
// public List<DivHelpContentResponse> getDivHelpContents(@RequestParam(value = "portal", required = false) String pid,
|
||||
// @RequestParam(value = "page", required = false) String page_route,
|
||||
// @RequestParam(value = "divId", required = false) String divIdId,
|
||||
// @RequestParam(required = false) String active) {
|
||||
// return divHelpContentService.getDivHelpContents(pid, page_route, divIdId, active);
|
||||
// }
|
||||
//
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/divhelpcontent/{id}", method = RequestMethod.GET)
|
||||
// public DivHelpContent getDivHelpContent(@PathVariable(value = "id") String id) {
|
||||
// return divHelpContentService.getDivHelpContent(id);
|
||||
// }
|
||||
//
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/divhelpcontent", method = RequestMethod.POST)
|
||||
// public DivHelpContent insertOrUpdateDivHelpContent(@RequestBody DivHelpContent divHelpContent) {
|
||||
//
|
||||
// return divHelpContentService.insertOrUpdateDivHelpContent(divHelpContent);
|
||||
// }
|
||||
//
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/divhelpcontent/delete", method = RequestMethod.POST)
|
||||
// public Boolean deleteDivHelpContents(@RequestBody List<String> divHelpContents) throws Exception {
|
||||
// return divHelpContentService.deleteDivHelpContents(divHelpContents);
|
||||
// }
|
||||
//
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/divhelpcontent/toggle", method = RequestMethod.POST)
|
||||
// public List<String> toggleDivHelpContent(@RequestBody List<String> divHelpContents, @RequestParam String status) throws Exception {
|
||||
// return divHelpContentService.toggleDivHelpContent(divHelpContents, status);
|
||||
// }
|
||||
//
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/divhelpcontent/{id}", method = RequestMethod.DELETE)
|
||||
// public void deleteDivHelpContent(@PathVariable(value = "id") String id) {
|
||||
// divHelpContentService.deleteDivHelpContent(id);
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -18,58 +18,71 @@ public class DivIdController {
|
|||
@Autowired
|
||||
private DivIdService divIdService;
|
||||
|
||||
@RequestMapping(value = "/div", method = RequestMethod.GET)
|
||||
public List<DivId> getDivIds(@RequestParam(required = false) String page,
|
||||
@RequestParam(required = false) String name,
|
||||
@RequestParam(value = "portal", required = false) String pid) {
|
||||
return divIdService.getDivIds(page, name, pid);
|
||||
}
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/div", method = RequestMethod.GET)
|
||||
// public List<DivId> getDivIds(@RequestParam(required = false) String page,
|
||||
// @RequestParam(required = false) String name,
|
||||
// @RequestParam(value = "portal", required = false) String pid) {
|
||||
// return divIdService.getDivIds(page, name, pid);
|
||||
// }
|
||||
//
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/div/{id}", method = RequestMethod.GET)
|
||||
// public DivId getDivId(@PathVariable(value = "id") String id) {
|
||||
// return divIdService.getDivId(id);
|
||||
// }
|
||||
//
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/div/{id}/full", method = RequestMethod.GET)
|
||||
// public DivIdResponse getDivIdFull(@PathVariable(value = "id") String id) {
|
||||
// return divIdService.getDivIdFull(id);
|
||||
// }
|
||||
//
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/div", method = RequestMethod.DELETE)
|
||||
// public void deleteAllDivIds() {
|
||||
// divIdService.deleteAllDivIds();
|
||||
// }
|
||||
|
||||
@RequestMapping(value = "/divFull", method = RequestMethod.GET)
|
||||
// used WITHOUT ANY PARAMS
|
||||
@RequestMapping(value = "/div/full", method = RequestMethod.GET)
|
||||
public List<DivIdResponse> getDivIdsFull(@RequestParam(required = false) String page,
|
||||
@RequestParam(required = false) String name,
|
||||
@RequestParam(value="portal", required = false) String pid) {
|
||||
return divIdService.getDivIdsFull(page, name, pid);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/div/{id}", method = RequestMethod.GET)
|
||||
public DivId getDivId(@PathVariable(value = "id") String id) {
|
||||
return divIdService.getDivId(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/divFull/{id}", method = RequestMethod.GET)
|
||||
public DivIdResponse getDivIdFull(@PathVariable(value = "id") String id) {
|
||||
return divIdService.getDivIdFull(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/div", method = RequestMethod.DELETE)
|
||||
public void deleteAllDivIds() {
|
||||
divIdService.deleteAllDivIds();
|
||||
}
|
||||
|
||||
// used
|
||||
// @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
|
||||
@RequestMapping(value = "/div/save", method = RequestMethod.POST)
|
||||
public DivIdResponse insertDivId(@RequestBody DivIdResponse divIdResponse) {
|
||||
return divIdService.insertDivId(divIdResponse);
|
||||
}
|
||||
|
||||
// used
|
||||
// @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
|
||||
@RequestMapping(value = "/div/update", method = RequestMethod.POST)
|
||||
public DivIdResponse updateDivId(@RequestBody DivIdResponse divIdResponse) {
|
||||
return divIdService.updateDivId(divIdResponse);
|
||||
}
|
||||
|
||||
// used
|
||||
// @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
|
||||
@RequestMapping(value = "/div/delete", method = RequestMethod.POST)
|
||||
public Boolean deleteDivIds(@RequestBody List<String> divIds) throws Exception {
|
||||
return divIdService.deleteDivIds(divIds);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/div/{id}", method = RequestMethod.DELETE)
|
||||
public void deleteDivId(@PathVariable(value = "id") String id) {
|
||||
divIdService.deleteDivId(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/div/pages", method = RequestMethod.GET)
|
||||
public Set<String> getDivIdsPages(@RequestParam(value="portal", required = false) String pid) {
|
||||
return divIdService.getDivIdsPages(pid);
|
||||
}
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/div/{id}", method = RequestMethod.DELETE)
|
||||
// public void deleteDivId(@PathVariable(value = "id") String id) {
|
||||
// divIdService.deleteDivId(id);
|
||||
// }
|
||||
//
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/div/pages", method = RequestMethod.GET)
|
||||
// public Set<String> getDivIdsPages(@RequestParam(value="portal", required = false) String pid) {
|
||||
// return divIdService.getDivIdsPages(pid);
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -18,43 +18,53 @@ public class EntityController {
|
|||
@Autowired
|
||||
private EntityService entityService;
|
||||
|
||||
// used
|
||||
@RequestMapping(value = "/entity", method = RequestMethod.GET)
|
||||
public List<Entity> getAllEntities() {
|
||||
return entityService.getAllEntities();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/entity", method = RequestMethod.DELETE)
|
||||
public void deleteAllEntities() {
|
||||
entityService.deleteAllEntities();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/entity", method = RequestMethod.POST)
|
||||
public Entity insertOrUpdateEntity(@RequestBody Entity entity) {
|
||||
return entityService.insertOrUpdateEntity(entity);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/entity/{id}", method = RequestMethod.GET)
|
||||
public Entity getEntity(@PathVariable(value = "id") String id) {
|
||||
return entityService.getEntity(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/entity/{id}", method = RequestMethod.DELETE)
|
||||
public void deleteEntity(@PathVariable(value = "id") String id) {
|
||||
entityService.deleteEntity(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/entity/update", method = RequestMethod.POST)
|
||||
public PortalEntity updateEntity(@RequestBody PortalEntity portalEntity) {
|
||||
return entityService.updateEntity(portalEntity);
|
||||
}
|
||||
|
||||
// used
|
||||
// @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
|
||||
@RequestMapping(value = "/entity/save", method = RequestMethod.POST)
|
||||
public PortalEntity insertEntity(@RequestBody Entity entity) {
|
||||
return entityService.insertEntity(entity);
|
||||
}
|
||||
|
||||
// used
|
||||
// @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
|
||||
@RequestMapping(value = "/entity/update", method = RequestMethod.POST)
|
||||
public PortalEntity updateEntity(@RequestBody PortalEntity portalEntity) {
|
||||
return entityService.updateEntity(portalEntity);
|
||||
}
|
||||
|
||||
// used
|
||||
// @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
|
||||
@RequestMapping(value = "/entity/delete", method = RequestMethod.POST)
|
||||
public Boolean deleteEntities(@RequestBody List<String> entities) throws Exception {
|
||||
return entityService.deleteEntities(entities);
|
||||
}
|
||||
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/entity", method = RequestMethod.DELETE)
|
||||
// public void deleteAllEntities() {
|
||||
// entityService.deleteAllEntities();
|
||||
// }
|
||||
//
|
||||
// // not used by portals @RequestMapping(value = "/entity", method = RequestMethod.POST)
|
||||
// public Entity insertOrUpdateEntity(@RequestBody Entity entity) {
|
||||
// return entityService.insertOrUpdateEntity(entity);
|
||||
// }
|
||||
//
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/entity/{id}", method = RequestMethod.GET)
|
||||
// public Entity getEntity(@PathVariable(value = "id") String id) {
|
||||
// return entityService.getEntity(id);
|
||||
// }
|
||||
//
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/entity/{id}", method = RequestMethod.DELETE)
|
||||
// public void deleteEntity(@PathVariable(value = "id") String id) {
|
||||
// entityService.deleteEntity(id);
|
||||
// }
|
||||
}
|
|
@ -18,12 +18,14 @@ public class PageController {
|
|||
@Autowired
|
||||
private PageService pageService;
|
||||
|
||||
@RequestMapping(value = "/pageFull", method = RequestMethod.GET)
|
||||
// used by portals WITHOUT ANY PARAMS
|
||||
@RequestMapping(value = "/page/full", method = RequestMethod.GET)
|
||||
public List<PortalPage> getPagesFull(@RequestParam(value="pid", required=false) String pid,
|
||||
@RequestParam(value="page_route", required=false) String page_route) {
|
||||
return pageService.getPagesFull(pid, page_route);
|
||||
}
|
||||
|
||||
// used by portals WITHOUT ANY PARAMS
|
||||
@RequestMapping(value = "/page", method = RequestMethod.GET)
|
||||
public List<Page> getAllPages(@RequestParam(value="pid", required=false) String pid,
|
||||
@RequestParam(value="page_route", required=false) String page_route,
|
||||
|
@ -31,43 +33,54 @@ public class PageController {
|
|||
return pageService.getAllPages(pid, page_route, with_positions);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page", method = RequestMethod.DELETE)
|
||||
public void deleteAllPages() {
|
||||
pageService.deleteAllPages();
|
||||
}
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/page", method = RequestMethod.DELETE)
|
||||
// public void deleteAllPages() {
|
||||
// pageService.deleteAllPages();
|
||||
// }
|
||||
|
||||
// used
|
||||
// @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
|
||||
@RequestMapping(value = "/page/update", method = RequestMethod.POST)
|
||||
public PortalPage updatePage(@RequestBody PortalPage portalPage) {
|
||||
return pageService.updatePage(portalPage);
|
||||
}
|
||||
|
||||
// used
|
||||
// @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
|
||||
@RequestMapping(value = "/page/save", method = RequestMethod.POST)
|
||||
public PortalPage insertPage(@RequestBody PortalPage portalPage) {
|
||||
return pageService.insertPage(portalPage);
|
||||
}
|
||||
|
||||
// used
|
||||
// @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
|
||||
@RequestMapping(value = "/page/delete", method = RequestMethod.POST)
|
||||
public Boolean deletePages(@RequestBody List<String> pages) throws Exception {
|
||||
return pageService.deletePages(pages);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page/{id}", method = RequestMethod.GET)
|
||||
public Page getPage(@PathVariable(value = "id") String id) {
|
||||
return pageService.getPage(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page/{id}", method = RequestMethod.DELETE)
|
||||
public void deletePage(@PathVariable(value = "id") String id) {
|
||||
pageService.deletePage(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page/{id}/entity", method = RequestMethod.GET)
|
||||
public List<String> getPageEntities(@PathVariable(value = "id") String id) {
|
||||
return pageService.getPageEntities(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "page/{id}/entity/toggle", method = RequestMethod.POST)
|
||||
public Page togglePageEntity(@PathVariable(value = "id") String id, @RequestParam String entityId, @RequestParam String status) throws Exception {
|
||||
return pageService.togglePageEntity(id, entityId, status);
|
||||
}
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/page/{id}", method = RequestMethod.GET)
|
||||
// public Page getPage(@PathVariable(value = "id") String id) {
|
||||
// return pageService.getPage(id);
|
||||
// }
|
||||
//
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/page/{id}", method = RequestMethod.DELETE)
|
||||
// public void deletePage(@PathVariable(value = "id") String id) {
|
||||
// pageService.deletePage(id);
|
||||
// }
|
||||
//
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/page/{id}/entity", method = RequestMethod.GET)
|
||||
// public List<String> getPageEntities(@PathVariable(value = "id") String id) {
|
||||
// return pageService.getPageEntities(id);
|
||||
// }
|
||||
//
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "page/{id}/entity/toggle", method = RequestMethod.POST)
|
||||
// public Page togglePageEntity(@PathVariable(value = "id") String id, @RequestParam String entityId, @RequestParam String status) throws Exception {
|
||||
// return pageService.togglePageEntity(id, entityId, status);
|
||||
// }
|
||||
}
|
|
@ -18,48 +18,56 @@ public class PageHelpContentController {
|
|||
@Autowired
|
||||
private PageHelpContentService pageHelpContentService;
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent", method = RequestMethod.GET)
|
||||
public List<PageHelpContentResponse> getPageHelpContents(@RequestParam(value = "portal", required = false) String pid,
|
||||
@RequestParam(required=false) String portalType,
|
||||
@RequestParam(required=false) String page,
|
||||
@RequestParam(required=false) String position,
|
||||
@RequestParam(required=false) String active,
|
||||
@RequestParam(required=false) String before) {
|
||||
return pageHelpContentService.getPageHelpContents(pid, portalType, page, position, active, before);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent", method = RequestMethod.DELETE)
|
||||
public void deleteAllPageHelpContents() {
|
||||
pageHelpContentService.deleteAllPageHelpContents();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent/save", method = RequestMethod.POST)
|
||||
public PageHelpContent insertPageHelpContent(@RequestBody PageHelpContent pageHelpContent) {
|
||||
return pageHelpContentService.insertPageHelpContent(pageHelpContent);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent/update", method = RequestMethod.POST)
|
||||
public PageHelpContent updatePageHelpContent(@RequestBody PageHelpContent pageHelpContent) {
|
||||
return pageHelpContentService.updatePageHelpContent(pageHelpContent);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent/{id}", method = RequestMethod.GET)
|
||||
public PageHelpContent getPageHelpContent(@PathVariable(value = "id") String id) {
|
||||
return pageHelpContentService.getPageHelpContent(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent/toggle", method = RequestMethod.POST)
|
||||
public List<String> togglePageHelpContent(@RequestBody List<String> pageHelpContents, @RequestParam String status) throws Exception {
|
||||
return pageHelpContentService.togglePageHelpContent(pageHelpContents, status);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent/{id}", method = RequestMethod.DELETE)
|
||||
public void deletePageHelpContent(@PathVariable(value = "id") String id) {
|
||||
pageHelpContentService.deletePageHelpContent(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent/delete", method = RequestMethod.POST)
|
||||
public Boolean deletePageHelpContents(@RequestBody List<String> pageHelpContents) throws Exception {
|
||||
return pageHelpContentService.deletePageHelpContents(pageHelpContents);
|
||||
}
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/pagehelpcontent", method = RequestMethod.GET)
|
||||
// public List<PageHelpContentResponse> getPageHelpContents(@RequestParam(value = "portal", required = false) String pid,
|
||||
// @RequestParam(required=false) String portalType,
|
||||
// @RequestParam(required=false) String page,
|
||||
// @RequestParam(required=false) String position,
|
||||
// @RequestParam(required=false) String active,
|
||||
// @RequestParam(required=false) String before) {
|
||||
// return pageHelpContentService.getPageHelpContents(pid, portalType, page, position, active, before);
|
||||
// }
|
||||
//
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/pagehelpcontent", method = RequestMethod.DELETE)
|
||||
// public void deleteAllPageHelpContents() {
|
||||
// pageHelpContentService.deleteAllPageHelpContents();
|
||||
// }
|
||||
//
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/pagehelpcontent/save", method = RequestMethod.POST)
|
||||
// public PageHelpContent insertPageHelpContent(@RequestBody PageHelpContent pageHelpContent) {
|
||||
// return pageHelpContentService.insertPageHelpContent(pageHelpContent);
|
||||
// }
|
||||
//
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/pagehelpcontent/update", method = RequestMethod.POST)
|
||||
// public PageHelpContent updatePageHelpContent(@RequestBody PageHelpContent pageHelpContent) {
|
||||
// return pageHelpContentService.updatePageHelpContent(pageHelpContent);
|
||||
// }
|
||||
//
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/pagehelpcontent/{id}", method = RequestMethod.GET)
|
||||
// public PageHelpContent getPageHelpContent(@PathVariable(value = "id") String id) {
|
||||
// return pageHelpContentService.getPageHelpContent(id);
|
||||
// }
|
||||
//
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/pagehelpcontent/toggle", method = RequestMethod.POST)
|
||||
// public List<String> togglePageHelpContent(@RequestBody List<String> pageHelpContents, @RequestParam String status) throws Exception {
|
||||
// return pageHelpContentService.togglePageHelpContent(pageHelpContents, status);
|
||||
// }
|
||||
//
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/pagehelpcontent/{id}", method = RequestMethod.DELETE)
|
||||
// public void deletePageHelpContent(@PathVariable(value = "id") String id) {
|
||||
// pageHelpContentService.deletePageHelpContent(id);
|
||||
// }
|
||||
//
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = "/pagehelpcontent/delete", method = RequestMethod.POST)
|
||||
// public Boolean deletePageHelpContents(@RequestBody List<String> pageHelpContents) throws Exception {
|
||||
// return pageHelpContentService.deletePageHelpContents(pageHelpContents);
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Portal;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.*;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.*;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.services.*;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -11,6 +11,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "{portalType}")
|
||||
@CrossOrigin(origins = "*")
|
||||
public class PortalController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
@ -18,313 +19,46 @@ public class PortalController {
|
|||
@Autowired
|
||||
private PortalService portalService;
|
||||
|
||||
@RequestMapping(value = {"/community", "/explore", "/connect"}, method = RequestMethod.GET)
|
||||
public List<Portal> getAllCommunities() {
|
||||
List<Portal> communities = portalService.getAllPortals();
|
||||
|
||||
return communities;
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/communityFull", "/exploreFull", "/connectFull"}, method = RequestMethod.GET)
|
||||
public List<PortalResponse> getAllCommunitiesFull() {
|
||||
// List<Community> communities = portalDAO.findAll();
|
||||
// List<CommunityResponse> communitiesResponse = new ArrayList<>();
|
||||
// for(Community community : communities) {
|
||||
// CommunityResponse communityResponse = new CommunityResponse(community);
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = {"/"}, method = RequestMethod.POST)
|
||||
// public Portal insertOrUpdatePortal(@PathVariable PortalType portalType, @RequestBody Portal portal) {
|
||||
// return portalService.insertOrUpdatePortal(portal);
|
||||
// }
|
||||
//
|
||||
// List<CommunityPage> pages = this.getPagesForCommunityByType(community.getPid(), null, null, null);
|
||||
// log.debug("PAGES number="+pages.size());
|
||||
// Iterator<CommunityPage> iteratorPages = pages.iterator();
|
||||
// while(iteratorPages.hasNext()) {
|
||||
// CommunityPage page = iteratorPages.next();
|
||||
// if(!page.getIsEnabled()) {
|
||||
// iteratorPages.remove();
|
||||
// }
|
||||
// }
|
||||
// communityResponse.setPages(pages);
|
||||
// log.debug("PAGES set");
|
||||
//
|
||||
// List<CommunityEntity> entities = this.getEntitiesForCommunity(community.getPid(), null);
|
||||
// log.debug("ENTITIES number="+entities.size());
|
||||
// Iterator<CommunityEntity> iteratorEntities = entities.iterator();
|
||||
// while(iteratorEntities.hasNext()) {
|
||||
// CommunityEntity entity = iteratorEntities.next();
|
||||
// if(!entity.getIsEnabled()) {
|
||||
// iteratorEntities.remove();
|
||||
// }
|
||||
// }
|
||||
// communityResponse.setEntities(entities);
|
||||
// Layout layout = layoutDAO.findById(community.getLayout());
|
||||
// communityResponse.setLayout(layout);
|
||||
// communitiesResponse.add(communityResponse);
|
||||
// }
|
||||
// return communitiesResponse;
|
||||
// TODO check where is this used? no more layout in response!!
|
||||
return portalService.getAllPortalsFull();
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/communityFull/{pid}", "/exploreFull/{pid}", "/connectFull/{pid}"}, method = RequestMethod.GET)
|
||||
public PortalResponse getCommunityFull(@PathVariable(value = "pid") String pid) {
|
||||
// Community community = portalDAO.findByPid(pid);
|
||||
// CommunityResponse communityResponse = new CommunityResponse(community);
|
||||
//
|
||||
// List<CommunityPage> pages = this.getPagesForCommunityByType(community.getPid(), null, null, null);
|
||||
// Iterator<CommunityPage> iteratorPages = pages.iterator();
|
||||
// while(iteratorPages.hasNext()) {
|
||||
// CommunityPage page = iteratorPages.next();
|
||||
// if(!page.getIsEnabled()) {
|
||||
// iteratorPages.remove();
|
||||
// }
|
||||
// }
|
||||
// communityResponse.setPages(pages);
|
||||
//
|
||||
// List<CommunityEntity> entities = this.getEntitiesForCommunity(community.getPid(), null);
|
||||
// Iterator<CommunityEntity> iteratorEntities = entities.iterator();
|
||||
// while(iteratorEntities.hasNext()) {
|
||||
// CommunityEntity entity = iteratorEntities.next();
|
||||
// if(!entity.getIsEnabled()) {
|
||||
// iteratorEntities.remove();
|
||||
// }
|
||||
// }
|
||||
// communityResponse.setEntities(entities);
|
||||
// Layout layout = layoutDAO.findById(community.getLayout());
|
||||
// communityResponse.setLayout(layout);
|
||||
//
|
||||
// return communityResponse;
|
||||
// TODO check where is this used? no more layout in response!!
|
||||
return portalService.getPortalFull(pid);
|
||||
}
|
||||
/*
|
||||
|
||||
@RequestMapping(value = "/communityFullByName/{name}", method = RequestMethod.GET)
|
||||
public CommunityResponse getCommunityFullByName(@PathVariable(value = "name") String name) {
|
||||
Community community = portalDAO.findByName(name);
|
||||
CommunityResponse communityResponse = new CommunityResponse(community);
|
||||
|
||||
List<CommunityPage> pages = this.getPagesForCommunityByType(community.getId(), null, null);
|
||||
Iterator<CommunityPage> iteratorPages = pages.iterator();
|
||||
while(iteratorPages.hasNext()) {
|
||||
CommunityPage page = iteratorPages.next();
|
||||
if(!page.getIsEnabled()) {
|
||||
iteratorPages.remove();
|
||||
}
|
||||
}
|
||||
communityResponse.setPages(pages);
|
||||
|
||||
List<CommunityEntity> entities = this.getEntitiesForCommunity(community.getId(), null);
|
||||
Iterator<CommunityEntity> iteratorEntities = entities.iterator();
|
||||
while(iteratorEntities.hasNext()) {
|
||||
CommunityEntity entity = iteratorEntities.next();
|
||||
if(!entity.getIsEnabled()) {
|
||||
iteratorEntities.remove();
|
||||
}
|
||||
}
|
||||
communityResponse.setEntities(entities);
|
||||
|
||||
return communityResponse;
|
||||
}
|
||||
*/
|
||||
|
||||
// @RequestMapping(value = "/community", method = RequestMethod.DELETE)
|
||||
// public void deleteAllCommunities() {
|
||||
// portalDAO.deleteAll();
|
||||
// // not used by portals
|
||||
// @RequestMapping(value = {"/{id}"}, method = RequestMethod.DELETE)
|
||||
// public void deletePortal(@PathVariable PortalType portalType, @PathVariable(value = "id") String id) {
|
||||
// portalService.deletePortalId(id);
|
||||
// }
|
||||
|
||||
@RequestMapping(value = {"/community", "/explore", "/connect"}, method = RequestMethod.POST)
|
||||
public Portal insertOrUpdateCommunity(@RequestBody Portal portal) {
|
||||
return portalService.insertOrUpdatePortal(portal);
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/community/{pid}", "/explore/{pid}", "/connect/{pid}"}, method = RequestMethod.GET)
|
||||
public Portal getCommunity(@PathVariable(value = "pid") String pid) {
|
||||
// used
|
||||
@RequestMapping(value = {"/{pid}"}, method = RequestMethod.GET)
|
||||
public Portal getPortal(@PathVariable PortalType portalType, @PathVariable(value = "pid") String pid) {
|
||||
log.debug("PID: "+ pid);
|
||||
return portalService.getPortal(pid);
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/community/{id}", "/explore/{id}", "/connect/{id}"}, method = RequestMethod.DELETE)
|
||||
public void deleteCommunity(@PathVariable(value = "id") String id) {
|
||||
portalService.deletePortalId(id);
|
||||
// used
|
||||
@RequestMapping(value = {"/{pid}/full"}, method = RequestMethod.GET)
|
||||
public PortalResponse getPortalFull(@PathVariable PortalType portalType, @PathVariable(value = "pid") String pid) {
|
||||
return portalService.getPortalFull(pid);
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/community/{pid}/pages", "/explore/{pid}/pages", "/connect/{pid}/pages"}, method = RequestMethod.GET)
|
||||
public List<PortalPage> getPagesForCommunityByType(@PathVariable(value = "pid") String pid,
|
||||
@RequestParam(value="page_type", required=false) String page_type,
|
||||
@RequestParam(value="page_route", required=false) String page_route,
|
||||
@RequestParam(value="div", required = false) String div) {
|
||||
// List<CommunityPage> return_pages = new ArrayList<CommunityPage>();
|
||||
// Map<String, Boolean> pages = portalDAO.findByPid(pid).getPages();
|
||||
//
|
||||
// if(pages != null) {
|
||||
// for (Map.Entry<String, Boolean> page : pages.entrySet()) {
|
||||
// if(div != null && div.equals("true")) {
|
||||
// Community community = portalDAO.findByPid(pid);
|
||||
// List<DivId> divIds = divIdDAO.findByPagesContaining(page.getKey());
|
||||
// Iterator<DivId> divIdIterator = divIds.iterator();
|
||||
//
|
||||
// while (divIdIterator.hasNext()) {
|
||||
// DivId divId = divIdIterator.next();
|
||||
// if((pid.equals("openaire") && !divId.getOpenaire()) ||
|
||||
// (pid.equals("connect") && !divId.getConnect()) ||
|
||||
// (!pid.equals("openaire") && !pid.equals("connect") && !divId.getCommunities())) {
|
||||
// divIdIterator.remove();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(divIds.isEmpty()) {
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Page p = pageDAO.findById(page.getKey());
|
||||
//
|
||||
// if((pid.equals("openaire") && p.getOpenaire()) || (pid.equals("connect") && p.getConnect()) ||(!pid.equals("openaire") && !pid.equals("connect") && p.getCommunities())) {
|
||||
// if ((page_type == null && page_route == null) || (page_route == null && p.getType().equals(page_type))
|
||||
// || p.getRoute().equals(page_route)) {
|
||||
// CommunityPage communityPage = new CommunityPage(p);
|
||||
//
|
||||
// List<Entity> entities = new ArrayList<>();
|
||||
// for (String entity : p.getEntities()) {
|
||||
// entities.add(entityDAO.findById(entity));
|
||||
// }
|
||||
// communityPage.setEntities(entities);
|
||||
// communityPage.setIsEnabled(page.getValue());
|
||||
//
|
||||
// return_pages.add(communityPage);
|
||||
//
|
||||
// if (page_route != null) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return_pages.sort(Comparator.comparing(CommunityPage::getName));
|
||||
// return return_pages;
|
||||
return portalService.getPagesForPortalByType(pid, page_type, page_route, div);
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/community/{id}/page", "/explore/{id}/page", "/connect/{id}/page"}, method = RequestMethod.POST)
|
||||
public Portal insertOrUpdatePage(@PathVariable(value = "id") String id, @RequestBody PortalPage page) {
|
||||
// Community community = portalDAO.findById(id);
|
||||
// Map<String, Boolean> pages = community.getPages();
|
||||
//
|
||||
// String name = page.getName();
|
||||
// boolean isEnabled = page.getIsEnabled();
|
||||
//
|
||||
// pages.put(name, isEnabled);
|
||||
// community.setPages(pages);
|
||||
//
|
||||
// return portalDAO.save(community);
|
||||
return portalService.insertOrUpdatePage(id, page);
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/community/{pid}/page/toggle", "/explore/{pid}/page/toggle", "/connect/{pid}/page/toggle"}, method = RequestMethod.POST)
|
||||
public Portal togglePage(@PathVariable(value = "pid") String pid, @RequestBody List<String> pageIds, @RequestParam String status) throws Exception {
|
||||
// Community community = portalDAO.findByPid(pid);
|
||||
// Map<String, Boolean> pages = community.getPages();
|
||||
//
|
||||
// for (String pageId: pageIds) {
|
||||
// log.debug("Toggle community page: " + pageId + " of community: " + pid + " to " + status);
|
||||
// pages.put(pageId, Boolean.parseBoolean(status));
|
||||
// }
|
||||
//
|
||||
// community.setPages(pages);
|
||||
// return portalDAO.save(community);
|
||||
return portalService.togglePage(pid, pageIds, status);
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/community/{pid}/entity/toggle", "/explore/{pid}/entity/toggle", "/connect/{pid}/entity/toggle"}, method = RequestMethod.POST)
|
||||
public Portal toggleEntity(@PathVariable(value = "pid") String pid, @RequestBody List<String> entityIds, @RequestParam String status) throws Exception {
|
||||
// Community community = portalDAO.findByPid(pid);
|
||||
// Map<String, Boolean> entities = community.getEntities();
|
||||
// Map<String, Boolean> pages = community.getPages();
|
||||
//
|
||||
// for (String entityId: entityIds) {
|
||||
// log.debug("Toggle community entity: " + entityId + " of community: " + pid + " to " + status);
|
||||
//
|
||||
// entities.put(entityId, Boolean.parseBoolean(status));
|
||||
//
|
||||
// if(pages != null) {
|
||||
// for (Map.Entry<String, Boolean> pageEntry : pages.entrySet()) {
|
||||
// Page page = pageDAO.findById(pageEntry.getKey());
|
||||
// if (page.getEntities().contains(entityId) && page.getType().equals("search")) {
|
||||
// pages.put(pageEntry.getKey(), Boolean.parseBoolean(status));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// community.setEntities(entities);
|
||||
// return portalDAO.save(community);
|
||||
return portalService.toggleEntity(pid, entityIds, status);
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/community/{pid}/entities", "/explore/{pid}/entities", "/connect/{pid}/entities"}, method = RequestMethod.GET)
|
||||
public List<PortalEntity> getEntitiesForCommunity(@PathVariable(value = "pid") String pid, @RequestParam(value="entity", required=false) String entity) {
|
||||
// List<CommunityEntity> return_entities = new ArrayList<CommunityEntity>();
|
||||
// Map<String, Boolean> entities = portalDAO.findByPid(pid).getEntities();
|
||||
//
|
||||
// log.debug("/community/"+pid+"/entities -- entity: "+entity);
|
||||
// if (entity != null) {
|
||||
// String entityId = entityDAO.findByPid(entity).getId();
|
||||
// CommunityEntity communityEntity = new CommunityEntity(entityDAO.findById(entityId));
|
||||
// communityEntity.setIsEnabled(entities.get(entityId));
|
||||
// return_entities.add(communityEntity);
|
||||
// } else {
|
||||
// if(entities != null) {
|
||||
// for (Map.Entry<String, Boolean> _entity : entities.entrySet()) {
|
||||
// CommunityEntity communityEntity = new CommunityEntity(entityDAO.findById(_entity.getKey()));
|
||||
// communityEntity.setIsEnabled(_entity.getValue());
|
||||
// return_entities.add(communityEntity);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return return_entities;
|
||||
return portalService.getEntitiesForPortal(pid, entity);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = {"/community/{pid}/pagehelpcontent", "/explore/{pid}/pagehelpcontent", "/connect/{pid}/pagehelpcontent"}, method = RequestMethod.GET)
|
||||
public Map<String, List<PageHelpContentResponse>> getPageHelpContentsByPosition(@PathVariable(value = "pid") String pid,
|
||||
@RequestParam(required=false) String page,
|
||||
@RequestParam(required=false) String active) {
|
||||
// Map<String, List<PageHelpContentResponse>> pageHelpContentResponses = new HashMap<>();
|
||||
//
|
||||
// List<PageHelpContentResponse> pageHelpContents = null;
|
||||
// pageHelpContents = pageHelpContentService.getPageHelpContents(pid, page, null, active, null);
|
||||
//
|
||||
// pageHelpContentResponses.put("top", new ArrayList<>());
|
||||
// pageHelpContentResponses.put("bottom", new ArrayList<>());
|
||||
// pageHelpContentResponses.put("left", new ArrayList<>());
|
||||
// pageHelpContentResponses.put("right", new ArrayList<>());
|
||||
//
|
||||
// for (PageHelpContentResponse pageHelpContentResponse : pageHelpContents) {
|
||||
// pageHelpContentResponses.get(pageHelpContentResponse.getPlacement()).add(pageHelpContentResponse);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// return pageHelpContentResponses;
|
||||
return portalService.getPageHelpContentsByPosition(pid, page, active);
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/community/{pid}/divhelpcontent", "/explore/{pid}/divhelpcontent", "/connect/{pid}/divhelpcontent"}, method = RequestMethod.GET)
|
||||
public Map<String, List<DivHelpContentResponse>> getDivHelpContentsByPosition(@PathVariable(value = "pid") String pid,
|
||||
@RequestParam(required=false) String page,
|
||||
@RequestParam(required=false) String active) {
|
||||
// Map<String, List<DivHelpContentResponse>> divHelpContentResponses = new HashMap<>();
|
||||
//
|
||||
// List<DivHelpContentResponse> divHelpContents = null;
|
||||
// divHelpContents = divHelpContentService.getDivHelpContents(pid, page, null, active);
|
||||
//
|
||||
// for (DivHelpContentResponse divHelpContentResponse : divHelpContents) {
|
||||
// if(!divHelpContentResponses.containsKey(divHelpContentResponse.getDivId())) {
|
||||
// divHelpContentResponses.put(divHelpContentResponse.getDivId().getName(), new ArrayList<>());
|
||||
// }
|
||||
// divHelpContentResponses.get(divHelpContentResponse.getDivId().getName()).add(divHelpContentResponse);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// return divHelpContentResponses;
|
||||
// used
|
||||
@RequestMapping(value = {"/{pid}/divhelpcontent/grouped"}, method = RequestMethod.GET)
|
||||
public Map<String, List<DivHelpContentResponse>> getDivHelpContentsByPosition(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid,
|
||||
@RequestParam(required=true) String page,
|
||||
@RequestParam(required=true) String active) {
|
||||
return portalService.getDivHelpContentsByPosition(pid, page, active);
|
||||
}
|
||||
|
||||
// used
|
||||
@RequestMapping(value = {"/{pid}/pagehelpcontent/grouped"}, method = RequestMethod.GET)
|
||||
public Map<String, List<PageHelpContentResponse>> getPageHelpContentsByPosition(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid,
|
||||
@RequestParam(required=true) String page,
|
||||
@RequestParam(required=true) String active) {
|
||||
return portalService.getPageHelpContentsByPosition(pid, page, active);
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@ public class DivId {
|
|||
|
||||
private String name;
|
||||
private List<String> pages;
|
||||
private String portalType; // explore, connect, community, monitor
|
||||
private PortalType portalType; // explore, connect, community, monitor
|
||||
|
||||
// private Boolean connect;
|
||||
// private Boolean communities;
|
||||
|
@ -50,7 +50,19 @@ public class DivId {
|
|||
this.pages = pages;
|
||||
}
|
||||
|
||||
public String getPortalType() { return portalType; }
|
||||
public String getPortalType() {
|
||||
if(portalType == null) {
|
||||
return null;
|
||||
}
|
||||
return portalType.name();
|
||||
}
|
||||
|
||||
public void setPortalType(String portalType) { this.portalType = portalType; }
|
||||
public void setPortalType(String portalType) {
|
||||
if(portalType == null) {
|
||||
this.portalType = null;
|
||||
} else {
|
||||
PortalType pType = PortalType.valueOf(portalType);
|
||||
this.portalType = pType;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ public class Page {
|
|||
private String name;
|
||||
private String type;
|
||||
private List<String> entities;
|
||||
private String portalType; // explore, connect, community, monitor
|
||||
private PortalType portalType; // explore, connect, community, monitor
|
||||
|
||||
// private Boolean connect;
|
||||
// private Boolean communities;
|
||||
|
@ -64,9 +64,25 @@ public class Page {
|
|||
|
||||
public void setEntities(List<String> entities) { this.entities = entities; }
|
||||
|
||||
public String getPortalType() { return portalType; }
|
||||
// public String getPortalType() { return portalType; }
|
||||
//
|
||||
// public void setPortalType(String portalType) { this.portalType = portalType; }
|
||||
|
||||
public void setPortalType(String portalType) { this.portalType = portalType; }
|
||||
public String getPortalType() {
|
||||
if(portalType == null) {
|
||||
return null;
|
||||
}
|
||||
return portalType.name();
|
||||
}
|
||||
|
||||
public void setPortalType(String portalType) {
|
||||
if(portalType == null) {
|
||||
this.portalType = null;
|
||||
} else {
|
||||
PortalType pType = PortalType.valueOf(portalType);
|
||||
this.portalType = pType;
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean getTop() {
|
||||
return top;
|
||||
|
|
|
@ -13,7 +13,7 @@ public class Portal {
|
|||
|
||||
private String pid;
|
||||
private String name;
|
||||
private String type; // explore, connect, community, monitor
|
||||
private PortalType type; // explore, connect, community, monitor
|
||||
private Map<String, Boolean> pages;
|
||||
private Map<String, Boolean> entities;
|
||||
|
||||
|
@ -44,11 +44,19 @@ public class Portal {
|
|||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
if(type == null) {
|
||||
return null;
|
||||
}
|
||||
return type.name();
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
if(type == null) {
|
||||
this.type = null;
|
||||
} else {
|
||||
PortalType pType = PortalType.valueOf(type);
|
||||
this.type = pType;
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Boolean> getPages() { return pages; }
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.entities;
|
||||
|
||||
public enum PortalType {
|
||||
explore, connect, community, monitor
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.PortalType;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -15,7 +16,7 @@ public class DivIdResponse {
|
|||
|
||||
private String name;
|
||||
private List<Page> pages;
|
||||
private String portalType; // explore, connect, community, monitor
|
||||
private PortalType portalType; // explore, connect, community, monitor
|
||||
|
||||
// private Boolean connect;
|
||||
// private Boolean communities;
|
||||
|
@ -53,7 +54,19 @@ public class DivIdResponse {
|
|||
this.pages = pages;
|
||||
}
|
||||
|
||||
public String getPortalType() { return portalType; }
|
||||
public String getPortalType() {
|
||||
if(portalType == null) {
|
||||
return null;
|
||||
}
|
||||
return portalType.name();
|
||||
}
|
||||
|
||||
public void setPortalType(String portalType) { this.portalType = portalType; }
|
||||
public void setPortalType(String portalType) {
|
||||
if(portalType == null) {
|
||||
this.portalType = null;
|
||||
} else {
|
||||
PortalType pType = PortalType.valueOf(portalType);
|
||||
this.portalType = pType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.PortalType;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -19,7 +20,7 @@ public class PortalPage {
|
|||
private String type;
|
||||
private List<Entity> entities;
|
||||
private Boolean isEnabled;
|
||||
private String portalType; // explore, connect, community, monitor
|
||||
private PortalType portalType; // explore, connect, community, monitor
|
||||
|
||||
// private Boolean connect;
|
||||
// private Boolean communities;
|
||||
|
@ -85,9 +86,21 @@ public class PortalPage {
|
|||
|
||||
public void setIsEnabled(Boolean isEnabled) { this.isEnabled = isEnabled; }
|
||||
|
||||
public String getPortalType() { return portalType; }
|
||||
public String getPortalType() {
|
||||
if(portalType == null) {
|
||||
return null;
|
||||
}
|
||||
return portalType.name();
|
||||
}
|
||||
|
||||
public void setPortalType(String portalType) { this.portalType = portalType; }
|
||||
public void setPortalType(String portalType) {
|
||||
if(portalType == null) {
|
||||
this.portalType = null;
|
||||
} else {
|
||||
PortalType pType = PortalType.valueOf(portalType);
|
||||
this.portalType = pType;
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean getTop() {
|
||||
return top;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.PortalType;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -14,7 +15,7 @@ public class PortalResponse {
|
|||
|
||||
private String pid;
|
||||
private String name;
|
||||
private String type; // explore, connect, community, monitor
|
||||
private PortalType type; // explore, connect, community, monitor
|
||||
private List<PortalPage> pages;
|
||||
private List<PortalEntity> entities;
|
||||
|
||||
|
@ -52,11 +53,19 @@ public class PortalResponse {
|
|||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
if(type == null) {
|
||||
return null;
|
||||
}
|
||||
return type.name();
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
if(type == null) {
|
||||
this.type = null;
|
||||
} else {
|
||||
PortalType pType = PortalType.valueOf(type);
|
||||
this.type = pType;
|
||||
}
|
||||
}
|
||||
|
||||
public List<PortalPage> getPages() { return pages; }
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.handlers;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.responses.ExceptionResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.MissingServletRequestParameterException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
|
||||
@ControllerAdvice
|
||||
public class AdminToolsLibraryExceptionsHandler {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@ExceptionHandler(MissingServletRequestParameterException.class)
|
||||
public ResponseEntity<ExceptionResponse> invalidInput(Exception ex) {
|
||||
ExceptionResponse response = new ExceptionResponse();
|
||||
response.setErrorCode("Validation Error");
|
||||
response.setErrorMessage("Invalid inputs.");
|
||||
response.setErrors(ex.getMessage());
|
||||
log.debug("invalidInput exception");
|
||||
|
||||
return new ResponseEntity<ExceptionResponse>(response, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@ExceptionHandler(MismatchingContentException.class)
|
||||
public ResponseEntity<ExceptionResponse> mismatchingContentException(Exception ex) {
|
||||
ExceptionResponse response = new ExceptionResponse();
|
||||
response.setErrorCode("Conflicting content given");
|
||||
response.setErrorMessage(ex.getMessage());
|
||||
response.setErrors(ex.getMessage());
|
||||
log.debug("mismatchingContent exception" + response.getErrorCode()+ " "+response.getErrorMessage());
|
||||
return new ResponseEntity<ExceptionResponse>(response, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@ExceptionHandler(ContentNotFoundException.class)
|
||||
public ResponseEntity<ExceptionResponse> contentNotFoundException(Exception ex) {
|
||||
ExceptionResponse response = new ExceptionResponse();
|
||||
response.setErrorCode("No content found");
|
||||
response.setErrorMessage(ex.getMessage());
|
||||
response.setErrors(ex.getMessage());
|
||||
log.debug("contentNotFound exception" + response.getErrorCode()+ " "+response.getErrorMessage());
|
||||
return new ResponseEntity<ExceptionResponse>(response, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@ExceptionHandler(NullPointerException.class)
|
||||
public ResponseEntity<ExceptionResponse> nullPointerException(Exception ex) {
|
||||
ExceptionResponse response = new ExceptionResponse();
|
||||
response.setErrorCode("Null pointer Exception");
|
||||
response.setErrorMessage("Null pointer Exception");
|
||||
response.setErrors(ex.getMessage());
|
||||
log.debug("nullPointerException exception");
|
||||
return new ResponseEntity<ExceptionResponse>(response, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@ExceptionHandler(InvalidReCaptchaException.class)
|
||||
public ResponseEntity<ExceptionResponse> invalidReCaptchaException(Exception ex) {
|
||||
ExceptionResponse response = new ExceptionResponse();
|
||||
response.setErrorCode("Invalid ReCaptcha Exception");
|
||||
response.setErrorMessage("Invalid ReCaptcha Exception");
|
||||
response.setErrors(ex.getMessage());
|
||||
log.debug("invalidReCaptchaException exception");
|
||||
return new ResponseEntity<ExceptionResponse>(response, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.handlers;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public class ContentNotFoundException extends RuntimeException {
|
||||
public ContentNotFoundException(String message){
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.handlers;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public class MismatchingContentException extends RuntimeException {
|
||||
public MismatchingContentException(String message){
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.recaptcha;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Configurable;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
|
@ -18,7 +19,7 @@ import eu.dnetlib.uoaadmintoolslibrary.handlers.InvalidReCaptchaException;
|
|||
@Service
|
||||
@Configurable
|
||||
public class VerifyRecaptcha {
|
||||
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
@Autowired
|
||||
private RestOperations restTemplate;
|
||||
|
||||
|
@ -34,7 +35,9 @@ public class VerifyRecaptcha {
|
|||
|
||||
public void processResponse(String response) throws InvalidReCaptchaException {
|
||||
if(!responseSanityCheck(response)) {
|
||||
throw new InvalidReCaptchaException("Response contains invalid characters");
|
||||
InvalidReCaptchaException e = new InvalidReCaptchaException("Response contains invalid characters");
|
||||
log.error("Response contains invalid characters", e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
URI verifyUri = URI.create(String.format(
|
||||
|
@ -44,7 +47,10 @@ public class VerifyRecaptcha {
|
|||
GoogleResponse googleResponse = restTemplate.getForObject(verifyUri, GoogleResponse.class);
|
||||
|
||||
if(!googleResponse.isSuccess()) {
|
||||
throw new InvalidReCaptchaException("reCaptcha was not successfully validated");
|
||||
log.error("Has client error:"+googleResponse.hasClientError());
|
||||
InvalidReCaptchaException e = new InvalidReCaptchaException("reCaptcha was not successfully validated");
|
||||
log.error("reCaptcha was not successfully validated", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.responses;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ExceptionResponse {
|
||||
|
||||
private String errorCode;
|
||||
private String errorMessage;
|
||||
private String errors;
|
||||
|
||||
public ExceptionResponse() {
|
||||
}
|
||||
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
public void setErrorCode(String errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
public void setErrorMessage(String errorMessage) {
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
public String getErrors() {
|
||||
return errors;
|
||||
}
|
||||
|
||||
public void setErrors(String errors) {
|
||||
this.errors = errors;
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ public class DivHelpContentService {
|
|||
@Autowired
|
||||
private PortalService portalService;
|
||||
|
||||
public List<DivHelpContentResponse> getDivHelpContents(String pid, String page, String divIdId, String active) {
|
||||
public List<DivHelpContentResponse> getDivHelpContents(String pid, String page_route, String divIdId, String active) {
|
||||
|
||||
Portal _portal = portalService.getPortal(pid);
|
||||
String portalId = null;
|
||||
|
@ -78,7 +78,7 @@ public class DivHelpContentService {
|
|||
}
|
||||
|
||||
for(Page p : divIdResponse.getPages()) {
|
||||
if (page == null || p.getRoute().equals(page)) {
|
||||
if (page_route == null || p.getRoute().equals(page_route)) {
|
||||
DivHelpContentResponse divHelpContentResponse = new DivHelpContentResponse(divHelpContent);
|
||||
divHelpContentResponse.setDivId(divIdResponse);
|
||||
divHelpContentResponse.setPortal(_portal);
|
||||
|
|
|
@ -90,13 +90,17 @@ public class PageHelpContentService {
|
|||
pageHelpContentDAO.deleteAll();
|
||||
}
|
||||
|
||||
public PageHelpContent insertPageHelpContent(PageHelpContent pageHelpContent) {
|
||||
String portalId = portalService.getPortal(pageHelpContent.getPortal()).getId();
|
||||
pageHelpContent.setPortal(portalId);
|
||||
return pageHelpContentDAO.save(pageHelpContent);
|
||||
}
|
||||
// public PageHelpContent insertPageHelpContent(PageHelpContent pageHelpContent) {
|
||||
// String portalId = portalService.getPortal(pageHelpContent.getPortal()).getId();
|
||||
// pageHelpContent.setPortal(portalId);
|
||||
// return pageHelpContentDAO.save(pageHelpContent);
|
||||
// }
|
||||
//
|
||||
// public PageHelpContent updatePageHelpContent(PageHelpContent pageHelpContent) {
|
||||
// return pageHelpContentDAO.save(pageHelpContent);
|
||||
// }
|
||||
|
||||
public PageHelpContent updatePageHelpContent(PageHelpContent pageHelpContent) {
|
||||
public PageHelpContent insertOrUpdatePageHelpContent(PageHelpContent pageHelpContent) {
|
||||
return pageHelpContentDAO.save(pageHelpContent);
|
||||
}
|
||||
|
||||
|
@ -131,7 +135,8 @@ public class PageHelpContentService {
|
|||
String organizations_page_content = "<div> <p>Here you can write more details about the organizations related to your community.</p> </div>";
|
||||
|
||||
PageHelpContent organizations_pageHelpContent = new PageHelpContent(organizationsPage.getId(), portalId, "top", 1, organizations_page_content, false, false);
|
||||
this.insertPageHelpContent(organizations_pageHelpContent);
|
||||
//this.insertPageHelpContent(organizations_pageHelpContent);
|
||||
pageHelpContentDAO.save(organizations_pageHelpContent);
|
||||
}
|
||||
|
||||
Page depositLearnHowPage = pageService.getPageByPortalTypeAndRoute(portalType, "/participate/deposit/learn-how");
|
||||
|
@ -140,15 +145,16 @@ public class PageHelpContentService {
|
|||
"<div class=\"uk-width-3-5 uk-align-center\"> " +
|
||||
" <div class=\"uk-text-bold\">How to comply with funder Open Access policies</div> " +
|
||||
" <ul class=\"uk-list uk-list-bullet\"> " +
|
||||
" <li>Read the <a class=\"custom-external\" href=\"https://www.openaire.eu/how-to-comply-to-h2020-mandates-for-publications\" target=\"_blank\"> OpenAIRE guide to learn how to comply with EC H2020 Open Access policy on publications </a></li> " +
|
||||
" <li>Read the <a class=\"custom-external\" href=\"https://www.openaire.eu/how-to-comply-to-h2020-mandates-for-data\" target=\"_blank\"> OpenAIRE guide to learn how to comply with EC H2020 Open Access policy on research data </a></li> " +
|
||||
" <li>If you want to know about National Open Access policies, please check them out <a class=\"custom-external\" href=\"https://www.openaire.eu/frontpage/country-pages\" target=\"_blank\">here</a></li> " +
|
||||
" <li>All OpenAIRE guides can be found <a class=\"custom-external\" href=\"https://www.openaire.eu/guides\" target=\"_blank\">here</a></li> " +
|
||||
" <li>Read the <a href=\"https://www.openaire.eu/how-to-comply-to-h2020-mandates-for-publications\" target=\"_blank\"> <span>OpenAIRE guide to learn how to comply with EC H2020 Open Access policy on publications>/span> <span class=\"custom-external custom-icon space\"> </span> </a></li> " +
|
||||
" <li>Read the <a href=\"https://www.openaire.eu/how-to-comply-to-h2020-mandates-for-data\" target=\"_blank\"> <span>OpenAIRE guide to learn how to comply with EC H2020 Open Access policy on research data</span> <span class=\"custom-external custom-icon space\"> </span></a></li> " +
|
||||
" <li>If you want to know about National Open Access policies, please check them out <a href=\"https://www.openaire.eu/frontpage/country-pages\" target=\"_blank\"><span>here</span> <span class=\"custom-external custom-icon space\"> </span></a></li> " +
|
||||
" <li>All OpenAIRE guides can be found <a href=\"https://www.openaire.eu/guides\" target=\"_blank\"><span>here</span> <span class=\"custom-external custom-icon space\"> </span></a></li> " +
|
||||
" </ul> " +
|
||||
"</div>";
|
||||
|
||||
PageHelpContent depositLearnHow_pageHelpContent = new PageHelpContent(depositLearnHowPage.getId(), portalId, "bottom", 1, depositLearnHow_page_content, true, false);
|
||||
this.insertPageHelpContent(depositLearnHow_pageHelpContent);
|
||||
//this.insertPageHelpContent(depositLearnHow_pageHelpContent);
|
||||
pageHelpContentDAO.save(depositLearnHow_pageHelpContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ public class PageService {
|
|||
portalPage.setId(savedPage.getId());
|
||||
|
||||
// add page in portals
|
||||
List<Portal> portals = portalService.getAllPortals();
|
||||
List<Portal> portals = portalService.getAllPortalsByType(portalPage.getPortalType());
|
||||
for( Portal portal : portals ) {
|
||||
Map<String, Boolean> pages = portal.getPages();
|
||||
pages.put(page.getId(), true);
|
||||
|
@ -248,7 +248,7 @@ public class PageService {
|
|||
}
|
||||
|
||||
// delete page from portals
|
||||
List<Portal> portals = portalService.getAllPortals();
|
||||
List<Portal> portals = portalService.getAllPortalsByType(page.getPortalType());
|
||||
for( Portal portal : portals ) {
|
||||
Map<String, Boolean> portalPages = portal.getPages();
|
||||
portalPages.remove(id);
|
||||
|
|
|
@ -7,6 +7,8 @@ import eu.dnetlib.uoaadmintoolslibrary.entities.Page;
|
|||
import eu.dnetlib.uoaadmintoolslibrary.entities.Portal;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.*;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.MismatchingContentException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -41,8 +43,13 @@ public class PortalService {
|
|||
return portals;
|
||||
}
|
||||
|
||||
public List<PortalResponse> getAllPortalsFull() {
|
||||
List<Portal> portals = portalDAO.findAll();
|
||||
public List<Portal> getAllPortalsByType(String type) {
|
||||
List<Portal> portals = portalDAO.findByType(type);
|
||||
|
||||
return portals;
|
||||
}
|
||||
|
||||
public List<PortalResponse> getPortalsFull(List<Portal> portals) {
|
||||
List<PortalResponse> portalsResponse = new ArrayList<>();
|
||||
for(Portal portal : portals) {
|
||||
PortalResponse portalResponse = new PortalResponse(portal);
|
||||
|
@ -58,8 +65,18 @@ public class PortalService {
|
|||
return portalsResponse;
|
||||
}
|
||||
|
||||
public List<PortalResponse> getAllPortalsFull() {
|
||||
List<Portal> portals = this.getAllPortals();
|
||||
return this.getPortalsFull(portals);
|
||||
}
|
||||
|
||||
public List<PortalResponse> getAllPortalsFullByType(String type) {
|
||||
List<Portal> portals = this.getAllPortalsByType(type);
|
||||
return this.getPortalsFull(portals);
|
||||
}
|
||||
|
||||
private void setEnabledPagesForPortalByType(Portal portal, PortalResponse portalResponse) {
|
||||
List<PortalPage> pages = this.getPagesForPortalByType(portal.getPid(), null, null, null);
|
||||
List<PortalPage> pages = this.getPagesForPortalByType(portal.getPid(), null, null, null, null);
|
||||
log.debug("PAGES number="+pages.size());
|
||||
Iterator<PortalPage> iteratorPages = pages.iterator();
|
||||
while(iteratorPages.hasNext()) {
|
||||
|
@ -293,9 +310,12 @@ public class PortalService {
|
|||
portalDAO.delete(id);
|
||||
}
|
||||
|
||||
public List<PortalPage> getPagesForPortalByType(String pid, String page_type, String page_route, String div) {
|
||||
public List<PortalPage> getPagesForPortalByType(String pid, String page_type, String page_route, String div, String with_positions) {
|
||||
List<PortalPage> return_pages = new ArrayList<PortalPage>();
|
||||
Portal portal = portalDAO.findByPid(pid);
|
||||
if(portal == null) {
|
||||
throw new ContentNotFoundException("Portal with pid: " + pid + " not found");
|
||||
}
|
||||
Map<String, Boolean> pages = portal.getPages();
|
||||
|
||||
if(pages != null) {
|
||||
|
@ -318,6 +338,20 @@ public class PortalService {
|
|||
|
||||
Page p = pageService.getPage(page.getKey());
|
||||
|
||||
if (with_positions != null) {
|
||||
boolean at_least_one_position = Boolean.parseBoolean(with_positions);
|
||||
|
||||
if(at_least_one_position) {
|
||||
if(!p.getTop() && !p.getBottom() && !p.getLeft() && !p.getRight()) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if(p.getTop() || p.getBottom() || p.getLeft() || p.getRight()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(portal.getType().equals(p.getPortalType())) {
|
||||
if ((page_type == null && page_route == null) || (page_route == null && p.getType().equals(page_type))
|
||||
|| p.getRoute().equals(page_route)) {
|
||||
|
@ -477,4 +511,15 @@ public class PortalService {
|
|||
return divHelpContentResponses;
|
||||
}
|
||||
|
||||
public void checkPortalInfo(String pid, String portalType, Portal portal, String portalId) {
|
||||
if(portal == null) {
|
||||
throw new ContentNotFoundException("Portal with id: "+portalId+" not found");
|
||||
}
|
||||
if(!portal.getType().equals(portalType)) {
|
||||
throw new MismatchingContentException("["+portalType+ " - "+ pid+"] Conflicting portal info: type: "+portal.getType());
|
||||
}
|
||||
if(!portal.getPid().equals(pid)) {
|
||||
throw new MismatchingContentException("["+portalType+ " - "+ pid+"] Conflicting portal info: pid: "+portal.getPid());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue