From 8e9c0653dd6c6862123c9609ae34e1206d86456e Mon Sep 17 00:00:00 2001 From: talig Date: Wed, 20 Dec 2017 14:30:43 +0200 Subject: Add collaboration feature Issue-ID: SDC-767 Change-Id: I14fb4c1f54086ed03a56a7ff7fab9ecd40381795 Signed-off-by: talig --- .../notifications-rest-services/pom.xml | 56 ++++++++++ .../rest/mapping/MapNotificationsStatusToDto.java | 64 +++++++++++ .../rest/mapping/MapNotificationsToDto.java | 57 ++++++++++ .../notifications/rest/services/Notifications.java | 94 +++++++++++++++++ .../rest/services/impl/NotificationsImpl.java | 117 +++++++++++++++++++++ .../notifications-rest-types/pom.xml | 23 ++++ .../notifications/types/NotificationEntityDto.java | 91 ++++++++++++++++ .../types/NotificationResponseStatus.java | 26 +++++ .../types/NotificationsStatusDto.java | 61 +++++++++++ .../types/UpdateNotificationResponseStatus.java | 65 ++++++++++++ .../notifications-rest/pom.xml | 24 +++++ 11 files changed, 678 insertions(+) create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsStatusToDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsToDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/Notifications.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/impl/NotificationsImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationEntityDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationResponseStatus.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationsStatusDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/UpdateNotificationResponseStatus.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/pom.xml (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest') diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/pom.xml new file mode 100644 index 0000000000..597b017b0f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/pom.xml @@ -0,0 +1,56 @@ + + + 4.0.0 + + + org.openecomp.sdc + notifications-rest + 1.2.0-SNAPSHOT + + + notifications-rest-services + + + + org.openecomp.sdc + openecomp-sdc-application-config-manager + ${project.version} + provided + + + org.openecomp.sdc + openecomp-sdc-common-rest + ${project.version} + + + javax.inject + javax.inject + 1 + + + + org.apache.cxf + cxf-rt-frontend-jaxrs + ${cxf.version} + + + org.openecomp.sdc + notifications-rest-types + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-notification-api + ${project.version} + + + org.springframework + spring-context + ${spring.framework.version} + + + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsStatusToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsStatusToDto.java new file mode 100644 index 0000000000..41376b040f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsStatusToDto.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.notifications.rest.mapping; + +import com.datastax.driver.core.utils.UUIDs; +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.notification.dao.types.NotificationEntity; +import org.openecomp.sdc.notification.dtos.NotificationsStatus; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.notifications.types.NotificationEntityDto; +import org.openecomp.sdcrests.notifications.types.NotificationsStatusDto; + +import java.text.DateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class MapNotificationsStatusToDto + extends MappingBase { + + private static final DateFormat formatter = + DateFormat.getDateTimeInstance(DateFormat.LONG, + DateFormat.SHORT); + + @Override + public void doMapping(NotificationsStatus source, NotificationsStatusDto target) { + + target.setLastScanned(source.getLastScanned()); + target.setNewEntries(source.getNewEntries()); + target.setEndOfPage(source.getEndOfPage()); + target.setNumOfNotSeenNotifications(source.getNumOfNotSeenNotifications()); + List entityDtos = new ArrayList<>(); + source.getNotifications() + .forEach(notification -> entityDtos.add(new NotificationEntityDto(notification.isRead(), + notification.getEventId(), notification.getEventType(), + JsonUtil.json2Object(notification.getEventAttributes(), Map.class), + extractDate(notification)))); + target.setNotifications(entityDtos); + } + + private String extractDate(NotificationEntity notification) { + return formatter.format(UUIDs.unixTimestamp + (notification + .getEventId())); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsToDto.java new file mode 100644 index 0000000000..558453b7b6 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsToDto.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.notifications.rest.mapping; + +import com.datastax.driver.core.utils.UUIDs; +import org.apache.commons.collections4.CollectionUtils; +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.notification.dao.types.NotificationEntity; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.notifications.types.NotificationEntityDto; +import org.openecomp.sdcrests.notifications.types.NotificationsStatusDto; + +import java.text.DateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class MapNotificationsToDto extends MappingBase, NotificationsStatusDto> { + private static final DateFormat formatter = + DateFormat.getDateTimeInstance(DateFormat.LONG, + DateFormat.SHORT); + @Override + public void doMapping(List source, NotificationsStatusDto target) { + List entityDtos = new ArrayList<>(); + if(CollectionUtils.isNotEmpty(source)) { + source.forEach(notification -> entityDtos.add(new NotificationEntityDto(notification.isRead(), + notification.getEventId(), notification.getEventType(), JsonUtil.json2Object(notification.getEventAttributes(), Map.class), + extractDate(notification)))); + target.setNotifications(entityDtos); + target.setLastScanned(source.get(0).getEventId()); + } + } + + private String extractDate(NotificationEntity notification) { + return formatter.format(UUIDs.unixTimestamp + (notification + .getEventId())); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/Notifications.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/Notifications.java new file mode 100644 index 0000000000..97199f604f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/Notifications.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.notifications.rest.services; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.openecomp.sdcrests.notifications.types.NotificationsStatusDto; +import org.openecomp.sdcrests.notifications.types.UpdateNotificationResponseStatus; +import org.springframework.validation.annotation.Validated; + +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.lang.reflect.InvocationTargetException; +import java.util.UUID; + +import static org.openecomp.sdcrests.common.RestConstants.LAST_DELIVERED_QUERY_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +@Path("/v1.0/notifications") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Notifications") +@Validated +public interface Notifications { + String LIMIT_QUERY_PARAM = "NOTIFICATION_ROWS_LIMIT"; + String END_OF_PAGE_QUERY_PARAM = "END_OF_PAGE_EVENT_ID"; + + @GET + @ApiOperation(value = "Retrive all user notifications", + response = NotificationsStatusDto.class, + responseContainer = "List") + Response getNotifications( + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user, + @QueryParam(LAST_DELIVERED_QUERY_PARAM) UUID lastDelvered, + @QueryParam(END_OF_PAGE_QUERY_PARAM) UUID endOfPage); + + @PUT + @Path("/{notificationId}") + @ApiOperation(value = "Mark notification as read", + response = UpdateNotificationResponseStatus.class) + Response markAsRead( + @ApiParam(value = "Notification Id") @PathParam("notificationId") String notificationId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) + throws InvocationTargetException, IllegalAccessException; + + @PUT + @Path("/last-seen/{notificationId}") + @ApiOperation(value = "Update Last Seen Notification", + response = UpdateNotificationResponseStatus.class) + Response updateLastSeenNotification( + @ApiParam(value = "Notification Id") @PathParam("notificationId") String notificationId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) + throws InvocationTargetException, IllegalAccessException; + + @GET + @Path("/worker") + @ApiOperation(value = "Retrive user not delivered notifications", + response = NotificationsStatusDto.class, + responseContainer = "List") + Response getNewNotificationsByOwnerId( + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user, + @QueryParam(LAST_DELIVERED_QUERY_PARAM) String eventId, + @QueryParam(LIMIT_QUERY_PARAM) String limit); + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/impl/NotificationsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/impl/NotificationsImpl.java new file mode 100644 index 0000000000..8ff0ac0eea --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/impl/NotificationsImpl.java @@ -0,0 +1,117 @@ +package org.openecomp.sdcrests.notifications.rest.services.impl; + +import org.openecomp.sdc.common.errors.Messages; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.datatypes.error.ErrorMessage; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.notification.dao.types.NotificationEntity; +import org.openecomp.sdc.notification.dtos.NotificationsStatus; +import org.openecomp.sdc.notification.exceptons.NotificationNotExistException; +import org.openecomp.sdc.notification.factories.NotificationsServiceFactory; +import org.openecomp.sdc.notification.services.NotificationsService; +import org.openecomp.sdcrests.notifications.rest.mapping.MapNotificationsStatusToDto; +import org.openecomp.sdcrests.notifications.rest.mapping.MapNotificationsToDto; +import org.openecomp.sdcrests.notifications.rest.services.Notifications; +import org.openecomp.sdcrests.notifications.types.NotificationsStatusDto; +import org.openecomp.sdcrests.notifications.types.UpdateNotificationResponseStatus; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import javax.inject.Named; +import javax.ws.rs.core.Response; +import java.lang.reflect.InvocationTargetException; +import java.util.List; +import java.util.Objects; +import java.util.UUID; + +/** + * @author Avrahamg + * @since June 22, 2017 + */ +@Named +@Service("notifications") +@Scope(value = "prototype") +public class NotificationsImpl implements Notifications { + + private static int selectionLimit = 10; + + private static final Logger LOGGER = LoggerFactory.getLogger(NotificationsImpl.class); + private NotificationsService notificationsService = NotificationsServiceFactory.getInstance().createInterface(); + + @Override + public Response getNotifications(String user, UUID lastDelivered, UUID endOfPage) { + MdcUtil.initMdc(LoggerServiceName.notifications.toString()); + NotificationsStatus notificationsStatus = notificationsService + .getNotificationsStatus(user, lastDelivered, selectionLimit, endOfPage); + MapNotificationsStatusToDto converter = new MapNotificationsStatusToDto(); + NotificationsStatusDto notificationsStatusDto = new NotificationsStatusDto(); + converter.doMapping(notificationsStatus, notificationsStatusDto); + + return Response.ok(notificationsStatusDto).build(); + } + + @Override + public Response updateLastSeenNotification(String notificationId, String user) + throws InvocationTargetException, IllegalAccessException { + UpdateNotificationResponseStatus + updateNotificationResponseStatus = new UpdateNotificationResponseStatus(); + try { + notificationsService.updateLastSeenNotification(user, UUID.fromString(notificationId)); + } catch (Exception ex) { + LOGGER.error( + String.format(Messages.FAILED_TO_UPDATE_LAST_SEEN_NOTIFICATION.getErrorMessage(), + user), ex); + updateNotificationResponseStatus.addStructureError(notificationId, + new ErrorMessage(ErrorLevel.ERROR, + Messages.FAILED_TO_UPDATE_LAST_SEEN_NOTIFICATION.getErrorMessage())); + } + return Response.ok(updateNotificationResponseStatus).build(); + } + + @Override + public Response markAsRead(String notificationId, String user) + throws InvocationTargetException, IllegalAccessException { + + UpdateNotificationResponseStatus + updateNotificationResponseStatus = new UpdateNotificationResponseStatus(); + try { + notificationsService.markAsRead(user, notificationId); + } catch (NotificationNotExistException ex) { + LOGGER.error(Messages.FAILED_TO_MARK_NOTIFICATION_AS_READ.getErrorMessage(), ex); + updateNotificationResponseStatus.addStructureError( + notificationId, new ErrorMessage(ErrorLevel.ERROR, Messages + .FAILED_TO_MARK_NOTIFICATION_AS_READ + .getErrorMessage())); + } + return Response.ok(updateNotificationResponseStatus).build(); + } + + @Override + public Response getNewNotificationsByOwnerId(String user, String eventId, String limitStr) { + MdcUtil.initMdc(LoggerServiceName.notifications.toString()); + + int limit = selectionLimit; + + if (Objects.nonNull(limitStr)) { + try { + limit = Integer.parseInt(limitStr); + } + catch (NumberFormatException f) { + LOGGER.error("Non numeric selection list size value specified: " + limitStr); + } + } + + List notifications = Objects.isNull(eventId) + ? notificationsService.getNotificationsByOwnerId(user, limit) + : notificationsService.getNewNotificationsByOwnerId(user, UUID.fromString(eventId), limit); + + MapNotificationsToDto converter = new MapNotificationsToDto(); + NotificationsStatusDto notificationsStatusDto = new NotificationsStatusDto(); + converter.doMapping(notifications, notificationsStatusDto); + + return Response.ok(notificationsStatusDto).build(); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/pom.xml new file mode 100644 index 0000000000..4a3300ad12 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + + org.openecomp.sdc + openecomp-sdc-datatypes-lib + ${project.version} + + + + + org.openecomp.sdc + notifications-rest + 1.2.0-SNAPSHOT + + + notifications-rest-types + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationEntityDto.java new file mode 100644 index 0000000000..d41deb3a4d --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationEntityDto.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.notifications.types; + +import java.util.Map; +import java.util.UUID; + +public class NotificationEntityDto { + private boolean read; + private UUID eventId; + private String dateTime; + private String eventType; + private Map eventAttributes; + + public NotificationEntityDto() { + } + public NotificationEntityDto(boolean read, UUID eventId, String eventType, + Map eventAttributes) { + this.read = read; + this.eventId = eventId; + this.eventType = eventType; + this.eventAttributes = eventAttributes; + } + + public NotificationEntityDto(boolean read, UUID eventId,String eventType, + Map eventAttributes, String dateTime) { + this.read = read; + this.eventId = eventId; + this.dateTime = dateTime; + this.eventType = eventType; + this.eventAttributes = eventAttributes; + } + + public boolean isRead() { + return read; + } + + public void setRead(boolean read) { + this.read = read; + } + + public UUID getEventId() { + return eventId; + } + + public void setEventId(UUID eventId) { + this.eventId = eventId; + } + + public String getEventType() { + return eventType; + } + + public void setEventType(String eventType) { + this.eventType = eventType; + } + + public Map getEventAttributes() { + return eventAttributes; + } + + public void setEventAttributes(Map eventAttributes) { + this.eventAttributes = eventAttributes; + } + + public String getDateTime() { + return dateTime; + } + + public void setDateTime(String dateTime) { + this.dateTime = dateTime; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationResponseStatus.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationResponseStatus.java new file mode 100644 index 0000000000..a0273d51e0 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationResponseStatus.java @@ -0,0 +1,26 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.notifications.types; + +public enum NotificationResponseStatus { + Success, + Failure +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationsStatusDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationsStatusDto.java new file mode 100644 index 0000000000..182245cc12 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationsStatusDto.java @@ -0,0 +1,61 @@ +package org.openecomp.sdcrests.notifications.types; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +/** + * @author avrahamg + * @since June 29, 2017 + */ +public class NotificationsStatusDto { + private List notifications; + private List newEntries = new ArrayList<>(); + private UUID lastScanned; + private UUID endOfPage; + private long numOfNotSeenNotifications; + + public NotificationsStatusDto() { + } + + public List getNotifications() { + return notifications; + } + + public void setNotifications( + List notifications) { + this.notifications = notifications; + } + + public List getNewEntries() { + return newEntries; + } + + public void setNewEntries(List newEntries) { + this.newEntries = newEntries; + } + + public UUID getLastScanned() { + return lastScanned; + } + + public void setLastScanned(UUID lastScanned) { + this.lastScanned = lastScanned; + } + + public UUID getEndOfPage() { + return endOfPage; + } + + public void setEndOfPage(UUID endOfPage) { + this.endOfPage = endOfPage; + } + + public long getNumOfNotSeenNotifications() { + return numOfNotSeenNotifications; + } + + public void setNumOfNotSeenNotifications(long numOfNotSeenNotifications) { + this.numOfNotSeenNotifications = numOfNotSeenNotifications; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/UpdateNotificationResponseStatus.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/UpdateNotificationResponseStatus.java new file mode 100644 index 0000000000..9e985726dc --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/UpdateNotificationResponseStatus.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.notifications.types; + +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.datatypes.error.ErrorMessage; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.openecomp.sdcrests.notifications.types.NotificationResponseStatus.Failure; +import static org.openecomp.sdcrests.notifications.types.NotificationResponseStatus.Success; + +/** + * Created by TALIO on 4/27/2016. + */ +public class UpdateNotificationResponseStatus { + private Map> errors = new HashMap<>(); + private NotificationResponseStatus status = Success; + + public Map> getErrors() { + return errors; + } + + public void setErrors(Map> errors) { + this.errors = errors; + } + + public NotificationResponseStatus getStatus() { + return status; + } + + public void setStatus(NotificationResponseStatus status) { + this.status = status; + } + + public void addStructureError(String notificationId, ErrorMessage errorMessage) { + List errorList = + errors.computeIfAbsent(notificationId, k -> new ArrayList<>()); + errorList.add(errorMessage); + if (ErrorLevel.ERROR.equals(errorMessage.getLevel())) { + status = Failure; + } + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/pom.xml new file mode 100644 index 0000000000..d35c5afbee --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + + org.openecomp.sdc + openecomp-sdc-rest-webapp + 1.2.0-SNAPSHOT + + + org.openecomp.sdc + notifications-rest + + pom + + + + notifications-rest-types + notifications-rest-services + + + \ No newline at end of file -- cgit 1.2.3-korg