3.3.7Generator services
The generator service is a webservice that can serve files from filesystem, that can execute servlets compiled from jsp files and has access to the documents of the CMS service.
The GeneratorPreview is configured to have a preview of the web page before publishing the content. It also adds some features to help the editor finding the document to edit in or showing errors why the documents are not filled properly. Also it provides direct editing in the preview website.
The GeneratorLive is configured to show only published content.
Property file and property key paths are:
Service properties file
<cmsWorks-installdir>/run/properties/generator.properties
Service property key paths
/app/cmsworks/service/generator/GeneratorPreview/
/app/cmsworks/service/generator/GeneratorLive/
Entry | Value | Description |
Port | 8080 | The preview page is accessable over this port of the IP or Hostname of the server the cmsWorks instance is running on. |
Htdocs | ../htdocs/generator.std/ | This is the path in the filesystem where the static files and the jsp-files are located. The name ending with .std indicates that this is the standard preview of the website. |
CMSServiceName | CMSCore | This is the name of the service that provides access to CMS documents |
Preview | true | True if the documents from CMS may be only changed and not published yet. This switch also acitvates Features using UILinks and Errors presentation |
GenerationFolders | /en/;/de/ | Only these root paths are enabled as CMS folders where documents can be found to be generated. These paths have to be absolute beginning from root / |
GenerationConfigFile | ../htdocs/cmsworks.generator.configs/generatorconfig-std.txt | The content of this file configures which document types are allowed to be generated in combination with a contenttype defined by the extension (i.e. .html) |
IncludeHosts | search=localhost:8091 | If a generation needs to call other HTTP-Server instances (i.e. a search request) the servers host and port can be listed here. With this configuration the same JSP may call different hosts in different generators (with different configurations) or in different cmsWorks instances like dev/test/live instances. |
Here is a full example of the generator configuration:
# ###################################################################################
#
# Properties for the preview generator service
#
# ###################################################################################
# hook service /app/cmsworks/service/generator,Generator
# service create /app/cmsworks/service/generator,Generator,GeneratorPreview
/app/cmsworks/service/generator/GeneratorPreview/StartTimeout=10000
/app/cmsworks/service/generator/GeneratorPreview/StopTimeout=10000
/app/cmsworks/service/generator/GeneratorPreview/AccessTimeout=1000
/app/cmsworks/service/generator/GeneratorPreview/StopInformExtern=1
/app/cmsworks/service/generator/GeneratorPreview/LogLevel=fatal error info debug
/app/cmsworks/service/generator/GeneratorPreview/Port=8080
/app/cmsworks/service/generator/GeneratorPreview/Htdocs=../htdocs/generator.std/
/app/cmsworks/service/generator/GeneratorPreview/CMSServiceName=CMSCore
/app/cmsworks/service/generator/GeneratorPreview/Preview=true
/app/cmsworks/service/generator/GeneratorPreview/GenerationFolders=/en/;/de/
/app/cmsworks/service/generator/GeneratorPreview/GenerationConfigFile=../htdocs/cmsworks.generator.configs/generatorconfig-std.txt
/app/cmsworks/service/generator/GeneratorPreview/IncludeHosts=search=localhost:8091
# ###################################################################################
#
# Properties for the live generator service
#
# ###################################################################################
# # the service was hooked before
# service create /app/cmsworks/service/generator,Generator,GeneratorLive
/app/cmsworks/service/generator/GeneratorLive/StartTimeout=10000
/app/cmsworks/service/generator/GeneratorLive/StopTimeout=10000
/app/cmsworks/service/generator/GeneratorLive/AccessTimeout=1000
/app/cmsworks/service/generator/GeneratorLive/StopInformExtern=1
/app/cmsworks/service/generator/GeneratorLive/LogLevel=fatal error info
/app/cmsworks/service/generator/GeneratorLive/Port=8081
/app/cmsworks/service/generator/GeneratorLive/Htdocs=../htdocs/generator.std/
/app/cmsworks/service/generator/GeneratorLive/CMSServiceName=CMSPublished
/app/cmsworks/service/generator/GeneratorLive/Preview=false
/app/cmsworks/service/generator/GeneratorLive/GenerationFolders=/en/;/de/
/app/cmsworks/service/generator/GeneratorLive/GenerationConfigFile=../htdocs/cmsworks.generator.configs/generatorconfig-std.txt
/app/cmsworks/service/generator/GeneratorLive/IncludeHosts=search=localhost:8091
Configuration example of the Generator services for website generation
This example configuration thereby assumes that all JSPs, JSFs, static files... for the live generator and preview generator are similiar, thus the same folder for these two is configured.
generatorconfig-std.txt
This file (normally located in the folder <cmsWorks-installdir>/htdocs/cmsworks.generator.configs) configures which document types are allowed to be generated by the Generator. This file is only read once while starting the Generator service. So after updating the configuration the service should be restarted to read the updated file.
No documents are allowed to be generated until there is a declaration in the generatorconfig-std.txt. The declarations generally do not aim at a particular document but at document types.
Here is a full example of a generatorconfig-std.txt:
specialurl=/special/topdiashows.json, /en/diashows/index.html?jsp=json-topdiashows.jsp
doctype=article, .html, page-article.jsp
doctype=diashow, .html, page-diashow.jsp
doctype=diashow, .json, json-diashow.jsp
doctype=navigation, .html
blobtype=medium, data, blob.jsp
Example of generatorconfig-std.txt allowing the generation of CMS documents contents
The goal of this configuration is to create URLs with correct mime type to ending assignments. An HTML-Page will have the ending .html, An XML-Feed is ending with .xml and so on. Also it's hiding what kind of generating processes are behind the website.
So here is how it's done:
Any line beginning with # or // is a comment and therefor ignored.
doctype=article, .html, page-article.jsp
This line assigns the page-article.jsp to handle a request for a CMS document of type article ending with .html in the URL (i.e.: http://mywebsite/de/acategory/somearticle.html)
For the document type diashow there are two different assignments. If the URL is ending with .html the page-diashow.jsp will be called to generate. But if the URL is endining with .json the json-diashow.jsp is in use.
doctype=navigation, .html
At this declaration the assignment of a JSP is missing. This declaration only means, that generating with a document of the type navigation is basically allowed. Assuming there is a document of type navigation storing a structure of the websites navigation links it would be preferable to call the generation of a website navigation the same way for different website page types like articles, diashows, searchresult pages or others. So the JSP producing the navigation will not build a complete website but only the navigation part of the website. This is not a content for public access. This content is only included while executing page JSPs. So not to assign a JSP in the configuration is the way for declaring only includeable content. A programming example for such includes can be found in the programmers guide.
blobtype=medium, data, blob.jsp
This sepcial declaration assumes there is a document type medium with a blob property called data. If creating a URL to a document of type medium it targets the stored blob within the document. This blob has its own mime type and special URL-Ending. If a .txt file is uploaded into the document, the URL must be ending with .txt too. If a .jpg file is uploaded, the URL ends with .jpg too otherwise the generation is not called and the request will be responded with a 404 file not found error. Currently a document having only one property of type blob is allowed.
specialurl=/special/topdiashows.json, /en/diashows/index.html?jsp=json-topdiashows.jsp
This is the task: call the JSP json-topdiashows.jsp with a cms document but do not show that a JSP is used and what its name is. Use a special URL to address this JSP as a unique call. Declare the path of the document, the JSP is called with - this would usually be a homepage document that will never change its location or name. So with this specialurl declaration the use of a JSP is most effectively disguised and the JSP did not have to be assigned to a special document type.
