Class MCRViewerConfiguration

java.lang.Object
org.mycore.viewer.configuration.MCRViewerConfiguration
Direct Known Subclasses:
MCRViewerAltoEditorConfiguration, MCRViewerBaseConfiguration, MCRViewerLogoConfiguration, MCRViewerMetadataConfiguration, MCRViewerPiwikConfiguration

public class MCRViewerConfiguration extends Object
Base class for the iview client configuration. You can add properties, javascript files and css files. To retrieve the configuration in xml call toXML(). To get it in json call toJSON().
Author:
Matthias Eichner
  • Constructor Details

    • MCRViewerConfiguration

      public MCRViewerConfiguration()
  • Method Details

    • getProperties

      public Map<String,Object> getProperties()
      Returns the properties of this configuration.
      Returns:
      map of all properties set in this configuration
    • getResources

      public com.google.common.collect.Multimap<MCRViewerConfiguration.ResourceType,String> getResources()
      Returns a multimap containing all resources (javascript and css url's).
      Returns:
      map of resources
    • setup

      public MCRViewerConfiguration setup(jakarta.servlet.http.HttpServletRequest request)
      Setup's the configuration with the request.
      Parameters:
      request - the request which should be parsed to build this configuration.
      Returns:
      itself
    • isDebugMode

      public static boolean isDebugMode(jakarta.servlet.http.HttpServletRequest request)
      Returns true if the debug/developer mode is active.
      • URL parameter iview2.debug = true
      • MCR.Viewer.DeveloperMode property = true
      Parameters:
      request - the request to check the iview2.debug parameter
      Returns:
      true if the debug mode is active, otherwise false
    • getDerivate

      public static String getDerivate(jakarta.servlet.http.HttpServletRequest request)
      Helper method to get the derivate id of the given request. Returns null if no derivate identifier could be found in the request object.
      Parameters:
      request - http request
      Returns:
      the derivate id embedded in the path of the request
    • getFilePath

      public static String getFilePath(jakarta.servlet.http.HttpServletRequest request)
      Helper method to get the path to the start file. The path is URI decoded and starts with a slash.
      Parameters:
      request - http request
      Returns:
      path to the file or null if the path couldn't be retrieved
    • addScript

      public void addScript(String url)
      Adds a new javascript file which should be included by the image viewer.
    • addLocalScript

      public void addLocalScript(String file)
      Shorthand MCRViewerConfiguration#addLocalScript(String, true, false)
      Parameters:
      file - the local javascript file to include
    • addLocalScript

      public void addLocalScript(String file, boolean hasMinified)
      Shorthand MCRViewerConfiguration#addLocalScript(file, hasMinified, false)
      Parameters:
      file - the local javascript file to include
      hasMinified - is a minified version available
    • addLocalScript

      public void addLocalScript(String file, boolean hasMinified, boolean debugMode)
      Adds a local (based in modules/iview2/js/) javascript file which should be included by the image viewer. You should always call this method with the base file version. E.g. addLocalScript("iview-client-mobile.js");.

      This method uses the minified (adds a .min) version only if hasMinified is true and debugMode is false.

      .
      Parameters:
      file - the local javascript file to include
      hasMinified - is a minified version available
      debugMode - if the debug mode is active or not
    • addCSS

      public void addCSS(String url)
      Adds a new css file which should be included by the image viewer.
      Parameters:
      url - the url to add e.g. baseURL + "modules/iview2/css/my.css"
    • addLocalCSS

      public void addLocalCSS(String file)
      Adds a local (based in modules/iview2/css/) css file.
      Parameters:
      file - to include
    • setProperty

      public void setProperty(String name, Object value)
      Sets a new property.
      Parameters:
      name - name of the property
      value - value of the property
    • removeProperty

      public Object removeProperty(String name)
      Removes a property by name.
      Parameters:
      name - name of the property which should be removed
      Returns:
      the removed value or null when nothing is done
    • toJSON

      public String toJSON()
      Returns the configuration in json format.
      Returns:
      json the configuration as json string
    • toXML

      public MCRXMLContent toXML() throws jakarta.xml.bind.JAXBException
      Returns the configuration in xml content format.
      Returns:
      the configuration as xml content
      Throws:
      jakarta.xml.bind.JAXBException