Installing the Contextual Image Delivery Java Web filter

The Web filter enables you to make use of the Contextual Image Delivery proxy, which forwards requests to the Contextual Image Delivery microservice.

Procedure

  1. Access your installation media and navigate to the folder Content Delivery\roles\.
  2. Navigate to cid\proxy\java\.
  3. Access the config\ subfolder and merge the contents of the XML files with the corresponding XML files in the WEB-INF/classes/ folder of your Web application.
  4. Copy all files from the lib\ subfolder to your Web application library location, WEB-INF\lib\.
  5. If you want to run the image transformer against a customized URL, access the WEB-INF/classes/ folder of your Web application.
  6. Open cd_ambient_conf.xml for editing.
  7. In the <ExcludedPaths> section, add a subelement <Path>/CUSTOM/PATH</Path>, where /CUSTOM/PATH refers to the customized URL that you want the image transformer to run against.
  8. Save and close cd_ambient_conf.xml.
  9. In the WEB-INF/ folder of your Web application, open web.xml for editing.
  10. Create a new filter section with the following contents (you can also copy-paste this section from the file Content Delivery\roles\cid\proxy\deployment-descriptor\web.xml on the installation media):
    <filter>
      <filter-name>CID filter</filter-name>
      <filter-class>com.sdl.delivery.image.filter.ContextualImageFilter</filter-class>
    </filter>
  11. Create a new filter-mapping section with the following contents (you can also copy-paste this section from the file Content Delivery\roles\cid\proxy\deployment-descriptor\web.xml on the installation media):
    <filter-mapping>
      <filter-name>CID filter</filter-name>
      <url-pattern>/CUSTOM/PATH/*</url-pattern>
    </filter-mapping>

    where /CUSTOM/PATH refers to the customized URL that you want the image transformer proxy filter to run against. If you do not want to create a customized URL, set <url-pattern> to /cid/*.

  12. Save and close web.xml.
  13. In the WEB-INF/classes/ folder of your Web application, open cd_client_conf.xml for editing.
  14. Ensure that the file contains a root-level element called ServiceConfig that looks as follows:
    <ServiceConfig
      ConnectionTimeout="TIMEOUT"
      CacheEnabled="CACHE_ENABLED"
      CacheExpirationDuration="CACHE_EXP"
      ServiceAvailabilityCheck="SERVICE_CHECK">
      <DiscoveryService ServiceUri="URI" />
      <TokenService ClientId="USERNAME" ClientSecret="PASSWORD" />
    </ServiceConfig>
    where:
    • TIMEOUT is the amount of time in milliseconds after which a connection to the Discovery Endpoint times out. A good default value would be 10000 (that is, 10 seconds).
    • CACHE_ENABLED is true if you intend to cache information retrieved from the Discovery Endpoint. Set this to true unless you have a pressing reason to disable it.
    • CACHE_EXP is the amount of time in seconds after which the cache expires. A good default value would be 600 (that is, 600 seconds or 10 minutes).
    • SERVICE_CHECK is true if the client should check if the service is available.
    • URI is the URL of the Discovery Endpoint.
    • USERNAME and PASSWORD are valid Token Service credentials that grant the client access to the Discovery Endpoint. You can find valid credentials in the Ambient Data Framework configuration file, cd_ambient_conf.xml, of the Discovery Service. USERNAME must be a user who assumes the cd role; by default, that user is called cduser. Note also that the value of ClientSecret must be an encrypted value.
  15. If your Web application server is WebSphere, use the WebSphere administrative console to instruct your Web module classloaders to search for classes in the application first. To do so, set the Web module classloader mode to the value PARENT_LAST. For more information, refer to the following WebSphere documentation resource: Administer classloaders using the WebSphere administrative console.
  16. Start or restart the Web application.