diff options
author | vasraz <vasyl.razinkov@est.tech> | 2021-03-22 15:33:06 +0000 |
---|---|---|
committer | Christophe Closset <christophe.closset@intl.att.com> | 2021-03-24 06:59:47 +0000 |
commit | d378c37fbd1ecec7b43394926f1ca32a695e07de (patch) | |
tree | 5c8a085f8732f980d871d966ac49361644efa698 /openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core | |
parent | a6ae7294ecd336d7e88f915710b08e2658eaee00 (diff) |
Reformat openecomp-be
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Issue-ID: SDC-3449
Change-Id: I13e02322f8e00820cc5a1d85752caaeda9bf10d1
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core')
16 files changed, 219 insertions, 274 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/destinationprovider/impl/MulticastDestination.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/destinationprovider/impl/MulticastDestination.java index b2a0a9ad03..0a5bca6cf8 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/destinationprovider/impl/MulticastDestination.java +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/destinationprovider/impl/MulticastDestination.java @@ -7,9 +7,9 @@ * 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. @@ -17,17 +17,15 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.destinationprovider.impl; -import org.apache.commons.lang3.ArrayUtils; -import org.openecomp.sdc.destinationprovider.DestinationProvider; -import org.openecomp.sdc.notification.services.SubscriptionService; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import org.apache.commons.lang3.ArrayUtils; +import org.openecomp.sdc.destinationprovider.DestinationProvider; +import org.openecomp.sdc.notification.services.SubscriptionService; /** * @author avrahamg @@ -39,8 +37,7 @@ public class MulticastDestination implements DestinationProvider { private SubscriptionService subscriptionService; private String[] excludedSubscribers; - public MulticastDestination(String entityId, SubscriptionService subscriptionService, - String... excludedSubscribers) { + public MulticastDestination(String entityId, SubscriptionService subscriptionService, String... excludedSubscribers) { this.entityId = entityId; this.excludedSubscribers = excludedSubscribers; this.subscriptionService = subscriptionService; diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/destinationprovider/impl/UnicastDestination.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/destinationprovider/impl/UnicastDestination.java index 2f4cc795e2..8485efdcef 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/destinationprovider/impl/UnicastDestination.java +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/destinationprovider/impl/UnicastDestination.java @@ -7,9 +7,9 @@ * 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. @@ -17,13 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.destinationprovider.impl; -import org.openecomp.sdc.destinationprovider.DestinationProvider; - import java.util.Collections; import java.util.List; +import org.openecomp.sdc.destinationprovider.DestinationProvider; /** * @author avrahamg diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/LastNotificationDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/LastNotificationDaoCassandraImpl.java index 0bfd6a314d..fa4481b881 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/LastNotificationDaoCassandraImpl.java +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/LastNotificationDaoCassandraImpl.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.notification.dao.impl; import com.datastax.driver.core.ResultSet; @@ -26,62 +25,57 @@ import com.datastax.driver.mapping.Mapper; import com.datastax.driver.mapping.Result; import com.datastax.driver.mapping.annotations.Accessor; import com.datastax.driver.mapping.annotations.Query; +import java.util.Collection; +import java.util.UUID; import org.openecomp.core.dao.impl.CassandraBaseDao; import org.openecomp.core.nosqldb.api.NoSqlDb; import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; import org.openecomp.sdc.notification.dao.LastNotificationDao; import org.openecomp.sdc.notification.dao.types.LastSeenNotificationEntity; -import java.util.Collection; -import java.util.UUID; - - public class LastNotificationDaoCassandraImpl extends CassandraBaseDao<LastSeenNotificationEntity> implements LastNotificationDao { - private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); - private static final Mapper<LastSeenNotificationEntity> mapper = - noSqlDb.getMappingManager().mapper(LastSeenNotificationEntity.class); - private static final LastNotificationAccessor accessor = - noSqlDb.getMappingManager().createAccessor(LastNotificationAccessor.class); - - @Override - protected Mapper<LastSeenNotificationEntity> getMapper() { - return mapper; - } - - @Override - protected Object[] getKeys(LastSeenNotificationEntity entity) { - return new Object[]{entity.getOwnerId()}; - } - - @Override - public Collection<LastSeenNotificationEntity> list(LastSeenNotificationEntity entity) { - return accessor.list(entity.getOwnerId()).all(); - } - - @Override - public UUID getOwnerLastEventId(String ownerId) { - ResultSet ownerLastEventId = accessor.getOwnerLastEventId(ownerId); - Row one = ownerLastEventId.one(); - return one != null ? one.getUUID("event_id") : null; - } - - @Override - public void persistOwnerLastEventId(String ownerId, UUID eventId) { - accessor.updateOwnerLastEventId(eventId, ownerId); - } - - @Accessor - interface LastNotificationAccessor { - - @Query("select * from last_notification where owner_id=?") - Result<LastSeenNotificationEntity> list(String ownerId); - - @Query("select event_id from last_notification where owner_id=?") - ResultSet getOwnerLastEventId(String ownerId); - - @Query("update last_notification set event_id=? where owner_id=?") - ResultSet updateOwnerLastEventId(UUID eventId, String ownerId); - } - + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static final Mapper<LastSeenNotificationEntity> mapper = noSqlDb.getMappingManager().mapper(LastSeenNotificationEntity.class); + private static final LastNotificationAccessor accessor = noSqlDb.getMappingManager().createAccessor(LastNotificationAccessor.class); + + @Override + protected Mapper<LastSeenNotificationEntity> getMapper() { + return mapper; + } + + @Override + protected Object[] getKeys(LastSeenNotificationEntity entity) { + return new Object[]{entity.getOwnerId()}; + } + + @Override + public Collection<LastSeenNotificationEntity> list(LastSeenNotificationEntity entity) { + return accessor.list(entity.getOwnerId()).all(); + } + + @Override + public UUID getOwnerLastEventId(String ownerId) { + ResultSet ownerLastEventId = accessor.getOwnerLastEventId(ownerId); + Row one = ownerLastEventId.one(); + return one != null ? one.getUUID("event_id") : null; + } + + @Override + public void persistOwnerLastEventId(String ownerId, UUID eventId) { + accessor.updateOwnerLastEventId(eventId, ownerId); + } + + @Accessor + interface LastNotificationAccessor { + + @Query("select * from last_notification where owner_id=?") + Result<LastSeenNotificationEntity> list(String ownerId); + + @Query("select event_id from last_notification where owner_id=?") + ResultSet getOwnerLastEventId(String ownerId); + + @Query("update last_notification set event_id=? where owner_id=?") + ResultSet updateOwnerLastEventId(UUID eventId, String ownerId); + } } diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/NotificationsDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/NotificationsDaoCassandraImpl.java index 6796ea11d2..daa8eaf1ea 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/NotificationsDaoCassandraImpl.java +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/NotificationsDaoCassandraImpl.java @@ -17,9 +17,10 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.notification.dao.impl; +import static org.openecomp.core.nosqldb.impl.cassandra.CassandraSessionFactory.getSession; + import com.datastax.driver.core.BatchStatement; import com.datastax.driver.core.ResultSet; import com.datastax.driver.core.Statement; @@ -28,6 +29,13 @@ import com.datastax.driver.mapping.Mapper; import com.datastax.driver.mapping.Result; import com.datastax.driver.mapping.annotations.Accessor; import com.datastax.driver.mapping.annotations.Query; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.UUID; +import java.util.stream.Collectors; import org.apache.commons.collections.CollectionUtils; import org.openecomp.core.dao.impl.CassandraBaseDao; import org.openecomp.core.nosqldb.api.NoSqlDb; @@ -35,23 +43,14 @@ import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; import org.openecomp.sdc.notification.dao.NotificationsDao; import org.openecomp.sdc.notification.dao.types.NotificationEntity; import org.openecomp.sdc.notification.dtos.NotificationsStatus; - -import java.util.*; -import java.util.stream.Collectors; - -import static org.openecomp.core.nosqldb.impl.cassandra.CassandraSessionFactory.getSession; - //import org.openecomp.sdc.notification.dao.types.LastSeenNotificationEntity; -//import java.util.Optional; -public class NotificationsDaoCassandraImpl extends CassandraBaseDao<NotificationEntity> - implements NotificationsDao { +//import java.util.Optional; +public class NotificationsDaoCassandraImpl extends CassandraBaseDao<NotificationEntity> implements NotificationsDao { private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); - private static final Mapper<NotificationEntity> mapper = - noSqlDb.getMappingManager().mapper(NotificationEntity.class); - private static final NotificationsAccessor accessor = - noSqlDb.getMappingManager().createAccessor(NotificationsAccessor.class); + private static final Mapper<NotificationEntity> mapper = noSqlDb.getMappingManager().mapper(NotificationEntity.class); + private static final NotificationsAccessor accessor = noSqlDb.getMappingManager().createAccessor(NotificationsAccessor.class); @Override protected Mapper<NotificationEntity> getMapper() { @@ -75,8 +74,7 @@ public class NotificationsDaoCassandraImpl extends CassandraBaseDao<Notification @Override public List<NotificationEntity> getNewNotificationsByOwnerId(String ownerId, UUID eventId) { - return getNewNotificationsByOwnerId(ownerId, eventId, - DEFAULT_LIMIT_OF_RESULTS_FOR_OWNER_NOTIFICATIONS); + return getNewNotificationsByOwnerId(ownerId, eventId, DEFAULT_LIMIT_OF_RESULTS_FOR_OWNER_NOTIFICATIONS); } @Override @@ -94,16 +92,17 @@ public class NotificationsDaoCassandraImpl extends CassandraBaseDao<Notification @Override public NotificationsStatus getNotificationsStatus(String ownerId, UUID lastScannedEventId, int numOfRecordsToReturn) { - NotificationsStatusImpl notificationsStatus = new NotificationsStatusImpl(); - List<NotificationEntity> entities = accessor.getNotifications(ownerId, numOfRecordsToReturn).all(); + NotificationsStatusImpl notificationsStatus = new NotificationsStatusImpl(); + List<NotificationEntity> entities = accessor.getNotifications(ownerId, numOfRecordsToReturn).all(); if (CollectionUtils.isNotEmpty(entities)) { long lastSeen = UUIDs.unixTimestamp(lastScannedEventId); populateNewNotifications(notificationsStatus, entities, lastSeen); UUID firstScannedEventId = entities.get(0).getEventId(); - notificationsStatus.setLastScanned(firstScannedEventId); - notificationsStatus.setNumOfNotSeenNotifications(accessor.getNewNotificationsCount(ownerId, lastScannedEventId, firstScannedEventId).one().getLong(0)); + notificationsStatus.setLastScanned(firstScannedEventId); + notificationsStatus + .setNumOfNotSeenNotifications(accessor.getNewNotificationsCount(ownerId, lastScannedEventId, firstScannedEventId).one().getLong(0)); } - return notificationsStatus; + return notificationsStatus; } private void populateNewNotifications(NotificationsStatusImpl notificationsStatus, List<NotificationEntity> entities, long lastSeen) { @@ -117,66 +116,64 @@ public class NotificationsDaoCassandraImpl extends CassandraBaseDao<Notification } @Override - public NotificationsStatus getNotificationsStatus(String ownerId, UUID lastSeenNotification, int numOfRecordsToReturn, UUID prevLastScannedEventId) { - NotificationsStatusImpl notificationsStatus = new NotificationsStatusImpl(); - List<NotificationEntity> entities = accessor.getPrevNotifications(ownerId, prevLastScannedEventId, numOfRecordsToReturn).all(); + public NotificationsStatus getNotificationsStatus(String ownerId, UUID lastSeenNotification, int numOfRecordsToReturn, + UUID prevLastScannedEventId) { + NotificationsStatusImpl notificationsStatus = new NotificationsStatusImpl(); + List<NotificationEntity> entities = accessor.getPrevNotifications(ownerId, prevLastScannedEventId, numOfRecordsToReturn).all(); if (CollectionUtils.isNotEmpty(entities)) { - long lastSeen = UUIDs.unixTimestamp(lastSeenNotification); + long lastSeen = UUIDs.unixTimestamp(lastSeenNotification); populateNewNotifications(notificationsStatus, entities, lastSeen); } - return notificationsStatus; + return notificationsStatus; } -/* - @Override - public NotificationsStatus getNotificationsStatus(String ownerId, - LastSeenNotificationEntity lastSeenNotification, - int numOfRecordsToReturn) { - - List<NotificationEntity> notificationEntities = - fetchNewNotifications(lastSeenNotification, numOfRecordsToReturn); - NotificationsStatusImpl notificationsStatus = new NotificationsStatusImpl(); - if (CollectionUtils.isEmpty(notificationEntities)) { - return notificationsStatus; - } - - notificationEntities.forEach(notification -> { - if (isNewNotification(lastSeenNotification, notification)) { - notificationsStatus.addNewNotificationUUID(notification.getEventId()); + /* + @Override + public NotificationsStatus getNotificationsStatus(String ownerId, + LastSeenNotificationEntity lastSeenNotification, + int numOfRecordsToReturn) { + + List<NotificationEntity> notificationEntities = + fetchNewNotifications(lastSeenNotification, numOfRecordsToReturn); + NotificationsStatusImpl notificationsStatus = new NotificationsStatusImpl(); + if (CollectionUtils.isEmpty(notificationEntities)) { + return notificationsStatus; } - notificationsStatus.addNotification(notification); - }); - Optional<NotificationEntity> latestNotification = notificationEntities.stream().findFirst(); - latestNotification.ifPresent(e -> notificationsStatus.setLastScanned(e.getEventId())); - return notificationsStatus; - } + notificationEntities.forEach(notification -> { + if (isNewNotification(lastSeenNotification, notification)) { + notificationsStatus.addNewNotificationUUID(notification.getEventId()); + } + notificationsStatus.addNotification(notification); + }); - private List<NotificationEntity> fetchNewNotifications( - LastSeenNotificationEntity lastSeenNotification, int numOfRecordsToReturn) { - String ownerId = lastSeenNotification.getOwnerId(); - UUID lastEventId = lastSeenNotification.getLastEventId(); - List<NotificationEntity> newNotificationsByOwnerId = - getNewNotificationsByOwnerId(ownerId, lastEventId); - newNotificationsByOwnerId = fetchMoreIfNeeded(ownerId, newNotificationsByOwnerId, - numOfRecordsToReturn, lastEventId); - return newNotificationsByOwnerId; - } + Optional<NotificationEntity> latestNotification = notificationEntities.stream().findFirst(); + latestNotification.ifPresent(e -> notificationsStatus.setLastScanned(e.getEventId())); + return notificationsStatus; + } - private boolean isNewNotification(LastSeenNotificationEntity lastSeenNotification, - NotificationEntity notification) { - return Objects.isNull(lastSeenNotification.getLastEventId()) || - UUIDs.unixTimestamp(notification.getEventId()) > - UUIDs.unixTimestamp(lastSeenNotification.getLastEventId()); - } -*/ + private List<NotificationEntity> fetchNewNotifications( + LastSeenNotificationEntity lastSeenNotification, int numOfRecordsToReturn) { + String ownerId = lastSeenNotification.getOwnerId(); + UUID lastEventId = lastSeenNotification.getLastEventId(); + List<NotificationEntity> newNotificationsByOwnerId = + getNewNotificationsByOwnerId(ownerId, lastEventId); + newNotificationsByOwnerId = fetchMoreIfNeeded(ownerId, newNotificationsByOwnerId, + numOfRecordsToReturn, lastEventId); + return newNotificationsByOwnerId; + } + private boolean isNewNotification(LastSeenNotificationEntity lastSeenNotification, + NotificationEntity notification) { + return Objects.isNull(lastSeenNotification.getLastEventId()) || + UUIDs.unixTimestamp(notification.getEventId()) > + UUIDs.unixTimestamp(lastSeenNotification.getLastEventId()); + } + */ @Override public void createBatch(List<NotificationEntity> notificationEntities) { BatchStatement batch = new BatchStatement(); - List<Statement> statements = notificationEntities.stream() - .map(mapper::saveQuery) - .collect(Collectors.toList()); + List<Statement> statements = notificationEntities.stream().map(mapper::saveQuery).collect(Collectors.toList()); batch.addAll(statements); getSession().execute(batch); } @@ -253,7 +250,6 @@ public class NotificationsDaoCassandraImpl extends CassandraBaseDao<Notification this.numOfNotSeenNotifications = numOfNotSeenNotifications; } } - /* private List<NotificationEntity> fetchMoreIfNeeded(String ownerId, List<NotificationEntity> notificationEntities, @@ -278,5 +274,4 @@ public class NotificationsDaoCassandraImpl extends CassandraBaseDao<Notification return notificationEntities; } */ - } diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/SubscribersDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/SubscribersDaoCassandraImpl.java index 8e8cf9b181..a22d3d30f3 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/SubscribersDaoCassandraImpl.java +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/SubscribersDaoCassandraImpl.java @@ -17,36 +17,30 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.notification.dao.impl; +import static java.util.Objects.isNull; + import com.datastax.driver.mapping.Mapper; import com.datastax.driver.mapping.Result; import com.datastax.driver.mapping.annotations.Accessor; import com.datastax.driver.mapping.annotations.Query; import com.google.common.collect.Sets; +import java.util.Collection; +import java.util.Collections; +import java.util.Objects; +import java.util.Set; import org.openecomp.core.dao.impl.CassandraBaseDao; import org.openecomp.core.nosqldb.api.NoSqlDb; import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; import org.openecomp.sdc.notification.dao.SubscribersDao; import org.openecomp.sdc.notification.dao.types.SubscribersEntity; -import java.util.Collection; -import java.util.Collections; -import java.util.Objects; -import java.util.Set; - -import static java.util.Objects.isNull; - -public class SubscribersDaoCassandraImpl extends CassandraBaseDao<SubscribersEntity> implements - SubscribersDao { +public class SubscribersDaoCassandraImpl extends CassandraBaseDao<SubscribersEntity> implements SubscribersDao { private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); - private static final Mapper<SubscribersEntity> mapper = - noSqlDb.getMappingManager().mapper(SubscribersEntity.class); - private static final SubscribersAccessor accessor = - noSqlDb.getMappingManager().createAccessor(SubscribersAccessor.class); - + private static final Mapper<SubscribersEntity> mapper = noSqlDb.getMappingManager().mapper(SubscribersEntity.class); + private static final SubscribersAccessor accessor = noSqlDb.getMappingManager().createAccessor(SubscribersAccessor.class); @Override protected Object[] getKeys(SubscribersEntity entity) { @@ -100,5 +94,4 @@ public class SubscribersDaoCassandraImpl extends CassandraBaseDao<SubscribersEnt @Query("update notification_subscribers set subscribers=subscribers-? WHERE entity_id=?") void unsubscribe(Set<String> ownerId, String entityId); } - } diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/LastNotificationDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/LastNotificationDaoFactoryImpl.java index c57cf5b654..8626186787 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/LastNotificationDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/LastNotificationDaoFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.notification.factories.impl; import org.openecomp.sdc.notification.dao.LastNotificationDao; @@ -28,12 +27,12 @@ import org.openecomp.sdc.notification.factories.LastNotificationDaoFactory; * @author itzikpa * @since June 23, 2017 */ - public class LastNotificationDaoFactoryImpl extends LastNotificationDaoFactory { - private static final LastNotificationDao INSTANCE = new LastNotificationDaoCassandraImpl(); - @Override - public LastNotificationDao createInterface() { - return INSTANCE; - } + private static final LastNotificationDao INSTANCE = new LastNotificationDaoCassandraImpl(); + + @Override + public LastNotificationDao createInterface() { + return INSTANCE; + } } diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationPropagationManagerFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationPropagationManagerFactoryImpl.java index 7b5ca8055a..c3c606f1d6 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationPropagationManagerFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationPropagationManagerFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.notification.factories.impl; import org.openecomp.sdc.notification.factories.NotificationPropagationManagerFactory; @@ -26,11 +25,10 @@ import org.openecomp.sdc.notification.factories.SubscriptionServiceFactory; import org.openecomp.sdc.notification.services.NotificationPropagationManager; import org.openecomp.sdc.notification.services.impl.NotificationPropagationManagerImpl; -public class NotificationPropagationManagerFactoryImpl extends - NotificationPropagationManagerFactory { +public class NotificationPropagationManagerFactoryImpl extends NotificationPropagationManagerFactory { + private static final NotificationPropagationManager INSTANCE = new NotificationPropagationManagerImpl( - PropagationServiceFactory.getInstance().createInterface(), SubscriptionServiceFactory - .getInstance().createInterface()); + PropagationServiceFactory.getInstance().createInterface(), SubscriptionServiceFactory.getInstance().createInterface()); @Override public NotificationPropagationManager createInterface() { diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationsDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationsDaoFactoryImpl.java index 5277dd7c08..d4b4e771a2 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationsDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationsDaoFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.notification.factories.impl; import org.openecomp.sdc.notification.dao.NotificationsDao; @@ -29,10 +28,11 @@ import org.openecomp.sdc.notification.factories.NotificationsDaoFactory; * @since June 20, 2017 */ public class NotificationsDaoFactoryImpl extends NotificationsDaoFactory { - private static final NotificationsDao INSTANCE = new NotificationsDaoCassandraImpl(); - @Override - public NotificationsDao createInterface() { - return INSTANCE; - } + private static final NotificationsDao INSTANCE = new NotificationsDaoCassandraImpl(); + + @Override + public NotificationsDao createInterface() { + return INSTANCE; + } } diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationsServiceFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationsServiceFactoryImpl.java index 30d2b859cf..23d1b2e6ac 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationsServiceFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationsServiceFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.notification.factories.impl; import org.openecomp.sdc.notification.factories.LastNotificationDaoFactory; @@ -31,12 +30,12 @@ import org.openecomp.sdc.notification.services.impl.NotificationsServiceImpl; * @since June 20, 2017 */ public class NotificationsServiceFactoryImpl extends NotificationsServiceFactory { - private static final NotificationsService INSTANCE = new NotificationsServiceImpl( - LastNotificationDaoFactory.getInstance().createInterface(), NotificationsDaoFactory - .getInstance().createInterface()); - @Override - public NotificationsService createInterface() { - return INSTANCE; - } + private static final NotificationsService INSTANCE = new NotificationsServiceImpl(LastNotificationDaoFactory.getInstance().createInterface(), + NotificationsDaoFactory.getInstance().createInterface()); + + @Override + public NotificationsService createInterface() { + return INSTANCE; + } } diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/PropagationServiceFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/PropagationServiceFactoryImpl.java index f6b41226a9..47fe559b56 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/PropagationServiceFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/PropagationServiceFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.notification.factories.impl; import org.openecomp.sdc.notification.factories.NotificationsDaoFactory; @@ -26,8 +25,8 @@ import org.openecomp.sdc.notification.services.PropagationService; import org.openecomp.sdc.notification.services.impl.PropagationServiceImpl; public class PropagationServiceFactoryImpl extends PropagationServiceFactory { - private static final PropagationService INSTANCE = new PropagationServiceImpl( - NotificationsDaoFactory.getInstance().createInterface()); + + private static final PropagationService INSTANCE = new PropagationServiceImpl(NotificationsDaoFactory.getInstance().createInterface()); @Override public PropagationService createInterface() { diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/SubscribersDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/SubscribersDaoFactoryImpl.java index ca5ca2df36..a45b2c5a33 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/SubscribersDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/SubscribersDaoFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,15 +17,14 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.notification.factories.impl; import org.openecomp.sdc.notification.dao.SubscribersDao; import org.openecomp.sdc.notification.dao.impl.SubscribersDaoCassandraImpl; import org.openecomp.sdc.notification.factories.SubscribersDaoFactory; - public class SubscribersDaoFactoryImpl extends SubscribersDaoFactory { + private static final SubscribersDao INSTANCE = new SubscribersDaoCassandraImpl(); @Override diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/SubscriptionServiceFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/SubscriptionServiceFactoryImpl.java index 1f872499b1..18499a93de 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/SubscriptionServiceFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/SubscriptionServiceFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.notification.factories.impl; import org.openecomp.sdc.notification.factories.SubscribersDaoFactory; @@ -25,10 +24,9 @@ import org.openecomp.sdc.notification.factories.SubscriptionServiceFactory; import org.openecomp.sdc.notification.services.SubscriptionService; import org.openecomp.sdc.notification.services.impl.SubscriptionServiceImpl; - public class SubscriptionServiceFactoryImpl extends SubscriptionServiceFactory { - private static final SubscriptionService INSTANCE = new SubscriptionServiceImpl - (SubscribersDaoFactory.getInstance().createInterface()); + + private static final SubscriptionService INSTANCE = new SubscriptionServiceImpl(SubscribersDaoFactory.getInstance().createInterface()); @Override public SubscriptionService createInterface() { diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/NotificationPropagationManagerImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/NotificationPropagationManagerImpl.java index 9795c7bd1a..d817f1798c 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/NotificationPropagationManagerImpl.java +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/NotificationPropagationManagerImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.notification.services.impl; import org.openecomp.sdc.destinationprovider.impl.MulticastDestination; @@ -36,16 +35,14 @@ public class NotificationPropagationManagerImpl implements NotificationPropagati private PropagationService propagationService; private SubscriptionService subscriptionService; - public NotificationPropagationManagerImpl(PropagationService propagationService, - SubscriptionService subscriptionService) { + public NotificationPropagationManagerImpl(PropagationService propagationService, SubscriptionService subscriptionService) { this.propagationService = propagationService; this.subscriptionService = subscriptionService; } @Override - public void notifySubscribers(Event event, String ... excludedSubscribers) { - propagationService.notify(event, new MulticastDestination(event.getEntityId(), - subscriptionService, excludedSubscribers)); + public void notifySubscribers(Event event, String... excludedSubscribers) { + propagationService.notify(event, new MulticastDestination(event.getEntityId(), subscriptionService, excludedSubscribers)); } @Override diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/NotificationsServiceImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/NotificationsServiceImpl.java index d3558d1904..0b5161ff63 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/NotificationsServiceImpl.java +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/NotificationsServiceImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,9 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.notification.services.impl; +import java.util.List; +import java.util.Objects; +import java.util.UUID; import org.openecomp.sdc.notification.dao.LastNotificationDao; import org.openecomp.sdc.notification.dao.NotificationsDao; import org.openecomp.sdc.notification.dao.types.LastSeenNotificationEntity; @@ -28,10 +30,6 @@ import org.openecomp.sdc.notification.dtos.NotificationsStatus; import org.openecomp.sdc.notification.exceptons.NotificationNotExistException; import org.openecomp.sdc.notification.services.NotificationsService; -import java.util.List; -import java.util.Objects; -import java.util.UUID; - /** * @author Avrahamg * @since June 26, 2017 @@ -41,54 +39,46 @@ public class NotificationsServiceImpl implements NotificationsService { private LastNotificationDao lastNotificationDao; private NotificationsDao notificationsDao; - public NotificationsServiceImpl(LastNotificationDao lastNotificationDao, - NotificationsDao notificationsDao) { + public NotificationsServiceImpl(LastNotificationDao lastNotificationDao, NotificationsDao notificationsDao) { this.lastNotificationDao = lastNotificationDao; this.notificationsDao = notificationsDao; } @Override public LastSeenNotificationEntity getLastNotification(String ownerId) { - return new LastSeenNotificationEntity(ownerId, - lastNotificationDao.getOwnerLastEventId(ownerId)); + return new LastSeenNotificationEntity(ownerId, lastNotificationDao.getOwnerLastEventId(ownerId)); } @Override - public void updateLastSeenNotification(String ownerId, UUID eventId) - { + public void updateLastSeenNotification(String ownerId, UUID eventId) { lastNotificationDao.persistOwnerLastEventId(ownerId, eventId); } @Override public NotificationsStatus getNotificationsStatus(String ownerId, UUID lastDelivered, int numOfRecordsToReturn, UUID endOfPage) { - if (Objects.isNull(lastDelivered)) { - LastSeenNotificationEntity entity = getLastNotification(ownerId); - if (Objects.nonNull(entity)) { - lastDelivered = entity.getLastEventId(); - } - if (Objects.isNull(lastDelivered)) { - lastDelivered = UUID.fromString("00000000-0000-1000-8080-808080808080"); // Lowest time UUID value - } - } - if (Objects.isNull(endOfPage)) { - // First page - return notificationsDao.getNotificationsStatus(ownerId, lastDelivered, numOfRecordsToReturn); - } - else { - // Next page + if (Objects.isNull(lastDelivered)) { + LastSeenNotificationEntity entity = getLastNotification(ownerId); + if (Objects.nonNull(entity)) { + lastDelivered = entity.getLastEventId(); + } + if (Objects.isNull(lastDelivered)) { + lastDelivered = UUID.fromString("00000000-0000-1000-8080-808080808080"); // Lowest time UUID value + } + } + if (Objects.isNull(endOfPage)) { + // First page + return notificationsDao.getNotificationsStatus(ownerId, lastDelivered, numOfRecordsToReturn); + } else { + // Next page return notificationsDao.getNotificationsStatus(ownerId, lastDelivered, numOfRecordsToReturn, endOfPage); - } + } } @Override - public void markAsRead(String ownerId, String notificationId) throws - NotificationNotExistException { - NotificationEntity notificationEntity = - notificationsDao.get(new NotificationEntity(ownerId, UUID.fromString(notificationId))); + public void markAsRead(String ownerId, String notificationId) throws NotificationNotExistException { + NotificationEntity notificationEntity = notificationsDao.get(new NotificationEntity(ownerId, UUID.fromString(notificationId))); if (Objects.isNull(notificationEntity)) { - throw new NotificationNotExistException( - "Notification '" + notificationId + "' is not related to ownerId" + - " '" + ownerId + "'"); + throw new NotificationNotExistException("Notification '" + notificationId + "' is not related to ownerId" + " '" + ownerId + "'"); } notificationEntity.setRead(true); notificationsDao.update(notificationEntity); @@ -96,17 +86,16 @@ public class NotificationsServiceImpl implements NotificationsService { @Override public List<NotificationEntity> getNotificationsByOwnerId(String ownerId, int limit) { - return notificationsDao.getNotificationsByOwnerId(ownerId, limit); + return notificationsDao.getNotificationsByOwnerId(ownerId, limit); } @Override public List<NotificationEntity> getNewNotificationsByOwnerId(String ownerId, UUID eventId) { - return notificationsDao.getNewNotificationsByOwnerId(ownerId, eventId); + return notificationsDao.getNewNotificationsByOwnerId(ownerId, eventId); } @Override public List<NotificationEntity> getNewNotificationsByOwnerId(String ownerId, UUID eventId, int limit) { - return notificationsDao.getNewNotificationsByOwnerId(ownerId, eventId, limit); + return notificationsDao.getNewNotificationsByOwnerId(ownerId, eventId, limit); } - } diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/PropagationServiceImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/PropagationServiceImpl.java index 99d35b3726..de6880c46c 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/PropagationServiceImpl.java +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/PropagationServiceImpl.java @@ -17,10 +17,15 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.notification.services.impl; +import static java.util.Objects.requireNonNull; + import com.datastax.driver.core.utils.UUIDs; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; import org.apache.commons.collections4.CollectionUtils; import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.sdc.destinationprovider.DestinationProvider; @@ -29,13 +34,6 @@ import org.openecomp.sdc.notification.dao.types.NotificationEntity; import org.openecomp.sdc.notification.dtos.Event; import org.openecomp.sdc.notification.services.PropagationService; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.stream.Collectors; - -import static java.util.Objects.requireNonNull; - public class PropagationServiceImpl implements PropagationService { private NotificationsDao notificationsDao; @@ -44,7 +42,6 @@ public class PropagationServiceImpl implements PropagationService { this.notificationsDao = notificationsDao; } - @Override public void notify(Event event, DestinationProvider destinationProvider) { requireNonNull(event.getEventType()); @@ -53,26 +50,21 @@ public class PropagationServiceImpl implements PropagationService { if (CollectionUtils.isEmpty(subscribers)) { return; } - List<NotificationEntity> notificationEntities = subscribers.stream().map( - subscriber -> { - UUID eventId = UUIDs.timeBased(); - return createNotificationEntity(event.getEventType(), subscriber, - event.getOriginatorId(), event.getAttributes(), eventId); - }).collect(Collectors.toList()); - if(CollectionUtils.isNotEmpty(notificationEntities)) { + List<NotificationEntity> notificationEntities = subscribers.stream().map(subscriber -> { + UUID eventId = UUIDs.timeBased(); + return createNotificationEntity(event.getEventType(), subscriber, event.getOriginatorId(), event.getAttributes(), eventId); + }).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(notificationEntities)) { notificationsDao.createBatch(notificationEntities); } } - private NotificationEntity createNotificationEntity(String eventType, String subscriber, - String originatorId, - Map<String, Object> attributes, + private NotificationEntity createNotificationEntity(String eventType, String subscriber, String originatorId, Map<String, Object> attributes, UUID eventId) { - NotificationEntity notificationEntity = - new NotificationEntity(subscriber, eventId, eventType, originatorId); + NotificationEntity notificationEntity = new NotificationEntity(subscriber, eventId, eventType, originatorId); if (attributes != null && !attributes.isEmpty()) { notificationEntity.setEventAttributes(JsonUtil.object2Json(attributes)); } return notificationEntity; } -}
\ No newline at end of file +} diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/SubscriptionServiceImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/SubscriptionServiceImpl.java index 2a12463fae..dbbbf43177 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/SubscriptionServiceImpl.java +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/SubscriptionServiceImpl.java @@ -17,14 +17,12 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.notification.services.impl; +import java.util.Set; import org.openecomp.sdc.notification.dao.SubscribersDao; import org.openecomp.sdc.notification.services.SubscriptionService; -import java.util.Set; - public class SubscriptionServiceImpl implements SubscriptionService { private SubscribersDao subscribersDao; @@ -47,4 +45,4 @@ public class SubscriptionServiceImpl implements SubscriptionService { public Set<String> getSubscribers(String entityId) { return subscribersDao.getSubscribers(entityId); } -}
\ No newline at end of file +} |