Package org.codice.ddf.catalog.actions
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 Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractMetacardActionProvider(String actionProviderId, String title, String description) Constructor that accepts the values to be used when a newActionis created by thisActionProvider. -
Method Summary
Modifier and TypeMethodDescription<T> booleancanHandle(T subject) Default implementation that ensures thesubjectprovided is aMetacardbefore delegating tocanHandleMetacard(Metacard).protected booleancanHandleMetacard(ddf.catalog.data.Metacard metacard) Determines if thisActionProvidercan handle thisMetacard.protected abstract ddf.action.ActioncreateMetacardAction(String actionProviderId, String title, String description, URL url) Factory method that creates the properActionobject from the information provided.<T> ddf.action.ActiongetAction(T subject) Default implementation that ensures thesubjectprovided is aMetacardwith a valid ID before delegating togetMetacardAction(String, Metacard).getId()protected ddf.action.ActiongetMetacardAction(String metacardSource, ddf.catalog.data.Metacard metacard) Creates a newActiongiven aMetacard.protected abstract URLgetMetacardActionUrl(String metacardSource, ddf.catalog.data.Metacard metacard) Gets theURLthat will be used when theActionis created.toString()
-
Constructor Details
-
AbstractMetacardActionProvider
Constructor that accepts the values to be used when a newActionis created by thisActionProvider.- Parameters:
actionProviderId- ID that will be assigned to theActionthat will be created. Cannot be empty or blank.title- title that will be used when thisActionProvidercreates a newActiondescription- description that will be used when thisActionProvidercreates a newAction
-
-
Method Details
-
getAction
public <T> ddf.action.Action getAction(T subject) Default implementation that ensures thesubjectprovided is aMetacardwith a valid ID before delegating togetMetacardAction(String, Metacard).- Specified by:
getActionin interfaceddf.action.ActionProvider
-
getId
- Specified by:
getIdin interfaceddf.action.ActionProvider
-
canHandle
public <T> boolean canHandle(T subject) Default implementation that ensures thesubjectprovided is aMetacardbefore delegating tocanHandleMetacard(Metacard). -
canHandleMetacard
protected boolean canHandleMetacard(ddf.catalog.data.Metacard metacard) Determines if thisActionProvidercan handle thisMetacard. Returnstrueby default. Should be overwritten if more complex verification is needed.- Parameters:
metacard- metacard to which thisActionProvidercould apply- Returns:
trueif thisActionProviderapplies to theMetacard
-
toString
-
getMetacardAction
protected ddf.action.Action getMetacardAction(String metacardSource, ddf.catalog.data.Metacard metacard) throws MalformedURLException, URISyntaxException, UnsupportedEncodingException Creates a newActiongiven aMetacard. This method delegates togetMetacardActionUrl(String, Metacard)andcreateMetacardAction(String, String, String, URL).- Parameters:
metacardSource- source ID of theMetacardmetacard-Metacardto create anActionfrom- Returns:
- new
Actionobject. Cannot benull. - Throws:
Exception- thrown if an error occurred while creating theActionMalformedURLExceptionURISyntaxExceptionUnsupportedEncodingException
-
createMetacardAction
protected abstract ddf.action.Action createMetacardAction(String actionProviderId, String title, String description, URL url) Factory method that creates the properActionobject from the information provided. Must be implemented by sub-classes.- Parameters:
actionProviderId-ActionIDtitle-Actiontitledescription-Actiondescriptionurl-Actionurl- Returns:
- new
Actionobject. Cannot benull.
-
getMetacardActionUrl
protected abstract URL getMetacardActionUrl(String metacardSource, ddf.catalog.data.Metacard metacard) throws MalformedURLException, URISyntaxException, UnsupportedEncodingException Gets theURLthat will be used when theActionis created.- Parameters:
metacardSource- source ID of theMetacardmetacard-Metacardfor which aURLneeds to be created- Returns:
URLthat will be used to create theAction- Throws:
Exception- thrown if theURLcouldn't be createdMalformedURLExceptionURISyntaxExceptionUnsupportedEncodingException
-