]
Peter Palaga updated GTNPORTAL-3501:
------------------------------------
Status: Resolved (was: Pull Request Sent)
Fix Version/s: 3.8.2.Final
3.9.0.Final
Resolution: Done
Introduce XML schema validation for gatein-resources.xml
--------------------------------------------------------
Key: GTNPORTAL-3501
URL:
https://issues.jboss.org/browse/GTNPORTAL-3501
Project: GateIn Portal
Issue Type: Task
Security Level: Public(Everyone can see)
Reporter: Peter Palaga
Assignee: Peter Palaga
Fix For: 3.8.2.Final, 3.9.0.Final
There are several lines of code that indicate that
{{org.exoplatform.commons.xml.XMLValidator}} was originally designed to check if a given
document complies with an XML schema declared in it:
{code:java}
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schema...;,
"http://www.w3.org/2001/XMLSchema");
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schema...;,
schemas);
factory.setNamespaceAware(true);
factory.setValidating(true);
{code}
However, there were no tests checking if the validation works and indeed, it does not. It
is out of the present scope to investigate what is wrong with {{XMLValidator}} and how it
can be corrected, because it is too general to be used for validating
{{gatein-resources.xml}} at this point. The main problem is that if we have not validated
so far, there must be a lot of schema-incompatible {{gatein-resources.xml}} out there in
the wild that were silently accepted by the portal in the past. Therefore, we cannot start
validating all {{gatein-resources.xml}} files now.
To meet the natural expectation that inputs are properly validated to widest possible
extent, I propose to start validating now, but only {{gatein-resources.xml}} documents
that use the namespace {{http://www.gatein.org/xml/ns/gatein_resources_1_5}} or newer.
{{gatein_resources_1_5.xsd}} will be introduced these days with fixing
GTNPORTAL-3485 and GTNPORTAL-3487. In this way we can stay backwards-compatible and start
validating from now on.