[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().
This commit is contained in:
parent
3b563eb5c2
commit
a265d414a4
|
@ -4,13 +4,16 @@ 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.responses.SingleValueWrapperResponse;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.services.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@RestController
|
||||
|
@ -67,24 +70,50 @@ public class AdminPortalRelationsController {
|
|||
// return portalService.getDivHelpContentsByPosition(pid, page, active);
|
||||
// }
|
||||
|
||||
// not used by portals
|
||||
@PreAuthorize("hasAnyAuthority(@AuthorizationService.PORTAL_ADMIN)")
|
||||
@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");
|
||||
}
|
||||
// @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(), "id");
|
||||
// return divHelpContent;
|
||||
// }
|
||||
|
||||
Portal portal = portalService.getPortalById(divHelpContent.getPortal());
|
||||
portalService.checkPortalInfo(pid, portalType.name(), portal, divHelpContent.getPortal(), "id");
|
||||
return divHelpContent;
|
||||
@RequestMapping(value = "/{pid}/{pageId}/divhelpcontent", method = RequestMethod.GET)
|
||||
public List<DivHelpContent> getDivHelpContentsByPageId(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid,
|
||||
@PathVariable(value = "pageId") String pageId) {
|
||||
return divHelpContentService.getDivHelpContentsBasic(pid, portalType.name(), pageId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{pid}/divhelpcontent/page/count", method = RequestMethod.GET)
|
||||
public Map<String, Integer> countDivHelpContentsForPages(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid) {
|
||||
Map<String, Integer> mapCount = new HashMap<String, Integer>();
|
||||
|
||||
List<Page> pages = pageService.getAllPages(pid, null, null);
|
||||
for(Page page : pages){
|
||||
List<DivHelpContent> divHelpContents = divHelpContentService.getDivHelpContentsBasic(pid, portalType.name(), page.getId());
|
||||
if (divHelpContents == null) {
|
||||
mapCount.put(page.getId(), 0);
|
||||
} else {
|
||||
mapCount.put(page.getId(), divHelpContents.size());
|
||||
}
|
||||
}
|
||||
return mapCount;
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAnyAuthority(" +
|
||||
|
@ -240,26 +269,54 @@ public class AdminPortalRelationsController {
|
|||
// return portalService.getPageHelpContentsByPosition(pid, page, active);
|
||||
// }
|
||||
|
||||
// not used by portals
|
||||
@PreAuthorize("hasAnyAuthority(@AuthorizationService.PORTAL_ADMIN)")
|
||||
@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(), "id");
|
||||
return pageHelpContent;
|
||||
// used
|
||||
@RequestMapping(value = "/{pid}/{pageId}/pagehelpcontent", method = RequestMethod.GET)
|
||||
public List<PageHelpContent> getPageHelpContentsByPageId(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid,
|
||||
@PathVariable(value = "pageId") String pageId) {
|
||||
return pageHelpContentService.getPageHelpContentsBasic(pid, portalType.name(), pageId);
|
||||
}
|
||||
|
||||
// used
|
||||
@RequestMapping(value = "/{pid}/pagehelpcontent/page/count", method = RequestMethod.GET)
|
||||
public Map<String, Integer> countPageHelpContentsForPages(@PathVariable PortalType portalType,
|
||||
@PathVariable(value = "pid") String pid) {
|
||||
Map<String, Integer> mapCount = new HashMap<String, Integer>();
|
||||
|
||||
List<Page> pages = pageService.getAllPages(pid, null, null);
|
||||
for(Page page : pages){
|
||||
List<PageHelpContent> pageHelpContents = pageHelpContentService.getPageHelpContentsBasic(pid, portalType.name(), page.getId());
|
||||
if (pageHelpContents == null) {
|
||||
mapCount.put(page.getId(), 0);
|
||||
} else {
|
||||
mapCount.put(page.getId(), pageHelpContents.size());
|
||||
}
|
||||
}
|
||||
return mapCount;
|
||||
}
|
||||
|
||||
// @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(), "id");
|
||||
// return pageHelpContent;
|
||||
// }
|
||||
|
||||
@PreAuthorize("hasAnyAuthority(" +
|
||||
"@AuthorizationService.PORTAL_ADMIN, " +
|
||||
"@AuthorizationService.curator(#portalType), @AuthorizationService.manager(#portalType, #pid))")
|
||||
|
|
|
@ -14,6 +14,7 @@ public interface DivHelpContentDAO {
|
|||
List<DivHelpContent> findByPortalAndIsActive(String portalId, boolean isActive);
|
||||
List<DivHelpContent> findByDivIdAndIsActive(String divId, boolean isActive);
|
||||
List<DivHelpContent> findByPortalAndDivIdAndIsActive(String portalId, String divId, boolean isActive);
|
||||
List<DivHelpContent> findByPortalAndPage(String portalId, String page);
|
||||
|
||||
DivHelpContent findById(String Id);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ public interface MongoDBDivHelpContentDAO extends DivHelpContentDAO, MongoReposi
|
|||
List<DivHelpContent> findByPortalAndIsActive(String portalId, boolean isActive);
|
||||
List<DivHelpContent> findByDivIdAndIsActive(String divId, boolean isActive);
|
||||
List<DivHelpContent> findByPortalAndDivIdAndIsActive(String portalId, String divId, boolean isActive);
|
||||
List<DivHelpContent> findByPortalAndPage(String portalId, String page);
|
||||
|
||||
DivHelpContent findById(String Id);
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ public interface MongoDBPageHelpContentDAO extends PageHelpContentDAO, MongoRepo
|
|||
List<PageHelpContent> findByPlacementAndIsActiveOrderByOrderAsc(String position, boolean isActive);
|
||||
List<PageHelpContent> findByPlacementAndIsPriorToOrderByOrderAsc(String position, boolean isPriorTo);
|
||||
List<PageHelpContent> findByIsActiveAndIsPriorToOrderByPlacementAscOrderAsc(boolean isActive, boolean isPriorTo);
|
||||
List<PageHelpContent> findByPortalAndPageOrderByPlacementAscOrderAsc(String portalId, String page);
|
||||
List<PageHelpContent> findByPortalOrderByPlacementAscOrderAsc(String portalId);
|
||||
List<PageHelpContent> findByPlacementOrderByOrderAsc(String postion);
|
||||
List<PageHelpContent> findByIsActiveOrderByPlacementAscOrderAsc(boolean isActive);
|
||||
|
|
|
@ -19,6 +19,7 @@ public interface PageHelpContentDAO {
|
|||
List<PageHelpContent> findByPlacementAndIsPriorToOrderByOrderAsc(String position, boolean isPriorTo);
|
||||
List<PageHelpContent> findByIsActiveAndIsPriorToOrderByPlacementAscOrderAsc(boolean isActive, boolean isPriorTo);
|
||||
List<PageHelpContent> findByPortalOrderByPlacementAscOrderAsc(String portalId);
|
||||
List<PageHelpContent> findByPortalAndPageOrderByPlacementAscOrderAsc(String portalId, String page);
|
||||
List<PageHelpContent> findByPlacementOrderByOrderAsc(String postion);
|
||||
List<PageHelpContent> findByIsActiveOrderByPlacementAscOrderAsc(boolean isActive);
|
||||
List<PageHelpContent> findByIsPriorToOrderByPlacementAscOrderAsc(boolean isPriorTo);
|
||||
|
|
|
@ -20,7 +20,7 @@ public class RolesUtils {
|
|||
}
|
||||
|
||||
public String getEmail() {
|
||||
return authorizationService.getAaiId();
|
||||
return authorizationService.getEmail();
|
||||
}
|
||||
|
||||
public String getAaiId() {
|
||||
|
|
|
@ -90,6 +90,31 @@ public class DivHelpContentService {
|
|||
return divHelpContentResponses;
|
||||
}
|
||||
|
||||
|
||||
public List<DivHelpContent> getDivHelpContentsBasic(String pid, String portalType, String pageId) {
|
||||
List<DivHelpContent> divHelpContents = null;
|
||||
|
||||
Portal _portal = null;
|
||||
String portalId = null;
|
||||
if(pid != null) {
|
||||
_portal = portalService.getPortal(pid);
|
||||
portalService.checkPortalInfo(pid, portalType, _portal, pid, "pid");
|
||||
if(_portal != null) {
|
||||
portalId = _portal.getId();
|
||||
}
|
||||
}
|
||||
|
||||
if(pid != null && pageId != null) {
|
||||
divHelpContents = divHelpContentDAO.findByPortalAndPage(portalId, pageId);
|
||||
} else if(pid != null) {
|
||||
divHelpContents = divHelpContentDAO.findByPortal(portalId);
|
||||
} else {
|
||||
divHelpContents = divHelpContentDAO.findAll();
|
||||
}
|
||||
|
||||
return divHelpContents;
|
||||
}
|
||||
|
||||
public DivHelpContent getDivHelpContent(String id) {
|
||||
return divHelpContentDAO.findById(id);
|
||||
}
|
||||
|
|
|
@ -89,6 +89,30 @@ public class PageHelpContentService {
|
|||
return pageHelpContentResponses;
|
||||
}
|
||||
|
||||
public List<PageHelpContent> getPageHelpContentsBasic(String pid, String portalType, String pageId) {
|
||||
List<PageHelpContent> pageHelpContents = null;
|
||||
|
||||
Portal _portal = null;
|
||||
String portalId = null;
|
||||
if(pid != null) {
|
||||
_portal = portalService.getPortal(pid);
|
||||
portalService.checkPortalInfo(pid, portalType, _portal, pid, "pid");
|
||||
if(_portal != null) {
|
||||
portalId = _portal.getId();
|
||||
}
|
||||
}
|
||||
|
||||
if(pid != null && pageId != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByPortalAndPageOrderByPlacementAscOrderAsc(portalId, pageId);
|
||||
} else if(pid != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByPortalOrderByPlacementAscOrderAsc(portalId);
|
||||
} else {
|
||||
pageHelpContents = pageHelpContentDAO.findAllByOrderByPlacementAscOrderAsc();
|
||||
}
|
||||
|
||||
return pageHelpContents;
|
||||
}
|
||||
|
||||
public void deleteAllPageHelpContents() {
|
||||
pageHelpContentDAO.deleteAll();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue