Magnolia 5.7 reached extended end of life on May 31, 2022. Support for this branch is limited, see End-of-life policy. Please note that to cover the extra maintenance effort, this EEoL period is a paid extension in the life of the branch. Customers who opt for the extended maintenance will need a new license key to run future versions of Magnolia 5.7. If you have any questions or to subscribe to the extended maintenance, please get in touch with your local contact at Magnolia.
The content you manage in Magnolia is typically stored in the JCR repository, but it doesn't have to be. A content connector defines where the content resides. With a content connector you can decouple content management from content storage. You can store content in a database, cloud storage or a Web service. You can create a connector that lets authors choose image assets from Flickr, for example. Authors benefit as they can manage all content in familiar Magnolia content apps. They don't have to leave Magnolia just because the content resides somewhere else.
Implementing a content connector
In technical terms, a content connector is a bridge to a data source. It allows you to access content outside the JCR repository.
The interface defines APIs that map arbitrary objects to three representations:
- A unique identifier known as itemId.
- A Vaadin
Item
that you can use in a detail form, for example. - A unique String representation that the content app uses as a location fragment.
A content app does not fetch data directly from the content connector but from a Vaadin Container
. In your content app you need to also provide content views (tree, list) that work with the container. These views and their presenter classes are configured in the workbench definition.
If required, you can inject your own content connector in the constructor of your class. Content connector has its own provider: info.magnolia.ui.contentapp.contentconnector.ContentConnectorProvider
. The provider creates one instance of a connector per subapp by default.
The Content app with non-JCR content tutorial explains how to implement a non-JCR content app, including a custom content connector.
Content connector definition
A connector definition specifies the data source. In case of a JCR connector, the definition requires you to specify a workspace and a path in that workspace. Each content app subapp must provide its own content connector definition. If you implement your own connector, extend info.magnolia.ui.vaadin.integration.contentconnector.ContentConnectorDefinition
.
subapps: browser: contentConnector: class: info.magnolia.ui.vaadin.integration.contentconnector.JcrContentConnectorDefinition implementationClass: info.magnolia.ui.vaadin.integration.contentconnector.JcrContentConnector
Node name | Value |
---|---|
subApps | |
browser | |
contentConnector | |
class | info.magnolia.ui.vaadin.integration.contentconnector.JcrContentConnectorDefinition |
implementationClass | info.magnolia.ui.vaadin.integration.contentconnector.JcrContentConnector |
Properties:
class | optional, default is Definition class. Only needed if you implement your own, non-JCR content connector. If you store content in the JCR repository this property is not needed but you need to define a number of other properties. See the JCR content connector example below. The value must be a fully-qualified class name. Examples of definition classes:
|
implementationClass | optional, default is Implementation class that implements the |
Example: JCR content connector
JCR content apps have at least two subapps. A browser subapp displays items and a detail subapp edits them. Both subapps need their own connector definition.
We highly recommend using the same
rootPath
in both the detail and browser sub-apps, to benefit from our standard set of actions provided out of the box.
browser subapp
A JCR content connector definition introduces properties that identify a JCR workspace as a data source. It also defines the node types to operate on.
subapps: browser: contentConnector: defaultOrder: jcrName includeProperties: false rootPath: / workspace: contacts nodeTypes: - name: mgnl:contact icon: icon-user-public
Node name | Value |
---|---|
subApps | |
browser | |
contentConnector | |
nodeTypes | |
contact | |
icon | icon-user-public |
name | mgnl:contact |
defaultOrder | jcrName |
includeProperties | false |
rootPath | / |
workspace | contacts |
Properties:
| required List of node types the content connector operates on. For example, the connector in the Contacts app displays contacts and folders. |
| required Arbitrary node name such as |
| required Node type the connector operates on. These are Magnolia or JCR node types such as |
| optional , default is none CSS class name of the icon displayed on the workbench. See the default icons that ship with Magnolia or create your own. |
| optional Specifies whether to include only the exact node type and ignore subtypes. |
| optional Specifies whether to display the current node in list view and and search results. Use this property to, for example, exclude folders. |
| required A workspace in the |
| optional Default sort order for the content items in list views. The value is the name of the property you want to sort by, such as |
| optional, default is Displays also the JCR properties of the node when set to |
| optional , default is Displays also nodes used by the system such as nodes internal to the operations of the JCR implementation. Set to |
| optional , default is Path configured as the root of the workspace. Only content below the path is operated on. |
detail subapp
The connect definition for a detail subapp is much simpler. You only need to define the workspace.
subapps: detail: contentConnector: workspace: contacts
Node name | Value |
---|---|
subApps | |
detail | |
contentConnector | |
workspace | contacts |
Example: non-JCR content connector
This is an example content connector definition for a content app that manages files on the local file system. This is a simplified example.
subApps: browser: contentConnector: class: info.magnolia.filesystembrowser.app.contentconnector.FSContentConnectorDefinition rootFolder: /Users/jsmith/Documents/magnolia
Node name | Value |
---|---|
fs-browser-app | |
apps | |
fs-browser | |
subApps | |
browser | |
contentConnector | |
class | info.magnolia.filesystembrowser.app.contentconnector.FSContentConnectorDefinition |
rootFolder | /Users/jsmith/Documents/magnolia |
Credits:
- Database icon by Anton Outkine from The Noun Project
- Cloud icon by Edward Boatman from The Noun Project