Features

This section will be about the features of Gentics Mesh. Each will be described in detail including examples and references to relevant parts of the API or related tutorials.

Content Trees

Gentics Mesh provides the means to organize your contents in terms of a content tree, or rather a node tree. Nodes can be hierarchically structured if a container schema is provided. For example, a book node can act as a container for chapter nodes. Alternatively, consider the example in our demo app, where vehicles are structured within categories.

While it is perfectly legitimate to organize your contents in a simple, flat structure with tagging and referencing, content trees come with big a bonus: they inherently allow for automatically generated hierarchical navigation menus, breadcrumbs and pretty URLs. This furthermore means routes are not hard-coded in your app but can be defined dynamically by content editors using the Gentics Mesh user interface.

To get you started, Gentics Mesh is shipped with a generic folder schema allowing you to follow the well-known file system paradigm for hierarchically organizing your content in a tree.

There are two properties when defining a schema for your nodes that are of importance in this respect.

  1. container: if true, nodes can contain child nodes and build a node tree.

  2. segmentField: allows to specify which schema field should be considered the path segment for the current node, i.e., it’s the basis for building URLs.

Let us consider the following example on the basis of our demo app to demonstrate how these properties work together to support navigation menus, breadcrumbs and pretty URLs:

Gentics Mesh Example of organizing content in a node tree

Within the demo project vehicles are organized in three different categories. The nodes Automobiles, Aircrafts and Yachts of type category serve as containers for nodes of type vehicle, e.g., the node Ford GT in category Automobiles.

The schema category has the container property set to true, thus allowing nodes of type category to have child nodes. The schema’s segmentField is specified to be the slug field. Thus, the resulting value for the path property of node Automobiles is /automobiles.

The schema vehicle has the container property set to false. The schema’s segmentField is again specified to be the slug field. Thus, the resulting value for the path property of node Ford GT is /automobiles/ford-gt.

Pretty URLs

Instead of relying on UUIDs to link your content, you can use pretty URLs like https://yourapp.com/automobiles/ford-gt. For each node, Gentics Mesh will provide you with a human readable path. Likewise, you can query your content using WebRoot paths instead of using UUIDs (see WebRoot API).

The segmentField is used to build the path of a specific node. According to the nodes’ schemas in our example, the path /automobiles/ford-gt for the node Ford GT is built using the slug field of the vehicle node, i.e. Ford GT, and the slug field of the category node, i.e. Automobiles.

Gentics Mesh Example for Building Pretty URLs

The path property as well as the languagesPath property (for available contents) of a node can be queried using the /api/v2/projectName/nodes/:nodeUuid endpoint together with the query parameter resolveLinks. Alternatively, the WebRoot API can be used /api/v2/:projectName/webroot/:path For more details see the documentation on node and WebRoot API, respectively.

You can also specify dedicated paths for nodes using the urlFields schema property. You can add string or string list fields to your schema and list them via the urlFields property. Gentics Mesh will utilize these fields in nodes in order to retrieve the node.

API endpoints

Description API endpoint

Get the node with the given UUID.

GET /api/v2/:projectName/nodes/:nodeUuid

Response Sample

{
  "uuid" : "fc3c85be82584ae2bc85be82588ae2b0",
  "creator" : {
    "uuid" : "e5861ba26b914b21861ba26b91ab211a"
  },
  "created" : "2018-02-23T16:30:44Z",
  "editor" : {
    "uuid" : "e5861ba26b914b21861ba26b91ab211a"
  },
  "edited" : "2018-03-16T15:28:04Z",
  "language" : "en",
  "availableLanguages" : {
    "en" : {
      "published" : true,
      "version" : "3.0",
      "publisher" : {
        "uuid" : "e5861ba26b914b21861ba26b91ab211a"
      },
      "publishDate" : "2018-03-16T15:28:04Z"
    }
  },
  "languagePaths" : {
    "en" : "/automobiles/ford-gt"
  },
  "parentNode" : {
    "projectName" : "demo",
    "uuid" : "ca6c7df3f45b48d4ac7df3f45ba8d42f",
    "displayName" : "Automobiles",
    "path" : "/automobiles",
    "schema" : {
      "name" : "category",
      "uuid" : "2ca2362b041247c4a2362b041227c4da"
    }
  },
  "tags" : [ {
    "name" : "Gasoline",
    "uuid" : "1c51487f8e8043c291487f8e8053c2c1",
    "tagFamily" : "Fuels"
  }, {
    "name" : "Blue",
    "uuid" : "6e6f1d9f055447d2af1d9f055417d289",
    "tagFamily" : "Colors"
  }, {
    "name" : "White",
    "uuid" : "94fec98d6f114e81bec98d6f118e81cc",
    "tagFamily" : "Colors"
  } ],
  "project" : {
    "name" : "demo",
    "uuid" : "217f8c981ada4642bf8c981adaa642c3"
  },
  "childrenInfo" : { },
  "schema" : {
    "name" : "vehicle",
    "uuid" : "2aa83a2b3cba40a1a83a2b3cba90a1de",
    "version" : "3.0"
  },
  "container" : false,
  "displayField" : "name",
  "displayName" : "Ford GT",
  "fields" : {
    "slug" : "ford-gt",
    "name" : "Ford GT",
    "weight" : 1520,
    "SKU" : 1,
    "price" : 4.1E49,
    "stocklevel" : 20,
    "description" : "The Ford GT is an American mid-engine two-seater sports car that was produced by Ford for the 2005 through 2006 model years.",
    "vehicleImage" : {
      "uuid" : "df8beb3922c94ea28beb3922c94ea2f6",
      "path" : "/images/ford-gt.jpg",
      "languagePaths" : {
        "en" : "/images/ford-gt.jpg"
      }
    },
    "somedate" : "2018-03-16T11:05:00Z"
  },
  "path" : "/automobiles/ford-gt",
  "breadcrumb" : [ {
    "projectName" : "demo",
    "uuid" : "688f7beae8d240bf8f7beae8d2a0bf2e",
    "path" : "/",
    "schema" : {
      "name" : "folder",
      "uuid" : "3021de5632e94fe8a1de5632e95fe87c"
    }
  }, {
    "projectName" : "demo",
    "uuid" : "ca6c7df3f45b48d4ac7df3f45ba8d42f",
    "displayName" : "Automobiles",
    "path" : "/automobiles",
    "schema" : {
      "name" : "category",
      "uuid" : "2ca2362b041247c4a2362b041227c4da"
    }
  }, {
    "projectName" : "demo",
    "uuid" : "fc3c85be82584ae2bc85be82588ae2b0",
    "displayName" : "Ford GT",
    "path" : "/automobiles/ford-gt",
    "schema" : {
      "name" : "vehicle",
      "uuid" : "2aa83a2b3cba40a1a83a2b3cba90a1de"
    }
  } ],
  "version" : "3.1",
  "permissions" : {
    "create" : false,
    "read" : true,
    "update" : false,
    "delete" : false,
    "publish" : false,
    "readPublished" : true
  }
}

When organizing your content in terms of a node tree, Gentics Mesh offers two ways of generating a nested navigation response.

The API endpoint /api/v2/:projectName/nodes/:nodeUuid/navigation returns a navigation object for the provided node, while the /api/v2/:projectName/navroot/:path API endpoint returns a navigation object for a node which is located using a given path. Each endpoint will return a navigation response which contains the nested navigation tree structure.

By default, only container nodes are included in a navigation response. The includeAll query parameter will include all nodes, if set to true. The maxDepth parameter may be used to limit the navigation depth. In order to include the path property in the navigation response, the resolveLinks query parameter can be used.

Gentics Mesh Example for Building Navigation Menus

The demo app includes a navigation object showing just the top-level elements Automobiles, Aircraft, and Yachts as well as the Home link. All the elements can be easily queried using the available navigation endpoints. In particular, the example uses the /api/v2/:projectName/navroot/:path API endpoint, with the URL parameter :path querying the project root node, i.e., / together with query parameter ?maxDepth limiting the resulting nested JSON object to the top-level nodes.

API endpoints

Description API endpoint

Returns a navigation object for the provided node.

GET /api/v2/:projectName/nodes/:nodeUuid/navigation

Return a navigation for the node which is located using the given path.

GET /api/v2/:projectName/navroot/:path

Response Sample

Retrieving a navigation object using the projects root node / including the top level navigation menu items.

The same can be achieved using the node specific navigation endpoint. In this case you can specify the root node of your navigation by providing the node uuid.

