Package 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
Modifier and TypeFieldDescriptionstatic final String
The "number" macro.static final PrintfFormat
Format for file create parameter. -
Method Summary
Modifier and TypeMethodDescriptiongetCopyFileName
(CmsObject cms, String parentFolder, String baseName) Returns a unique copy filename for the given base name and the parent folder.getNewFileName
(CmsObject cms, String namePattern, int defaultDigits) Generates a new file name based on the provided OpenCms user context and name pattern.getNewFileName
(CmsObject cms, String namePattern, int defaultDigits, boolean explorerMode) Generates a new file name based on the provided OpenCms user context and name pattern.getUniqueFileName
(CmsObject cms, String parentFolder, String baseName) Returns a unique filename for the given base name and the parent folder.getUrlNameSequence
(String baseName) Returns a sequence of URL name candidates for the given base name as an iterator.default void
setAdminCms
(CmsObject cms) Initializes this instance with an admin CMS context.
-
Field Details
-
MACRO_NUMBER
The "number" macro.- See Also:
-
NUMBER_FORMAT
Format for file create parameter.
-
-
Method Details
-
getCopyFileName
Returns a unique copy filename for the given base name and the parent folder.For example from the given baseName 'test.txt' the copy file name 'test_copy.txt' will be generated.
- Parameters:
cms
- the current OpenCms user contextparentFolder
- the parent folder of the filebaseName
- the base file name- Returns:
- the unique file name
-
getNewFileName
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 contextnamePattern
- the pattern to be used when generating the new resource namedefaultDigits
- 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
-
getNewFileName
String getNewFileName(CmsObject cms, String namePattern, int defaultDigits, boolean explorerMode) 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 contextnamePattern
- the pattern to be used when generating the new resource namedefaultDigits
- the default number of digits to use for numbering the created file namesexplorerMode
- if true, tries the name without a number, and also automatically inserts an underscore before the number- Returns:
- a new resource name based on the provided OpenCms user context and name pattern
- Throws:
CmsException
- in case something goes wrong
-
getUniqueFileName
Returns a unique filename for the given base name and the parent folder.- Parameters:
cms
- the current OpenCms user contextparentFolder
- the parent folder of the filebaseName
- the proposed file name- Returns:
- the unique file name
-
getUrlNameSequence
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
-
setAdminCms
Initializes this instance with an admin CMS context.- Parameters:
cms
- the admin CMS context
-