Class 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 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 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​(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 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()