Developers · Installation¶
What you get¶
One JAR — com.habito1:h1-sites — containing:
- 1 light module:
h1-sites-light-module, with the content type, the app, the REST endpoint registration, the MCP tool registration and the i18n bundle (default,en,es). - 3 singleton components registered in the module descriptor:
SiteRepository(implemented byJcrSiteRepository),SiteMapperandSiteService. - 1 REST resource —
SiteController— under/.rest/v1/sites, with six operations (list, get by id, resolve, create, update, delete). - 1 content app (
h1-sites-app) over 1 content type (h1-site) and 1 JCR workspace (h1-sites, created on first start byautoCreate: true). - 1 MCP tool (
site), active only whenh1-mcp-apiis present.
Maven coordinates¶
<dependency>
<groupId>com.habito1</groupId>
<artifactId>h1-sites</artifactId>
<version>1.0.1-SNAPSHOT</version>
</dependency>
Deploy¶
- Add the dependency to your webapp POM.
h1-helperstravels with it as acompiledependency; you do not declare it yourself unless you want to pin its version. - Build and deploy the WAR as usual.
- Start the instance. On first start the module creates the
h1-sitesworkspace and the version handler grants thesuperuserrole full access to it (see Upgrading). - Check Tools › Modules for
h1-sitesand confirm the version. - Place the app in a launcher group of your own. The module registers
h1-sites-appand ships the group label (app-launcher.h1sites.label), but it does not add the group, so on a fresh instance the app installs correctly and still does not appear in AdminCentral.
Wiring you have to do¶
The module ships the content type, the app, the REST resource and the MCP tool. It cannot guess where in your project they belong.
1. Decide how the front end authenticates¶
The resolution call runs on every page request of a headless front end. Either call it with Basic Auth credentials, or grant the anonymous user read access to the workspace — see Permissions. There is no third option built into the module: it does not expose a public URL of its own.
2. Create the first site¶
Nothing resolves until at least one site exists with a Root Page and at least one row in Domains (regex). A site with no domain rows is never matched.
Permissions¶
The REST resource is read by whoever the front end authenticates as. When the front end calls it anonymously — and on a public instance it usually does — grant anonymous read access to:
| Workspace | Needed for |
|---|---|
h1-sites |
Every REST operation of this module. It is also the workspace h1-seo reads, in the request's own session, to fill in the organization type, the default social image and the social profiles of its structured data. |
Warning — a missing ACL does not surface as an error.
GET /v1/sitesreturns an empty array,getSitereturns404, andh1-seoquietly drops the site globals from its structured data rather than failing. If something is silently empty in production but fine on author, suspect the ACL before suspecting the code.
Verify the installation¶
# Every site
curl -s http://localhost:8080/magnoliaAuthor/.rest/v1/sites
# Resolve by domain
curl -s "http://localhost:8080/magnoliaAuthor/.rest/v1/sites/getSite?domain=www.habito1.com"
# Resolve by root page, the fallback a front end uses when the host matches nothing
curl -s "http://localhost:8080/magnoliaAuthor/.rest/v1/sites/getSite?rootWebsite=/h1"
[] from the first call is a valid answer: the module is installed and the workspace is readable,
there are simply no sites yet. A 404 from getSite means no site claimed that domain — check the
patterns and the order before assuming the module is broken. A 400 means neither domain nor
rootWebsite was sent.
Upgrading¶
The version handler applies these deltas:
| Version | Delta |
|---|---|
1.0.1 |
Grants the superuser role ALL on / of the h1-sites workspace. |