Class UifViewBeanWrapper
- All Implemented Interfaces:
org.springframework.beans.BeanWrapper,org.springframework.beans.ConfigurablePropertyAccessor,org.springframework.beans.PropertyAccessor,org.springframework.beans.PropertyEditorRegistry,org.springframework.beans.TypeConverter
Registers custom property editors configured on the field associated with the property name for which
we are getting or setting a value. In addition determines if the field requires encryption and if so applies
the UifEncryptionPropertyEditorWrapper
- Author:
- Kuali Rice Team (rice.collab@kuali.org)
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.beans.AbstractNestablePropertyAccessor
org.springframework.beans.AbstractNestablePropertyAccessor.PropertyHandler -
Field Summary
Fields inherited from interface org.springframework.beans.PropertyAccessor
NESTED_PROPERTY_SEPARATOR, NESTED_PROPERTY_SEPARATOR_CHAR, PROPERTY_KEY_PREFIX, PROPERTY_KEY_PREFIX_CHAR, PROPERTY_KEY_SUFFIX, PROPERTY_KEY_SUFFIX_CHAR -
Constructor Summary
ConstructorsConstructorDescriptionUifViewBeanWrapper(ViewModel model, UifBeanPropertyBindingResult bindingResult) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanannotationMatchesMethodToCalls(String[] annotationMethodToCalls, String methodToCall) Indicates whether one of the given request accessible methods to call in the given array matches the actual methodToCall of the request.protected booleanannotationMatchesRequestMethod(org.springframework.web.bind.annotation.RequestMethod[] annotationMethods, String requestMethod) Indicates whether one of the given request methods in the given array matches the actual method of the request.protected BooleancheckBindingAnnotationsInPath(String propertyPath) Determines whether one of the binding annotations is present within the given property path, and if so returns whether access should be granted based on those annotation(s).protected booleancheckPropertyBindingAccess(String propertyName) Determines whether request binding is allowed for the given property name/path.protected StringdecryptValueIfNecessary(String propertyName, String propertyValue) If the given property name is secure, decrypts the value by calling the encryption service.protected org.springframework.beans.BeanWrapperImplgetPropertyAccessorForPropertyPath(String propertyPath) Overridden to copy property editor registration to the new bean wrapper.protected ObjectgetPropertyValue(String propertyName, boolean autoGrowNestedPaths) Override to register property editors from the view before the value is retrieved.protected booleanChecks whether the given property is secure.protected ObjectprocessValueBeforeSet(String propertyName, Object value) Registers any custom property editor for the property name/path, converts empty string values to null, and calls helper method to decrypt secure values.protected voidregisterEditorFromView(String propertyName) Attempts to find a corresponding data field for the given property name in the current view or previous view, then if the field has a property editor configured it is registered with the property editor registry to use for this property.voidsetPropertyValue(String propertyName, Object value) Overridden to perform processing before and after the value is set.voidsetPropertyValue(org.springframework.beans.PropertyValue pv) Overridden to perform processing before and after the value is set.Methods inherited from class org.kuali.rice.krad.web.bind.UifBeanWrapper
getPropertyValue, getRootBeanWrapper, newNestedPropertyAccessor, setRootBeanWrapperMethods inherited from class org.springframework.beans.BeanWrapperImpl
convertForProperty, createNotWritablePropertyException, getLocalPropertyHandler, getPropertyDescriptor, getPropertyDescriptors, getSecurityContext, setBeanInstance, setIntrospectionClass, setSecurityContext, setWrappedInstanceMethods inherited from class org.springframework.beans.AbstractNestablePropertyAccessor
convertForProperty, getAutoGrowCollectionLimit, getFinalPath, getNestedPath, getPropertyHandler, getPropertyType, getPropertyTypeDescriptor, getPropertyValue, getRootClass, getRootInstance, getWrappedClass, getWrappedInstance, isReadableProperty, isWritableProperty, setAutoGrowCollectionLimit, setPropertyValue, setWrappedInstance, toStringMethods inherited from class org.springframework.beans.AbstractPropertyAccessor
isAutoGrowNestedPaths, isExtractOldValueForEditor, setAutoGrowNestedPaths, setExtractOldValueForEditor, setPropertyValues, setPropertyValues, setPropertyValues, setPropertyValuesMethods inherited from class org.springframework.beans.TypeConverterSupport
convertIfNecessary, convertIfNecessary, convertIfNecessary, convertIfNecessaryMethods inherited from class org.springframework.beans.PropertyEditorRegistrySupport
copyCustomEditorsTo, copyDefaultEditorsTo, findCustomEditor, getConversionService, getDefaultEditor, guessPropertyTypeFromEditors, hasCustomEditorForElement, overrideDefaultEditor, registerCustomEditor, registerCustomEditor, registerDefaultEditors, setConversionService, useConfigValueEditorsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.beans.BeanWrapper
getAutoGrowCollectionLimit, getWrappedClass, getWrappedInstance, setAutoGrowCollectionLimitMethods inherited from interface org.springframework.beans.ConfigurablePropertyAccessor
getConversionService, isAutoGrowNestedPaths, isExtractOldValueForEditor, setAutoGrowNestedPaths, setConversionService, setExtractOldValueForEditorMethods inherited from interface org.springframework.beans.PropertyAccessor
getPropertyType, getPropertyTypeDescriptor, isReadableProperty, isWritableProperty, setPropertyValues, setPropertyValues, setPropertyValues, setPropertyValuesMethods inherited from interface org.springframework.beans.PropertyEditorRegistry
findCustomEditor, registerCustomEditor, registerCustomEditorMethods inherited from interface org.springframework.beans.TypeConverter
convertIfNecessary, convertIfNecessary, convertIfNecessary, convertIfNecessary
-
Constructor Details
-
UifViewBeanWrapper
-
-
Method Details
-
getPropertyValue
Override to register property editors from the view before the value is retrieved. Returns the value for the given property growing nested paths depending on the parameter.- Overrides:
getPropertyValuein classUifBeanWrapper- Parameters:
propertyName- name of the property to get value forautoGrowNestedPaths- whether nested paths should be grown (initialized if null)- Returns:
- value for property
-
registerEditorFromView
Attempts to find a corresponding data field for the given property name in the current view or previous view, then if the field has a property editor configured it is registered with the property editor registry to use for this property.- Parameters:
propertyName- name of the property to find field and editor for
-
setPropertyValue
public void setPropertyValue(org.springframework.beans.PropertyValue pv) throws org.springframework.beans.BeansException Overridden to perform processing before and after the value is set.First binding security is checked to determine whether the path allows binding. Next, access security is checked to determine whether the value needs decrypted. Finally, if change tracking is enabled, the original value is compared with the new for indicating a modified path.
Override to set auto grow to true for setting property values.- Specified by:
setPropertyValuein interfaceorg.springframework.beans.PropertyAccessor- Overrides:
setPropertyValuein classUifBeanWrapper- Throws:
org.springframework.beans.BeansException
-
setPropertyValue
public void setPropertyValue(String propertyName, Object value) throws org.springframework.beans.BeansException Overridden to perform processing before and after the value is set.First binding security is checked to determine whether the path allows binding. Next, access security is checked to determine whether the value needs decrypted. Finally, if change tracking is enabled, the original value is compared with the new for indicating a modified path.
Override to set auto grow to true for setting property values.- Specified by:
setPropertyValuein interfaceorg.springframework.beans.PropertyAccessor- Overrides:
setPropertyValuein classUifBeanWrapper- Throws:
org.springframework.beans.BeansException
-
checkPropertyBindingAccess
Determines whether request binding is allowed for the given property name/path.Binding access is determined by default based on the view's post metadata. A set of accessible binding paths (populated during the view lifecycle) is maintained within this data. Overrides can be specified using the annotations
RequestProtectedandRequestAccessible.If the path is not accessible, it is recorded in the binding results suppressed fields. Controller methods can accept the binding result and further handle these properties if necessary.
- Parameters:
propertyName- name/path of the property to check binding access for- Returns:
- boolean true if binding access is allowed, false if not allowed
-
checkBindingAnnotationsInPath
Determines whether one of the binding annotations is present within the given property path, and if so returns whether access should be granted based on those annotation(s).Binding annotations may occur anywhere in the property path. For example, if the path is 'object.field1', a binding annotation may be present on the 'object' property or the 'field1' property. If multiple annotations are found in the path, the annotation at the deepest level is taken. If both the protected and accessible annotation are found at the same level, the protected access is used.
- Parameters:
propertyPath- path to look for annotations- Returns:
- Boolean true if an annotation is found and the access is allowed, false if an annotation is found and the access is protected, null if no annotations where found in the path
-
annotationMatchesMethodToCalls
protected boolean annotationMatchesMethodToCalls(String[] annotationMethodToCalls, String methodToCall) Indicates whether one of the given request accessible methods to call in the given array matches the actual methodToCall of the request.- Parameters:
annotationMethodToCalls- array of request accessible methods to call to check againstmethodToCall- method to call of the request- Returns:
- boolean true if one of the annotation methods to call match, false if none match
-
annotationMatchesRequestMethod
protected boolean annotationMatchesRequestMethod(org.springframework.web.bind.annotation.RequestMethod[] annotationMethods, String requestMethod) Indicates whether one of the given request methods in the given array matches the actual method of the request.- Parameters:
annotationMethods- array of request methods to checkrequestMethod- method of the request to match on- Returns:
- boolean true if one of the annotation methods match, false if none match
-
processValueBeforeSet
Registers any custom property editor for the property name/path, converts empty string values to null, and calls helper method to decrypt secure values.- Parameters:
propertyName- name of the propertyvalue- value of the property to process- Returns:
- updated (possibly) property value
-
decryptValueIfNecessary
If the given property name is secure, decrypts the value by calling the encryption service.- Parameters:
propertyName- name of the propertypropertyValue- value of the property- Returns:
- String decrypted property value (or original value if not secure)
-
isSecure
Checks whether the given property is secure.- Parameters:
wrappedClass- class the property is associated withpropertyPath- path to the property- Returns:
- boolean true if the property is secure, false if not
-
getPropertyAccessorForPropertyPath
protected org.springframework.beans.BeanWrapperImpl getPropertyAccessorForPropertyPath(String propertyPath) Overridden to copy property editor registration to the new bean wrapper.This is necessary because spring only copies over the editors when a new bean wrapper is created. The wrapper is then cached and use for subsequent calls. But the get calls could bring in new custom editors we need to copy.
Override to set auto grown on the nested bean wrapper to the setting of the root bean wrapper.This is necessary because the nested bean wrapper could have been cached, and its auto-grow setting reflect an earler get or set call
- Overrides:
getPropertyAccessorForPropertyPathin classUifBeanWrapper
-