Category Archives: Mint2

Cross domain requests

I created a CrossDomainPage action to use for cross domain AJAX requests in the browser. It gets a URL in the url parameter, makes a request to that URL and copies the results to the crossdomain.jsp (through the html attribute).

You can make a cross domain request from the browser by using the Mint2.crossDomainPage function like this:

Mint2.crossDomainPage("http://the.url.com", function(response) {
    // This is a callback that gets the results in the response variable
});

PS. I thought I needed it for the documentation functions, but I didn’t use it after all. If we ever need such a functionality, we can build on that.

XSD schema setup

When setting up a new XSD schema, Mint 2 executes the following steps:

  1. Gets the requested XSD from a path relative to paths.schemas directory defined in mint.properties.
  2. Looks for available configuration in the same directory as of the XSDs, with the same name plus the .conf suffix (If such a file does not exist, it attempts to generate basic configuration properties automatically).
  3. Parses the XSD and generates a mapping template based on the schema configuration file. This template is stored in the jsonOriginal property of the XmlSchema database object.
  4. Parses annotations in the XSD to generate schema documentation, available in the mapping editor. The result is stored in the schema’s documentation property.
  5. If a customization Groovy script is defined in the configuration file (through the customization property), it loads the script and runs it with this mapping template as input. The result is stored in the jsonTemplate property, which is used to create a new mapping. If no script is defined, jsonOriginal is copied in jsonTemplate.

This process is controlled from the Home>Administration>Manage XSDs page, which uses the OutputXSD action and schemasummary.jsp. Already processed schemas appear there with the following control options:

  • Rename schema. Use this to rename the schema entry.
  • Reload for mapping. Use this if the XSD has changed and you want to start the process from the beginning.
  • Reapply configuration. Use this if only the schema configuration or the customization Groovy script have changed and you want to reconfigure the mapping template. It will use the already stored template in jsonOriginal and will take significantly less time since it will not parse the XSD schema. Note that if the item configuration property has changed then you have to use the Reload option because parsing is needed to generate a template for the new item root.
  • View XSD. Shows the filename of the XSD.
  • View schema configuration properties. View configuration properties stored in the database for this schema. These are also used by mappings at all times (even if created before this version of the configuration file was loaded).
  • View original template. View the mapping template generated by the parser, before any customization applied.
  • View customized template. View the customized mapping template that is used to create a new mapping.
  • Edit template. This is an experimental feature to allow editing of the customized jsonTemplate using the mapping editor. Currently it is possible to modify the template, but changes will be lost if you reapply configuration.

Mint2 local.properties for local configuration

In order to avoid mint.properties cluttering of test configuration properties, I modified the Config class to support an additional properties file called local.properties. Properties in local.properties have higher priority than custom.properties (which have higher priority than mint.properties). They should not be submitted to the SVN repository and they should be used for local tests during development. They are not required for a Mint2 installation and they will be ignored if missing or empty.

Parameters support in schema’s preview configuration

A schema’s preview configuration now supports XSL parameters. This was implemented to support, for example, the provider parameter in LIDO to ESE XSL. Parameters are currently supported only in preview tabs that have an ‘xsl‘ field. In order to add parameters, a new JSON array called ‘parameters‘ is used in the preview configuration for the specific preview tab. This array contains parameter objects with three fields:

  • name: The parameter name.
  • value: Controls the value of the parameter in the XSL, based on the parameter type (see below)
  • type: Type of the parameter. Currently supports two options:
    • constant: Constant value parameters. The parameter will always have the value of the ‘value‘ field.
    • mint: Mint defined parameters. The parameter will have the value of the mint property specified by the ‘value‘ field.

An example of the parameter’s configuration, from lido-v1.0-proxy.xsd.conf:

{
    "xsl": "lido-v1.0-to-ese-v3.4-transform-v3.xsl",
    "parameters": [
            {
                "name": "provider",
                "type": "mint",
                "value": "mint.provider"
            }
    ], 
    "label": "ESE",
    "output": "xml"
}