Class ContentService

java.lang.Object
org.ctan.site.services.content.ContentService

public class ContentService extends Object
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
 
  • Constructor Details

    • ContentService

      public ContentService(@NonNull @NonNull CtanConfiguration.ContentConfig config, @NonNull @NonNull CtanConfiguration.CtanConfig ctanConfig)
      This is the constructor for the class ContentService.
      Parameters:
      config - the content configuration
      ctanConfig - the CTAN configuration
  • Method Details

    • findTeaser

      public Path findTeaser(ContentService.TeaserType type, @NonNull @NonNull String key)
      The method findTeaser provides means to check whether a teaser image exists.
      Parameters:
      type - the type
      key - the key of the package
      Returns:
      true iff the teaser image could be found
    • getImage

      public byte[] getImage(String path) throws IOException
      Find an image file.
      Parameters:
      path - the path
      Returns:
      the image
      Throws:
      IOException - in case of an I/O error
    • getImageType

      public String getImageType(String path)
      Map the image name to the file type.
      Parameters:
      path - the path
      Returns:
      the file type or null
    • getPage

      public ContentService.ContentPageTo getPage(@NonNull @NonNull String path, String lang) throws IOException
      The method getPage provides means to retrieve a page.
      Parameters:
      path - the path in the content workspace; i.e. relative to the base directory
      lang - the ISO language code consisting of two lower-case letters
      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 method getPageList provides means to retrieve a directory listing.
      Parameters:
      lang - the ISO language code consisting of two lower-case letters
      path - 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 method getPageTree provides means to retrieve a tree of pages.
      Parameters:
      lang - the locale
      path - the path
      depth - the maximal depth
      Returns:
      the tree
      Throws:
      IOException - in case of an I/O error
    • getPublications

      public Map<String,String> getPublications(String lang) throws IOException
      The method getPublications provides means to TODO gene.
      Parameters:
      lang - the language
      Returns:
      a map with the values
      Throws:
      IOException
    • getTeaser

      public byte[] getTeaser(@NonNull @NonNull ContentService.TeaserType type, @NonNull @NonNull String key) throws IOException
      The method getPkgTeaser provides means to read a teaser image.
      Parameters:
      type - the type of the teaser
      key - the key of the package
      Returns:
      the teaser image
      Throws:
      IOException - in case of an I/O errors
    • getTeaserCopyright

      public String getTeaserCopyright(ContentService.TeaserType type, @NonNull @NonNull String key)
      The method hasTeaserCopyright provides means to get the copyright for a teaser image.
      Parameters:
      type - the type
      key - the key of the package
      Returns:
      null iff the teaser copyright could not be found
    • getText

      public ContentService.ContentPageTo getText(@NonNull @NonNull String path, String lang) throws IOException
      The method getText provides means to retrieve a text fragment.
      Parameters:
      path - the path in the content workspace; i.e. relative to the base directory
      lang - the ISO language code consisting of two lower-case letters
      Returns:
      the page or null
      Throws:
      IOException - in case of an I/O error
    • hasTeaser

      public boolean hasTeaser(ContentService.TeaserType type, @NonNull @NonNull String key)
      The method hasTeaser provides means to check whether a teaser image exists.
      Parameters:
      type - the type
      key - the key of the package
      Returns:
      true iff the teaser image could be found