Package de.espirit.firstspirit.generate
Interface UrlCreator
- All Superinterfaces:
UrlCreator
Replacement for the FirstSpirit v4 interface
Use this interface to determine the urls of
This interface provides methods to determine file names (for
If you need access to the content of generated files you should consider using a
UrlCreator
. Since FirstSpirit v5
none of these interfaces should be implemented. Instead implement the interfaces UrlFactory
and
FilenameFactory
. Consult the developer documentation for more details.
Use this interface to determine the urls of
medium
and
site-store
nodes or for
plugin elements
(like e.g. font images).
This interface provides methods to determine file names (for
medium
and site-store
nodes, and for
plugin files
). Please note that these methods are not
supported in every environment. Most notably during preview processing. But there may be also situations when
generating where content is not stored in an ordinary file system (but e.g. in a database) so that
there is simply no file. You should be aware of this when using these methods. This also applies for the usage of
Mode.FILE_PATH
.If you need access to the content of generated files you should consider using a
ContentProcessor
.- Since:
- 5.0.3
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
Factory to transform a legacyUrlCreator
implementation into a newUrlCreator
instance.static enum
The different flavours an url can be created in. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Absolute link with prefix (e.g.static final int
Absolute link without prefix (e.g.static final List<UrlCreator.Mode>
Unmodifieable list of mode values, sorted by ordinal.static final int
relative link (e.g. "../.. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanUp()
Callback for clean up, called when the instance is not longer used.getFilename
(ContentProducer contentProducer, TemplateSet templateSet, Language language, PageParams pageParams) The complete file name (relative to content root) where the produced content of the providedcontentProducer
will be stored.getFilename
(Media media, Language language, Resolution resolution) The complete file name (relative to content root) where the produced content of the providedmedium
will be stored.getFilename
(String pluginName, String filename, @Nullable String extension, @Nullable Language language) The complete path (relative to content root) where the produced content of the providedtype
will be stored.getUrl
(@NotNull Media media, @Nullable Language language, @Nullable Resolution resolution, int mode) Get the url for the specified medium (for the specified language and resolution).getUrl
(ContentProducer node, Language language, TemplateSet templateSet, PageParams pageParams, int mode) Get the url for the specified page in the specified language.getUrl
(String pluginName, String filename, @Nullable String extension, @Nullable Language language, int mode) Get the url for the provided combination oftype
,name
,extension
, andlanguage
.@Nullable String
Get the url prefix for absolute urls.Methods inherited from interface de.espirit.firstspirit.access.UrlCreator
getFilename, init, setUrlPrefix
-
Field Details
-
MODES
Unmodifieable list of mode values, sorted by ordinal.- Since:
- 5.0.3
-
RELATIVE_URL
static final int RELATIVE_URLrelative link (e.g. "../../foo/bar.html").- Since:
- 5.0.3
-
ABSOLUTE_URL
static final int ABSOLUTE_URLAbsolute link with prefix (e.g. "http:/domain.com/foo/bar.html").- Since:
- 5.0.3
-
ABSOLUTE_URL_NO_PREFIX
static final int ABSOLUTE_URL_NO_PREFIXAbsolute link without prefix (e.g. "/foo/bar.html").- Since:
- 5.0.3
-
-
Method Details
-
getUrlPrefix
Get the url prefix for absolute urls. Not every url creator has an url prefix.- Specified by:
getUrlPrefix
in interfaceUrlCreator
- Returns:
- the url prefix for absolute urls.
- Since:
- 4.0.17
- See Also:
-
getFilename
String getFilename(ContentProducer contentProducer, TemplateSet templateSet, Language language, PageParams pageParams) The complete file name (relative to content root) where the produced content of the providedcontentProducer
will be stored.
See the comment for file name methods.- Parameters:
contentProducer
- node.templateSet
- template set.language
- language.pageParams
- the page params.- Returns:
- A file name including path.
- Since:
- 5.0.3
-
getUrl
String getUrl(ContentProducer node, Language language, TemplateSet templateSet, PageParams pageParams, int mode) Get the url for the specified page in the specified language. Ifmode
isUrlCreator.Mode.RELATIVE_URL
the url is relative to the actual node provided byGenerationContext
(which is set in methodUrlCreator.init(GenerationContext)
). The returned url must match the filename produced bygetFilename(de.espirit.firstspirit.access.store.ContentProducer, de.espirit.firstspirit.access.project.TemplateSet, Language, PageParams)
getFilename(..)} with the same parameter set.- Specified by:
getUrl
in interfaceUrlCreator
- Parameters:
node
- node.language
- language.templateSet
- template set.pageParams
- page params, containing e.g. the content id to which is linked.mode
- seeUrlCreator.Mode
.- Returns:
- The produced url.
- Since:
- 4.1
- See Also:
-
getFilename
The complete file name (relative to content root) where the produced content of the providedmedium
will be stored.
See the comment for file name methods.- Specified by:
getFilename
in interfaceUrlCreator
- Parameters:
media
- the media object.language
- the language instance.resolution
- the resolution instance.- Returns:
- A file name including path.
- Throws:
IOException
- if the backend throws an io exception.- Since:
- 4.0.17
- See Also:
-
getUrl
String getUrl(@NotNull @NotNull Media media, @Nullable @Nullable Language language, @Nullable @Nullable Resolution resolution, int mode) throws IOException Get the url for the specified medium (for the specified language and resolution). The returned url must match the filename produced bygetFilename(..)
with the same parameter set.- Specified by:
getUrl
in interfaceUrlCreator
- Parameters:
media
- the media nodelanguage
- may benull
(for language independent media)resolution
- may benull
(for files)mode
- seeUrlCreator.Mode
- Returns:
- the url
- Throws:
IOException
- if the backend throws an io exception.- Since:
- 4.0.17
- See Also:
-
getFilename
String getFilename(String pluginName, String filename, @Nullable @Nullable String extension, @Nullable @Nullable Language language) The complete path (relative to content root) where the produced content of the providedtype
will be stored. The (unique) pluginName usually will be mapped to a directory, the uniqueness of the provided combination offilename
,extension
, andlanguage
must be guaranteed by the caller.
See the comment for file name methods.- Specified by:
getFilename
in interfaceUrlCreator
- Parameters:
pluginName
- (Unique) plugin name.filename
- filename of the file.extension
- extension of the file - may benull
if file has no extension.language
- language of the file - may benull
.- Returns:
- A file filename including path.
- Since:
- 4.0.120
- See Also:
-
getUrl
String getUrl(String pluginName, String filename, @Nullable @Nullable String extension, @Nullable @Nullable Language language, int mode) Get the url for the provided combination oftype
,name
,extension
, andlanguage
. The returned url must match the filename produced bygetFilename(..)
for the same combination.- Specified by:
getUrl
in interfaceUrlCreator
- Parameters:
pluginName
- (Unique) plugin name.filename
- file name of the file.extension
- extension of the file - may benull
if file has no extension.language
- language of the file - may benull
.mode
- seeEnum.ordinal()
.- Since:
- 4.0.17
- See Also:
-
cleanUp
void cleanUp()Callback for clean up, called when the instance is not longer used.- Specified by:
cleanUp
in interfaceUrlCreator
- Since:
- 4.0.63
-