public class ReadOnlyUserVariablesFilter extends SysControllerFilter
By providing a list of User Variables names the filter will automatically discard all update/delete requests that match the passed variables list.
This of course affects only client-side requests, while server-side updates will not be subject to filtering. The filter works on a per-Zone basis, so each Zone that requires this feature will need its own filter.
Here's an example of how to initialize the filter inside the Zone Extension:
public class MyExtension extends SFSExtension
{
public void init()
{
// Reset filter chain to clean previous filters
getParentZone().resetSystemFilterChain();
ISystemFilterChain filterChain = new SysControllerFilterChain();
ReadOnlyUserVariablesFilter filter = new ReadOnlyUserVariablesFilter(getParentZone(), Arrays.asList("alpha", "beta"));
filterChain.addFilter("ReadOnlyUserVars", filter);
// Plug the filter chain
getParentZone().setFilterChain(SystemRequest.SetUserVariables, filterChain);
}
public void destroy()
{
super.destroy();
}
}
SysControllerFilter,
SysControllerFilterChainlogger| Constructor and Description |
|---|
ReadOnlyUserVariablesFilter(Zone zone)
Builds an empty filter.
|
ReadOnlyUserVariablesFilter(Zone zone,
java.util.List<java.lang.String> varNames)
Builds a new filter with a list of read-only User Variables names.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addVariable(java.lang.String varName)
Add a new User Variable name to be set as read-only
|
void |
clearFilter()
Resets the filter: all variable names are removed.
|
java.util.List<java.lang.String> |
getFilteredVariables() |
FilterAction |
handleClientRequest(User sender,
ISFSObject params)
Handles a client request
|
void |
removeVariable(java.lang.String varName)
Removes a variable name, rendering the related User Variable readable and writable
|
getName, setName, trace, tracepublic ReadOnlyUserVariablesFilter(Zone zone)
zone - the Zonepublic ReadOnlyUserVariablesFilter(Zone zone, java.util.List<java.lang.String> varNames)
zone - the ZonevarNames - the list of variables namespublic void addVariable(java.lang.String varName)
varName - the variable namepublic void removeVariable(java.lang.String varName)
varName - public java.util.List<java.lang.String> getFilteredVariables()
public void clearFilter()
public FilterAction handleClientRequest(User sender, ISFSObject params) throws SFSException
ISystemFiltersender - the sender of the requestparams - the parameters of the requestSFSExceptionFilterAction