org.opencms.loader
Interface I_CmsFileNameGenerator

All Known Implementing Classes:
CmsDefaultFileNameGenerator

public interface I_CmsFileNameGenerator

Provides methods to generate file names either for the urlName mapping or when using a "new" operation in the context of the direct edit interface.

Since:
8.0.0

Field Summary
static java.lang.String MACRO_NUMBER
          The "number" macro.
static PrintfFormat NUMBER_FORMAT
          Format for file create parameter.
 
Method Summary
 java.lang.String getNewFileName(CmsObject cms, java.lang.String namePattern, int defaultDigits)
          Generates a new file name based on the provided OpenCms user context and name pattern.
 java.lang.String getUniqueFileName(CmsObject cms, java.lang.String parentFolder, java.lang.String baseName)
          Returns a unique filename for the given base name and the parent folder.
 java.util.Iterator<java.lang.String> getUrlNameSequence(java.lang.String baseName)
          Returns a sequence of URL name candidates for the given base name as an iterator.
 

Field Detail

MACRO_NUMBER

static final java.lang.String MACRO_NUMBER
The "number" macro.

See Also:
Constant Field Values

NUMBER_FORMAT

static final PrintfFormat NUMBER_FORMAT
Format for file create parameter.

Method Detail

getNewFileName

java.lang.String getNewFileName(CmsObject cms,
                                java.lang.String namePattern,
                                int defaultDigits)
                                throws CmsException
Generates a new file name based on the provided OpenCms user context and name pattern.

Used by the collector API as well as the galleries introduced with OpenCms 8 (ADE).

Parameters:
cms - the current OpenCms user context
namePattern - the pattern to be used when generating the new resource name
defaultDigits - the default number of digits to use for numbering the created file names
Returns:
a new resource name based on the provided OpenCms user context and name pattern
Throws:
CmsException - in case something goes wrong

getUniqueFileName

java.lang.String getUniqueFileName(CmsObject cms,
                                   java.lang.String parentFolder,
                                   java.lang.String baseName)
Returns a unique filename for the given base name and the parent folder.

Parameters:
cms - the current OpenCms user context
parentFolder - the parent folder of the file
baseName - the proposed file name
Returns:
the unique file name

getUrlNameSequence

java.util.Iterator<java.lang.String> getUrlNameSequence(java.lang.String baseName)
                                                        throws CmsException
Returns a sequence of URL name candidates for the given base name as an iterator.

This is used by the urlName mapping of XML contents which enable SEO friendly URLs automatically generated for example from the resource title.

Usually the first URL name from this sequence which does not already exist for a different resource will be used for the URL name mapping.

Parameters:
baseName - the base name
Returns:
the sequence of URL name candidates
Throws:
CmsException - if something goes wrong