{
  "uuid" : "688f7beae8d240bf8f7beae8d2a0bf2e",
  "node" : {
    "uuid" : "688f7beae8d240bf8f7beae8d2a0bf2e",
    "creator" : {
      "uuid" : "e5861ba26b914b21861ba26b91ab211a"
    },
    "created" : "2018-07-02T10:48:53Z",
    "editor" : {
      "uuid" : "e5861ba26b914b21861ba26b91ab211a"
    },
    "edited" : "2018-07-02T10:49:13Z",
    "language" : "en",
    "availableLanguages" : {
      "en" : {
        "published" : true,
        "version" : "1.0",
        "publisher" : {
          "uuid" : "e5861ba26b914b21861ba26b91ab211a"
        },
        "publishDate" : "2018-07-02T10:49:13Z"
      }
    },
    "languagePaths" : {
      "en" : "/"
    },
    "tags" : [ ],
    "project" : {
      "name" : "demo",
      "uuid" : "217f8c981ada4642bf8c981adaa642c3"
    },
    "childrenInfo" : {
      "folder" : {
        "schemaUuid" : "839ef8b50bf9493e9ef8b50bf9e93e24",
        "count" : 1
      },
      "category" : {
        "schemaUuid" : "2ca2362b041247c4a2362b041227c4da",
        "count" : 3
      }
    },
    "schema" : {
      "name" : "folder",
      "uuid" : "839ef8b50bf9493e9ef8b50bf9e93e24",
      "version" : "1.0"
    },
    "container" : true,
    "displayField" : "name",
    "fields" : { },
    "path" : "/",
    "breadcrumb" : [ {
      "projectName" : "demo",
      "uuid" : "688f7beae8d240bf8f7beae8d2a0bf2e",
      "path" : "/",
      "schema" : {
        "name" : "folder",
        "uuid" : "839ef8b50bf9493e9ef8b50bf9e93e24"
      }
    } ],
    "version" : "1.0",
    "permissions" : {
      "create" : false,
      "read" : true,
      "update" : false,
      "delete" : false,
      "publish" : false,
      "readPublished" : true
    }
  },
  "children" : [ {
    "uuid" : "15d5ef7a9abf416d95ef7a9abf316d68",
    "node" : {
      "uuid" : "15d5ef7a9abf416d95ef7a9abf316d68",
      "creator" : {
        "uuid" : "e5861ba26b914b21861ba26b91ab211a"
      },
      "created" : "2018-07-02T10:49:04Z",
      "editor" : {
        "uuid" : "e5861ba26b914b21861ba26b91ab211a"
      },
      "edited" : "2018-07-02T10:49:13Z",
      "language" : "en",
      "availableLanguages" : {
        "en" : {
          "published" : true,
          "version" : "1.0",
          "publisher" : {
            "uuid" : "e5861ba26b914b21861ba26b91ab211a"
          },
          "publishDate" : "2018-07-02T10:49:13Z"
        }
      },
      "languagePaths" : {
        "en" : "/images"
      },
      "parentNode" : {
        "projectName" : "demo",
        "uuid" : "688f7beae8d240bf8f7beae8d2a0bf2e",
        "path" : "/",
        "schema" : {
          "name" : "folder",
          "uuid" : "839ef8b50bf9493e9ef8b50bf9e93e24"
        }
      },
      "tags" : [ ],
      "project" : {
        "name" : "demo",
        "uuid" : "217f8c981ada4642bf8c981adaa642c3"
      },
      "childrenInfo" : {
        "vehicleImage" : {
          "schemaUuid" : "b12272150db4490ea272150db4190e72",
          "count" : 11
        }
      },
      "schema" : {
        "name" : "folder",
        "uuid" : "839ef8b50bf9493e9ef8b50bf9e93e24",
        "version" : "1.0"
      },
      "container" : true,
      "displayField" : "name",
      "displayName" : "Vehicle Images",
      "fields" : {
        "slug" : "images",
        "name" : "Vehicle Images"
      },
      "path" : "/images",
      "breadcrumb" : [ {
        "projectName" : "demo",
        "uuid" : "688f7beae8d240bf8f7beae8d2a0bf2e",
        "path" : "/",
        "schema" : {
          "name" : "folder",
          "uuid" : "839ef8b50bf9493e9ef8b50bf9e93e24"
        }
      }, {
        "projectName" : "demo",
        "uuid" : "15d5ef7a9abf416d95ef7a9abf316d68",
        "displayName" : "Vehicle Images",
        "path" : "/images",
        "schema" : {
          "name" : "folder",
          "uuid" : "839ef8b50bf9493e9ef8b50bf9e93e24"
        }
      } ],
      "version" : "1.0",
      "permissions" : {
        "create" : false,
        "read" : true,
        "update" : false,
        "delete" : false,
        "publish" : false,
        "readPublished" : true
      }
    }
  }, {
    "uuid" : "ca6c7df3f45b48d4ac7df3f45ba8d42f",
    "node" : {
      "uuid" : "ca6c7df3f45b48d4ac7df3f45ba8d42f",
      "creator" : {
        "uuid" : "e5861ba26b914b21861ba26b91ab211a"
      },
      "created" : "2018-07-02T10:49:08Z",
      "editor" : {
        "uuid" : "e5861ba26b914b21861ba26b91ab211a"
      },
      "edited" : "2018-07-02T10:49:13Z",
      "language" : "en",
      "availableLanguages" : {
        "en" : {
          "published" : true,
          "version" : "1.0",
          "publisher" : {
            "uuid" : "e5861ba26b914b21861ba26b91ab211a"
          },
          "publishDate" : "2018-07-02T10:49:13Z"
        }
      },
      "languagePaths" : {
        "en" : "/automobiles"
      },
      "parentNode" : {
        "projectName" : "demo",
        "uuid" : "688f7beae8d240bf8f7beae8d2a0bf2e",
        "path" : "/",
        "schema" : {
          "name" : "folder",
          "uuid" : "839ef8b50bf9493e9ef8b50bf9e93e24"
        }
      },
      "tags" : [ ],
      "project" : {
        "name" : "demo",
        "uuid" : "217f8c981ada4642bf8c981adaa642c3"
      },
      "childrenInfo" : {
        "vehicle" : {
          "schemaUuid" : "2aa83a2b3cba40a1a83a2b3cba90a1de",
          "count" : 6
        }
      },
      "schema" : {
        "name" : "category",
        "uuid" : "2ca2362b041247c4a2362b041227c4da",
        "version" : "1.0"
      },
      "container" : true,
      "displayField" : "name",
      "displayName" : "Automobiles",
      "fields" : {
        "name" : "Automobiles",
        "slug" : "automobiles"
      },
      "path" : "/automobiles",
      "breadcrumb" : [ {
        "projectName" : "demo",
        "uuid" : "688f7beae8d240bf8f7beae8d2a0bf2e",
        "path" : "/",
        "schema" : {
          "name" : "folder",
          "uuid" : "839ef8b50bf9493e9ef8b50bf9e93e24"
        }
      }, {
        "projectName" : "demo",
        "uuid" : "ca6c7df3f45b48d4ac7df3f45ba8d42f",
        "displayName" : "Automobiles",
        "path" : "/automobiles",
        "schema" : {
          "name" : "category",
          "uuid" : "2ca2362b041247c4a2362b041227c4da"
        }
      } ],
      "version" : "1.0",
      "permissions" : {
        "create" : false,
        "read" : true,
        "update" : false,
        "delete" : false,
        "publish" : false,
        "readPublished" : true
      }
    }
  }, {
    "uuid" : "21203632520b4d19a03632520b2d19c1",
    "node" : {
      "uuid" : "21203632520b4d19a03632520b2d19c1",
      "creator" : {
        "uuid" : "e5861ba26b914b21861ba26b91ab211a"
      },
      "created" : "2018-07-02T10:49:12Z",
      "editor" : {
        "uuid" : "e5861ba26b914b21861ba26b91ab211a"
      },
      "edited" : "2018-07-02T10:49:13Z",
      "language" : "en",
      "availableLanguages" : {
        "en" : {
          "published" : true,
          "version" : "1.0",
          "publisher" : {
            "uuid" : "e5861ba26b914b21861ba26b91ab211a"
          },
          "publishDate" : "2018-07-02T10:49:13Z"
        }
      },
      "languagePaths" : {
        "en" : "/aircrafts"
      },
      "parentNode" : {
        "projectName" : "demo",
        "uuid" : "688f7beae8d240bf8f7beae8d2a0bf2e",
        "path" : "/",
        "schema" : {
          "name" : "folder",
          "uuid" : "839ef8b50bf9493e9ef8b50bf9e93e24"
        }
      },
      "tags" : [ ],
      "project" : {
        "name" : "demo",
        "uuid" : "217f8c981ada4642bf8c981adaa642c3"
      },
      "childrenInfo" : {
        "vehicle" : {
          "schemaUuid" : "2aa83a2b3cba40a1a83a2b3cba90a1de",
          "count" : 3
        }
      },
      "schema" : {
        "name" : "category",
        "uuid" : "2ca2362b041247c4a2362b041227c4da",
        "version" : "1.0"
      },
      "container" : true,
      "displayField" : "name",
      "displayName" : "Aircraft",
      "fields" : {
        "name" : "Aircraft",
        "slug" : "aircrafts"
      },
      "path" : "/aircrafts",
      "breadcrumb" : [ {
        "projectName" : "demo",
        "uuid" : "688f7beae8d240bf8f7beae8d2a0bf2e",
        "path" : "/",
        "schema" : {
          "name" : "folder",
          "uuid" : "839ef8b50bf9493e9ef8b50bf9e93e24"
        }
      }, {
        "projectName" : "demo",
        "uuid" : "21203632520b4d19a03632520b2d19c1",
        "displayName" : "Aircraft",
        "path" : "/aircrafts",
        "schema" : {
          "name" : "category",
          "uuid" : "2ca2362b041247c4a2362b041227c4da"
        }
      } ],
      "version" : "1.0",
      "permissions" : {
        "create" : false,
        "read" : true,
        "update" : false,
        "delete" : false,
        "publish" : false,
        "readPublished" : true
      }
    }
  }, {
    "uuid" : "eb2ebdcc0e894a9eaebdcc0e896a9e1d",
    "node" : {
      "uuid" : "eb2ebdcc0e894a9eaebdcc0e896a9e1d",
      "creator" : {
        "uuid" : "e5861ba26b914b21861ba26b91ab211a"
      },
      "created" : "2018-07-02T10:49:13Z",
      "editor" : {
        "uuid" : "e5861ba26b914b21861ba26b91ab211a"
      },
      "edited" : "2018-07-02T10:49:13Z",
      "language" : "en",
      "availableLanguages" : {
        "en" : {
          "published" : true,
          "version" : "1.0",
          "publisher" : {
            "uuid" : "e5861ba26b914b21861ba26b91ab211a"
          },
          "publishDate" : "2018-07-02T10:49:13Z"
        }
      },
      "languagePaths" : {
        "en" : "/yachts"
      },
      "parentNode" : {
        "projectName" : "demo",
        "uuid" : "688f7beae8d240bf8f7beae8d2a0bf2e",
        "path" : "/",
        "schema" : {
          "name" : "folder",
          "uuid" : "839ef8b50bf9493e9ef8b50bf9e93e24"
        }
      },
      "tags" : [ ],
      "project" : {
        "name" : "demo",
        "uuid" : "217f8c981ada4642bf8c981adaa642c3"
      },
      "childrenInfo" : {
        "vehicle" : {
          "schemaUuid" : "2aa83a2b3cba40a1a83a2b3cba90a1de",
          "count" : 2
        }
      },
      "schema" : {
        "name" : "category",
        "uuid" : "2ca2362b041247c4a2362b041227c4da",
        "version" : "1.0"
      },
      "container" : true,
      "displayField" : "name",
      "displayName" : "Yachts",
      "fields" : {
        "name" : "Yachts",
        "slug" : "yachts"
      },
      "path" : "/yachts",
      "breadcrumb" : [ {
        "projectName" : "demo",
        "uuid" : "688f7beae8d240bf8f7beae8d2a0bf2e",
        "path" : "/",
        "schema" : {
          "name" : "folder",
          "uuid" : "839ef8b50bf9493e9ef8b50bf9e93e24"
        }
      }, {
        "projectName" : "demo",
        "uuid" : "eb2ebdcc0e894a9eaebdcc0e896a9e1d",
        "displayName" : "Yachts",
        "path" : "/yachts",
        "schema" : {
          "name" : "category",
          "uuid" : "2ca2362b041247c4a2362b041227c4da"
        }
      } ],
      "version" : "1.0",
      "permissions" : {
        "create" : false,
        "read" : true,
        "update" : false,
        "delete" : false,
        "publish" : false,
        "readPublished" : true
      }
    }
  } ]
}

