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 Details

    • DEFAULT_MAX_NAME_LENGTH

      public static final int DEFAULT_MAX_NAME_LENGTH
      See Also:
  • Constructor Details

    • DefaultNodeNameGenerator

      public DefaultNodeNameGenerator()
    • DefaultNodeNameGenerator

      public DefaultNodeNameGenerator(String[] parameterNames, int maxNameLength)
  • Method Details

    • getValueToUse

      protected String getValueToUse(RequestParameterMap parameters, String paramName)
      Determine the value to use for the specified parameter. This also considers the parameter with a SlingPostConstants.VALUE_FROM_SUFFIX
      Parameters:
      parameters - the map of request parameters
      paramName - 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(SlingHttpServletRequest request, String basePath, boolean requirePrefix, NodeNameGenerator defaultNodeNameGenerator)
      Get a "nice" node name, if possible, based on given request
      Specified by:
      getNodeName in interface NodeNameGenerator
      Parameters:
      request - the request
      basePath - the base path
      requirePrefix - true if the parameter names for properties requires a prefix
      defaultNodeNameGenerator - a default generator
      Returns:
      a nice node name
    • nextCounter

      public int nextCounter()