org.deepamehta.plugins.subscriptions
Class SubscriptionsPlugin

Show UML class diagram
java.lang.Object
  extended by de.deepamehta.core.osgi.PluginActivator
      extended by org.deepamehta.plugins.subscriptions.SubscriptionsPlugin
All Implemented Interfaces:
PluginContext, EventListener, PluginService, de.deepamehta.plugins.websockets.event.WebsocketTextMessageListener, SubscriptionService, org.osgi.framework.BundleActivator

public class SubscriptionsPlugin
extends PluginActivator
implements SubscriptionService, de.deepamehta.plugins.websockets.event.WebsocketTextMessageListener

A DeepaMehta 4 Plugin introducing notifications on subscribed topics based on dm4-websockets.

Version:
1.0.1-SNAPSHOT
Author:
Malte Reißig ()

Field Summary
private  AccessControlService aclService
           
private static String DEEPAMEHTA_TAG_TYPE
           
private static String DEFAULT_ROLE_TYPE
           
private static Logger log
           
private static String NOTIFICATION_BODY_TYPE
           
private static String NOTIFICATION_INVOLVED_ITEM_ID_TYPE
           
private static String NOTIFICATION_RECIPIENT_EDGE_TYPE
           
private static String NOTIFICATION_SEEN_TYPE
           
private static String NOTIFICATION_SUB_ITEM_ID_TYPE
           
private static String NOTIFICATION_TITLE_TYPE
           
private static String NOTIFICATION_TYPE
           
private static String SUBSCRIPTION_EDGE_TYPE
           
private static String USER_ACCOUNT_TYPE
           
private  de.deepamehta.plugins.websockets.service.WebSocketsService webSocketsService
           
 
Fields inherited from class de.deepamehta.core.osgi.PluginActivator
bundle, dms
 
Constructor Summary
SubscriptionsPlugin()
           
 
Method Summary
private  boolean associationExists(String edge_type, long itemId, long accountId)
           
 void createNotifications(String title, String message, long actionAccountId, DeepaMehtaObject item)
          Creates new notifications for all users with a direct or indirect (tags) subscription to the given item.
private  void createNotificationTopics(String title, String text, long accountId, DeepaMehtaObject involvedItem)
           
private  void createNotificationTopics(String title, String text, long accountId, DeepaMehtaObject involvedItem, DeepaMehtaObject subscribedItem)
           
 ResultList<RelatedTopic> getAllNotifications()
          Gets all notifications for the logged-in user.
 ResultList<RelatedTopic> getAllNotificationsForUser()
           
 ArrayList<RelatedTopic> getAllUnseenNotifications()
          Gets all unread notifications for the logged-in user.
 ArrayList<RelatedTopic> getAllUnseenNotificationsForUser()
           
 ResultList<RelatedTopic> getSubscriptions()
          Gets all subscribed topics for the logged-in user.
 void serviceArrived(PluginService service)
           
 void serviceGone(PluginService service)
           
 boolean setNotificationSeen(long newsId)
           
 void subscribe(long accountId, long itemId, ClientState clientState)
          Create a subscription edge for useraccount to item.
 javax.ws.rs.core.Response subscribeUser(long itemId, ClientState clientState)
           
 void unsubscribe(long accountId, long itemId)
          Remove subscription (edge) for given user account and item.
 javax.ws.rs.core.Response unsubscribeUser(long itemId)
           
 void websocketTextMessage(String message)
           
 
Methods inherited from class de.deepamehta.core.osgi.PluginActivator
getBundleContext, getUri, init, postInstall, publishDirectory, setCoreService, shutdown, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static Logger log

NOTIFICATION_TYPE

private static final String NOTIFICATION_TYPE
See Also:
Constant Field Values

NOTIFICATION_TITLE_TYPE

private static final String NOTIFICATION_TITLE_TYPE
See Also:
Constant Field Values

NOTIFICATION_BODY_TYPE

private static final String NOTIFICATION_BODY_TYPE
See Also:
Constant Field Values

NOTIFICATION_INVOLVED_ITEM_ID_TYPE

private static final String NOTIFICATION_INVOLVED_ITEM_ID_TYPE
See Also:
Constant Field Values

NOTIFICATION_SUB_ITEM_ID_TYPE

private static final String NOTIFICATION_SUB_ITEM_ID_TYPE
See Also:
Constant Field Values

NOTIFICATION_RECIPIENT_EDGE_TYPE

