Class DefaultNodeNameGenerator
- java.lang.Object
-
- org.apache.sling.servlets.post.impl.helper.DefaultNodeNameGenerator
-
- All Implemented Interfaces:
NodeNameGenerator
public class DefaultNodeNameGenerator extends Object implements NodeNameGenerator
Generates a node name based on a set of well-known request parameters like title, description, etc. See SLING-128.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_MAX_NAME_LENGTH
-
Constructor Summary
Constructors Constructor Description DefaultNodeNameGenerator()
DefaultNodeNameGenerator(String[] parameterNames, int maxNameLength)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getNodeName(org.apache.sling.api.SlingHttpServletRequest request, String basePath, boolean requirePrefix, NodeNameGenerator defaultNodeNameGenerator)
Get a "nice" node name, if possible, based on given requestprotected String
getValueToUse(org.apache.sling.api.request.RequestParameterMap parameters, String paramName)
Determine the value to use for the specified parameter.int
nextCounter()
-
-
-
Field Detail
-
DEFAULT_MAX_NAME_LENGTH
public static final int DEFAULT_MAX_NAME_LENGTH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultNodeNameGenerator
public DefaultNodeNameGenerator()
-
DefaultNodeNameGenerator
public DefaultNodeNameGenerator(String[] parameterNames, int maxNameLength)
-
-
Method Detail
-
getValueToUse
protected String getValueToUse(org.apache.sling.api.request.RequestParameterMap parameters, String paramName)
Determine the value to use for the specified parameter. This also considers the parameter with aSlingPostConstants.VALUE_FROM_SUFFIX
- Parameters:
parameters
- the map of request parametersparamName
- the parameter to get the value for- Returns:
- the value to use for the parameter or null if it could not be determined
-
getNodeName
public String getNodeName(org.apache.sling.api.SlingHttpServletRequest request, String basePath, boolean requirePrefix, NodeNameGenerator defaultNodeNameGenerator)
Get a "nice" node name, if possible, based on given request- Specified by:
getNodeName
in interfaceNodeNameGenerator
- Parameters:
request
- the requestbasePath
- the base pathrequirePrefix
-true
if the parameter names for properties requires a prefixdefaultNodeNameGenerator
- a default generator- Returns:
- a nice node name
-
nextCounter
public int nextCounter()
-
-