Package org.apache.nifi.parameter
Class StandardParameterContext
java.lang.Object
org.apache.nifi.parameter.StandardParameterContext
- All Implemented Interfaces:
Authorizable,ComponentAuthorizable,ParameterContext,ParameterLookup
- Direct Known Subclasses:
ReferenceOnlyParameterContext
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Stringprivate final Stringprivate final List<ParameterContext> private static final org.slf4j.Loggerprivate Stringprivate ParameterProviderprivate ParameterProviderConfigurationprivate final ParameterProviderLookupprivate final ParameterReferenceManagerprivate final Map<ParameterDescriptor, Parameter> private final Authorizableprivate final Lockprivate final ReadWriteLockprivate AtomicLongprivate final LockFields inherited from interface org.apache.nifi.parameter.ParameterLookup
EMPTY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedStandardParameterContext(String id, String name, ParameterReferenceManager parameterReferenceManager, Authorizable parentAuthorizable, ParameterProviderLookup parameterProviderLookup, ParameterProviderConfiguration parameterProviderConfiguration) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidalertReferencingComponents(Map<String, ParameterUpdate> parameterUpdates) Alerts all referencing components of any relevant updates.voidauthorize(Authorizer authorizer, RequestAction action, NiFiUser user) private voidauthorizeParameterProviderRead(Authorizer authorizer, ParameterProvider parameterProvider, NiFiUser user) private voidcombineOverrides(Map<ParameterDescriptor, List<Parameter>> existingOverrides, Map<ParameterDescriptor, List<Parameter>> newOverrides) voidconfigureParameterProvider(ParameterProviderConfiguration parameterProviderConfiguration) private ParametercreateFullyPopulatedParameter(Parameter proposedParameter) When updating a Parameter, the provided 'updated' Parameter may or may not contain a value.booleanA ParameterContext's identity is its identifier.private Map<ParameterDescriptor, Parameter> getEffectiveParameters(List<ParameterContext> parameterContexts) Constructs an effective view of the parameters, including nested parameters, assuming the given list of ParameterContexts.private Map<ParameterDescriptor, Parameter> getEffectiveParameters(List<ParameterContext> parameterContexts, Map<ParameterDescriptor, Parameter> proposedParameters) private Map<ParameterDescriptor, Parameter> getEffectiveParameters(List<ParameterContext> parameterContexts, Map<ParameterDescriptor, Parameter> proposedParameters, Map<ParameterDescriptor, List<Parameter>> allOverrides) private Map<ParameterDescriptor, Parameter> getEffectiveParameters(Map<ParameterDescriptor, Parameter> proposedParameters) Constructs an effective view of the parameters, including nested parameters, assuming the given map of parameters.getEffectiveParameterUpdates(Map<String, Parameter> parameterUpdates, List<ParameterContext> inheritedParameterContexts) getEffectiveParameterUpdates(Map<ParameterDescriptor, Parameter> currentEffectiveParameters, Map<ParameterDescriptor, Parameter> effectiveProposedParameters) Returns a map that can be used to indicate all effective parameters updates, including removed parameters.private ParameterDescriptorgetFullyPopulatedDescriptor(Parameter proposedParameter) getName()getParameter(String parameterName) getParameter(ParameterDescriptor parameterDescriptor) private ParameterProviderNodegetParameterProviderNode(ParameterProvider parameterProvider) private Map<ParameterDescriptor, Parameter> getProposedParameters(Map<String, Parameter> proposedParameterUpdates) longinthashCode()A ParameterContext's identity is its identifier.booleanhasReferencingComponents(Parameter parameter) booleaninheritsFrom(String parameterContextId) booleanisAuthorized(Authorizer authorizer, RequestAction action, NiFiUser user) booleanisEmpty()private Map<ParameterDescriptor, List<Parameter>> overrideParameters(Map<ParameterDescriptor, Parameter> existingParameters, Map<ParameterDescriptor, Parameter> overridingParameters, ParameterContext overridingContext) private voidregisterParameterProvider(ParameterProvider parameterProvider) voidsetDescription(String description) voidsetInheritedParameterContexts(List<ParameterContext> inheritedParameterContexts) voidvoidsetParameters(Map<String, Parameter> updatedParameters) toString()private ParameterDescriptorunescape(ParameterDescriptor descriptor) private Map<String, ParameterUpdate> updateParameters(Map<ParameterDescriptor, Parameter> currentParameters, Map<String, Parameter> updatedParameters, boolean performUpdate) Returns a map from parameter name to ParameterUpdate for any actual updates to parameters.private voidvalidateParameterSensitivity(Parameter parameter, ComponentNode componentNode) private voidvalidateReferencingComponents(String parameterName, Parameter parameter, boolean duringUpdate) private voidvalidateSensitiveFlag(Map<ParameterDescriptor, Parameter> currentParameters, Parameter updatedParameter) voidverifyCanSetParameters(Map<String, Parameter> updatedParameters) private voidverifyCanSetParameters(Map<String, Parameter> updatedParameters, boolean duringUpdate) Ensures that it is legal to update the Parameters for this Parameter Context to match the given set of ParametersvoidverifyCanSetParameters(Map<ParameterDescriptor, Parameter> currentParameters, Map<String, Parameter> updatedParameters, boolean duringUpdate) voidverifyCanUpdateParameterContext(Map<String, Parameter> parameterUpdates, List<ParameterContext> inheritedParameterContexts) private voidverifyCanUpdateParameterContext(Map<String, Parameter> parameterUpdates, List<ParameterContext> inheritedParameterContexts, boolean duringUpdate) private voidverifyNoCycles(List<ParameterContext> parameterContexts) Verifies that no cycles would exist in the ParameterContext reference graph, if this ParameterContext were to inherit from the given list of ParameterContexts.private voidverifyNoCycles(Stack<String> traversedIds, List<ParameterContext> parameterContexts) A helper method for performing a depth first search to verify there are no cycles in the proposed list of ParameterContexts.private voidverifyProvidedParameters(Map<String, Parameter> parameterUpdates) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.nifi.authorization.resource.Authorizable
authorize, checkAuthorization, checkAuthorization, getRequestedResource
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
id
-
parameterReferenceManager
-
parameterProviderLookup
-
parentAuthorizable
-
name
-
version
-
parameters
-
inheritedParameterContexts
-
parameterProvider
-
parameterProviderConfiguration
-
description
-
rwLock
-
readLock
-
writeLock
-
-
Constructor Details
-
StandardParameterContext
protected StandardParameterContext(String id, String name, ParameterReferenceManager parameterReferenceManager, Authorizable parentAuthorizable, ParameterProviderLookup parameterProviderLookup, ParameterProviderConfiguration parameterProviderConfiguration)
-
-
Method Details
-
getIdentifier
- Specified by:
getIdentifierin interfaceComponentAuthorizable- Specified by:
getIdentifierin interfaceParameterContext
-
getProcessGroupIdentifier
- Specified by:
getProcessGroupIdentifierin interfaceComponentAuthorizable
-
getName
- Specified by:
getNamein interfaceParameterContext
-
setName
- Specified by:
setNamein interfaceParameterContext
-
setDescription
- Specified by:
setDescriptionin interfaceParameterContext
-
getDescription
- Specified by:
getDescriptionin interfaceParameterContext
-
setParameters
- Specified by:
setParametersin interfaceParameterContext
-
getProposedParameters
-
alertReferencingComponents
Alerts all referencing components of any relevant updates.- Parameters:
parameterUpdates- A map from parameter name to ParameterUpdate (empty if none are applicable)
-
updateParameters
private Map<String,ParameterUpdate> updateParameters(Map<ParameterDescriptor, Parameter> currentParameters, Map<String, Parameter> updatedParameters, boolean performUpdate) Returns a map from parameter name to ParameterUpdate for any actual updates to parameters.- Parameters:
currentParameters- The current parametersupdatedParameters- An updated parameters mapperformUpdate- If true, this will actually perform the updates on the currentParameters map. Otherwise, the updates are simply collected and returned.- Returns:
- A map from parameter name to ParameterUpdate for any actual parameters
-
createFullyPopulatedParameter
When updating a Parameter, the provided 'updated' Parameter may or may not contain a value. This is done because once a Parameter is set, a user may want to change the description of the Parameter but cannot include the value of the Parameter in the request if the Parameter is sensitive (because the value of the Parameter, when retrieved, is masked for sensitive Parameters). As a result, a call may be made tosetParameters(Map)that includes a Parameter whose value isnull. If we encounter this, we do not want to change the value of the Parameter, so we want to insert into our Map a Parameter object whose value is equal to the current value for that Parameter (if any). This method, then, takes a Parameter whose value may or may not be populated and returns a Parameter whose value is populated, if there is an appropriate value to populate it with.- Parameters:
proposedParameter- the proposed parameter- Returns:
- a Parameter whose descriptor is the same as the given proposed parameter but whose value has been populated based on the existing value for that Parameter (if any) if the given proposed parameter does not have its value populated
-
getFullyPopulatedDescriptor
-
getVersion
public long getVersion()- Specified by:
getVersionin interfaceParameterLookup
-
getParameter
- Specified by:
getParameterin interfaceParameterLookup
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceParameterLookup
-
getParameter
- Specified by:
getParameterin interfaceParameterContext
-
unescape
-
getParameters
- Specified by:
getParametersin interfaceParameterContext
-
getEffectiveParameters
- Specified by:
getEffectiveParametersin interfaceParameterContext
-
getEffectiveParameterUpdates
public Map<String,Parameter> getEffectiveParameterUpdates(Map<String, Parameter> parameterUpdates, List<ParameterContext> inheritedParameterContexts) - Specified by:
getEffectiveParameterUpdatesin interfaceParameterContext
-
getEffectiveParameters
private Map<ParameterDescriptor,Parameter> getEffectiveParameters(Map<ParameterDescriptor, Parameter> proposedParameters) Constructs an effective view of the parameters, including nested parameters, assuming the given map of parameters. This allows an inspection of what parameters would be available if the given parameters were set in this ParameterContext.- Parameters:
proposedParameters- A Map of proposed parameters that should be used in place of the current parameters- Returns:
- The view of the parameters with all overriding applied
-
getEffectiveParameters
private Map<ParameterDescriptor,Parameter> getEffectiveParameters(List<ParameterContext> parameterContexts) Constructs an effective view of the parameters, including nested parameters, assuming the given list of ParameterContexts. This allows an inspection of what parameters would be available if the given list were set in this ParameterContext.- Parameters:
parameterContexts- An ordered list of ParameterContexts from which to inherit- Returns:
- The view of the parameters with all overriding applied
-
getEffectiveParameters
private Map<ParameterDescriptor,Parameter> getEffectiveParameters(List<ParameterContext> parameterContexts, Map<ParameterDescriptor, Parameter> proposedParameters) -
getEffectiveParameters
private Map<ParameterDescriptor,Parameter> getEffectiveParameters(List<ParameterContext> parameterContexts, Map<ParameterDescriptor, Parameter> proposedParameters, Map<ParameterDescriptor, List<Parameter>> allOverrides) -
combineOverrides
private void combineOverrides(Map<ParameterDescriptor, List<Parameter>> existingOverrides, Map<ParameterDescriptor, List<Parameter>> newOverrides) -
overrideParameters
private Map<ParameterDescriptor,List<Parameter>> overrideParameters(Map<ParameterDescriptor, Parameter> existingParameters, Map<ParameterDescriptor, Parameter> overridingParameters, ParameterContext overridingContext) -
getParameterReferenceManager
- Specified by:
getParameterReferenceManagerin interfaceParameterContext
-
getParameterProviderLookup
- Specified by:
getParameterProviderLookupin interfaceParameterContext
-
getParameterProvider
- Specified by:
getParameterProviderin interfaceParameterContext
-
configureParameterProvider
public void configureParameterProvider(ParameterProviderConfiguration parameterProviderConfiguration) - Specified by:
configureParameterProviderin interfaceParameterContext
-
getParameterProviderConfiguration
- Specified by:
getParameterProviderConfigurationin interfaceParameterContext
-
registerParameterProvider
-
getParameterProviderNode
-
verifyNoCycles
Verifies that no cycles would exist in the ParameterContext reference graph, if this ParameterContext were to inherit from the given list of ParameterContexts.- Parameters:
parameterContexts- A list of proposed ParameterContexts
-
verifyNoCycles
A helper method for performing a depth first search to verify there are no cycles in the proposed list of ParameterContexts.- Parameters:
traversedIds- A collection of already traversed ids in the graphparameterContexts- The ParameterContexts for which to check for cycles- Throws:
IllegalStateException- If a cycle was detected
-
verifyCanUpdateParameterContext
public void verifyCanUpdateParameterContext(Map<String, Parameter> parameterUpdates, List<ParameterContext> inheritedParameterContexts) - Specified by:
verifyCanUpdateParameterContextin interfaceParameterContext
-
verifyCanUpdateParameterContext
private void verifyCanUpdateParameterContext(Map<String, Parameter> parameterUpdates, List<ParameterContext> inheritedParameterContexts, boolean duringUpdate) -
verifyProvidedParameters
-
setInheritedParameterContexts
- Specified by:
setInheritedParameterContextsin interfaceParameterContext
-
getEffectiveParameterUpdates
private Map<String,Parameter> getEffectiveParameterUpdates(Map<ParameterDescriptor, Parameter> currentEffectiveParameters, Map<ParameterDescriptor, Parameter> effectiveProposedParameters) Returns a map that can be used to indicate all effective parameters updates, including removed parameters.- Parameters:
currentEffectiveParameters- A current map of effective parameterseffectiveProposedParameters- A map of effective parameters that would result if a proposed update were applied- Returns:
- a map that can be used to indicate all effective parameters updates, including removed parameters
-
hasReferencingComponents
- Specified by:
hasReferencingComponentsin interfaceParameterContext
-
getInheritedParameterContexts
- Specified by:
getInheritedParameterContextsin interfaceParameterContext
-
getInheritedParameterContextNames
- Specified by:
getInheritedParameterContextNamesin interfaceParameterContext
-
inheritsFrom
- Specified by:
inheritsFromin interfaceParameterContext
-
verifyCanSetParameters
- Specified by:
verifyCanSetParametersin interfaceParameterContext
-
verifyCanSetParameters
Ensures that it is legal to update the Parameters for this Parameter Context to match the given set of Parameters- Parameters:
updatedParameters- the updated set of parameters, keyed by Parameter nameduringUpdate- If true, this check will be treated as if a ParameterContext update is imminent, meaning referencing components may not be active even for updated values. If false, a parameter value update will be valid even if referencing components are active because it will be assumed that these will be stopped prior to the actual update.- Throws:
IllegalStateException- if setting the given set of Parameters is not legal
-
verifyCanSetParameters
-
validateSensitiveFlag
private void validateSensitiveFlag(Map<ParameterDescriptor, Parameter> currentParameters, Parameter updatedParameter) -
validateReferencingComponents
-
validateParameterSensitivity
-
toString
-
authorize
public void authorize(Authorizer authorizer, RequestAction action, NiFiUser user) throws AccessDeniedException - Specified by:
authorizein interfaceAuthorizable- Throws:
AccessDeniedException
-
isAuthorized
- Specified by:
isAuthorizedin interfaceAuthorizable
-
authorizeParameterProviderRead
private void authorizeParameterProviderRead(Authorizer authorizer, ParameterProvider parameterProvider, NiFiUser user) -
getParentAuthorizable
- Specified by:
getParentAuthorizablein interfaceAuthorizable
-
getResource
- Specified by:
getResourcein interfaceAuthorizable
-
equals
A ParameterContext's identity is its identifier. -
hashCode
public int hashCode()A ParameterContext's identity is its identifier.
-