Introduction
The "jcr system view" xml format is difficult to work with in typical team source control cases, such as diffing and merging.
The xml format is hard to read and perform manual edits on which is not an uncommon task in project development.
MAGNOLIA-6683
-
Getting issue details...
STATUS
.
JCR document view
Mikaël Geljić: JCR specifies the Document View, specifically providing a human-readable serialization. This should be fairly easy to work with, diff/merge.
This format is legit bootstrap and works in Magnolia / Jackrabbit out of the box.
website.sportstation.documentView.xml
works out of the box
still XML with meta information (can be omitted/filtered out?)
YAML
same format for light development
/
no meta information, easy to read (but this should not be a replacement for XML bootstrap files, just an easy to alternative, right?)
What do we need?
Export
Node → Raw view → YAML
- allow to export non registry items as YAML
- implement helper for importing yaml content into a workspace
- slightly custom n2b transformer (OR a custom node wrapper?) due to the node type information (JCR properties are filtered out by default)
- nodeName(mgnl:page) vs nodeName/jcrNodeType=mgnlPage
- slightly custom n2b transformer (OR a custom node wrapper?) due to the node type information (JCR properties are filtered out by default)
Import
Implementation
N2B
N2B Transformer specifies getChildren() method but filtering of properties is hardcoded. We need at least jcr:primaryType and jcr:uuid for export (and we probably want to support all of those). A solution is to introduce N2BTransformer.getProperties() in the same fashion as getChildren().
DefinitionRawViewToYamlConverter
- Components 0 and 00
- YAML reader considers both '0' and '00' as number 0
Resulting in only one of those nodes added
- Solution: enclose non simple propeties into apostrophes:
Resulting in only one of those nodes added
'0': hideTeaserImage: true '00': headline: 'Careers'
- Data types
- YAML supports numbers, dates and binaries
- dates has to be in certain format
!!binary R0lGODlhDAAMAIQAAP//9/X=- SnakeYaml reads it as byte[]
- explicit vs. implicit annotation
!!str 2002-04-28
- YAML supports numbers, dates and binaries
Commands
- Overrides impl of import and download as YAML commands.
- Location?
- It's using tools from magnolia-configuration but it's not about a content a configuration anymore
- Still place it to magnolia-configuration
- content-importer
- It's using tools from magnolia-configuration but it's not about a content a configuration anymore
jcr:name: page Binary: !!binary QmluYXJ5 Date: 2017-03-09T10:27:58.617+01 Double: 1.0 Name: !Name 'mgnl:contentNode' Path: !Path '/page' Reference: !Reference 'cafebabe-cafe-babe-cafe-babecafebabe' URI: !URI '/page' WeakReference: !WeakReference 'cafebabe-cafe-babe-cafe-babecafebabe' jcr:primaryType: !Name 'mgnl:contentNode' jcr:uuid: '76207274-03f9-4aca-b587-5cfc2ecd1763' mgnl:created: 2017-03-09T10:27:58.615+01 mgnl:createdBy: 'anonymous' mgnl:lastModified: 2017-03-09T10:27:58.615+01 mgnl:lastModifiedBy: 'anonymous' propertyName: 'propertyValue' '00': jcr:primaryType: !Name 'mgnl:content' jcr:uuid: '20cfdb2b-fb33-45f2-b5e4-d8d90455d938' mgnl:created: 2017-03-09T10:27:58.619+01 mgnl:createdBy: 'anonymous' mgnl:lastModified: 2017-03-09T10:27:58.619+01 mgnl:lastModifiedBy: 'anonymous' '0': childProperty: ['child:PropertyValue1', 'childPropertyValue2'] jcr:primaryType: !Name 'mgnl:content' jcr:uuid: '1a481550-e2f8-402f-8d15-044c5157a598' mgnl:created: 2017-03-09T10:27:58.620+01 mgnl:createdBy: 'anonymous' mgnl:lastModified: 2017-03-09T10:27:58.620+01 mgnl:lastModifiedBy: 'anonymous'
4 Comments
Christopher Zimmermann
An advantage of YAML is that it is very comfortable for developers to work with.
Christopher Zimmermann
JSON is also valid YAML. Developers very often work with content or mock content in json files. Does the implementation researched also accept JSON? This would be great.
Ilgun Ilgun
Document view does not support multi values.
Once upon a time, I wrote a document regarding that.
Roman Kovařík
Thanks for the input. We decided to continue with the YAML format.