private static final String NOTIFICATION_RECIPIENT_EDGE_TYPE
See Also:
Constant Field Values

SUBSCRIPTION_EDGE_TYPE

private static final String SUBSCRIPTION_EDGE_TYPE
See Also:
Constant Field Values

NOTIFICATION_SEEN_TYPE

private static final String NOTIFICATION_SEEN_TYPE
See Also:
Constant Field Values

USER_ACCOUNT_TYPE

private static final String USER_ACCOUNT_TYPE
See Also:
Constant Field Values

DEEPAMEHTA_TAG_TYPE

private static final String DEEPAMEHTA_TAG_TYPE
See Also:
Constant Field Values

DEFAULT_ROLE_TYPE

private static final String DEFAULT_ROLE_TYPE
See Also:
Constant Field Values

aclService

private AccessControlService aclService

webSocketsService

private de.deepamehta.plugins.websockets.service.WebSocketsService webSocketsService
Constructor Detail

SubscriptionsPlugin

public SubscriptionsPlugin()
Method Detail

serviceArrived

public void serviceArrived(PluginService service)
Specified by:
serviceArrived in interface PluginContext
Overrides:
serviceArrived in class PluginActivator

serviceGone

public void serviceGone(PluginService service)
Specified by:
serviceGone in interface PluginContext
Overrides:
serviceGone in class PluginActivator

subscribeUser

public javax.ws.rs.core.Response subscribeUser(long itemId,
                                               @HeaderParam(value="Cookie")
                                               ClientState clientState)

unsubscribeUser

public javax.ws.rs.core.Response unsubscribeUser(long itemId)

getSubscriptions

public ResultList<RelatedTopic> getSubscriptions()
Description copied from interface: SubscriptionService
Gets all subscribed topics for the logged-in user.

Specified by:
getSubscriptions in interface SubscriptionService

setNotificationSeen

public boolean setNotificationSeen(long newsId)

getAllNotificationsForUser

public ResultList<RelatedTopic> getAllNotificationsForUser()

getAllUnseenNotificationsForUser

public ArrayList<RelatedTopic> getAllUnseenNotificationsForUser()

subscribe

public void subscribe(long accountId,
                      long itemId,
                      ClientState clientState)
Description copied from interface: SubscriptionService
Create a subscription edge for useraccount to item.

Specified by:
subscribe in interface SubscriptionService
Parameters:
accountId - topic-id of user account
itemId - topic-id of user account

unsubscribe

public void unsubscribe(long accountId,
                        long itemId)
Description copied from interface: SubscriptionService
Remove subscription (edge) for given user account and item.

Specified by:
unsubscribe in interface SubscriptionService

createNotifications

public void createNotifications(String title,
                                String message,
                                long actionAccountId,
                                DeepaMehtaObject item)
Description copied from interface: SubscriptionService
Creates new notifications for all users with a direct or indirect (tags) subscription to the given item. Notifications are created if the (given) item is either of TopicType "User Account" or of any other TopicType which has the TopicType=Tag as a child-type. In the latter case, all subscribers of the _Tag_ are notified.

Specified by:
createNotifications in interface SubscriptionService
Parameters:
title - title of the notification
message - text part of the notification
actionAccountId - topic-id of user account performing the action which leads to the notification of all others
item - item users can have subscribed (either "User Account" or any TopicType with "Tags" as child)

getAllNotifications

public ResultList<RelatedTopic> getAllNotifications()
Description copied from interface: SubscriptionService
Gets all notifications for the logged-in user.

Specified by:
getAllNotifications in interface SubscriptionService

getAllUnseenNotifications

public ArrayList<RelatedTopic> getAllUnseenNotifications()
Description copied from interface: SubscriptionService
Gets all unread notifications for the logged-in user.

Specified by:
getAllUnseenNotifications in interface SubscriptionService

websocketTextMessage

public void websocketTextMessage(String message)
Specified by:
websocketTextMessage in interface de.deepamehta.plugins.websockets.event.WebsocketTextMessageListener

createNotificationTopics

private void createNotificationTopics(String title,
                                      String text,
                                      long accountId,
                                      DeepaMehtaObject involvedItem)

createNotificationTopics

private void createNotificationTopics(String title,
                                      String text,
                                      long accountId,
                                      DeepaMehtaObject involvedItem,
                                      DeepaMehtaObject subscribedItem)

associationExists

private boolean associationExists(String edge_type,
                                  long itemId,
                                  long accountId)


Copyright © 2014. All Rights Reserved.