Class AbstractMetacardActionProvider

java.lang.Object
org.codice.ddf.catalog.actions.AbstractMetacardActionProvider
All Implemented Interfaces:
ddf.action.ActionProvider

public abstract class AbstractMetacardActionProvider extends Object implements ddf.action.ActionProvider
Abstract base class for ActionProviders that can handle Metacard source objects.
  • Constructor Details

    • AbstractMetacardActionProvider

      protected AbstractMetacardActionProvider(String actionProviderId, String title, String description)
      Constructor that accepts the values to be used when a new Action is created by this ActionProvider.
      Parameters:
      actionProviderId - ID that will be assigned to the Action that will be created. Cannot be empty or blank.
      title - title that will be used when this ActionProvider creates a new Action
      description - description that will be used when this ActionProvider creates a new Action
  • Method Details

    • getAction

      public <T> ddf.action.Action getAction(T subject)
      Default implementation that ensures the subject provided is a Metacard with a valid ID before delegating to getMetacardAction(String, Metacard).

      Specified by:
      getAction in interface ddf.action.ActionProvider
    • getId

      public String getId()
      Specified by:
      getId in interface ddf.action.ActionProvider
    • canHandle

      public <T> boolean canHandle(T subject)
      Default implementation that ensures the subject provided is a Metacard before delegating to canHandleMetacard(Metacard).

    • canHandleMetacard

      protected boolean canHandleMetacard(ddf.catalog.data.Metacard metacard)
      Determines if this ActionProvider can handle this Metacard. Returns true by default. Should be overwritten if more complex verification is needed.
      Parameters:
      metacard - metacard to which this ActionProvider could apply
      Returns:
      true if this ActionProvider applies to the Metacard
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getMetacardAction

      protected ddf.action.Action getMetacardAction(String metacardSource, ddf.catalog.data.Metacard metacard) throws MalformedURLException, URISyntaxException, UnsupportedEncodingException
      Creates a new Action given a Metacard. This method delegates to getMetacardActionUrl(String, Metacard) and createMetacardAction(String, String, String, URL).
      Parameters:
      metacardSource - source ID of the Metacard
      metacard - Metacard to create an Action from
      Returns:
      new Action object. Cannot be null.
      Throws:
      Exception - thrown if an error occurred while creating the Action
      MalformedURLException
      URISyntaxException
      UnsupportedEncodingException
    • createMetacardAction

      protected abstract ddf.action.Action createMetacardAction(String actionProviderId, String title, String description, URL url)
      Factory method that creates the proper Action object from the information provided. Must be implemented by sub-classes.
      Parameters:
      actionProviderId - Action ID
      title - Action title
      description - Action description
      url - Action url
      Returns:
      new Action object. Cannot be null.
    • getMetacardActionUrl

      protected abstract URL getMetacardActionUrl(String metacardSource, ddf.catalog.data.Metacard metacard) throws MalformedURLException, URISyntaxException, UnsupportedEncodingException
      Gets the URL that will be used when the Action is created.
      Parameters:
      metacardSource - source ID of the Metacard
      metacard - Metacard for which a URL needs to be created
      Returns:
      URL that will be used to create the Action
      Throws:
      Exception - thrown if the URL couldn't be created
      MalformedURLException
      URISyntaxException
      UnsupportedEncodingException