diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java')
21 files changed, 813 insertions, 0 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 new file mode 100644 index 0000000000..0c6dfc8580 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/destinationprovider/DestinationProvider.java @@ -0,0 +1,11 @@ +package org.openecomp.sdc.destinationprovider; + +import java.util.List; + +/** + * @author avrahamg + * @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 new file mode 100644 index 0000000000..f0bf7e8874 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/LastNotificationDao.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.notification.dao; + +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); + +} 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 new file mode 100644 index 0000000000..6542d70158 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/NotificationsDao.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.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; + + +public interface NotificationsDao extends BaseDao<NotificationEntity> { + + int DEFAULT_LIMIT_OF_RESULTS_FOR_OWNER_NOTIFICATIONS = 1000; + + List<NotificationEntity> getNotificationsByOwnerId(String ownerId, int limit); + + List<NotificationEntity> getNewNotificationsByOwnerId(String ownerId, UUID eventId); + + List<NotificationEntity> getNewNotificationsByOwnerId(String ownerId, UUID eventId, int limit); + + NotificationsStatus getNotificationsStatus(String ownerId, UUID lastSeenNotification, int numOfRecordsToReturn); + + NotificationsStatus getNotificationsStatus(String ownerId, UUID lastSeenNotification, int numOfRecordsToReturn, UUID prevLastNotification); + + 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 new file mode 100644 index 0000000000..3daf165efc --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/SubscribersDao.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.notification.dao; + +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); + + 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 new file mode 100644 index 0000000000..d6e717d1b3 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/LastSeenNotificationEntity.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.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.Objects; +import java.util.UUID; + +@Table(keyspace = "dox", name = "last_notification") +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; + + public LastSeenNotificationEntity() { + } + + /** + * Instantiates a new Notification entity. + * + * @param ownerId the owner id + * @param lastEventId the last event id + */ + public LastSeenNotificationEntity(String ownerId, UUID lastEventId) { + this.ownerId = ownerId; + this.lastEventId = lastEventId; + } + + public String getOwnerId() { + return ownerId; + } + + public void setOwnerId(String ownerId) { + this.ownerId = ownerId; + } + + public UUID getLastEventId() { + return lastEventId; + } + + public void setLastEventId(UUID lastEventId) { + this.lastEventId = lastEventId; + } + + @Override + public boolean equals(Object other) { + if (Objects.equals(this, other)) { + return true; + } + + if (Objects.equals(getClass(), other.getClass())) { + return false; + } + + LastSeenNotificationEntity that = (LastSeenNotificationEntity) other; + + if (Objects.equals(ownerId, that.ownerId)) { + return false; + } + + return !Objects.equals(lastEventId, that.lastEventId); + } + + @Override + public int hashCode() { + int result = ownerId != null ? ownerId.hashCode() : 0; + result = 31 * result + (lastEventId != null ? lastEventId.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "LastSeenNotificationEntity {" + + "ownerId='" + ownerId + '\'' + + '}'; + } +} 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 new file mode 100644 index 0000000000..52377077cf --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/NotificationEntity.java @@ -0,0 +1,188 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.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.Objects; +import java.util.UUID; + +@Table(keyspace = "dox", name = "notifications") +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; + + public NotificationEntity() { + } + + public NotificationEntity(String ownerId) { + this.ownerId = ownerId; + } + + /** + * Instantiates a new Notification entity. + * + * @param ownerId the owner id + * @param eventId the event id + * @param eventType the event type + * @param originatorId the originator id + */ + public NotificationEntity(String ownerId, UUID eventId, String eventType, String originatorId, boolean read, String eventAttributes) { + this.ownerId = ownerId; + this.read = read; + this.eventId = eventId; + this.eventType = eventType; + this.originatorId = originatorId; + this.eventAttributes = eventAttributes; + } + + public NotificationEntity(String ownerId, UUID eventId, String eventType, String originatorId) { + this(ownerId, eventId, eventType, originatorId, false, null); + } + + public NotificationEntity(String ownerId, UUID eventId) { + this(ownerId, eventId, null, null); + } + + public String getOwnerId() { + return ownerId; + } + + public void setOwnerId(String ownerId) { + this.ownerId = ownerId; + } + + public boolean isRead() { + return read; + } + + public void setRead(boolean read) { + this.read = read; + } + + public UUID getEventId() { + return eventId; + } + + public void setEventId(UUID eventId) { + this.eventId = eventId; + } + + public String getEventType() { + return eventType; + } + + public void setEventType(String eventType) { + this.eventType = eventType; + } + + public String getEventAttributes() { + return eventAttributes; + } + + public void setEventAttributes(String eventAttributes) { + this.eventAttributes = eventAttributes; + } + + public String getOriginatorId() { + return originatorId; + } + + public void setOriginatorId(String originatorId) { + this.originatorId = originatorId; + } + + @Override + public boolean equals(Object other) { + if (Objects.equals(this, other)) { + return true; + } + + if (Objects.equals(getClass(), other.getClass())) { + return false; + } + + NotificationEntity that = (NotificationEntity) other; + + if (Objects.equals(ownerId, that.ownerId)) { + return false; + } + if (read != that.read) { + return false; + } + if (Objects.equals(eventId, that.eventId)) { + return false; + } + if (Objects.equals(eventType, that.eventType)) { + return false; + } + if (Objects.equals(eventAttributes, that.eventAttributes)) { + return false; + } + if (Objects.equals(originatorId, that.originatorId)) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + int result = ownerId != null ? ownerId.hashCode() : 0; + result = 31 * result + (eventId != null ? eventId.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "NotificationEntity {" + + "ownerId='" + ownerId + '\'' + + ", state='" + (read ? "Read" : "Noread") + '\'' + + ", originatorId='" + originatorId + '\'' + + ", eventId='" + eventId + '\'' + + ", eventType='" + eventType + '\'' + + ", eventAttributes='" + eventAttributes + '\'' + + '}'; + } +} 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 new file mode 100644 index 0000000000..d858cbd9eb --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/SubscribersEntity.java @@ -0,0 +1,68 @@ +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.Objects; +import java.util.Set; + +import static java.util.Objects.hash; + +@Table(keyspace = "dox", name = "notification_subscribers") +public class SubscribersEntity { + + @PartitionKey + @Column(name = "entity_id") + private String entityId; + + @Column(name = "subscribers") + private Set<String> subscribers; + + + public SubscribersEntity() { + } + + public SubscribersEntity(String entityId, Set<String> subscribers) { + this.entityId = entityId; + this.subscribers = subscribers; + } + + public String getEntityId() { + return entityId; + } + + public void setEntityId(String entityId) { + this.entityId = entityId; + } + + public Set<String> getSubscribers() { + return subscribers; + } + + public void setSubscribers(Set<String> subscribers) { + this.subscribers = subscribers; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SubscribersEntity that = (SubscribersEntity) o; + return Objects.equals(entityId, that.entityId) && + Objects.equals(subscribers, that.subscribers); + } + + @Override + public int hashCode() { + return hash(entityId, subscribers); + } + + @Override + public String toString() { + return "SubscribersEntity{" + + "entityId='" + entityId + '\'' + + ", subscribers=" + subscribers + + '}'; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dtos/Event.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dtos/Event.java new file mode 100644 index 0000000000..f7a181e5e6 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dtos/Event.java @@ -0,0 +1,14 @@ +package org.openecomp.sdc.notification.dtos; + +import java.util.Map; + +public interface Event { + + String getEventType(); + + String getOriginatorId(); + + Map<String, Object> getAttributes(); + + String getEntityId(); +} 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 new file mode 100644 index 0000000000..1620569ec5 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dtos/NotificationsStatus.java @@ -0,0 +1,24 @@ +package org.openecomp.sdc.notification.dtos; + +import org.openecomp.sdc.notification.dao.types.NotificationEntity; + +import java.util.List; +import java.util.UUID; + +/** + * @author Avrahamg + * @since June 26, 2017 + */ +public interface NotificationsStatus { + + List<NotificationEntity> getNotifications(); + + List<UUID> getNewEntries(); + + UUID getLastScanned(); + + 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 new file mode 100644 index 0000000000..90e53ea69a --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/exceptons/NotificationNotExistException.java @@ -0,0 +1,18 @@ +package org.openecomp.sdc.notification.exceptons; + +/** + * @author avrahamg + * @since July 02, 2017 + */ +public class NotificationNotExistException extends Exception { + private 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 new file mode 100644 index 0000000000..6e6f9f063a --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/LastNotificationDaoFactory.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.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); + } + +} 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 new file mode 100644 index 0000000000..356055e26c --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationPropagationManagerFactory.java @@ -0,0 +1,15 @@ +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.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 new file mode 100644 index 0000000000..341af7e296 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationsDaoFactory.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.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); + } + +} 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 new file mode 100644 index 0000000000..eab26188c1 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationsServiceFactory.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.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); + } + +} 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 new file mode 100644 index 0000000000..e82783c40c --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/PropagationServiceFactory.java @@ -0,0 +1,15 @@ +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.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 new file mode 100644 index 0000000000..33b62e2f5d --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/SubscribersDaoFactory.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.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 new file mode 100644 index 0000000000..3e789c22a7 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/SubscriptionServiceFactory.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.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 new file mode 100644 index 0000000000..7a1596eb95 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/NotificationPropagationManager.java @@ -0,0 +1,12 @@ +package org.openecomp.sdc.notification.services; + +import org.openecomp.sdc.notification.dtos.Event; + +/** + * @author avrahamg + * @since July 09, 2017 + */ +public interface NotificationPropagationManager { + 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 new file mode 100644 index 0000000000..17cfac1e5d --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/NotificationsService.java @@ -0,0 +1,31 @@ +package org.openecomp.sdc.notification.services; + +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); + + NotificationsStatus getNotificationsStatus(String ownerId, UUID lastDelivered, int numOfRecordsToReturn, UUID endOfPage); + + void updateLastSeenNotification(String ownerId, UUID eventId); + + 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/PropagationService.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/PropagationService.java new file mode 100644 index 0000000000..c084aa8015 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/PropagationService.java @@ -0,0 +1,9 @@ +package org.openecomp.sdc.notification.services; + +import org.openecomp.sdc.destinationprovider.DestinationProvider; +import org.openecomp.sdc.notification.dtos.Event; + +public interface PropagationService { + + void notify(Event event, DestinationProvider destinationProvider); +} 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 new file mode 100644 index 0000000000..98cd458ca2 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/SubscriptionService.java @@ -0,0 +1,15 @@ +package org.openecomp.sdc.notification.services; + +import java.util.Set; + +/** + * @author avrahamg + * @since July 09, 2017 + */ +public interface SubscriptionService { + void subscribe(String ownerId, String entityId); + + void unsubscribe(String ownerId, String entityId); + + Set<String> getSubscribers(String entityId); +} |