Fixed
Details
Assignee
Steve EbersoleSteve EbersoleReporter
Steve EbersoleSteve EbersoleTime tracking
1.37h loggedComponents
Fix versions
Priority
Major
Details
Details
Assignee
Steve Ebersole
Steve EbersoleReporter
Steve Ebersole
Steve EbersoleTime tracking
1.37h logged
Components
Fix versions
Priority
Created January 24, 2014 at 2:45 PM
Updated May 5, 2022 at 11:09 AM
Resolved February 8, 2014 at 12:49 AM
was kind enough to outline the basic steps needed:
Parse the first bit of the XML document using StAX. StAX is used here as it only reads as much of the XML file as you request and can easily have validation disabled which you want for the first step.
Set up the Woodstox StAX parser for reading the first element: PortalDataKeyFileProcessor.java#L63
Read the first element and parse the type and version information from it: PortalDataKeyFileProcessor.java#L104
This code uses a bunch of custom StAX utility code that exists in org.jasig.portal.xml primarily to try and avoid ever reading from a file more than absolutely necessary. Not sure you'll need all of this extra logic since you're not parsing thousands or millions of files. You can simply re-create the StAX stream which is much simpler.
Update the XML if needed
Most updates can be done via XSLT if you're comfortable with it
Example of an XSLT based updater using StAX: XsltDataUpgrader.java
Example XSLT files for chained upgrades of an XML file: https://github.com/Jasig/uPortal/tree/master/uportal-war/src/main/resources/org/jasig/portal/io/xml/portlet
Example XML files for those XSLTs: https://github.com/Jasig/uPortal/blob/master/uportal-war/src/test/resources/org/jasig/portal/io/xml/portlet/
Look at the files whose name starts with test-portlet-1
You can see the upgrade path from 26 to 30 to 31 to 32 to 40
You now have the XML in the most recent format and do whatever validation you would do on it otherwise.
Some of this we already have in place, like the move to StAX and peeking at the version.