Breadcrumbs

Each node in Gentics Mesh provides information on where it is located within the node tree in terms of its breadcrumb property. The property provides an array of node references representing the path from the project root down to the current node. For more details see the documentation on node.

In our demo app example, the breadcrumb property for node Ford GT will therefore include the node Automobiles.

Gentics Mesh Example for Building Breadcumbs

The breadcrumb property will be returned in all API responses containing nodes. Using the resolveLink query parameter will also the paths of the nodes listed in the array.

API endpoints

Description API endpoint

Get all nodes of a project and return a paged list response.

GET /api/v2/projectName/nodes

Get the node with the given UUID.

GET /api/v2/:projectName/nodes/:nodeUuid

Load the node or the node’s binary data, which is located using the provided path.

GET /api/v2/:projectName/webroot/:path

Response Sample

{
  "uuid" : "fc3c85be82584ae2bc85be82588ae2b0",
  "creator" : {
    "uuid" : "e5861ba26b914b21861ba26b91ab211a"
  },
  "created" : "2018-07-02T10:49:09Z",
  "editor" : {
    "uuid" : "e5861ba26b914b21861ba26b91ab211a"
  },
  "edited" : "2018-07-02T10:49:13Z",
  "language" : "en",
  "availableLanguages" : {
    "en" : {
      "published" : true,
      "version" : "1.0",
      "publisher" : {
        "uuid" : "e5861ba26b914b21861ba26b91ab211a"
      },
      "publishDate" : "2018-07-02T10:49:13Z"
    }
  },
  "languagePaths" : {
    "en" : "/automobiles/ford-gt"
  },
  "parentNode" : {
    "projectName" : "demo",
    "uuid" : "ca6c7df3f45b48d4ac7df3f45ba8d42f",
    "displayName" : "Automobiles",
    "path" : "/automobiles",
    "schema" : {
      "name" : "category",
      "uuid" : "2ca2362b041247c4a2362b041227c4da"
    }
  },
  "tags" : [ {
    "name" : "Gasoline",
    "uuid" : "1c51487f8e8043c291487f8e8053c2c1",
    "tagFamily" : "Fuels"
  }, {
    "name" : "Blue",
    "uuid" : "6e6f1d9f055447d2af1d9f055417d289",
    "tagFamily" : "Colors"
  }, {
    "name" : "White",
    "uuid" : "94fec98d6f114e81bec98d6f118e81cc",
    "tagFamily" : "Colors"
  } ],
  "project" : {
    "name" : "demo",
    "uuid" : "217f8c981ada4642bf8c981adaa642c3"
  },
  "childrenInfo" : { },
  "schema" : {
    "name" : "vehicle",
    "uuid" : "2aa83a2b3cba40a1a83a2b3cba90a1de",
    "version" : "1.0"
  },
  "container" : false,
  "displayField" : "name",
  "displayName" : "Ford GT",
  "fields" : {
    "slug" : "ford-gt",
    "name" : "Ford GT",
    "weight" : 1520,
    "SKU" : 1,
    "price" : 139995,
    "stocklevel" : 20,
    "description" : "The Ford GT is an American mid-engine two-seater sports car that was produced by Ford for the 2005 through 2006 model years.",
    "vehicleImage" : {
      "uuid" : "df8beb3922c94ea28beb3922c94ea2f6",
      "path" : "/images/ford-gt.jpg",
      "languagePaths" : {
        "en" : "/images/ford-gt.jpg"
      }
    }
  },
  "path" : "/automobiles/ford-gt",
  "breadcrumb" : [ {
    "projectName" : "demo",
    "uuid" : "688f7beae8d240bf8f7beae8d2a0bf2e",
    "path" : "/",
    "schema" : {
      "name" : "folder",
      "uuid" : "839ef8b50bf9493e9ef8b50bf9e93e24"
    }
  }, {
    "projectName" : "demo",
    "uuid" : "ca6c7df3f45b48d4ac7df3f45ba8d42f",
    "displayName" : "Automobiles",
    "path" : "/automobiles",
    "schema" : {
      "name" : "category",
      "uuid" : "2ca2362b041247c4a2362b041227c4da"
    }
  }, {
    "projectName" : "demo",
    "uuid" : "fc3c85be82584ae2bc85be82588ae2b0",
    "displayName" : "Ford GT",
    "path" : "/automobiles/ford-gt",
    "schema" : {
      "name" : "vehicle",
      "uuid" : "2aa83a2b3cba40a1a83a2b3cba90a1de"
    }
  } ],
  "version" : "1.0",
  "permissions" : {
    "create" : false,
    "read" : true,
    "update" : false,
    "delete" : false,
    "publish" : false,
    "readPublished" : true
  }
}

Fetch Content with WebRoot Paths

The WebRoot API is an alternative way for fetching content from Gentics Mesh. Other than accessing nodes with their UUID, one can use the way more intuitive WebRoot paths.

Gentics Mesh Example for Fetching Content by Path using the WebRoot API

This functionality builds on top of the schema segmentField and urlFields property to define the path of a specific node.

WebRoot paths of arbitrary depth can be created, in combination with organizing content hierarchically in terms of a content tree by specifying nodes to be containers for their child nodes. The WebRoot API endpoint uses this information to resolve a given path to a node UUID. Each node in turn will provide a single segment to the full path via the referenced segmentField.

In addition to that it is also possible to create completely custom URLs to your content using the urlFields schema property. You can reference string and string list fields within your schema using the property. Those fields can in turn contain a custom path to your node. Gentics Mesh will only make sure that there are no collisions between custom paths of other nodes. Saving a node which uses the same urlField value would cause a conflict error. It is important to note that conflicts between custom url field values and existing paths which are build using the segmentPath property will not cause a conflict. You can use this in order to override an existing path to a node using a custom path. Custom paths via the urlFields property will always be resolved first and thus overrule the segmentField paths.

Possible applications for the urlFields property are:

  • Short URL support

  • Nice URL handling

  • Redirection handling

Using the WebRoot API it is possible to easily integrate Gentics Mesh with many known routing frameworks.

Framework Language Example

Silex

PHP

blog post

ExpressJS

JS

blog post

Vert.x

Java,JS,Ceylon

blog post

Lotus

Ruby

-

API endpoints

Description API endpoint

Load the node or the node’s binary data, which is located using the provided path.

GET /api/v2/:projectName/webroot/:path

Query content by path

A WebRoot path may consist of multiple path segments, each corresponding to a node within the content tree. The segmentField property from the schema is used to determine the node’s relevant field value.

Each segment of the URL must be URL-encoded. A node’s contents must provide different path segment in order to guarantee unique paths.

Fetch node with UUID

Loading the node with the given UUID using API endpoint GET /api/v2/:projectName/nodes/:nodeUuid.

Query binary content by path

The WebRoot API, furthermore, directly supports delivering binary content (e.g., images, documents, etc.) using the fileName meta-data field of the binary field.

The Webroot-Response-Type header can be used to differentiate between binary and node responses. The values of this header can be either binary or node. This allows to differentiate between binary content with Content-Type: application/json and typical node responses also delivered with Content-Type: application/json.
Downloads of resized images currently do not support byte range requests.

Fetch an image with UUID

Downloading a node’s binary field with the given name using API endpoint GET /api/v2/:projectName/nodes/:nodeUuid/binary/:fieldName.

Fetch an image with WebRoot path

When using a routing framework, in order to find out if a requested resource is binary data or JSON data you need to check the HTTP Content-Disposition response header. If it is set, it’s binary data.

Image manipulation by path

In case, the binary data is an image, the WebRoot API allows to directly perform Image Manipulation such as cropping and resizing.

Crop and resize an image with WebRoot path

Find out more about this topic in our blog post about Gentics Mesh’s Image Manipulation API and Interface.

Link resolving represents the counterpart of the WebRoot API - a node UUID can be resolved into a WebRoot path.

Gentics Mesh Example for automatically Resolving Links

Typically, editors create content including internal links to other nodes. When fetching content for your apps, however, Gentics Mesh will resolve these internal links for you and return a WebRoot path.

For example, {{mesh.link("2f2de9297c8143e8ade9297c8193e8fc", "en")}} will be transformed into /api/v2/demo/webroot/images/ford-gt.jpg when using the ?resolveLinks=full query parameter.

The ?resolveLinks query parameter defines if and how links are resolved:

  • off - links will not be resolved. This is the default.

  • full - the resolved links will contain the WebRoot prefix and project name (/api/v2/:projectName/webRoot/:path).

  • medium - the resolved links will contain the project name (/:projectName/:path).

  • short - will contain neither WebRoot prefix nor project name, just the path (:path).

The ?resolveLinks query parameter can be applied to all API endpoints returning nodes.

In some cases it may be desirable to be able to create links which point to nodes within different projects. In these situations the link should no longer be relative but instead contain the domain and protocol which is used by the project of the referenced node.

You can specify the hostname and ssl flag when creating a project. This will in turn store this information within the created branch of the project. Gentics Mesh will make use of this information once you render a foreign node’s link using the short type. The links will automatically start with https:// if the ssl flag of the branch has been set to true. You can update the hostname/ssl flag at any time by updating the branch of the project.

Foreign links can only be rendered using the ?resolveLinks=short type. Other resolver types do not support this mechanism.

Specifying Branches

It is also possible to specify a branch as a third parameter of the mesh link. Both the UUID and branch name can be used to resolve the branch. If the uuid or branch name cannot be found for the linked node, the latest branch will be used instead.

Examples:

  • {{mesh.link("2f2de9297c8143e8ade9297c8193e8fc", "en", "winter")}}

  • {{mesh.link("2f2de9297c8143e8ade9297c8193e8fc", "en", "e007a9f6f6c8404fbd81f96489764401")}}

API endpoints

Description API endpoint

Get all nodes of a project and return a paged list response.

GET /api/v2/projectName/nodes

Get the node with the given UUID.

