X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ecomp-portal-BE-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenecomp%2Fportalapp%2Fportal%2Fcontroller%2FTicketEventController.java;h=102f7709606e7a256f8ccc45a0bd0816a560c8e4;hb=978dbcf0a196acbafad72fe1e2478ec0e384f02f;hp=e0a9e587db318ea889a8d23f5367e5d4a024b405;hpb=bc7350dce5b7b1dcd1c472a3922b42c4ea99809d;p=portal.git diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/TicketEventController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/TicketEventController.java index e0a9e587..102f7709 100644 --- a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/TicketEventController.java +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/TicketEventController.java @@ -36,8 +36,10 @@ import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; import org.openecomp.portalapp.portal.service.UserNotificationService; import org.openecomp.portalapp.portal.transport.EpNotificationItem; import org.openecomp.portalapp.portal.transport.EpRoleNotificationItem; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; import org.openecomp.portalapp.portal.utils.PortalConstants; import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.util.SystemProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; @@ -62,6 +64,7 @@ import io.swagger.annotations.ApiOperation; @EPAuditLog public class TicketEventController implements BasicAuthenticationController { + @Autowired private UserNotificationService userNotificationService; @@ -73,6 +76,8 @@ public class TicketEventController implements BasicAuthenticationController { private final ObjectMapper mapper = new ObjectMapper(); + + @ApiOperation(value = "Accepts messages from external ticketing systems and creates notifications for Portal users.", response = PortalRestResponse.class) @RequestMapping(value = { "/ticketevent" }, method = RequestMethod.POST) public PortalRestResponse handleRequest(HttpServletRequest request, HttpServletResponse response, @@ -108,6 +113,12 @@ public class TicketEventController implements BasicAuthenticationController { } String eventSource = header.get("eventSource").asText(); epItem.setMsgSource(eventSource); + String ticket = body.get("ticketNum").asText(); + String hyperlink = SystemProperties.getProperty(EPCommonSystemProperties.EXTERNAL_SYSTEM_NOTIFICATION_URL)+eventSource+"num="+ticket; + if(body.get("notificationHyperlink")!=null){ + hyperlink=body.get("notificationHyperlink").asText(); + } + epItem.setNotificationHyperlink(hyperlink); epItem.setStartTime(new Date(eventDate)); Calendar calendar = Calendar.getInstance(); calendar.setTime(epItem.getStartTime()); @@ -171,14 +182,26 @@ public class TicketEventController implements BasicAuthenticationController { JsonNode header = event.get("header"); JsonNode body = event.get("body"); JsonNode SubscriberInfo = ticketEventNotif.get("SubscriberInfo"); + JsonNode userList = SubscriberInfo.get("UserList"); + if (application == null) - return "application is mandatory"; + return "Application is mandatory"; if (body == null) return "body is mandatory"; if (header.get("eventSource") == null) return "Message Source is mandatory"; - if (SubscriberInfo.get("UserList") == null) + if (userList == null) return "At least one user Id is mandatory"; + JsonNode eventDate=body.get("eventDate"); + + if(eventDate!=null&&eventDate.asText().length()==8) + return "EventDate is invalid"; + String UserIds[] = userList.toString().replace("[", "").replace("]", "").trim().replace("\"", "") + .split(","); + List users = userNotificationService.getUsersByOrgIds(Arrays.asList(UserIds)); + if(users==null||users.size()==0) + return "Invalid Attuid"; return null; } + }