Package org.ctan.site.services.content
Class ContentService
java.lang.Object
org.ctan.site.services.content.ContentService
The class
ContentService
contains the service to access the
content area. There pages and assets are stored.
Pages
The pages are HTML files. Only the title section and the body are extracted.
<title>the title</title> <body> the body </body>
Images
The images are taken from the sub-directory images/
of the base
directory.
Configuration
ctan: languages: - en - de content: directory: /serv/www/www.ctan.org/ctan-content
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
The classContentPageListTo
contains the transport object for an entry in the page list.static class
The classContentPageTo
contains the transport object for a page.static class
The classContentPageTreeTo
contains the transport object for a page tree.static enum
The enumTeaserType
contains types of supported teasers. -
Constructor Summary
ConstructorsConstructorDescriptionContentService
(@NonNull CtanConfiguration.ContentConfig config, @NonNull CtanConfiguration.CtanConfig ctanConfig) This is the constructor for the classContentService
. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
Find an image file.getImageType
(String path) Map the image name to the file type.The methodgetPage
provides means to retrieve a page.getPageList
(@NonNull String lang, @NonNull String path) The methodgetPageList
provides means to retrieve a directory listing.getPageTree
(String lang, @NonNull String path, int depth) The methodgetPageTree
provides means to retrieve a tree of pages.byte[]
getTeaser
(@NonNull ContentService.TeaserType type, @NonNull String key) The methodgetPkgTeaser
provides means to read a teaser image.The methodgetText
provides means to retrieve a text fragment.boolean
hasTeaser
(ContentService.TeaserType type, @NonNull String key) The methodhasTeaser
provides means to check whether a teaser image exists.
-
Constructor Details
-
ContentService
public ContentService(@NonNull @NonNull CtanConfiguration.ContentConfig config, @NonNull @NonNull CtanConfiguration.CtanConfig ctanConfig) This is the constructor for the classContentService
.- Parameters:
config
- the content configurationctanConfig
- the CTAN configuration
-
-
Method Details
-
getImage
Find an image file.- Parameters:
path
- the path- Returns:
- the image
- Throws:
IOException
- in case of an I/O error
-
getImageType
Map the image name to the file type.- Parameters:
path
- the path- Returns:
- the file type or
null
-
getPage
public ContentService.ContentPageTo getPage(String lang, @NonNull @NonNull String path) throws IOException The methodgetPage
provides means to retrieve a page.- Parameters:
lang
- the ISO language code consisting of two lower-case letterspath
- the path in the content workspace; i.e. relative to the base directory- Returns:
- the page or
null
- Throws:
IOException
- in case of an I/O error
-
getPageList
public ContentService.ContentPageTo getPageList(@NonNull @NonNull String lang, @NonNull @NonNull String path) throws IOException The methodgetPageList
provides means to retrieve a directory listing.- Parameters:
lang
- the ISO language code consisting of two lower-case letterspath
- the path in the content workspace; i.e. relative to the base directory- Returns:
- the page or
null
- Throws:
IOException
- in case of an I/O error
-
getPageTree
public ContentService.ContentPageTreeTo getPageTree(String lang, @NonNull @NonNull String path, int depth) throws IOException The methodgetPageTree
provides means to retrieve a tree of pages.- Parameters:
lang
- the localepath
- the pathdepth
- the maximal depth- Returns:
- the tree
- Throws:
IOException
- in case of an I/O error
-
getText
public ContentService.ContentPageTo getText(@NonNull @NonNull String path, String lang) throws IOException The methodgetText
provides means to retrieve a text fragment.- Parameters:
path
- the path in the content workspace; i.e. relative to the base directorylang
- the ISO language code consisting of two lower-case letters- Returns:
- the page or
null
- Throws:
IOException
- in case of an I/O error
-