GET /api/v2/:projectName/nodes/:nodeUuid

Load the node or the node’s binary data, which is located using the provided path.

GET /api/v2/:projectName/webroot/:path

Get a navigation object for the provided node.

GET /api/v2/:projectName/nodes/:nodeUuid/navigation

Return a navigation for the node which is located using the given path.

GET /api/v2/:projectName/navroot/:path

In addition to the above, Gentics Mesh offers the /api/v2/utilities/linkResolver endpoint that can be used to resolve Gentics Mesh links within the posted text data. This is useful when resolving links for a preview page.

It’s necessary to send the content in which links should get resolved to the API endpoint in plain text or JSON. The query parameter ?resolveLinks is used to specify how links shall be resolved.

Valid links:

  • {{mesh.link("2f2de9297c8143e8ade9297c8193e8fc", "en")}}

  • {{mesh.link('2f2de9297c8143e8ade9297c8193e8fc', 'en')}}

  • {{mesh.link(\"2f2de9297c8143e8ade9297c8193e8fc\", \"en\")}}

  • {{mesh.link(2f2de9297c8143e8ade9297c8193e8fc, en)}}

  • {{mesh.link("2f2de9297c8143e8ade9297c8193e8fc")}} (link to default language)

  • {{mesh.link(2f2de9297c8143e8ade9297c8193e8fc)}} (link to default language)

S3 Support

S3 Support is a feature that allows binaries to be uploaded directly to S3 buckets (for example using AWS). The Async Client of AWS SDK in Java is used. This allows Mesh to perform different types of requests (HeadObjectRequest,GetObjectRequest,PutObjectRequest, etc.) in an asynchronous way in order to handle all the endpoints. Mesh uses the configuration in mesh.yml to set up the S3 connection to a bucket.

For on-demand image manipulation (using query parameters when getting images from Mesh) an additional cache bucket can be configured, where transformed variants of images are stored

Mesh stores only a reference of the binary location in S3 and allows handling of the binaries using REST endpoints. For more information on available settings have a look at the administration guide.

Binary Upload

Gentics Mesh allows storing binary data in S3.

The storing is done in two phases: in the first one, Mesh is creating a reference and is returning a presigned URL, which serves to upload the file in S3; in the second phase the presigned URL can be used to do the upload in S3.

Only the presigned URL from S3 needs the file in its body.

The file is stored in S3 using a combination of nodeUuid and fieldName in the bucket specified in the configuration file. This is stored in the Mesh field as s3ObjectKey and can be used in the AWS SDK for Java to get the object using a GetObjectRequest. This address can be retrieved along with the other elements of the S3 fields in Mesh.

All the presigned URLs come with a timeout that can be specified in the /docs/administration-guide/#conf[Mesh configuration file]. After this timeout the URL is invalid.

The Mesh endpoint to use for upload is: POST /api/v2/:project/nodes/:uuid/s3binary/:fieldName

Metadata Extraction

After a binary is uploaded to S3 metadata extraction can be invoked. This will download the binary referenced in the s3 binary field, parse its metadata and store the results to be used in Elasticsearch. This can be skipped if no metadata is needed.

The Mesh endpoint to use for upload is: POST /api/v2/:project/nodes/:uuid/s3binary/:fieldName/parseMetadata

Cache

Mesh S3 Support offers the configuration of a cache bucket. Using this cache bucket, the user can request transformation for the images stored in S3. It is possible to set a retention policy. This will delete images in the S3 cache bucket after a configurable period of time.

Transformation and Download

It is possible to transform and download the binaries stored in S3 via Mesh. The endpoints are the same as for non S3 binaries stored in Mesh.

  • GET /api/v2/:project/nodes/:uuid/:fieldName

  • GET /api/v2/:project/webroot/:path

  • GET /api/v2/:project/webrootfield/:fieldName/:path

The download endpoints actually don’t contain the file itself, as it resides in the S3t. The response from the download endpoints for S3 is a 302 Redirected which will redirect the client to download directly from S3.

In case of a temporary transformation (On-Demand) a separate object is created/retrieved in the Cache bucket and returned to the user. If the binary needs to be transformed on its original bucket, the object gets updated in AWS and the client gets an updated presigned URL.

If the file contains an image, or if specific transformations need to be done, it is necessary to run metadata extraction before transforming the data. Otherwise it is not possible for Mesh to find the file type.

An existing image permanently will first download the image in Mesh, then the image is transformed and uploaded back to S3.

Deletion

After deleting a node or a field, Mesh does check if the deletion contains something referencing a S3 Object. If so, the object in S3 and the Mesh reference get deleted.

Event Handling

Gentics Mesh creates events for the lifecycle of the S3 Binaries, giving other services the possibility to get updated during the process. There are currently three events:

  • CREATED : when the the s3 field is created successfully on Mesh. - This happens as soon as the first presigned upload URL is created. Note - Mesh does not know if the URL will ever be used as this happens between the client and S3.

  • METADATA_EXTRACTED : when the metadata from a S3 Binary is extracted and stored in Mesh.

  • DELETED : when the S3 binary and the Mesh reference are deleted.

File Upload

Binary data can be attached to node binary fields. The /api/v2/nodes/:uuid/binary/:fieldName endpoint can be used to POST binary data and thus update the stored binary field.

This endpoint is accepting multipart/form-data, only.

It is required to specify the version and language within the update request. This is similar to regular node update requests in which these information must be added to the JSON object.

----------Geg2Oob
Content-Disposition: form-data; name="version"

1.0

----------Geg2Oob
Content-Disposition: form-data; name="language"

en

----------Geg2Oob
Content-Disposition: form-data; name="shohY6d"; filename="somefile.bin"
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary

fileData

----------Geg2Oob--

The mimeType of binaries which don’t have a mimeType property will be automatically be determined via the file extension as a fallback mechanism.

Configuration

Gentics Mesh stores all binary files on the filesystem. The default directory data/binaryfiles can be changed in the upload section of the main configuration file mesh.yml.

The upload limit can be configured in bytes using the uploadOptions.byteLimit setting.

For more information on available settings have a look at the administration guide.

Metadata handling

Metadata information of uploads will automatically be extracted and added the metadata object of the binary field.

You can disable this feature in the global options by setting upload.parser to false.

You can also disable this feature per field. See binary schema field documentation for more information.

You can set a whitelist of allowed metadata (upload.metadataWhitelist). Setting that list will only save metadata with keys specified in that list.

Currently the following mime-types are supported:

Doc:

  • application/pdf

  • application/msword

  • application/vnd.openxmlformats-officedocument.wordprocessingml.document

Image:

  • image/jpeg

  • image/jpg

  • image/png

Audio:

  • audio/flac

  • audio/mp3

  • audio/ogg

  • audio/x-matroska

Video:

  • video/ogg

  • video/mp4

  • video/x-matroska

The GPS information of images will be processed and provided in a location object. A geopoint will automatically be stored for the document in the search index. This way it is possible to run geo search queries to locate images within a specific area.

Example response:

{
…
  "fields" : {
    "binary" : {
      "binaryUuid" : "304a132ca8e740f68a132ca8e710f60d",
      "fileName" : "android-africa-gps.jpg",
      "width" : 200,
      "height" : 150,
      "sha512sum" : "0dbd4fcfc27be88aae7f78848b75e55f30983b0bccdf187f483e3c1e28d11b697e765254c1b52ea79a2c1cfa6fb6b749c4500baceb5ed70ee22646515fff94e7",
      "fileSize" : 29354,
      "mimeType" : "image/jpeg",
      "dominantColor" : "#a5a4a1",
      "metadata" : {
        "location" : {
          "lon" : 18.408889,
          "lat" : -33.961111
        },
        "date" : "2018-07-17T13:16:37",
        "exif_ExposureTime" : "0.016666666666666666",
        "Compression" : "JPEG (old-style)",
        "Image_Height" : "376 pixels",
        "Resolution_Units" : "inch",
        "Thumbnail_Width_Pixels" : "0",
        "File_Size" : "29354 bytes",
        "White_Balance_Mode" : "Auto white balance",
        "Focal_Length_35" : "26 mm",
        "tiff_YResolution" : "72.0",
        "Exif_Image_Height" : "150 pixels",
        "Max_Aperture_Value" : "f/1.7",
        "Metering_Mode" : "Center weighted average",
        "F-Number" : "f/1.7",
        "tiff_BitsPerSample" : "8",
        "modified" : "2018-07-17T13:16:37",
        "w_comments" : "Komischer Hamser",
        "tiff_Make" : "samsung",
        "Exif_Version" : "2.20",
        "Exif_Image_Width" : "200 pixels",
        "Scene_Capture_Type" : "Standard",
        "YCbCr_Positioning" : "Center of pixel array",
        "Date/Time_Original" : "2018:02:17 18:03:22",
        "Creation-Date" : "2018-02-17T19:03:22",
        "Make" : "samsung",
        "Orientation" : "Top, left side (Horizontal / normal)",
        "Exposure_Program" : "Program normal",
        "ISO_Speed_Ratings" : "64",
        "exif_Flash" : "false",
        "meta_creation-date" : "2018-02-17T19:03:22",
        "Focal_Length" : "4.2 mm",
        "tiff_ResolutionUnit" : "Inch",
        "Number_of_Components" : "3",
        "Resolution_Unit" : "Inch",
        "Exposure_Mode" : "Auto exposure",
        "Number_of_Tables" : "2 Huffman tables",
        "GPS_Latitude_Ref" : "S",
        "dcterms_created" : "2018-02-17T19:03:22",
        "Software" : "GIMP 2.8.18",
        "FlashPix_Version" : "1.00",
        "exif_DateTimeOriginal" : "2018-02-17T19:03:22",
        "Date/Time_Digitized" : "2018:02:17 18:03:22",
        "Data_Precision" : "8 bits",
        "exif_IsoSpeedRatings" : "64",
        "Last-Modified" : "2018-07-17T13:16:37",
        "tiff_ImageWidth" : "200",
        "Last-Save-Date" : "2018-07-17T13:16:37",
        "tiff_Software" : "GIMP 2.8.18",
        "File_Modified_Date" : "Tue Jul 17 14:06:48 +02:00 2018",
        "Image_Width" : "504 pixels",
        "tiff_ImageLength" : "150",
        "tiff_Orientation" : "1",
        "GPS_Latitude" : "-33° 57' 40\"",
        "Compression_Type" : "Progressive, Huffman",
        "GPS_Longitude_Ref" : "E",
        "Thumbnail_Offset" : "886 bytes",
        "Flash" : "Flash did not fire",
        "exif_FocalLength" : "4.2",
        "Exposure_Time" : "1/60 sec",
        "Makernote" : "[98 values]",
        "Comments" : "Animal in africa",
        "tiff_Model" : "SM-G955F",
        "Y_Resolution" : "72 dots per inch",
        "Date/Time" : "2018:07:17 11:16:37",
        "Thumbnail_Height_Pixels" : "0",
        "Component_1" : "Y component: Quantization table 0, Sampling factors 1 horiz/1 vert",
        "Thumbnail_Length" : "4435 bytes",
        "JPEG_Comment" : "Animal in africa",
        "exif_FNumber" : "1.7",
        "X_Resolution" : "72 dots per inch",
        "Component_3" : "Cr component: Quantization table 1, Sampling factors 1 horiz/1 vert",
        "dcterms_modified" : "2018-07-17T13:16:37",
        "Component_2" : "Cb component: Quantization table 1, Sampling factors 1 horiz/1 vert",
        "Color_Space" : "sRGB",
        "Model" : "SM-G955F",
        "GPS_Longitude" : "18° 24' 32\"",
        "comment" : "Animal in africa",
        "Unique_Image_ID" : "F12LLJA00SM F12LLKG01GM",
        "meta_save-date" : "2018-07-17T13:16:37",
        "tiff_XResolution" : "72.0"
      }
    }
  },
…
}

The metadata of a binary field can also be updated in order to remove, add new or update existing meta attributes.

The metadata within the image data itself will not be updated.
Uploading a binary to a field will override any custom metadata with the freshly parsed metadata of the upload.

Example response:

{
…
  "fields" : {
    "binary" : {
      "binaryUuid" : "304a132ca8e740f68a132ca8e710f60d",
      "fileName" : "android-africa-gps.jpg",
      "width" : 200,
      "height" : 150,
      "sha512sum" : "0dbd4fcfc27be88aae7f78848b75e55f30983b0bccdf187f483e3c1e28d11b697e765254c1b52ea79a2c1cfa6fb6b749c4500baceb5ed70ee22646515fff94e7",
      "fileSize" : 29354,
      "mimeType" : "image/jpeg",
      "dominantColor" : "#a5a4a1",
      "metadata" : {
        "location" : {
          "lon" : 18.408889,
          "lat" : -33.961111
        },
        "description": "Image of an angry animal in africa",
        "animal_name": "Procavia capensis"
      }
    }
  },
…
}

Text extraction

Uploaded documents (PDF, Doc, Docx) will automatically be parsed to extract the the plain text content. The upload.parserLimit configuration in the mesh.yml can be used to limit the parser output. By default a limit of 40.000 characters has been configured.

The plainText can be accessed via the plainText field in GraphQL. The same field is also included in the REST response of a binary field. This field can be modified via REST.

The parser limit of documents also affects the metadata extraction. In-line attributes of PDF files will only be added to the list of metadata when the parser limit is set high enough. A parserLimit of -1 can be used to fully parse documents and to ensure that all attributes are identified.

Multi-Language

Gentics Mesh comes with multi-language support out of the box. In particular, a node serves as a container for one or more contents. These contents will store the actual content fields.

You can query individual contents by appending the ?lang query parameter. The language json property within an update or create request will be used to identify which language variant should be created or updated.

Requests for nodes should contain the requested languages (as comma separated list)as query parameter:

Endpoint: /api/v2/:projectName/nodes/:uuid?lang=en,de

If the requested node is available in any of the languages, the response will contain the fields in that language (first language found).

Language Fallback

Gentics Mesh allows to configure a defaultLanguage in the main configuration file mesh.yml. This default language is used as a fallback in case:

  1. the lang query parameter has been omitted, or

  2. the requested content is not available in the specified language.

This fallback mechanism works when fetching nodes but also when requesting navigation objects or breadcrumb information.

In order to work properly, the fallback mechanism requires all nodes to have a language variant for the specified defaultLanguage.

Permissions

Overview

Permissions allow to equip different groups of users with access to the content of your project.

In Gentics Mesh, we distinguish the concepts of user, group, and role for managing different needs of access.

  • A user represents a physical person or a client app that needs to interact with your content.

  • Groups are used to gather users of same content needs and access levels, e.g. administrators, editors, and users of your app.

  • A role describes a set of permissions on other elements in Gentics Mesh, e.g. nodes, tags, schemas, users.

By assigning a role to a group, the role’s permissions are efficiently granted to a set of users.

For reasons of readability, we will describe granting permissions to users though technically, permissions are granted to a specific role and applied to users via groups.
Permissions in Gentics Mesh
Permission Description

create

grants the right to create instances of the element

read

grants read access to the element

update

grants the right to update the element

delete

grants the right to delete the element

publish

grants the right to publish/unpublish a node

readPublished

grants the right to read the published version of the node

The publish and readPublish permissions are specifically available for node elements.

Most API responses within Gentics Mesh contain a list of permissions. This list indicates which permissions the requesting user has been granted on the returned element(s).

Example

Try the example
Permission of user anonymous on node Delorean https://demo.getmesh.io/api/v2/demo/nodes/fc3c85be82584ae2bc85be82588ae2b0?version=published
// permissions for node https://demo.getmesh.io/api/v2/demo/nodes/fd58237c79d64bf198237c79d6bbf107?version=published
...
  "permissions" : {
    "create" : false,        //create other nodes
    "read" : false,          //read all versions of the node
    "update" : false,        //update the node
    "delete" : false,        //delete the node
    "publish" : false,       //publish or unpublish the node
    "readPublished" : true   //read the published version of the node
  }
...

The example above shows that the requesting user anonymous has the readPublish permission on the requested node, only. This means the user is allowed to read the published version of the node but not previous versions or a draft version of the requested element.

Furthermore the user is not allowed to

  • create child nodes

  • read a draft version of the node

  • update the requested node

  • delete the requested node

  • publish a draft version of the requested node, or unpublish a node.

Gentics Mesh by default returns the draft version of nodes. This means for supporting the anonymous user and public content, you need to add the ?version=published query parameter on all requests for nodes to avoid "Missing permissions on object" errors. Find out more in the Versioning section.

Following, we will discuss how to query, assign and revoke permissions in Gentics Mesh including the available API endpoints:

API endpoints for querying, assigning, and revoking permissions
Description API endpoint

Read the user permissions on element(s) that can be located by the specified path.

GET /api/v2/users/:userUuid/permissions/:path

Load the permissions between given role and the targeted element(s).

GET /api/v2/roles/:roleUuid/permissions/:path

Set the permissions between role and the targeted element(s).

POST /api/v2/roles/:roleUuid/permissions/:path

The examples provided subsequently, rely on our demo project.

Querying Permissions

There are dedicated API endpoints for querying permissions on elements.

The following example links, require prior authentication with user admin (credentials: admin/admin). Please refer to the authentication section to learn about the different authentication mechanisms provided by Gentics Mesh. The Insomnia REST client can be used to build and invoke requests from your browser to Gentics Mesh.

Querying Role Permissions

The GET /api/v2/roles/:roleUuid/permissions/:path endpoint can be used to query a role’s permission on a specific element or set of elements.

For example, the authenticated admin user is able to find out the configured permissions for role Public User on node fc3c85be82584ae2bc85be82588ae2b0.

Try the example with user admin
https://demo.getmesh.io/api/v2/roles/10447951fd264e6a847951fd266e6ae6/permissions/projects/217f8c981ada4642bf8c981adaa642c3/nodes/88fac3fbc61041c1bac3fbc610d1c182 Note, that a request with user anonymous will yield a Missing object permissions error response.
GET https://demo.getmesh.io/api/v2/roles/10447951fd264e6a847951fd266e6ae6/permissions/projects/217f8c981ada4642bf8c981adaa642c3/nodes/88fac3fbc61041c1bac3fbc610d1c182

RESPONSE
{
    "create": false,
    "read": false,
    "update": false,
    "delete": false,
    "publish": false,
    "readPublished": true
}

Alternatively, you can use query the element using the respective API endpoint (e.g. GET /api/v2/projectName/nodes) and use the role query parameter to find out another role’s (i.e. anonymous) permissions on the element:

GET https://demo.getmesh.io/api/v2/roles/10447951fd264e6a847951fd266e6ae6/permissions/projects/217f8c981ada4642bf8c981adaa642c3/nodes/88fac3fbc61041c1bac3fbc610d1c182

RESPONSE
...
  "permissions" : { // permissions of requesting user admin
    "create" : true,
    "read" : true,
    "update" : true,
    "delete" : true,
    "publish" : true,
    "readPublished" : true
  },
  "rolePerms" : { // permissions of requested role anonymous
    "create" : false,
    "read" : false,
    "update" : false,
    "delete" : false,
    "publish" : false,
    "readPublished" : true
  }
  ...

Querying User Permissions

The endpoint GET /api/v2/users/:userUuid/permissions/:path provides a shortcut for querying permissions for specific users directly, e.g., for user anonymous, which is essentially inheriting all permissions from role anonymous.

Assigning & Revoking Permissions

The POST /api/v2/roles/:roleUuid/permissions/:path API endpoint can be used to assign or revoke permissions to/from a role.

  • It is important to note that permissions can be granted on individual elements and onto a set of elements, which is identified by the element path name (e.g.: /users/:uuid and /users).

  • Furthermore, the endpoint offers the property recursive for applying permissions recursively on child elements.

Following, we go through all Gentics Mesh objects that can be subject to permissions.

How to grant Permissions on Users

In order to grant permission on individual or all users, one need to specify the path to be either /users/:uuid or /users, respectively.

Applying permissions on /users recursively will affect all users.

If you need to grant permission on users of a specific group, please use the /groups/:uuid element path together with property recursively.
Example

The following example shows how to grant the Editor Role role the permission to read all users. Since this is an operation to be performed on a set of users, the element path /users needs to be used together with property recursive=true.

Links used in the example require prior authentication with user admin (credentials: admin/admin). Please refer to the authentication section to learn about the different authentication mechanisms provided by Gentics Mesh. The Insomnia REST client can be used to build and invoke requests from your browser to Gentics Mesh.
POST https://demo.getmesh.io/api/v2/roles/6754d83b086244d894d83b086204d87f/permissions/users
{
  "permissions": {
    "create": false,
    "read": true,
    "update": false,
    "delete": false,
    "publish": false,
    "readPublished": false
  },
  "recursive": true
}
{
    "message": "Permission for role Editor Role updated."
}

You can query the updated permissions with user admin:

Role permissions

All possible role permissions on users are summarized in the following table.

Role permissions on individual users and set of users
Role permission Element path Permission Recursive

Can create new users

/users

Create

false

Can read all users

/users

Read

true

Can update all users

/users

Update

true

Can delete all users

/users

Delete

true

Can read user

/users/:uuid

Read

false

Can update user

/users/:uuid

Update

false

Can delete user

/users/:uuid

Delete

false

How to grant Permissions on Groups

Permissions on a single or multiple groups are applied via /groups/:uuid path and /groups path respectively.

  • Granting permissions on /groups recursively will affect all groups.

  • Granting permissions on /groups/:uuid recursively will affect users of the group.

Example

The following example shows how to grant the Editor Role role the permission to read a specific group (i.e. Client Group) and its users (i.e. webclient). This operation needs to be applied recursively (i.e., recursive=true), otherwise read permissions would be granted to the group, only.

Links used in the example require prior authentication with user admin (credentials: admin/admin). Please refer to the authentication section to learn about the different authentication mechanisms provided by Gentics Mesh. The Insomnia REST client can be used to build and invoke requests from your browser to Gentics Mesh.
POST https://demo.getmesh.io/api/v2/roles/6754d83b086244d894d83b086204d87f/permissions/groups/df81c23d9ff1450081c23d9ff195005e
{
  "permissions": {
    "create": false,
    "read": true,
    "update": false,
    "delete": false,
    "publish": false,
    "readPublished": false
  },
  "recursive": true
}
{
    "message": "Permission for role Editor Role updated."
}

You can query the updated permissions with user admin:

Role permissions

All possible role permissions on groups are summarized in the following table.

Role permissions on a specific group and multiple groups
Role permission Element path Permission Recursive

Can create new groups

/groups

Create

false

Can read all groups

/groups

Read

true

Can update all groups

/groups

Update

true

Can delete all groups

/groups

Delete

true

Can read group

/groups/:uuid

Read

false

Can update group

/groups/:uuid

Update

false

Can delete group

/groups/:uuid

Delete

false

Can read group and its users

/groups/:uuid

Read

true

Can update group and its users

/groups/:uuid

Update

true

Can delete group and its users

/groups/:uuid

Delete

true

How to Grant Permissions on Roles

By granting permissions on roles, you effectively grant users the right to change permissions of other users.

  • Permissions on a single or multiple roles are applied via /roles/:uuid path and /roles path respectively.

  • Granting permissions on /roles recursively will affect all roles.

Example

The following example shows how to grant the Editor Role role permissions to create new roles and subsequently manage them (i.e., read, update, delete) but no access to existing roles.

Links used in the example require prior authentication with user admin (credentials: admin/admin). Please refer to the authentication section to learn about the different authentication mechanisms provided by Gentics Mesh. The Insomnia REST client can be used to build and invoke requests from your browser to Gentics Mesh.
POST https://demo.getmesh.io/api/v2/roles/6754d83b086244d894d83b086204d87f/permissions/roles
{
  "permissions": {
    "create": true,
    "read": false,
    "update": false,
    "delete": false,
    "publish": false,
    "readPublished": false
  },
  "recursive": false
}
{
    "message": "Permission for role Editor Role updated."
}

You can query the updated permissions with user admin:

Role permissions

All possible role permissions on roles are summarized in the following table.

Role permissions on a specific role and multiple roles
Role permission Element path Permission Recursive

Can create new roles

/roles

Create

false

Can read all roles

/roles

Read

true

Can update all roles

/roles

Update

true

Can delete all roles

/roles

Delete

true

Can read role

/roles/:uuid

Read

false

Can update role

/roles/:uuid

Update

false

Can delete role

/roles/:uuid

Delete

false

How to Grant Permissions on Schemas

Permissions on a single or multiple schemas are applied via /schemas/:uuid path and /schemas path respectively.

  • Granting permissions on /schemas recursively will affect all schemas.

  • Read permissions on a schema are needed for creating nodes based on that schema.

Role permissions on a specific schema and multiple schemas
Role permission Element path Permission Recursive

Can create new schemas

/schemas

Create

false

Can read all schemas, and create nodes

/schemas

Read

true

Can update all schemas

/schemas

Update

true

Can delete all schemas

/schemas

Delete

true

Can read schema, and create nodes

/schemas/:uuid

Read

false

Can update schema

/schemas/:uuid

Update

false

Can delete schema

/schemas/:uuid

Delete

false

How to Grant Permissions on Microschemas

Permissions on a single or multiple microschemas are applied via /microschemas/:uuid path and /microschemas path respectively.

  • Granting permissions on /microschemas recursively will affect all microschemas.

  • Read permissions on a microschemaModel are needed for creating, reading, updating, and deleting micronodes based on that schema.

Role permissions on a specific microschemaModel and multiple microschemas
Role permission Element path Permission Recursive

Can create new microschemas

/microschemas

Create

false

Can read all microschemas, and create micronodes

/microschemas

Read

true

Can update all microschemas

/microschemas

Update

true

Can delete all microschemas

/microschemas

Delete

true

Can read microschemas, and create micronodes

/microschemas/:uuid

Read

false

Can update microschemas

/microschemas/:uuid

Update

false

Can delete microschemas

/microschemas/:uuid

Delete

false

How to Grant Permissions on Projects

Permissions on a single or multiple projects are applied via /projects/:uuid path and /projects path respectively.

  • Granting permissions on /projects/:uuid will also affect sub elements, i.e., used schemas, microschemas, tagfamilies & tags, nodes & sub nodes of the project.

  • Granting permissions on /projects recursively will affect all projects and their sub elements.

Role permissions on a specific project and multiple projects
Role permission Element path Permission Recursive

Can create new project

/projects

Create

false

Can read all projects and sub elements

/projects

Read

true

Can update all projects and sub elements

/projects

Update

true

Can delete all projects and sub elements

/projects

Delete

true

Can read published nodes and subnodes of all project

/projects

Read Published

true

Can un/publish nodes and subnodes of all project

/projects

Publish

true

Can read project and sub elements

/projects/:uuid

Read

true

Can update project and sub elements

/projects/:uuid

Update

true

Can delete project and sub elements

/projects/:uuid

Delete

true

Can read published nodes and subnodes of project

/projects/:uuid

Read Published

true

Can un/publish nodes and subnodes of project

/projects/:uuid

Publish

true

How to Grant Permissions on Tag Families

In order to grant permission on tag families the /:projectName/tagFamilies path can be used.

  • Granting permissions on /:projectName/tagFamilies/:uuid together with property recursive=true allows setting permissions for tags of a tag family.

  • Granting permissions on /:projectName/tagFamilies together with property recursive=true allows setting permissions for all tag families and their tags.

Role permissions on tag families
Role permission Element path Permission Recursive

Can create new tag families

/:projectName/tagFamilies

Create

false

Can create new tag families and tags for tagFamilies

/:projectName/tagFamilies

Create

true

Can read all tag families and tags

/:projectName/tagFamilies

Read

true

Can update all tag families and tags

/:projectName/tagFamilies

Update

true

Can delete all tag families and tags

/:projectName/tagFamilies

Delete

true

Can create tags in tag family

/:projectName/tagFamilies/:uuid

Create

false

Can read tag family

/:projectName/tagFamilies/:uuid

Read

false

Can update tag family

/:projectName/tagFamilies/:uuid

Update

false

Can delete tag family

/:projectName/tagFamilies/:uuid

Delete

false

Can read tag family and tags

/:projectName/tagFamilies/:uuid

Read

true

Can update tag family and tags

/:projectName/tagFamilies/:uuid

Update

true

Can delete tag family and tags

/:projectName/tagFamilies/:uuid

Delete

true

How to Grant Permissions on Tags

In order to grant permission on tags the /:projectName/tagFamilies/:uuid/tags and /:projectName/tagFamilies/:uuid/tags/:uuid paths can be used.

  • Currently, using path /:projectName/tagFamilies/:uuid/tags works same as using path /:projectName/tagFamilies/:uuid

  • Granting permissions on /:projectName/tagFamilies/:uuid/tags together with property recursive=true allows setting permissions for tags of a tag family, otherwise the property has no effect.

Role permissions on tag families
Role permission Element path Permission Recursive

Can create tags in tag family

/:projectName/tagFamilies/:uuid/tags

Create

false

Can read tag family

/:projectName/tagFamilies/:uuid/tags

Read

false

Can update tag family

/:projectName/tagFamilies/:uuid/tags

Update

false

Can delete tag family

/:projectName/tagFamilies/:uuid/tags

Delete

false

Can read tag family and tags

/:projectName/tagFamilies/:uuid/tags

Read

true

Can update tag family and tags

/:projectName/tagFamilies/:uuid/tags

Update

true

Can delete tag family and tags

/:projectName/tagFamilies/:uuid/tags

Delete

true

Can read tag

/:projectName/tagFamilies/:uuid/tags/:uuid

Read

false

Can update tag

/:projectName/tagFamilies/:uuid/tags/:uuid

Update

false

Can delete tag

/:projectName/tagFamilies/:uuid/tags/:uuid

Delete

false

How to Grant Permissions on Nodes

Permissions on a single or multiple nodes are applied via /:projectName/nodes and /:projectName/nodes/:uuid path:

  • /:projectName/nodes/:uuid is used to grant permissions on single nodes.

  • /:projectName/nodes together with property recursive=true can be used to quickly grant permissions on all node of the project.

  • In order to grant permissions on sub trees of the content tree /:projectName/nodes/:uuid together with property recursive=true is to be used.

Role permissions on nodes
Role permission Element path Permission Recursive

Can create new sub nodes in all nodes of the project

/:projectName/nodes

Create

true

Can read all project nodes (and all node versions)

/:projectName/nodes

Read

true

Can update all nodes of the project

/:projectName/nodes

Update

true

Can delete all nodes of the project

/:projectName/nodes

Delete

true

Can read the published version of all project nodes

/:projectName/nodes

ReadPublished

true

Can publish/unpublish all nodes of the project

/:projectName/nodes

Publish

true

Can create new sub nodes in specified node

/:projectName/nodes/:uuid

Create

false

Can read specified node

/:projectName/nodes/:uuid

Read

false

Can update specified node

/:projectName/nodes/:uuid

Update

false

Can delete specified node

/:projectName/nodes/:uuid

Delete

false

Can read the published version specified node

/:projectName/nodes/:uuid

ReadPublished

false

Can publish/unpublish specified node

/:projectName/nodes/:uuid

Publish

false

Can create new sub nodes in specified node & sub nodes

/:projectName/nodes/:uuid

Create

true

Can read specified node & sub nodes

/:projectName/nodes/:uuid

Read

true

Can update specified node & sub nodes

/:projectName/nodes/:uuid

Update

true

Can delete specified node & sub nodes

/:projectName/nodes/:uuid

Delete

true

Can read the published version specified node & sub nodes

/:projectName/nodes/:uuid

ReadPublished

true

Can publish/unpublish specified node & sub nodes

/:projectName/nodes/:uuid

Publish

true

How to Grant Permissions on project branches

Permissions on a single or multiple branches are applied via /api/v2/:projectName/branches/:uuid path and /api/v2/:projectName/branches path respectively.

Branches can not be deleted. Hence, permissions for deleting do not apply.
Role permissions on a specific branch and multiple branches
Role permission Element path Permission Recursive

Can create new branch

/api/v2/:projectName/branches

Create

false

Can read all branches

/api/v2/:projectName/branches

Read

true

Can update all branches

/api/v2/:projectName/branches

Update

true

Can read the branch

/api/v2/:projectName/branches/:uuid

Read

false

Can update the branch

/api/v2/:projectName/branches/:uuid

Update

false

Versioning

In order to understand the concept of versioning in Gentics Mesh it is important to remember that nodes are containers for language specific contents (see Multi-Language). The content of a node contains the fields and thus stores all the content.

Versioning within Gentics Mesh only applies to contents and their referenced fields. Other elements such as users, groups, roles, permissions are not versioned.

Various content management tasks will have different effects for versioning in Gentics Mesh. Some of them create versions, others don’t. Following, we go through all of these actions which involve versioning.

Node Creation

Once a node has been created the initial version 0.1 will be assigned to its content.

Node Updates

Updating a node’s content may create a minor version 0.2 of that content if changes have been detected within the posted request fields.

No Locks:

It is not required to handle locks in Gentics Mesh. Instead it is required to specify the version in the update request which identifies the version on which the update request was based upon.

Conflict detection:

Gentics Mesh will check whether new versions have been created in the meanwhile. Long running edit operations or multiple concurrent editors may create additional versions.

The detected changes will be compared automatically in order to determine whether the current update request causes a conflict with a newer edit request. Gentics Mesh will return a response which contains information about the conflict in those cases. Other update operations which do not cause a conflict will be stored and the changed fields will be updated.

The latest version which was created using an update request is called the draft version. Only a single draft version per content exists.

Publishing Nodes

Node contents can be published and taken offline. This is particularly useful if you want to first work on a draft, then review it and publish it at a later point in time.

Publishing requires a POST request on the /api/v2/:projectName/nodes/:uuid/published endpoint, which will publish all contents of the node. It is also possible to just publish specific contents with dedicated POST requests on /api/v2/:projectName/nodes/:uuid/languages/:languageTag/published.

Gentics Mesh will automatically create a new major version when publishing a node language variant (e.g.: 1.0, 2.0). The draft reference will also be updated to point to the major version, e.g. 1.0.

Furthermore, it is possible to retrieve information about the published status via a GET request on /api/v2/:/nodes/:uuid/published.

Publishing node contents requires the user to be assigned to a group with a role which provides the publish permission.
{
  "availableLanguages" : {
    "de" : {
      "published" : false,
      "version" : "0.4"
    },
    "en" : {
      "published" : true,
      "version" : "3.0",
      "publisher" : {
        "firstName" : "Joe",
        "lastName" : "Doe",
        "uuid" : "589319933be24ec79319933be24ec7fe"
      },
      "publishDate" : "2018-11-20T20:12:01.084Z"
    },
    "fr" : {
      "published" : false,
      "version" : "5.2"
    }
  }
}
It is not possible to publish a specific version. Publish always affects the latest draft version of the language variant.

Taking Nodes Offline

Similarly to publishing, the contents of a node can be taken offline via a DELETE request on /api/v2/:projectName/nodes/:uuid/published. E.g., taking a specific node language variant with version 1.0 offline using DELETE /api/v2/:projectName/nodes/:uuid/languages/:languageTag/published will just change the node’s publish state. Version 1.0 will still be available.

Taking node contents offline requires the user have publish permissions on the node.

Reading Nodes

It is possible to fetch older versions by specifying the ?version query parameter. Similarly, the published version of a node language variant can also be loaded using the parameter ?version=published or the draft version via ?version=draft.

Gentics Mesh by default returns the draft version of nodes. This means for supporting the anonymous user and public content, you need to add the ?version=published query parameter on all requests for nodes to avoid "Missing permissions on object" errors.
Reading published nodes requires the user to be assigned to a role which grants the readPublished permission.

Listing versions

Versions of a node can be listed via the /api/v2/:projectName/nodes/:uuid/versions endpoint.

"versions" : {
    "de" : [ {
      "creator" : {
        "firstName" : "Joe",
        "lastName" : "Doe",
        "uuid" : "307cf98b66424db5bcf98b66424db5aa"
      },
      "created" : "2019-05-22T19:04:10Z",
      "version" : "2.0",
      "draft" : true,
      "published" : true,
      "branchRoot" : false
    }
    …
  } ]
}

A version can be used as a draft version. This version can also be referenced as a published version when published. The branchRoot flag indicates whether the version is being referenced as root version in a branch. All these three different kind of versions are not purgeable. Versions which have been made in between can be purged.

Versions are language specific. This means that each language of a node has its dedicated version history.

Auto Purge

The auto purge mechanism can be used to control the versioning mechanism. The mechanism will automatically purge the previously used version when a new version gets created. This way the version history of a node can be kept small. This will reduce disk usage and reduce the complexity of the Graph that stores the versions. Actions such as update node, upload binary, publish node, take node offline create versions. The auto purge feature can be controlled by a global default setting which can be fine tuned on a per-schema level.

Auto Purge settings
Defaut setting Schema setting Auto Purge

true

null

Enabled

true

false

Disabled

false

true

Enabled

false

false

Disabled

Enabling auto purge mechanism will not stop version numbers to increase. Instead the mechanism will automatically purge the previously used version (if possible).
Setting the auto purge flag in a schema will not automatically purge any version. The versions will only be purged when content gets modified.

Default Setting

The global autoPurge flag from the mesh.yml configuration file will be used for schemas which don’t have autoPurge property set. Setting the autoPurge property will thus also allow to override the default configuration in the mesh.yml.

mesh.yml
content:
  autoPurge: true

Schema Setting

Versioning can be controlled on a per-schema basis. The autoPurge property within the schema controls whether additional versions for a content will be kept.

The default behaviour can be configured via the environment variable MESH_CONTENT_AUTO_PURGE or the config file.

Purging versions

The POST /api/v2/projects/:projectUuid/maintenance/purge endpoint can be used to purge older versions from the system.

When invoked a new job will be triggered which purges all possible content versions from the given project.

The ?before query parameter can be used to control what versions should be purged.

The call POST /api/v2/projects/:projectUuid/maintenance/purge?before=2019-04-20T18:00Z will thus only purge versions which are older than the given date. Omitting the parameter will purge all versions.

Draft and publish versions will not be purged since they are still required. Additionally when the initial version of a node can also not be purged since it is bound to the Branch of the node. Gentics Mesh requires this version to keep track of the branch starting point. The version lists endpoint will mark those versions using the branchRoot flag.

The purge operation requires admin role and delete permissions on the project to be executed.

The version purge mechanism works independently from the auto purge mechanism.

Content Branches

So far we learned that node contents can be versioned and published. Additionally Gentics Mesh versioning provides a powerful concept we call Branches. A project branch is very similar to branches in a versioning control system like Git or similar systems.

Branches can be used to restructure your nodes and change the contents within a specific branch without affecting a different branch which provides a different structure/content.

Structural references for nodes always contain branch information. This applies to parent/child relationship or taggings, publish states of nodes. This way branches are completely isolated from each other.

It is currently not possible to migrate from one branch to another. Nodes of branches can’t be automatically merged to other branches.

Typical usecases are:

  • Updating an existing application installation which uses Gentics Mesh to a new version. The new application version requires new schema versions. By creating a branch and migrating the nodes to the new branch (new schema versions), it is possible to serve content for both application versions. Each application versions chooses the correct branch for getting nodes.

  • Schema versions must be assigned to the branch. Each project can have multiple branches. An initial branch will automatically be created when creating a project.

All operations to nodes can be scoped to a specific branch by adding the ?branch=name query parameter. If omitted the latest branch will be used to execute the operation.

Implementations which use mesh should always reference a specific branch. Otherwise the document structure could change without the implementation being aware of these changes.

Creating a project branch

A branch requires an unique name. Existing nodes within the project will automatically be migrated into the branch. Please note the started node migration will be processed asynchronously and thus not all nodes may be directly accessible within the scope of the branch.

This migration is different from a schema version migration. The branch node migration just takes care of making all nodes from the previous branch available in the newly created branch. Unlike the schema migration the node migration will not create new language variant versions.

You can use the eventbus bridge or the dedicated /api/v2/admin/status/migrations endpoint to query the migration status. The migrated JSON property within the branch response also indicates whether the node migration has been completed.

Note: Migrated nodes will still have the same uuid as before.

Updating a project branch

A branch can be renamed and new schema/microschemaModel versions can be assigned to it.

Renaming is useful if you want to change your development branch to be the current production branch.

Assigning schema versions to the branch via a PUT request to /api/v2/:projectName/branches/:uuid/schemas will automatically trigger a schema migration of the affected nodes contents within the branch.

{
  "schemas" : [ {
    "name" : "content",
    "uuid" : "39f69bee0baa415eb69bee0baa115e82",
    "version" : "1.0"
  }, {
    "name" : "folder",
    "uuid" : "39f69bee0baa415eb69bee0baa115e82",
    "version" : "1.0"
  }, {
    "name" : "binary-data",
    "uuid" : "39f69bee0baa415eb69bee0baa115e82",
    "version" : "1.0"
  } ]
}

It is also possible to assign microschemas via a PUT request to /api/v2/:projectName/branches/:uuid/microschemas to the branch.

{
  "microschemas" : [ {
    "name" : "vcard",
    "uuid" : "2715307deafc4ecc95307deafccecc10",
    "version" : "2.0"
  }, {
    "name" : "geolocation",
    "uuid" : "2715307deafc4ecc95307deafccecc10",
    "version" : "1.0"
  } ]
}

All nodes which reference the branch via the updated schema version will automatically be migrated to use the newer schema version. Please note the started schema migration will be processed asynchronously and thus not all node contents may be directly accessible within the scope of the branch.

The migration will create new versions for the affected node contents.

It is note worthy that updating a schema and thus creating new schema version will not automatically affect the branch. Each schema update created a new schema version. This new version must first be assigned to the branch.

Deleting a project branch

At the moment it is not possible to delete a branch.

Moving Nodes

Branches enable Gentics Mesh to setup multiple content project tree structures. Moving nodes can be scoped to a specific branch using the ?branch query parameter. The project’s initial branch will be used to execute the move operation if no branch has been selected.

Tagging Nodes

The tag operation is also scoped to a specific branch. This way new tags can be assigned to your nodes for a specific branch without affecting the taggings of nodes within an older branch.

Tags and tag families are not versioned. Deleting a tag will remove the tag from all nodes that previously referenced this tag.
Taggings to nodes are not versioned.

Deleting Nodes

Deleting nodes is also branch specific. Deleting a node via DELETE to /api/v2/:projectName/node/:uuid?branch=winter2016 will delete the node and all its sub nodes from the winter2016 branch. The node will be completely removed from the system if no more contents are referenced within any branch.

It is also possible to just delete a specific language variant via DELETE to /api/v2/:projectName/node/:uuid/languages/en?branch=winter2016 from branch winter2016.

Updating Nodes

Branches are completely isolated from each other as explained earlier. This also applies to a node’s language variant versions.

Example:

  • Create project branch summer2016

  • Create node with language variant de at version 1.0 in branch summer2016

  • Create project branch winter2016

  • Update previously created node in branch summer2016 and thus create version 1.1

Branch summer2016 will reference node language variant 1.1 and winter2016 will still reference version 1.0 since the winter2016 branch was created at the specific point of time in which the language variant in branch summer2016 was still at version 1.0.

It is currently not possible to migrate 1.1 from summer2016 to winter2016.

Additionally creating new nodes in summer2016 will not be available in branch winter2016.

Permissions

Permissions are not branch specific.

Preview Handling

The Gentics Mesh User Interface provides a preview button when editing nodes. A post request to a configureable url is being dispatched when the button is triggered. The post request will contain the node JSON data of the current editing state. This way a preview page can be easily rendered by custom frontend implementations.

Password Recovery

A user who lost his password is able to recover it using a reset token. This token, typically, is issued by a user or service having permissions to create new users. The /api/v2/users/:userUuid/reset_token endpoint will return a token code which then can be passed along to an email service sending a recovery email to the user including named token.

A token is valid for 30 minutes and will be invalidated once it has been used.

The user can use this token to update his user record by issuing a POST request to the /api/v2/users/:userUuid?token=TOKENCODE endpoint. E.g., this can be done by presenting the user a form for updating his password. This works even if the user is not authenticated.

Schema & Microschema Migration

Gentics Mesh provides a changelog like system in order to apply and keep track of schema changes. A schema change may be a single change that adds a new field to the schema or a change which updates the schema properties.

Gentics Mesh supports the following change operations:

Operation: addfield

Properties Description

after

Name of the field after which the new field should be inserted

field

Name of the field that should be added

type

Type of the field

listType

Optional list type

{
  "operation" : "ADDFIELD",
  "properties" : {
    "field" : "fieldToBeAdded",
    "label" : "Field Label Value",
    "after" : "firstField",
    "type" : "list",
    "listType" : "html"
  }
}

Operation: removefield

Properties Description

field

Name of the field to be removed

{
  "operation" : "REMOVEFIELD",
  "properties" : {
    "field" : "fieldToBeRemoved"
  }
}

Operation: changefieldtype

Properties Description

field

Name of the field to be modified

type

New field type

listType

(Only applies for lists) New list type

{
  "operation" : "CHANGEFIELDTYPE",
  "properties" : {
    "field" : "fieldToBeChanged",
    "type" : "html"
  }
}

Operation: updatefield

Properties Description

field

Field to be updated

label

New field label

{
  "operation" : "UPDATEFIELD",
  "properties" : {
    "field" : "fieldToBeUpdated",
    "name" : "newName"
  }
}

Operation: updateschema

Properties Description

description

New schema description

order

Array of strings that contains the field order

displayFieldname

New displayFieldname value of the schema

segmentFieldname

New segmentFieldname value of the schema

container

New container flag of the schema

{
  "operation" : "UPDATESCHEMA",
  "properties" : {
    "container" : "true",
    "segmentFieldname" : "newSegmentField",
    "displayFieldname" : "newSegmentField",
    "description" : "new description",
    "label" : "new label"
  }
}

Operation: updatemicroschema

Properties Description

description

New microschemaModel description

{
  "operation" : "UPDATEMICROSCHEMA",
  "properties" : {
    "description" : "new description",
    "label" : "new label"
  }
}

Each change may also provide a migration script. The migration script can be used to modify nodes that were affected by the migration.

Typical usecases for migration scripts are for example dynamic field removal or even custom reformatting of field data. It is also possible to split a single field value into values for two new fields.

The /api/v2/schemas/:uuid/diff and /api/v2/microschemas/:uuid/diff endpoints can be used to generate a list of changes by comparing the stored and posted schema.

This list of changes can be modified and posted to /api/v2/schemas/:uuid/changes for schemas or /api/v2/microschemas/:uuid/changes for microschemas. The posted list of changes will be validated and stored when valid. A schema migration process will be started which runs in the background.

The SockJS compliant /api/v2/eventbus endpoint can be used to register to migration specific messages.

Additionally to websocket it is possible to query whether a migration is running via the /api/v2/admin/status/migrations endpoint.

Sending a schema to /api/v2/schemas:uuid using the PUT method will conveniently combine the diff generation and invocation of the schema migration.

Please note that by default conflicting data will be removed and this action can only be avoided by specifying a custom migration script.

Custom Migration Scripts

Sometimes it is desired to overwrite the default migration behaviour.

The following migration script converts the number value from field node.fields[fieldname] into a ISO-8601 date string which is then stored within the node.fields[fieldname] field.

function migrate(node, fieldname, convert) {
    node.fields[fieldname] = new Date(new Date(node.fields[fieldname]).getTime() + 864000).toISOString();
    return node;
}

Migration scripts also allow you to split up a field value into two different fields.

function migrate(node, fieldname, convert) {
    node.fields["fieldA"] = "First field set";
    node.fields["fieldB"] = "Second field set";
    return node;
}

The provided converter can be used to convert in between field types. This converter will be used if no custom migration script was specified.

function migrate(node, fieldname, convert) {
    var stringValue = convert.toString(node.fields[fieldname]);

    // It is important to use the Java.from method to convert the java list object into a number array.
    var numberArray    = Java.from(convert.toNumberList(node.fields[fieldname]));
    var micronodeArray = Java.from(convert.toMicronodeList(node.fields[fieldname]));
    var dateArray      = Java.from(convert.toDateList(node.fields[fieldname]));
    var booleanArray   = Java.from(convert.toBooleanList(node.fields[fieldname]));

    var numberValue    = convert.toNumber(node.fields[fieldname]);
    var nodeValue      = convert.toNode(node.fields[fieldname]);
    var micronodeValue = convert.toMicronode(node.fields[fieldname]);
    var dateValue      = convert.toDate(node.fields[fieldname]);
    var booleanValue   = convert.toBoolean(node.fields[fieldname]);
    var binaryValue    = convert.toBinary(node.fields[fieldname]);

    // Delete the field
    delete node.fields[fieldname];
    return node;
}

Finally the changes can be applied by sending the request to /api/v2/schemas/:uuid/changes.

{
  "changes" : [ {
    "operation" : "ADDFIELD",
    "properties" : {
      "field" : "listFieldToBeAddedField",
      "label" : "Field Label Value",
      "type" : "list",
      "listType" : "html"
    }
  }, {
    "operation" : "CHANGEFIELDTYPE",
    "properties" : {
      "field" : "fieldToBeUpdated",
      "type" : "string"
    }
  }, {
    "operation" : "REMOVEFIELD",
    "properties" : {
      "field" : "fieldToBeRemoved"
    }
  }, {
    "operation" : "UPDATEFIELD",
    "properties" : {
      "field" : "fieldToBeUpdated",
      "displayFieldname" : "newDisplayField",
      "label" : "newLabel"
    }
  }, {
    "operation" : "UPDATESCHEMA",
    "properties" : { }
  } ]
}

Executing migrations

Migrations can potentially affect a huge amount of nodes depending on the size of your project. As such the migration could take some time to complete. This is why we designed migrations in ways that they can be executed asynchronously. Various operations in Gentics Mesh (e.g. Schema update, assigning versions to branches, creating branches) may trigger migrations. Before the migration is being executed a job is added to the job queue. You can view the queue via the /api/v2/admin/jobs endpoint. These jobs will be processed and execute the actual migration.

By default updating a schema will create a new schema version and the nodes will be migrated to that new version. If you want to defer this operation you can set the updateAssignedBranches query parameter to false when updating a schema/microschemaModel. This leads to a new schema version being created but the version would not be linked to your current branch and no migration would be invoked.

Once a job has been queued and a migration has been invoked the status can be checked via the /api/v2/admin/status/migrations endpoint.

A job will only be removed from the job list when the job completed without any error. Erroneous jobs will stay in the job list. This way interrupted migrations can be picked up and executed once again.

Intermediate errors may cause a job to fail. In those cases it is possible to reset the error flag of a job by executing DELETE /api/v2/admin/jobs/:jobUuid/error. The job can run again once the error flag has been cleared. It is possible to invoke POST /api/v2/admin/processJobs to trigger a manual event which will start the job processing.

Jobs which keep failing can be permanently removed from the job queue via the DELETE /api/v2/admin/jobs/:jobUuid endpoint. Please note that it is only possible to remove jobs which have failed. Jobs which don’t fail will automatically be removed from the list.

Clustering

Clustering is described in detail in our dedicated clustering documentation.