Class WatchdogContext

All Implemented Interfaces:
WatchDogEventInterface

public class WatchdogContext extends ConnectorContextBase implements WatchDogEventInterface
WatchdogContext provides a watchdog action service with access to information about the survey request along with access to the open metadata repository interfaces.
  • Constructor Details

    • WatchdogContext

      public WatchdogContext(String localServerName, String localServiceName, String externalSourceGUID, String externalSourceName, String connectorId, String connectorName, String connectorUserId, String connectorGUID, boolean generateIntegrationReport, OpenMetadataClient openMetadataClient, OpenGovernanceClient openGovernanceClient, GovernanceCompletionInterface governanceCompletionClient, WatchDogEventInterface watchdogEventClient, AuditLog auditLog, int maxPageSize, DeleteMethod deleteMethod, String engineActionGUID, String notificationTypeGUID, String requestType, Map<String,String> requestParameters, List<ActionTargetElement> actionTargetElements, String watchdogActionServiceName, String requesterUserId)
      Constructor sets up the key parameters for using the context.
      Parameters:
      localServerName - name of local server
      localServiceName - name of the service to call
      externalSourceGUID - metadata collection unique id
      externalSourceName - metadata collection unique name
      connectorId - id of this connector instance
      connectorName - name of this connector instance
      connectorUserId - userId to use when issuing open metadata requests
      connectorGUID - unique identifier of the connector element that describes this connector in the open metadata store(s)
      generateIntegrationReport - should the context generate an integration report?
      openMetadataClient - client to access open metadata store
      openGovernanceClient - client to the open governance services for use by the governance action service
      governanceCompletionClient - client to the open governance services for use by the governance action service
      watchdogEventClient - client to the open governance services for use by the governance action service
      auditLog - logging destination
      maxPageSize - max number of results
      deleteMethod - default delete method
      engineActionGUID - unique identifier of the engine action that triggered this governance service
      notificationTypeGUID - unique identifier of the notification type to process
      requestType - request type used to initiate the watchdog action service
      requestParameters - name-value properties to control the watchdog action service
      actionTargetElements - metadata elements that need to be worked on by the governance action service
      watchdogActionServiceName - name of the running service
      requesterUserId - original user requesting this governance service
  • Method Details

    • getNotificationTypeGUID

      public String getNotificationTypeGUID() throws UserNotAuthorizedException
      Return the unique identifier of the asset being discovered.
      Returns:
      string guid
      Throws:
      UserNotAuthorizedException - exception thrown if connector is no longer active
    • getNotificationType

      Return details of notification type to monitor along with its linked resources and subscribers, the actions it has caused and any additional context.
      Returns:
      string guid
      Throws:
      InvalidParameterException - an invalid property has been passed
      UserNotAuthorizedException - the user is not authorized or the connector is not active
      PropertyServerException - there is a problem communicating with the metadata server (or it has a logic error).
    • registerListener

      public void registerListener(WatchdogGovernanceListener listener, List<OpenMetadataEventType> interestingEventTypes, List<String> interestingMetadataTypes, String specificInstance) throws InvalidParameterException
      Register a listener to receive events about changes to metadata elements in the open metadata store. There can be only one registered listener. If this method is called more than once, the new parameters replace the existing parameters. This means the watchdog governance action service can change the listener and the parameters that control the types of events received while it is running.

      The types of events passed to the listener are controlled by the combination of the interesting event types and the interesting metadata types. That is an event is only passed to the listener if it matches both the interesting event types and the interesting metadata types.

      If specific instance, interestingEventTypes or interestingMetadataTypes are null, it defaults to "any". If the listener parameter is null, no more events are passed to the listener. The type name specified in the interestingMetadataTypes refers to the subject of the event - so it is the type of the metadata element for metadata element types, the type of the relationship for related elements events and the name of the classification for classification events.
      Specified by:
      registerListener in interface WatchDogEventInterface
      Parameters:
      listener - listener object to receive events
      interestingEventTypes - types of events that should be passed to the listener
      interestingMetadataTypes - types of elements that are the subject of the interesting event types
      specificInstance - unique identifier of a specific instance (metadata element or relationship) to watch for
      Throws:
      InvalidParameterException - one or more of the type names are unrecognized
    • disconnectListener

      public void disconnectListener()
      Unregister the listener permanently from the event infrastructure.
      Specified by:
      disconnectListener in interface WatchDogEventInterface
    • getNotificationProperties

      public NotificationProperties getNotificationProperties(MessageDefinition notificationDescription)
      Convert the message definitions into properties for a notification. This includes setting the qualified name and status.
      Parameters:
      notificationDescription - description of the notification
      Returns:
      notification properties
    • getMonitoredResources

      Return the unique identifier of the asset being discovered.
      Returns:
      string guid
      Throws:
      InvalidParameterException - an invalid property has been passed
      UserNotAuthorizedException - the user is not authorized or the connector is not active
      PropertyServerException - there is a problem communicating with the metadata server (or it has a logic error).
    • getNotificationSubscribers

      Return the unique identifier of the asset being discovered.
      Returns:
      string guid
      Throws:
      InvalidParameterException - an invalid property has been passed
      UserNotAuthorizedException - the user is not authorized or the connector is not active
      PropertyServerException - there is a problem communicating with the metadata server (or it has a logic error).
    • notifySubscriber

      public void notifySubscriber(String subscriberGUID, NotificationProperties notificationProperties, Map<String,String> requestParameters, List<NewActionTarget> newActionTargets) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException
      Create a notification/action for one of the subscribers.
      Parameters:
      subscriberGUID - unique identifier of the subscriber
      notificationProperties - properties for the notification
      requestParameters - properties to pass to the next governance service
      newActionTargets - map of action target names to GUIDs for the resulting governance action service
      Throws:
      InvalidParameterException - the completion status is null
      UserNotAuthorizedException - the governance action service is not authorized to update the governance action service status
      PropertyServerException - there is a problem connecting to the metadata store
    • notifySubscribers

      public void notifySubscribers(NotificationProperties notificationProperties, Map<String,String> requestParameters, List<NewActionTarget> newActionTargets) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException
      Create a notification/action for each of the subscribers.
      Parameters:
      notificationProperties - properties for the notification
      requestParameters - properties to pass to the next governance service
      newActionTargets - map of action target names to GUIDs for the resulting governance action service
      Throws:
      InvalidParameterException - the completion status is null
      UserNotAuthorizedException - the governance action service is not authorized to update the governance action service status
      PropertyServerException - there is a problem connecting to the metadata store
    • getRequestType

      public String getRequestType() throws UserNotAuthorizedException
      Return the request type that was used to start this watchdog action service.
      Returns:
      AdditionalProperties object storing the analysis parameters
      Throws:
      UserNotAuthorizedException - exception thrown if connector is no longer active
    • getRequestParameters

      public Map<String,String> getRequestParameters() throws UserNotAuthorizedException
      Return the properties that hold the parameters used to drive this watchdog action service.
      Returns:
      AdditionalProperties object storing the analysis parameters
      Throws:
      UserNotAuthorizedException - exception thrown if connector is no longer active
    • getActionTargetElements

      public List<ActionTargetElement> getActionTargetElements()
      Return the list of elements that this governance action service should work on.
      Returns:
      cached list of action target metadata elements
    • getRequesterUserId

      public String getRequesterUserId()
      Return the requester user identifier.
      Returns:
      userId
    • recordCompletionStatus

      public void recordCompletionStatus(CompletionStatus status, List<String> outputGuards, Map<String,String> newRequestParameters, List<NewActionTarget> newActionTargets, AuditLogMessageDefinition completionMessage) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException
      Declare that all the processing for the governance service is finished and the status of the work.
      Parameters:
      status - completion status enum value
      outputGuards - optional guard strings for triggering subsequent action(s)
      newRequestParameters - properties to pass to the next governance service
      newActionTargets - map of action target names to GUIDs for the resulting governance action service
      completionMessage - message to describe completion results or reasons for failure
      Throws:
      InvalidParameterException - the completion status is null
      UserNotAuthorizedException - the governance action service is not authorized to update the governance action service status
      PropertyServerException - there is a problem connecting to the metadata store
    • recordCompletionStatus

      public void recordCompletionStatus(CompletionStatus status, List<String> outputGuards, Map<String,String> newRequestParameters, List<NewActionTarget> newActionTargets, String completionMessage) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException
      Declare that all the processing for the governance action service is finished and the status of the work.
      Parameters:
      status - completion status enum value
      outputGuards - optional guard strings for triggering subsequent action(s)
      newRequestParameters - additional request parameters. These override/augment any request parameters defined for the next invoked service
      newActionTargets - list of action target names to GUIDs for the resulting governance action service
      completionMessage - message to describe completion results or reasons for failure
      Throws:
      InvalidParameterException - the completion status is null
      UserNotAuthorizedException - the governance action service is not authorized to update the governance action service completion status
      PropertyServerException - there is a problem connecting to the metadata store
    • getWatchdogActionServiceName

      public String getWatchdogActionServiceName()
      Return the watchdog action service.
      Returns:
      qualified name
    • getCompletionStatus

      public CompletionStatus getCompletionStatus()
      Return the completion status provided by the watchdog action service.
      Returns:
      enum
    • toString

      public String toString()
      Standard toString method.
      Overrides:
      toString in class Object
      Returns:
      print out of variables in a JSON-style