log4j2 #1
2
pom.xml
2
pom.xml
|
@ -38,7 +38,7 @@
|
||||||
<dependency> <!-- this dependency includes dependency to uoa-authorization-library -->
|
<dependency> <!-- this dependency includes dependency to uoa-authorization-library -->
|
||||||
<groupId>eu.dnetlib</groupId>
|
<groupId>eu.dnetlib</groupId>
|
||||||
<artifactId>uoa-admin-tools-library</artifactId>
|
<artifactId>uoa-admin-tools-library</artifactId>
|
||||||
<version>1.0.6</version>
|
<version>1.0.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--swagger-->
|
<!--swagger-->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -7,6 +7,7 @@ import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.PortalResponse;
|
||||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.MismatchingContentException;
|
import eu.dnetlib.uoaadmintoolslibrary.handlers.MismatchingContentException;
|
||||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.utils.RolesUtils;
|
import eu.dnetlib.uoaadmintoolslibrary.handlers.utils.RolesUtils;
|
||||||
|
import eu.dnetlib.uoaadmintoolslibrary.services.PageService;
|
||||||
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
|
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
@ -43,6 +44,9 @@ public class CommunityController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private PortalService portalService;
|
private PortalService portalService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PageService pageService;
|
||||||
|
|
||||||
@RequestMapping(value = {""}, method = RequestMethod.GET)
|
@RequestMapping(value = {""}, method = RequestMethod.GET)
|
||||||
public List<Portal> getAllCommunities() {
|
public List<Portal> getAllCommunities() {
|
||||||
return portalService.getAllPortalsByType("community");
|
return portalService.getAllPortalsByType("community");
|
||||||
|
@ -72,6 +76,8 @@ public class CommunityController {
|
||||||
subscriberService.updatePid(old_pid, new_pid);
|
subscriberService.updatePid(old_pid, new_pid);
|
||||||
layoutService.updatePid(old_pid, new_pid);
|
layoutService.updatePid(old_pid, new_pid);
|
||||||
notificationsService.updatePid(old_pid, new_pid);
|
notificationsService.updatePid(old_pid, new_pid);
|
||||||
|
menuService.updatePid(old_pid, new_pid);
|
||||||
|
pageService.updatePid(old_pid, new_pid, portal.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
return portalResponse;
|
return portalResponse;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import eu.dnetlib.uoaadmintoolslibrary.entities.Portal;
|
||||||
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.PortalResponse;
|
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.PortalResponse;
|
||||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.MismatchingContentException;
|
import eu.dnetlib.uoaadmintoolslibrary.handlers.MismatchingContentException;
|
||||||
|
import eu.dnetlib.uoaadmintoolslibrary.services.PageService;
|
||||||
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
|
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
@ -27,6 +28,9 @@ public class ConnectController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private PortalService portalService;
|
private PortalService portalService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PageService pageService;
|
||||||
|
|
||||||
@PreAuthorize("hasAnyAuthority(@AuthorizationService.PORTAL_ADMIN)")
|
@PreAuthorize("hasAnyAuthority(@AuthorizationService.PORTAL_ADMIN)")
|
||||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||||
public PortalResponse updateConnect(@RequestBody Portal portal) {
|
public PortalResponse updateConnect(@RequestBody Portal portal) {
|
||||||
|
@ -35,12 +39,14 @@ public class ConnectController {
|
||||||
throw new MismatchingContentException("Update Connect: Portal with id: " + portal.getId() + " has type: " + portal.getType() + " instead of connect");
|
throw new MismatchingContentException("Update Connect: Portal with id: " + portal.getId() + " has type: " + portal.getType() + " instead of connect");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String old_pid = portalService.getPortalById(portal.getId()).getPid();
|
||||||
|
String new_pid = portal.getPid();
|
||||||
|
|
||||||
PortalResponse portalResponse = portalService.updatePortal(portal);
|
PortalResponse portalResponse = portalService.updatePortal(portal);
|
||||||
|
|
||||||
String old_pid = portalResponse.getPid();
|
|
||||||
String new_pid = portal.getPid();
|
|
||||||
if (!old_pid.equals(new_pid)) {
|
if (!old_pid.equals(new_pid)) {
|
||||||
layoutService.updatePid(old_pid, new_pid);
|
layoutService.updatePid(old_pid, new_pid);
|
||||||
|
pageService.updatePid(old_pid, new_pid, portal.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
return portalResponse;
|
return portalResponse;
|
||||||
|
|
|
@ -4,6 +4,7 @@ import eu.dnetlib.uoaadmintoolslibrary.entities.Portal;
|
||||||
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.PortalResponse;
|
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.PortalResponse;
|
||||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.MismatchingContentException;
|
import eu.dnetlib.uoaadmintoolslibrary.handlers.MismatchingContentException;
|
||||||
|
import eu.dnetlib.uoaadmintoolslibrary.services.PageService;
|
||||||
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
|
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
@ -23,13 +24,23 @@ public class ExploreController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private PortalService portalService;
|
private PortalService portalService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PageService pageService;
|
||||||
|
|
||||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||||
public PortalResponse updateExplore(@RequestBody Portal portal) {
|
public PortalResponse updateExplore(@RequestBody Portal portal) {
|
||||||
if(!portal.getType().equals("explore")) {
|
if(!portal.getType().equals("explore")) {
|
||||||
// EXCEPTION - MismatchingContent
|
// EXCEPTION - MismatchingContent
|
||||||
throw new MismatchingContentException("Update Explore: Portal with id: "+portal.getId()+" has type: "+portal.getType()+" instead of explore");
|
throw new MismatchingContentException("Update Explore: Portal with id: "+portal.getId()+" has type: "+portal.getType()+" instead of explore");
|
||||||
}
|
}
|
||||||
|
String old_pid = portalService.getPortalById(portal.getId()).getPid();
|
||||||
|
String new_pid = portal.getPid();
|
||||||
|
|
||||||
PortalResponse portalResponse = portalService.updatePortal(portal);
|
PortalResponse portalResponse = portalService.updatePortal(portal);
|
||||||
|
|
||||||
|
if (!old_pid.equals(new_pid)) {
|
||||||
|
pageService.updatePid(old_pid, new_pid, portal.getType());
|
||||||
|
}
|
||||||
return portalResponse;
|
return portalResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package eu.dnetlib.uoaadmintools.services;
|
||||||
|
|
||||||
import eu.dnetlib.uoaadmintools.dao.MenuDAO;
|
import eu.dnetlib.uoaadmintools.dao.MenuDAO;
|
||||||
import eu.dnetlib.uoaadmintools.dao.MenuItemDAO;
|
import eu.dnetlib.uoaadmintools.dao.MenuItemDAO;
|
||||||
|
import eu.dnetlib.uoaadmintools.entities.Notifications;
|
||||||
import eu.dnetlib.uoaadmintools.entities.menu.*;
|
import eu.dnetlib.uoaadmintools.entities.menu.*;
|
||||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.MismatchingContentException;
|
import eu.dnetlib.uoaadmintoolslibrary.handlers.MismatchingContentException;
|
||||||
|
@ -372,4 +373,23 @@ public class MenuService {
|
||||||
|
|
||||||
return menuDAO.save(menu);
|
return menuDAO.save(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updatePid(String old_pid, String new_pid) {
|
||||||
|
log.debug("menu service: updatePid");
|
||||||
|
Menu menu = menuDAO.findByPortalPid(old_pid);
|
||||||
|
if(menu != null) {
|
||||||
|
menu.setPortalPid(new_pid);
|
||||||
|
menuDAO.save(menu);
|
||||||
|
log.debug("menu saved!");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<MenuItem> menuItems = menuItemDAO.findByPortalPid(old_pid);
|
||||||
|
if(menuItems != null) {
|
||||||
|
menuItems.forEach(menuItem -> {
|
||||||
|
menuItem.setPortalPid(new_pid);
|
||||||
|
menuItemDAO.save(menuItem);
|
||||||
|
log.debug("menuItem saved!");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue