Class PushNotificationHandler
java.lang.Object
org.apache.camel.builder.BuilderSupport
org.apache.camel.builder.RouteBuilder
org.openremote.manager.notification.PushNotificationHandler
- All Implemented Interfaces:
org.apache.camel.builder.ModelRoutesBuilder,org.apache.camel.CamelContextAware,org.apache.camel.Ordered,org.apache.camel.RoutesBuilder,org.apache.camel.spi.HasCamelContext,org.apache.camel.spi.ResourceAware,NotificationHandler,org.openremote.model.ContainerService
public class PushNotificationHandler
extends org.apache.camel.builder.RouteBuilder
implements NotificationHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AssetStorageServicestatic final intstatic final Stringprotected GatewayServiceprotected ManagerIdentityServicestatic final Stringstatic final intprotected booleanFields inherited from class org.apache.camel.builder.RouteBuilder
logFields inherited from interface org.openremote.model.ContainerService
DEFAULT_PRIORITY, HIGH_PRIORITY, LOW_PRIORITY, MED_PRIORITYFields inherited from interface org.apache.camel.Ordered
HIGHEST, LOWEST -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static com.google.firebase.messaging.MessagebuildFCMMessage(long id, org.openremote.model.notification.PushNotificationMessage pushMessage) voidgetFcmToken(org.openremote.model.asset.impl.ConsoleAsset asset) intList<org.openremote.model.notification.Notification.Target> getTargets(org.openremote.model.notification.Notification.Source source, String sourceId, List<org.openremote.model.notification.Notification.Target> targets, org.openremote.model.notification.AbstractNotificationMessage message) Map the requested targets to one or more targets that are compatible with this handler; if there are no compatible targets then return null.The unique type name; it must correspond with the value set inAbstractNotificationMessage.getType()so thatAbstractNotificationMessages can be mapped to aNotificationHandler.voidinit(org.openremote.model.Container container) protected booleanisConsoleSubscribedToTopic(org.openremote.model.asset.impl.ConsoleAsset consoleAsset, String topic) protected static booleanisLinkedToFcmProvider(org.openremote.model.asset.impl.ConsoleAsset asset) booleanisMessageValid(org.openremote.model.notification.AbstractNotificationMessage message) Allows the handler to validate the specifiedAbstractNotificationMessage.booleanisValid()Indicates if this handler has a valid configuration and is usable.protected voidprocessConsoleAssetChange(org.openremote.model.asset.impl.ConsoleAsset asset, org.openremote.model.PersistenceEvent<org.openremote.model.asset.impl.ConsoleAsset> persistenceEvent) voidsendMessage(long id, org.openremote.model.notification.Notification.Source source, String sourceId, org.openremote.model.notification.Notification.Target target, org.openremote.model.notification.AbstractNotificationMessage message) Send the specifiedAbstractNotificationMessageto the target; the target supplied would be a target previously returned byNotificationHandler.getTargets(org.openremote.model.notification.Notification.Source, java.lang.String, java.util.List<org.openremote.model.notification.Notification.Target>, org.openremote.model.notification.AbstractNotificationMessage).voidsendMessage(com.google.firebase.messaging.Message message) voidstart(org.openremote.model.Container container) voidstop(org.openremote.model.Container container) Methods inherited from class org.apache.camel.builder.RouteBuilder
addLifecycleInterceptor, addRoutes, addRoutesToCamelContext, addTemplatedRoutesToCamelContext, bindToRegistry, bindToRegistry, checkInitialized, configuration, configureRest, configureRests, configureRoute, configureRouteConfiguration, configureRoutes, configureRouteTemplate, configureTemplatedRoute, customize, customize, dataFormat, errorHandler, errorHandler, expression, from, from, from, fromF, fromV, fromV, getBeans, getOrder, getResource, getRestCollection, getRestConfiguration, getRests, getRouteCollection, getRoutes, getRouteTemplateCollection, getTemplatedRouteCollection, initializeCamelContext, intercept, interceptFrom, interceptFrom, interceptSendToEndpoint, loadRoutesBuilder, loadRoutesBuilder, onCompletion, onException, onException, populateBeans, populateOrUpdateRoutes, populateRests, populateRoutes, populateRouteTemplates, populateTemplatedRoutes, populateTransformers, populateValidators, prepareModel, property, propertyInject, removeLifecycleInterceptor, rest, rest, restConfiguration, routeTemplate, setErrorHandlerFactory, setResource, setRestCollection, setRouteTemplateCollection, setTemplatedRouteCollection, templatedRoute, tokenizer, toString, transformer, updateRoutesToCamelContext, validatorMethods inherited from class org.apache.camel.builder.BuilderSupport
body, bodyAs, constant, constant, constant, createErrorHandlerBuilder, csimple, csimple, datasonnet, datasonnet, datasonnet, deadLetterChannel, deadLetterChannel, defaultErrorHandler, endpoint, endpoint, exceptionMessage, exchangeProperty, expression, getCamelContext, getContext, getErrorHandlerFactory, hasErrorHandlerFactory, header, java, java, joor, joor, jq, jq, jsonpath, jsonpath, jtaTransactionErrorHandler, jtaTransactionErrorHandler, jtaTransactionErrorHandler, method, method, method, method, noErrorHandler, regexReplaceAll, regexReplaceAll, setCamelContext, simple, simple, simpleF, simpleF, springTransactionErrorHandler, springTransactionErrorHandler, springTransactionErrorHandler, systemProperty, systemProperty, variable, xpath, xpath, xpath, xpath
-
Field Details
-
OR_FIREBASE_CONFIG_FILE
- See Also:
-
CONNECT_TIMEOUT_MILLIS
public static final int CONNECT_TIMEOUT_MILLIS- See Also:
-
READ_TIMEOUT_MILLIS
public static final int READ_TIMEOUT_MILLIS- See Also:
-
FCM_PROVIDER_NAME
- See Also:
-
managerIdentityService
-
assetStorageService
-
gatewayService
-
valid
protected boolean valid -
consoleFCMTokenMap
-
fcmTokenBlacklist
-
-
Constructor Details
-
PushNotificationHandler
public PushNotificationHandler()
-
-
Method Details
-
getPriority
public int getPriority()- Specified by:
getPriorityin interfaceorg.openremote.model.ContainerService
-
init
- Specified by:
initin interfaceorg.openremote.model.ContainerService- Throws:
Exception
-
start
- Specified by:
startin interfaceorg.openremote.model.ContainerService- Throws:
Exception
-
stop
- Specified by:
stopin interfaceorg.openremote.model.ContainerService- Throws:
Exception
-
configure
- Specified by:
configurein classorg.apache.camel.builder.RouteBuilder- Throws:
Exception
-
getTypeName
Description copied from interface:NotificationHandlerThe unique type name; it must correspond with the value set inAbstractNotificationMessage.getType()so thatAbstractNotificationMessages can be mapped to aNotificationHandler.- Specified by:
getTypeNamein interfaceNotificationHandler
-
isMessageValid
public boolean isMessageValid(org.openremote.model.notification.AbstractNotificationMessage message) Description copied from interface:NotificationHandlerAllows the handler to validate the specifiedAbstractNotificationMessage.- Specified by:
isMessageValidin interfaceNotificationHandler
-
getTargets
public List<org.openremote.model.notification.Notification.Target> getTargets(org.openremote.model.notification.Notification.Source source, String sourceId, List<org.openremote.model.notification.Notification.Target> targets, org.openremote.model.notification.AbstractNotificationMessage message) Description copied from interface:NotificationHandlerMap the requested targets to one or more targets that are compatible with this handler; if there are no compatible targets then return null. If the requested target is already compatible then it can just be returned; handlers are free to determine how the requested target should be mapped (e.g. if requestedNotification.TargetTypewasNotification.TargetType.REALMand this handler only supports targets of typeNotification.TargetType.ASSETwhere theAssets must beConsoleAssetthen the handler needs to find all console assets that belong to the specified realm). Handlers can also add extraNotification.TargetType.CUSTOMhandlers extracted from the message.- Specified by:
getTargetsin interfaceNotificationHandler
-
sendMessage
public void sendMessage(long id, org.openremote.model.notification.Notification.Source source, String sourceId, org.openremote.model.notification.Notification.Target target, org.openremote.model.notification.AbstractNotificationMessage message) throws Exception Description copied from interface:NotificationHandlerSend the specifiedAbstractNotificationMessageto the target; the target supplied would be a target previously returned byNotificationHandler.getTargets(org.openremote.model.notification.Notification.Source, java.lang.String, java.util.List<org.openremote.model.notification.Notification.Target>, org.openremote.model.notification.AbstractNotificationMessage). It is the responsibility of theNotificationHandlerto maintain any required cache to ensure this call is as performant as possible (i.e. the handler should avoid making excessive DB calls if possible).The ID can be used by the
NotificationHandlerto update the delivered and/or acknowledged status of the notification by callingNotificationService.setNotificationDelivered(long)orNotificationService.setNotificationAcknowledged(long, java.lang.String)- Specified by:
sendMessagein interfaceNotificationHandler- Throws:
Exception
-
isValid
public boolean isValid()Description copied from interface:NotificationHandlerIndicates if this handler has a valid configuration and is usable.- Specified by:
isValidin interfaceNotificationHandler
-
sendMessage
- Throws:
Exception
-
isConsoleSubscribedToTopic
protected boolean isConsoleSubscribedToTopic(org.openremote.model.asset.impl.ConsoleAsset consoleAsset, String topic) -
buildFCMMessage
protected static com.google.firebase.messaging.Message buildFCMMessage(long id, org.openremote.model.notification.PushNotificationMessage pushMessage) -
isLinkedToFcmProvider
protected static boolean isLinkedToFcmProvider(org.openremote.model.asset.impl.ConsoleAsset asset) -
getFcmToken
-
processConsoleAssetChange
protected void processConsoleAssetChange(org.openremote.model.asset.impl.ConsoleAsset asset, org.openremote.model.PersistenceEvent<org.openremote.model.asset.impl.ConsoleAsset> persistenceEvent)
-