summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-notification-lib
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-03-22 15:33:06 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-03-24 06:59:47 +0000
commitd378c37fbd1ecec7b43394926f1ca32a695e07de (patch)
tree5c8a085f8732f980d871d966ac49361644efa698 /openecomp-be/lib/openecomp-sdc-notification-lib
parenta6ae7294ecd336d7e88f915710b08e2658eaee00 (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')
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/destinationprovider/DestinationProvider.java1
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/LastNotificationDao.java9
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/NotificationsDao.java11
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/SubscribersDao.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/LastSeenNotificationEntity.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/NotificationEntity.java9
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/SubscribersEntity.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dtos/NotificationsStatus.java14
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/exceptons/NotificationNotExistException.java5
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/LastNotificationDaoFactory.java9
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationPropagationManagerFactory.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationsDaoFactory.java9
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationsServiceFactory.java9
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/PropagationServiceFactory.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/SubscribersDaoFactory.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/SubscriptionServiceFactory.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/NotificationPropagationManager.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/NotificationsService.java14
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/SubscriptionService.java1
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/destinationprovider/impl/MulticastDestination.java15
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/destinationprovider/impl/UnicastDestination.java8
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/LastNotificationDaoCassandraImpl.java96
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/NotificationsDaoCassandraImpl.java135
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/SubscribersDaoCassandraImpl.java25
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/LastNotificationDaoFactoryImpl.java17
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationPropagationManagerFactoryImpl.java12
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationsDaoFactoryImpl.java16
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationsServiceFactoryImpl.java19
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/PropagationServiceFactoryImpl.java9
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/SubscribersDaoFactoryImpl.java7
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/SubscriptionServiceFactoryImpl.java10
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/NotificationPropagationManagerImpl.java13
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/NotificationsServiceImpl.java69
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/PropagationServiceImpl.java36
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/SubscriptionServiceImpl.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-websocket/src/main/java/org/openecomp/sdc/notification/websocket/NotificationWebsocketHandler.java109
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/config/ConfigurationManager.java44
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/types/NotificationEntityDto.java1
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/types/NotificationsStatusDto.java5
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NewNotificationsReader.java7
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NotificationReceiver.java17
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NotificationWorker.java164
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/impl/NewNotificationsReaderRestImpl.java19
43 files changed, 409 insertions, 573 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/destinationprovider/DestinationProvider.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/destinationprovider/DestinationProvider.java
index fb8f3ce0ef..2ece29bdcb 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/destinationprovider/DestinationProvider.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/destinationprovider/DestinationProvider.java
@@ -26,5 +26,6 @@ import java.util.List;
* @since July 09, 2017
*/
public interface DestinationProvider {
+
List<String> getSubscribers();
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/LastNotificationDao.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/LastNotificationDao.java
index f0bf7e8874..38603f8ac7 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/LastNotificationDao.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/LastNotificationDao.java
@@ -17,18 +17,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.notification.dao;
+import java.util.UUID;
import org.openecomp.core.dao.BaseDao;
import org.openecomp.sdc.notification.dao.types.LastSeenNotificationEntity;
-import java.util.UUID;
-
public interface LastNotificationDao extends BaseDao<LastSeenNotificationEntity> {
- UUID getOwnerLastEventId(String ownerId);
-
- void persistOwnerLastEventId(String ownerId, UUID eventId);
+ UUID getOwnerLastEventId(String ownerId);
+ void persistOwnerLastEventId(String ownerId, UUID eventId);
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/NotificationsDao.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/NotificationsDao.java
index 6542d70158..111cfa699d 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/NotificationsDao.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/NotificationsDao.java
@@ -17,17 +17,14 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.notification.dao;
-import org.openecomp.core.dao.BaseDao;
-import org.openecomp.sdc.notification.dao.types.NotificationEntity;
-import org.openecomp.sdc.notification.dtos.NotificationsStatus;
-
import java.util.Collection;
import java.util.List;
import java.util.UUID;
-
+import org.openecomp.core.dao.BaseDao;
+import org.openecomp.sdc.notification.dao.types.NotificationEntity;
+import org.openecomp.sdc.notification.dtos.NotificationsStatus;
public interface NotificationsDao extends BaseDao<NotificationEntity> {
@@ -43,7 +40,7 @@ public interface NotificationsDao extends BaseDao<NotificationEntity> {
NotificationsStatus getNotificationsStatus(String ownerId, UUID lastSeenNotification, int numOfRecordsToReturn, UUID prevLastNotification);
- void markNotificationAsRead(String ownerId, Collection<UUID> eventIds);
+ void markNotificationAsRead(String ownerId, Collection<UUID> eventIds);
void createBatch(List<NotificationEntity> notificationEntities);
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/SubscribersDao.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/SubscribersDao.java
index 3daf165efc..d0c16e6e7c 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/SubscribersDao.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/SubscribersDao.java
@@ -17,15 +17,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.notification.dao;
+import java.util.Set;
import org.openecomp.core.dao.BaseDao;
import org.openecomp.sdc.notification.dao.types.SubscribersEntity;
-import java.util.Set;
-
-
public interface SubscribersDao extends BaseDao<SubscribersEntity> {
void subscribe(String ownerId, String entityId);
@@ -33,5 +30,4 @@ public interface SubscribersDao extends BaseDao<SubscribersEntity> {
void unsubscribe(String ownerId, String entityId);
Set<String> getSubscribers(String entityId);
-
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/LastSeenNotificationEntity.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/LastSeenNotificationEntity.java
index 97aba63f1c..a09d687c5a 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/LastSeenNotificationEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/LastSeenNotificationEntity.java
@@ -13,19 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.notification.dao.types;
import com.datastax.driver.mapping.annotations.Column;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
-
import java.util.UUID;
-
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
-import lombok.ToString;
@Data
@AllArgsConstructor
@@ -34,11 +30,9 @@ import lombok.ToString;
public class LastSeenNotificationEntity {
public static final String ENTITY_TYPE = "Event Notification";
-
@PartitionKey
@Column(name = "owner_id")
private String ownerId;
-
@Column(name = "event_id")
private UUID lastEventId;
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/NotificationEntity.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/NotificationEntity.java
index b45a2a0c7d..a8d631512c 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/NotificationEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/NotificationEntity.java
@@ -13,16 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.notification.dao.types;
import com.datastax.driver.mapping.annotations.ClusteringColumn;
import com.datastax.driver.mapping.annotations.Column;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
-
import java.util.UUID;
-
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -34,24 +31,18 @@ import lombok.NoArgsConstructor;
public class NotificationEntity {
public static final String ENTITY_TYPE = "Event Notification";
-
@PartitionKey
@Column(name = "owner_id")
private String ownerId;
-
@Column(name = "read")
private boolean read;
-
@ClusteringColumn
@Column(name = "event_id")
private UUID eventId;
-
@Column(name = "event_type")
private String eventType;
-
@Column(name = "event_attributes")
private String eventAttributes;
-
@Column(name = "originator_id")
private String originatorId;
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/SubscribersEntity.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/SubscribersEntity.java
index b1b80cd135..248c82974e 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/SubscribersEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/SubscribersEntity.java
@@ -13,15 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.notification.dao.types;
import com.datastax.driver.mapping.annotations.Column;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
-
import java.util.Set;
-
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -35,7 +32,6 @@ public class SubscribersEntity {
@PartitionKey
@Column(name = "entity_id")
private String entityId;
-
@Column(name = "subscribers")
private Set<String> subscribers;
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dtos/NotificationsStatus.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dtos/NotificationsStatus.java
index 7532ab9218..152b7b72e7 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dtos/NotificationsStatus.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dtos/NotificationsStatus.java
@@ -19,10 +19,9 @@
*/
package org.openecomp.sdc.notification.dtos;
-import org.openecomp.sdc.notification.dao.types.NotificationEntity;
-
import java.util.List;
import java.util.UUID;
+import org.openecomp.sdc.notification.dao.types.NotificationEntity;
/**
* @author Avrahamg
@@ -30,14 +29,13 @@ import java.util.UUID;
*/
public interface NotificationsStatus {
- List<NotificationEntity> getNotifications();
-
- List<UUID> getNewEntries();
+ List<NotificationEntity> getNotifications();
- UUID getLastScanned();
+ List<UUID> getNewEntries();
- UUID getEndOfPage();
+ UUID getLastScanned();
- long getNumOfNotSeenNotifications();
+ UUID getEndOfPage();
+ long getNumOfNotSeenNotifications();
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/exceptons/NotificationNotExistException.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/exceptons/NotificationNotExistException.java
index cb3b8a4b07..7ac7bf81ec 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/exceptons/NotificationNotExistException.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/exceptons/NotificationNotExistException.java
@@ -24,12 +24,13 @@ package org.openecomp.sdc.notification.exceptons;
* @since July 02, 2017
*/
public class NotificationNotExistException extends Exception {
- private String message;
+ private String message;
- public NotificationNotExistException(String Message){
+ public NotificationNotExistException(String Message) {
this(Message, null);
}
+
public NotificationNotExistException(String message, Throwable cause) {
super(cause);
this.message = message;
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/LastNotificationDaoFactory.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/LastNotificationDaoFactory.java
index 6e6f9f063a..26415de8a0 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/LastNotificationDaoFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/LastNotificationDaoFactory.java
@@ -17,18 +17,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.notification.factories;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
import org.openecomp.sdc.notification.dao.LastNotificationDao;
-
public abstract class LastNotificationDaoFactory extends AbstractComponentFactory<LastNotificationDao> {
- public static LastNotificationDaoFactory getInstance() {
- return AbstractFactory.getInstance(LastNotificationDaoFactory.class);
- }
-
+ public static LastNotificationDaoFactory getInstance() {
+ return AbstractFactory.getInstance(LastNotificationDaoFactory.class);
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationPropagationManagerFactory.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationPropagationManagerFactory.java
index 134920635e..9286dc700f 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationPropagationManagerFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationPropagationManagerFactory.java
@@ -25,10 +25,7 @@ import org.openecomp.sdc.notification.services.NotificationPropagationManager;
public abstract class NotificationPropagationManagerFactory extends AbstractComponentFactory<NotificationPropagationManager> {
-
public static NotificationPropagationManagerFactory getInstance() {
return AbstractFactory.getInstance(NotificationPropagationManagerFactory.class);
}
-
-
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationsDaoFactory.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationsDaoFactory.java
index 341af7e296..82c7ba15b3 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationsDaoFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationsDaoFactory.java
@@ -17,18 +17,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.notification.factories;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
import org.openecomp.sdc.notification.dao.NotificationsDao;
-
public abstract class NotificationsDaoFactory extends AbstractComponentFactory<NotificationsDao> {
- public static NotificationsDaoFactory getInstance() {
- return AbstractFactory.getInstance(NotificationsDaoFactory.class);
- }
-
+ public static NotificationsDaoFactory getInstance() {
+ return AbstractFactory.getInstance(NotificationsDaoFactory.class);
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationsServiceFactory.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationsServiceFactory.java
index eab26188c1..2b94de31f6 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationsServiceFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationsServiceFactory.java
@@ -17,18 +17,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.notification.factories;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
import org.openecomp.sdc.notification.services.NotificationsService;
-
public abstract class NotificationsServiceFactory extends AbstractComponentFactory<NotificationsService> {
- public static NotificationsServiceFactory getInstance() {
- return AbstractFactory.getInstance(NotificationsServiceFactory.class);
- }
-
+ public static NotificationsServiceFactory getInstance() {
+ return AbstractFactory.getInstance(NotificationsServiceFactory.class);
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/PropagationServiceFactory.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/PropagationServiceFactory.java
index 7a20e985e3..0859f45db5 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/PropagationServiceFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/PropagationServiceFactory.java
@@ -25,10 +25,7 @@ import org.openecomp.sdc.notification.services.PropagationService;
public abstract class PropagationServiceFactory extends AbstractComponentFactory<PropagationService> {
-
public static PropagationServiceFactory getInstance() {
return AbstractFactory.getInstance(PropagationServiceFactory.class);
}
-
-
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/SubscribersDaoFactory.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/SubscribersDaoFactory.java
index 33b62e2f5d..07cbd8cbd9 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/SubscribersDaoFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/SubscribersDaoFactory.java
@@ -17,18 +17,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.notification.factories;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
import org.openecomp.sdc.notification.dao.SubscribersDao;
-
public abstract class SubscribersDaoFactory extends AbstractComponentFactory<SubscribersDao> {
public static SubscribersDaoFactory getInstance() {
return AbstractFactory.getInstance(SubscribersDaoFactory.class);
}
-
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/SubscriptionServiceFactory.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/SubscriptionServiceFactory.java
index 3e789c22a7..26b045f27a 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/SubscriptionServiceFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/SubscriptionServiceFactory.java
@@ -17,18 +17,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.notification.factories;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
import org.openecomp.sdc.notification.services.SubscriptionService;
-
public abstract class SubscriptionServiceFactory extends AbstractComponentFactory<SubscriptionService> {
public static SubscriptionServiceFactory getInstance() {
return AbstractFactory.getInstance(SubscriptionServiceFactory.class);
}
-
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/NotificationPropagationManager.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/NotificationPropagationManager.java
index 9912990084..6fa9e52dc0 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/NotificationPropagationManager.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/NotificationPropagationManager.java
@@ -26,6 +26,8 @@ import org.openecomp.sdc.notification.dtos.Event;
* @since July 09, 2017
*/
public interface NotificationPropagationManager {
- void notifySubscribers(Event event, String ... excludedSubscribers);
+
+ void notifySubscribers(Event event, String... excludedSubscribers);
+
void directNotification(Event event, String destinationId);
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/NotificationsService.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/NotificationsService.java
index 9990f6dc2e..aca8eacde3 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/NotificationsService.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/NotificationsService.java
@@ -19,32 +19,30 @@
*/
package org.openecomp.sdc.notification.services;
+import java.util.List;
+import java.util.UUID;
import org.openecomp.sdc.notification.dao.types.LastSeenNotificationEntity;
import org.openecomp.sdc.notification.dao.types.NotificationEntity;
import org.openecomp.sdc.notification.dtos.NotificationsStatus;
import org.openecomp.sdc.notification.exceptons.NotificationNotExistException;
-import java.util.List;
-import java.util.UUID;
-
/**
* @author Avrahamg
* @since June 22, 2017
*/
public interface NotificationsService {
- LastSeenNotificationEntity getLastNotification(String ownerId);
+ LastSeenNotificationEntity getLastNotification(String ownerId);
- NotificationsStatus getNotificationsStatus(String ownerId, UUID lastDelivered, int numOfRecordsToReturn, UUID endOfPage);
+ NotificationsStatus getNotificationsStatus(String ownerId, UUID lastDelivered, int numOfRecordsToReturn, UUID endOfPage);
- void updateLastSeenNotification(String ownerId, UUID eventId);
+ void updateLastSeenNotification(String ownerId, UUID eventId);
- void markAsRead(String ownerId, String notificationId) throws NotificationNotExistException;
+ void markAsRead(String ownerId, String notificationId) throws NotificationNotExistException;
List<NotificationEntity> getNotificationsByOwnerId(String ownerId, int limit);
List<NotificationEntity> getNewNotificationsByOwnerId(String ownerId, UUID eventId);
List<NotificationEntity> getNewNotificationsByOwnerId(String ownerId, UUID eventId, int limit);
-
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/SubscriptionService.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/SubscriptionService.java
index a0b1721796..35aa5c6924 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/SubscriptionService.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/SubscriptionService.java
@@ -26,6 +26,7 @@ import java.util.Set;
* @since July 09, 2017
*/
public interface SubscriptionService {
+
void subscribe(String ownerId, String entityId);
void unsubscribe(String ownerId, String entityId);
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
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-websocket/src/main/java/org/openecomp/sdc/notification/websocket/NotificationWebsocketHandler.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-websocket/src/main/java/org/openecomp/sdc/notification/websocket/NotificationWebsocketHandler.java
index 1e424631f7..7f21dee9a2 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-websocket/src/main/java/org/openecomp/sdc/notification/websocket/NotificationWebsocketHandler.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-websocket/src/main/java/org/openecomp/sdc/notification/websocket/NotificationWebsocketHandler.java
@@ -17,10 +17,14 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.notification.websocket;
import com.google.gson.Gson;
+import java.io.IOException;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.function.Consumer;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.notification.types.NotificationsStatusDto;
@@ -31,100 +35,81 @@ import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.handler.TextWebSocketHandler;
-import java.io.IOException;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.UUID;
-import java.util.function.Consumer;
-
public class NotificationWebsocketHandler extends TextWebSocketHandler {
- private static final String USER_ID_HEADER_PARAM = "USER_ID";
- private static final String LAST_DELIVERED_QUERY_PARAM = "LAST_DELIVERED_EVENT_ID";
- private static final String COOKIE = "Cookie";
- private static Logger LOGGER = LoggerFactory.getLogger(NotificationWebsocketHandler.class);
- private NotificationWorker worker;
+ private static final String USER_ID_HEADER_PARAM = "USER_ID";
+ private static final String LAST_DELIVERED_QUERY_PARAM = "LAST_DELIVERED_EVENT_ID";
+ private static final String COOKIE = "Cookie";
+ private static Logger LOGGER = LoggerFactory.getLogger(NotificationWebsocketHandler.class);
+ private NotificationWorker worker;
- public NotificationWebsocketHandler(NotificationWorker worker) {
- super();
- this.worker = Objects.requireNonNull(worker, "NotificationWorker object is not initialized.");
- }
+ public NotificationWebsocketHandler(NotificationWorker worker) {
+ super();
+ this.worker = Objects.requireNonNull(worker, "NotificationWorker object is not initialized.");
+ }
- @Override
+ @Override
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
super.afterConnectionEstablished(session);
-
- String ownerId = getOwnerId(session);
- if (ownerId == null) {
- return;
- }
- UUID lastDelivered = getLastEventId(session);
-
- Consumer<NotificationsStatusDto> notesProcessor = (notes) -> notifyReceiver(session, notes);
-
- worker.register(ownerId, lastDelivered, notesProcessor);
+ String ownerId = getOwnerId(session);
+ if (ownerId == null) {
+ return;
+ }
+ UUID lastDelivered = getLastEventId(session);
+ Consumer<NotificationsStatusDto> notesProcessor = (notes) -> notifyReceiver(session, notes);
+ worker.register(ownerId, lastDelivered, notesProcessor);
}
- @Override
+ @Override
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
- String ownerId = getOwnerId(session);
- if (ownerId != null) {
- worker.unregister(ownerId);
- }
- super.afterConnectionClosed(session, status);
+ String ownerId = getOwnerId(session);
+ if (ownerId != null) {
+ worker.unregister(ownerId);
+ }
+ super.afterConnectionClosed(session, status);
}
- private void notifyReceiver(WebSocketSession session, NotificationsStatusDto notificationsStatusDto) {
-
- try {
- session.sendMessage(new TextMessage(new Gson().toJson(notificationsStatusDto)));
- } catch (IOException e) {
- LOGGER.error("IO Exception during Receiver notification.", e);
- }
- }
+ private void notifyReceiver(WebSocketSession session, NotificationsStatusDto notificationsStatusDto) {
+ try {
+ session.sendMessage(new TextMessage(new Gson().toJson(notificationsStatusDto)));
+ } catch (IOException e) {
+ LOGGER.error("IO Exception during Receiver notification.", e);
+ }
+ }
private String getOwnerId(WebSocketSession session) {
-
HttpHeaders handshakeHeaders = session.getHandshakeHeaders();
if (handshakeHeaders.containsKey(COOKIE)) {
- String[] cookies = handshakeHeaders.get(COOKIE).get(0).split("; ");
- Optional<String> cookie = extractValue(cookies, USER_ID_HEADER_PARAM);
- if (cookie.isPresent()) {
- return cookie.get();
- }
- }
-
- LOGGER.error("No " + USER_ID_HEADER_PARAM + " specified in the session cookies.");
- return null;
+ String[] cookies = handshakeHeaders.get(COOKIE).get(0).split("; ");
+ Optional<String> cookie = extractValue(cookies, USER_ID_HEADER_PARAM);
+ if (cookie.isPresent()) {
+ return cookie.get();
+ }
+ }
+ LOGGER.error("No " + USER_ID_HEADER_PARAM + " specified in the session cookies.");
+ return null;
}
private UUID getLastEventId(WebSocketSession session) {
-
String uriQuery = session.getUri().getQuery();
if (uriQuery != null) {
-
String[] queries = uriQuery.split("; ");
Optional<String> paramValue = extractValue(queries, LAST_DELIVERED_QUERY_PARAM);
if (paramValue.isPresent()) {
return UUID.fromString(paramValue.get());
}
}
-
LOGGER.warn("No " + LAST_DELIVERED_QUERY_PARAM + " specified in the request URI.");
return null;
}
- private Optional<String> extractValue(String[] pairs, String name) {
-
- for (String nameValuePair : pairs) {
-
+ private Optional<String> extractValue(String[] pairs, String name) {
+ for (String nameValuePair : pairs) {
String[] value = nameValuePair.split("=");
if (value[0].equals(name)) {
return Optional.of(value[1]);
}
}
-
- return Optional.empty();
- }
-
+ return Optional.empty();
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/config/ConfigurationManager.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/config/ConfigurationManager.java
index c016a4797f..e597de0f20 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/config/ConfigurationManager.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/config/ConfigurationManager.java
@@ -17,96 +17,76 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.notification.config;
-import org.onap.sdc.tosca.services.YamlUtil;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.BiConsumer;
+import org.onap.sdc.tosca.services.YamlUtil;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
public class ConfigurationManager {
private static final String CONFIGURATION_YAML_FILE = "onboarding_configuration.yaml";
private static final String NOTIFICATIONS_CONFIG = "notifications";
-
- private LinkedHashMap<String, Object> notificationsConfiguration;
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationManager.class);
private static final ConfigurationManager SINGLETON = new ConfigurationManager();
-
- public static ConfigurationManager getInstance() {
- return SINGLETON;
- }
+ private LinkedHashMap<String, Object> notificationsConfiguration;
private ConfigurationManager() {
initConfiguration();
}
- private void initConfiguration() {
+ public static ConfigurationManager getInstance() {
+ return SINGLETON;
+ }
+ private void initConfiguration() {
YamlUtil yamlUtil = new YamlUtil();
readConfigurationFromStream(yamlUtil, (filename, stream) -> {
-
if (stream == null) {
LOGGER.warn("Configuration not found: " + filename + ". Using defaults");
return;
}
-
Map<String, LinkedHashMap<String, Object>> configurationMap = yamlUtil.yamlToMap(stream);
if (configurationMap == null) {
LOGGER.warn("Configuration cannot be parsed: " + filename + ". Using defaults");
return;
}
-
notificationsConfiguration = configurationMap.get(NOTIFICATIONS_CONFIG);
if (notificationsConfiguration == null) {
- LOGGER.error(NOTIFICATIONS_CONFIG +
- " is missing in configuration file '" + filename + "'. Using defaults");
+ LOGGER.error(NOTIFICATIONS_CONFIG + " is missing in configuration file '" + filename + "'. Using defaults");
}
});
}
- private void readConfigurationFromStream(YamlUtil yamlUtil,
- BiConsumer<String, InputStream> reader) {
-
+ private void readConfigurationFromStream(YamlUtil yamlUtil, BiConsumer<String, InputStream> reader) {
String configurationYamlFile = System.getProperty(CONFIGURATION_YAML_FILE);
-
try {
-
if (configurationYamlFile == null) {
-
- try (InputStream inputStream =
- yamlUtil.loadYamlFileIs("/" + CONFIGURATION_YAML_FILE)) {
+ try (InputStream inputStream = yamlUtil.loadYamlFileIs("/" + CONFIGURATION_YAML_FILE)) {
reader.accept(CONFIGURATION_YAML_FILE, inputStream);
}
-
} else {
-
try (InputStream inputStream = new FileInputStream(configurationYamlFile)) {
reader.accept(configurationYamlFile, inputStream);
}
}
-
} catch (IOException e) {
LOGGER.error("Failed to read configuration", e);
}
}
public <T> T getConfigValue(String name, T defaultValue) {
-
Object value = notificationsConfiguration.get(name);
-
try {
return value == null ? defaultValue : (T) value;
} catch (ClassCastException e) {
- LOGGER.warn(String.format("Failed to read configuration property '%s' as requested type. Using default '%s'",
- name, defaultValue), e);
+ LOGGER.warn(String.format("Failed to read configuration property '%s' as requested type. Using default '%s'", name, defaultValue), e);
return defaultValue;
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/types/NotificationEntityDto.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/types/NotificationEntityDto.java
index a48b16add6..9e92a2b983 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/types/NotificationEntityDto.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/types/NotificationEntityDto.java
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.notification.types;
import java.util.Map;
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/types/NotificationsStatusDto.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/types/NotificationsStatusDto.java
index 7aca3fd63d..c4522c4e04 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/types/NotificationsStatusDto.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/types/NotificationsStatusDto.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.types;
import java.util.ArrayList;
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NewNotificationsReader.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NewNotificationsReader.java
index 75b9f5c786..8dd64c348b 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NewNotificationsReader.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NewNotificationsReader.java
@@ -17,13 +17,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.notification.workers;
-import org.openecomp.sdc.notification.types.NotificationsStatusDto;
-
import java.util.UUID;
+import org.openecomp.sdc.notification.types.NotificationsStatusDto;
public interface NewNotificationsReader {
- NotificationsStatusDto getNewNotifications(String ownerId, UUID eventId, int limit);
+
+ NotificationsStatusDto getNewNotifications(String ownerId, UUID eventId, int limit);
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NotificationReceiver.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NotificationReceiver.java
index 4ce87427aa..e357fda982 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NotificationReceiver.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NotificationReceiver.java
@@ -17,28 +17,25 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.notification.workers;
-import org.openecomp.sdc.notification.types.NotificationsStatusDto;
-
import java.util.UUID;
import java.util.function.Consumer;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
-
+import org.openecomp.sdc.notification.types.NotificationsStatusDto;
@Getter
@Setter
@AllArgsConstructor
public class NotificationReceiver {
- private String ownerId = null;
- private UUID lastEventId = null;
- private Consumer<NotificationsStatusDto> notesProcessor = null;
+ private String ownerId = null;
+ private UUID lastEventId = null;
+ private Consumer<NotificationsStatusDto> notesProcessor = null;
- NotificationReceiver(String ownerId, Consumer<NotificationsStatusDto> notesProcessor) {
- this(ownerId, null, notesProcessor);
- }
+ NotificationReceiver(String ownerId, Consumer<NotificationsStatusDto> notesProcessor) {
+ this(ownerId, null, notesProcessor);
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NotificationWorker.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NotificationWorker.java
index dce8edb356..c69c4ca524 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NotificationWorker.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NotificationWorker.java
@@ -17,103 +17,91 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.notification.workers;
-import org.apache.commons.collections4.CollectionUtils;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.notification.config.ConfigurationManager;
-import org.openecomp.sdc.notification.types.NotificationsStatusDto;
-
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
+import org.apache.commons.collections4.CollectionUtils;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.notification.config.ConfigurationManager;
+import org.openecomp.sdc.notification.types.NotificationsStatusDto;
public class NotificationWorker {
- private static final int DEFAULT_POLLING_INTERVAL = 2000;
- private static final String POLLING_INTERVAL = "pollingIntervalMsec";
- private static final int DEFAULT_SELECTION_LIMIT = 10;
- private static final String SELECTION_SIZE = "selectionSize";
-
- private static boolean stopRunning = false;
-
- private int selectionLimit = DEFAULT_SELECTION_LIMIT;
- private int pollingSleepInterval = DEFAULT_POLLING_INTERVAL;
-
- private static final Logger LOGGER = LoggerFactory.getLogger(NotificationWorker.class);
-
- private static Map<String, NotificationReceiver> activeUsers = new ConcurrentHashMap<>();
- private NewNotificationsReader news = null;
-
- public NotificationWorker(NewNotificationsReader news) {
- ConfigurationManager cm = ConfigurationManager.getInstance();
- pollingSleepInterval = cm.getConfigValue(POLLING_INTERVAL, DEFAULT_POLLING_INTERVAL);
- selectionLimit = cm.getConfigValue(SELECTION_SIZE, DEFAULT_SELECTION_LIMIT);
-
- Objects.requireNonNull(news, "NotificationNews object is not initialized.");
- this.news = news;
-
- NotificationWorker.Poller p = new Poller();
- Thread thread = new Thread(p);
- thread.start();
- }
-
- public Map<String, NotificationReceiver> getActiveUsers() {
- return activeUsers;
- }
-
- public class Poller extends Thread {
- @Override
- public void run() {
- try {
- while (!stopRunning) {
- pollNotifications();
- Thread.sleep(pollingSleepInterval);
- }
- }
- catch (InterruptedException e) {
- LOGGER.error("Interrupted Exception during Notification poller launch.", e);
- Thread.currentThread().interrupt();
- }
- }
-
- private void pollNotifications() {
-
- Map<String, NotificationReceiver> currUsers = new HashMap<>();
- currUsers.putAll(getActiveUsers());
-
- for (NotificationReceiver receiver : currUsers.values()) {
- String ownerId = receiver.getOwnerId();
- UUID eventId = receiver.getLastEventId();
- NotificationsStatusDto status = news.getNewNotifications(ownerId, eventId, selectionLimit);
- if(Objects.nonNull(status) && CollectionUtils.isNotEmpty(status.getNotifications())) {
- receiver.setLastEventId(status.getLastScanned());
- receiver.getNotesProcessor().accept(status);
- }
- }
- }
-
- }
-
- public void register(String ownerId, UUID lastDelivered, Consumer<NotificationsStatusDto> notesProcessor) {
- NotificationReceiver receiver = new NotificationReceiver(ownerId, lastDelivered, notesProcessor);
- activeUsers.put(ownerId, receiver);
- LOGGER.debug("User {} is registered with eventId: {}", ownerId, receiver.getLastEventId());
- }
-
- public void unregister(String ownerId) {
- activeUsers.remove(ownerId);
- LOGGER.debug("User {} is unregistered.", ownerId);
- }
-
- public void stopPolling() {
- LOGGER.debug("Stop notification polling.");
- stopRunning = true;
- }
-
+ private static final int DEFAULT_POLLING_INTERVAL = 2000;
+ private static final String POLLING_INTERVAL = "pollingIntervalMsec";
+ private static final int DEFAULT_SELECTION_LIMIT = 10;
+ private static final String SELECTION_SIZE = "selectionSize";
+ private static final Logger LOGGER = LoggerFactory.getLogger(NotificationWorker.class);
+ private static boolean stopRunning = false;
+ private static Map<String, NotificationReceiver> activeUsers = new ConcurrentHashMap<>();
+ private int selectionLimit = DEFAULT_SELECTION_LIMIT;
+ private int pollingSleepInterval = DEFAULT_POLLING_INTERVAL;
+ private NewNotificationsReader news = null;
+
+ public NotificationWorker(NewNotificationsReader news) {
+ ConfigurationManager cm = ConfigurationManager.getInstance();
+ pollingSleepInterval = cm.getConfigValue(POLLING_INTERVAL, DEFAULT_POLLING_INTERVAL);
+ selectionLimit = cm.getConfigValue(SELECTION_SIZE, DEFAULT_SELECTION_LIMIT);
+ Objects.requireNonNull(news, "NotificationNews object is not initialized.");
+ this.news = news;
+ NotificationWorker.Poller p = new Poller();
+ Thread thread = new Thread(p);
+ thread.start();
+ }
+
+ public Map<String, NotificationReceiver> getActiveUsers() {
+ return activeUsers;
+ }
+
+ public void register(String ownerId, UUID lastDelivered, Consumer<NotificationsStatusDto> notesProcessor) {
+ NotificationReceiver receiver = new NotificationReceiver(ownerId, lastDelivered, notesProcessor);
+ activeUsers.put(ownerId, receiver);
+ LOGGER.debug("User {} is registered with eventId: {}", ownerId, receiver.getLastEventId());
+ }
+
+ public void unregister(String ownerId) {
+ activeUsers.remove(ownerId);
+ LOGGER.debug("User {} is unregistered.", ownerId);
+ }
+
+ public void stopPolling() {
+ LOGGER.debug("Stop notification polling.");
+ stopRunning = true;
+ }
+
+ public class Poller extends Thread {
+
+ @Override
+ public void run() {
+ try {
+ while (!stopRunning) {
+ pollNotifications();
+ Thread.sleep(pollingSleepInterval);
+ }
+ } catch (InterruptedException e) {
+ LOGGER.error("Interrupted Exception during Notification poller launch.", e);
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ private void pollNotifications() {
+ Map<String, NotificationReceiver> currUsers = new HashMap<>();
+ currUsers.putAll(getActiveUsers());
+ for (NotificationReceiver receiver : currUsers.values()) {
+ String ownerId = receiver.getOwnerId();
+ UUID eventId = receiver.getLastEventId();
+ NotificationsStatusDto status = news.getNewNotifications(ownerId, eventId, selectionLimit);
+ if (Objects.nonNull(status) && CollectionUtils.isNotEmpty(status.getNotifications())) {
+ receiver.setLastEventId(status.getLastScanned());
+ receiver.getNotesProcessor().accept(status);
+ }
+ }
+ }
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/impl/NewNotificationsReaderRestImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/impl/NewNotificationsReaderRestImpl.java
index 86a3030bd3..7f2390b38a 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/impl/NewNotificationsReaderRestImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/impl/NewNotificationsReaderRestImpl.java
@@ -17,25 +17,23 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.notification.workers.impl;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.InputStreamReader;
+import java.util.UUID;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
-import com.fasterxml.jackson.databind.ObjectMapper;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.notification.config.ConfigurationManager;
import org.openecomp.sdc.notification.types.NotificationsStatusDto;
import org.openecomp.sdc.notification.workers.NewNotificationsReader;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import java.io.InputStreamReader;
-import java.util.UUID;
-
public class NewNotificationsReaderRestImpl implements NewNotificationsReader {
private static final String USER_ID_HEADER_PARAM = "USER_ID";
@@ -47,12 +45,10 @@ public class NewNotificationsReaderRestImpl implements NewNotificationsReader {
private static final int DEFAULT_BE_PORT = 8080;
private static final String URL = "http://%s:%d/onboarding-api/v1.0/notifications/worker?";
private static final ObjectMapper mapper = new ObjectMapper();
-
+ private static final Logger LOGGER = LoggerFactory.getLogger(NewNotificationsReaderRestImpl.class);
private static String beHost;
private static int bePort;
- private static final Logger LOGGER = LoggerFactory.getLogger(NewNotificationsReaderRestImpl.class);
-
public NewNotificationsReaderRestImpl() {
ConfigurationManager cm = ConfigurationManager.getInstance();
bePort = cm.getConfigValue(BE_PORT, DEFAULT_BE_PORT);
@@ -62,17 +58,14 @@ public class NewNotificationsReaderRestImpl implements NewNotificationsReader {
public NotificationsStatusDto getNewNotifications(String ownerId, UUID eventId, int limit) {
HttpClient client = HttpClientBuilder.create().build();
String url = String.format(URL, beHost, bePort);
-
url = url + LIMIT_QUERY_PARAM + "=" + limit;
if (eventId != null) {
url = url + "&" + LAST_DELIVERED_QUERY_PARAM + "=" + eventId;
}
-
HttpGet request = new HttpGet(url);
request.addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
request.addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
request.addHeader(USER_ID_HEADER_PARAM, ownerId);
-
try {
HttpResponse response = client.execute(request);
return mapper.readValue(new InputStreamReader(response.getEntity().getContent()), NotificationsStatusDto.class);