blob: cdc6f165151b12e12772add689516efe89088ec2 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Simplified Representations :: Apache Isis</title>
<link rel="canonical" href="https://isis.apache.org/vro/2.0.0-M3/simplified-representations.html">
<meta name="generator" content="Antora 2.2.0">
<link rel="stylesheet" href="../../_/css/site.css">
<link rel="stylesheet" href="../../_/css/site-custom.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,700,700i|Raleway:300,400,500,700,800|Montserrat:300,400,700" rel="stylesheet">
<link rel="home" href="https://isis.apache.org" title="Apache Isis">
<link rel="next" href="configuration-properties.html" title="Configuration Properties">
<link rel="prev" href="health-check.html" title="Health Check">
</head>
<body class="article">
<header class="header">
<nav class="navbar">
<div class="navbar-brand">
<a class="navbar-item" href="https://isis.apache.org">
<span class="icon">
<img src="../../_/img/isis-logo-48x48.png"></img>
</span>
<span>Apache Isis</span>
</a>
<button class="navbar-burger" data-target="topbar-nav">
<span></span>
<span></span>
<span></span>
</button>
</div>
<div id="topbar-nav" class="navbar-menu">
<a class="navbar-end">
<div class="navbar-item has-dropdown is-hoverable">
<a class="navbar-link" href="#">Quick Start</a>
<div class="navbar-dropdown">
<span class="navbar-item navbar-heading">Starter Apps</span>
<a class="navbar-item" href="../../docs/latest/starters/helloworld.html">Hello World</a>
<a class="navbar-item" href="../../docs/latest/starters/simpleapp.html">Simple App</a>
<hr class="navbar-divider"/>
<span class="navbar-item navbar-heading">Demos &amp; Tutorials</span>
<a class="navbar-item" href="../../docs/latest/demo/about.html">Demo App</a>
<a class="navbar-item" href="https://danhaywood.gitlab.io/isis-petclinic-tutorial-docs/petclinic/1.16.2/intro.html">Petclinic (tutorial)</a>
<hr class="navbar-divider"/>
<span class="navbar-item navbar-heading">Resources</span>
<a class="navbar-item" href="../../docs/latest/resources/cheatsheet.html">Cheatsheet</a>
<a class="navbar-item" href="../../docs/latest/resources/icons.html">Icons</a>
</div>
</div>
<div class="navbar-item has-dropdown is-hoverable">
<a class="navbar-link" href="#">Guides</a>
<div class="navbar-dropdown">
<span class="navbar-item navbar-heading">Development</span>
<a class="navbar-item" href="../../setupguide/latest/about.html">Setup Guide</a>
<hr class="navbar-divider"/>
<span class="navbar-item navbar-heading">Core</span>
<a class="navbar-item" href="../../userguide/latest/about.html">User Guide</a>
<a class="navbar-item" href="../../refguide/latest/about.html">Reference Guide</a>
<a class="navbar-item" href="../../testing/latest/about.html">Testing Guide</a>
</div>
</div>
<div class="navbar-item has-dropdown is-hoverable">
<a class="navbar-link" href="#">Libraries</a>
<div class="navbar-dropdown">
<span class="navbar-item navbar-heading">For Use in Apps</span>
<a class="navbar-item" href="../../subdomains/latest/about.html">Subdomain Libraries</a>
<a class="navbar-item" href="../../valuetypes/latest/about.html">Value Types</a>
<hr class="navbar-divider"/>
<span class="navbar-item navbar-heading">Integrate between Apps</span>
<a class="navbar-item" href="../../mappings/latest/about.html">Bounded Context Mapping Libraries</a>
<hr class="navbar-divider"/>
<span class="navbar-item navbar-heading">Other</span>
<a class="navbar-item" href="../../incubator/latest/about.html">Incubator</a>
<a class="navbar-item" href="../../legacy/latest/about.html">Legacy</a>
</div>
</div>
<div class="navbar-item has-dropdown is-hoverable">
<a class="navbar-link" href="#">Components</a>
<div class="navbar-dropdown">
<span class="navbar-item navbar-heading">Viewers</span>
<a class="navbar-item" href="../../vw/latest/about.html">Wicket UI</a>
<a class="navbar-item" href="../../vro/latest/about.html">Restful Objects (REST)</a>
<hr class="navbar-divider"/>
<span class="navbar-item navbar-heading">Security</span>
<a class="navbar-item" href="../../security/latest/about.html">Security Guide</a>
<hr class="navbar-divider"/>
<span class="navbar-item navbar-heading">Persistence</span>
<a class="navbar-item" href="../../pjdo/latest/about.html">DataNucleus (JDO)</a>
<hr class="navbar-divider"/>
<span class="navbar-item navbar-heading">Extensions</span>
<a class="navbar-item" href="../../extensions/latest/about.html">Extensions Catalog</a>
</div>
</div>
<div class="navbar-item has-dropdown is-hoverable">
<a class="navbar-link" href="#">Support</a>
<div class="navbar-dropdown">
<span class="navbar-item navbar-heading">Contact</span>
<a class="navbar-item" href="../../docs/latest/support/slack-channel.html">Slack</a>
<a class="navbar-item" href="../../docs/latest/support/mailing-list.html">Mailing Lists</a>
<a class="navbar-item" href="https://issues.apache.org/jira/browse/ISIS">JIRA</a>
<a class="navbar-item" href="https://stackoverflow.com/questions/tagged/isis">Stack Overflow</a>
<hr class="navbar-divider"/>
<span class="navbar-item navbar-heading">Releases</span>
<a class="navbar-item" href="../../docs/latest/downloads/how-to.html">Downloads</a>
<a class="navbar-item" href="../../relnotes/latest/about.html">Release Notes</a>
<a class="navbar-item" href="../../docs/latest/archive/1-x.html">Archive (1.x)</a>
<hr class="navbar-divider"/>
<span class="navbar-item navbar-heading">Framework</span>
<a class="navbar-item" href="../../conguide/latest/about.html">Contributors' Guide</a>
<a class="navbar-item" href="../../comguide/latest/about.html">Committers' Guide</a>
<a class="navbar-item" href="../../core/latest/about.html">Core Design</a>
</div>
</div>
<div class="navbar-item has-dropdown is-hoverable">
<a class="navbar-link" href="#">ASF</a>
<div class="navbar-dropdown">
<a class="navbar-item" href="http://www.apache.org/">Apache Homepage</a>
<a class="navbar-item" href="https://www.apache.org/events/current-event">Events</a>
<a class="navbar-item" href="https://www.apache.org/licenses/">Licenses</a>
<a class="navbar-item" href="https://www.apache.org/security/">Security</a>
<a class="navbar-item" href="https://www.apache.org/foundation/sponsorship.html">Sponsorship</a>
<a class="navbar-item" href="https://www.apache.org/foundation/thanks.html">Thanks</a>
<hr class="navbar-divider"/>
<a class="navbar-item" href="https://whimsy.apache.org/board/minutes/Isis.html">PMC board minutes</a>
</div>
</div>
<a class="navbar-item" href="../../docs/latest/about.html">
<span class="icon">
<img src="../../_/img/home.png"></img>
</span>
</a>
</div>
</div>
</nav>
</header>
<div class="body ">
<div class="nav-container" data-component="vro" data-version="2.0.0-M3">
<aside class="nav">
<div class="panels">
<div class="nav-panel-pagination">
<a class="page-previous" rel="prev" href="health-check.html" title="Health Check"><span></span></a>
<a class="page-next" rel="next"
href="configuration-properties.html" title="Configuration Properties"><span></span></a>
<!--
page.parent doesn't seem to be set...
<a class="page-parent disabled" rel="prev" href="" title="Health Check"><span></span></a>
-->
</div>
<div class="nav-panel-menu is-active" data-panel="menu">
<nav class="nav-menu">
<h3 class="title"><a href="about.html">Restful Objects Viewer</a></h3>
<ul class="nav-list">
<li class="nav-item" data-depth="0">
<ul class="nav-list">
<li class="nav-item" data-depth="1">
<a class="nav-link" href="ro-spec.html">RO Spec</a>
</li>
<li class="nav-item" data-depth="1">
<a class="nav-link" href="architecture.html">Architecture</a>
</li>
<li class="nav-item" data-depth="1">
<a class="nav-link" href="layout-resources.html">Layout Resources</a>
</li>
<li class="nav-item" data-depth="1">
<a class="nav-link" href="health-check.html">Health Check</a>
</li>
<li class="nav-item is-current-page" data-depth="1">
<a class="nav-link" href="simplified-representations.html">Simplified Representations</a>
</li>
<li class="nav-item" data-depth="1">
<a class="nav-link" href="configuration-properties.html">Configuration Properties</a>
</li>
<li class="nav-item" data-depth="1">
<a class="nav-link" href="security.html">Security</a>
</li>
<li class="nav-item" data-depth="1">
<a class="nav-link" href="hints-and-tips.html">Hints-n-Tips</a>
</li>
<li class="nav-item" data-depth="1">
<button class="nav-item-toggle"></button>
<span class="nav-text">Extensions</span>
<ul class="nav-list">
<li class="nav-item" data-depth="2">
<a class="nav-link" href="cors/about.html">CORS</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
</div>
<div class="nav-panel-explore" data-panel="explore">
<div class="context">
<span class="title">Restful Objects Viewer</span>
<span class="version">2.0.0-M3</span>
</div>
<ul class="components">
<li class="component">
<span class="title"> </span>
<ul class="versions">
<li class="version is-latest">
<a href="../../docs/2.0.0-M3/about.html">2.0.0-M3</a>
</li>
</ul>
</li>
<li class="component">
<span class="title">BC Mappings Catalog</span>
<ul class="versions">
<li class="version is-latest">
<a href="../../mappings/2.0.0-M3/about.html">2.0.0-M3</a>
</li>
</ul>
</li>
<li class="component">
<span class="title">Committers' Guide</span>
<ul class="versions">
<li class="version is-latest">
<a href="../../comguide/2.0.0-M3/about.html">2.0.0-M3</a>
</li>
</ul>
</li>
<li class="component">
<span class="title">Contributors' Guide</span>
<ul class="versions">
<li class="version is-latest">
<a href="../../conguide/2.0.0-M3/about.html">2.0.0-M3</a>
</li>
</ul>
</li>
<li class="component">
<span class="title">Design Docs</span>
<ul class="versions">
<li class="version is-latest">
<a href="../../core/2.0.0-M3/about.html">2.0.0-M3</a>
</li>
</ul>
</li>
<li class="component">
<span class="title">Extensions Catalog</span>
<ul class="versions">
<li class="version is-latest">
<a href="../../extensions/2.0.0-M3/about.html">2.0.0-M3</a>
</li>
</ul>
</li>
<li class="component">
<span class="title">Incubator Catalog</span>
<ul class="versions">
<li class="version is-latest">
<a href="../../incubator/2.0.0-M3/about.html">2.0.0-M3</a>
</li>
</ul>
</li>
<li class="component">
<span class="title">JDO/DataNucleus</span>
<ul class="versions">
<li class="version is-latest">
<a href="../../pjdo/2.0.0-M3/about.html">2.0.0-M3</a>
</li>
</ul>
</li>
<li class="component">
<span class="title">Legacy Catalog</span>
<ul class="versions">
<li class="version is-latest">
<a href="../../legacy/2.0.0-M3/about.html">2.0.0-M3</a>
</li>
</ul>
</li>
<li class="component">
<span class="title">Reference Guide</span>
<ul class="versions">
<li class="version is-latest">
<a href="../../refguide/2.0.0-M3/about.html">2.0.0-M3</a>
</li>
</ul>
</li>
<li class="component">
<span class="title">Release Notes</span>
<ul class="versions">
<li class="version is-latest">
<a href="../../relnotes/2.0.0-M3/about.html">2.0.0-M3</a>
</li>
</ul>
</li>
<li class="component is-current">
<span class="title">Restful Objects Viewer</span>
<ul class="versions">
<li class="version is-current is-latest">
<a href="about.html">2.0.0-M3</a>
</li>
</ul>
</li>
<li class="component">
<span class="title">Security Guide</span>
<ul class="versions">
<li class="version is-latest">
<a href="../../security/2.0.0-M3/about.html">2.0.0-M3</a>
</li>
</ul>
</li>
<li class="component">
<span class="title">Setup Guide</span>
<ul class="versions">
<li class="version is-latest">
<a href="../../setupguide/2.0.0-M3/about.html">2.0.0-M3</a>
</li>
</ul>
</li>
<li class="component">
<span class="title">Subdomains Catalog</span>
<ul class="versions">
<li class="version is-latest">
<a href="../../subdomains/2.0.0-M3/about.html">2.0.0-M3</a>
</li>
</ul>
</li>
<li class="component">
<span class="title">Testing Guide</span>
<ul class="versions">
<li class="version is-latest">
<a href="../../testing/2.0.0-M3/about.html">2.0.0-M3</a>
</li>
</ul>
</li>
<li class="component">
<span class="title">User Guide</span>
<ul class="versions">
<li class="version is-latest">
<a href="../../userguide/2.0.0-M3/about.html">2.0.0-M3</a>
</li>
</ul>
</li>
<li class="component">
<span class="title">Value Types Catalog</span>
<ul class="versions">
<li class="version is-latest">
<a href="../../valuetypes/2.0.0-M3/about.html">2.0.0-M3</a>
</li>
</ul>
</li>
<li class="component">
<span class="title">Wicket Viewer</span>
<ul class="versions">
<li class="version is-latest">
<a href="../../vw/2.0.0-M3/about.html">2.0.0-M3</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
</aside>
</div>
<main role="main">
<div class="toolbar" role="navigation">
<button class="nav-toggle"></button>
<a href="../../docs/2.0.0-M3/about.html" class="home-link"></a>
<nav class="breadcrumbs" aria-label="breadcrumbs">
<ul>
<li><a href="about.html">Restful Objects Viewer</a></li>
<li><a href="simplified-representations.html">Simplified Representations</a></li>
</ul>
</nav>
<div class="edit-this-page"><a href="https://github.com/apache/isis/edit/2.0.0-M3/viewers/restfulobjects/adoc/modules/ROOT/pages/simplified-representations.adoc">Edit</a></div>
</div>
<article class="doc">
<a name="section-top"></a>
<h1 class="page">Simplified Representations</h1>
<div id="preamble">
<div class="sectionbody">
<div class="admonitionblock warning">
<table>
<tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
TODO: this content has not yet been reviewed/updated for v2.0
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The representations defined by the RO spec are very rich and enable complex client-side applications to be built.
However, their sophistication can be an impediment to their use if one wishes to write a simple app using third-party components that expect to consume much simpler representations.
Examples of such tools are
<a href="http://angular-ui.github.io/bootstrap/">Angular Bootstrap</a>,
<a href="http://vitalets.github.io/angular-xeditable/">Angular XEditable</a>,
<a href="https://github.com/mgcrea/angular-strap">Angular Strap</a>.</p>
</div>
<div class="paragraph">
<p>Apache Isis also provides support for its own simplified representation for the most commonly-used representations.
This is implemented using the <code>ContentNegotiationService</code> described in the
<a href="architecture.html" class="page">architecture</a> chapter.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="apache-isis-profile"><a class="anchor" href="#apache-isis-profile"></a>The Apache Isis "Profile"</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The RO spec uses the standard <code>Accept</code> header for content negotiation, and defines its own "profile" for the standard
representations; these take the form:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code>Accept: application/json;profile="urn:org.restfulobjects:repr-types/xxx"</code></pre>
</div>
</div>
<div class="paragraph">
<p>where "xxx" varies by resource. The detail can be found in section 2.4.1 of the RO spec.</p>
</div>
<div class="paragraph">
<p>The Apache Isis viewer also defines its own "Isis" profile which enables the client to request simplified
representations for the most frequently accessed resources. This is done by specifying an <code>Accept</code> header of:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code>Accept: application/json;profile="urn:org.apache.isis/v1"</code></pre>
</div>
</div>
<div class="paragraph">
<p>Not every resource supports this header, but the most commonly accessed ones do. In each case the server will set the
<code>Content-Type</code> header so that the client knows how to process the representation.</p>
</div>
<div class="paragraph">
<p>The <a href="https://www.youtube.com/watch?v=HMSqapQDY_4">screencast</a> demonstrates the feature.</p>
</div>
<div class="paragraph">
<p>The sections below explain in a little more detail what is returned when this profile is activated.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="domain-object"><a class="anchor" href="#domain-object"></a>Domain Object</h2>
<div class="sectionbody">
<div class="paragraph">
<p>If a domain object resource (section 14) is accessed with the Apache Isis profile, the resultant representation is a
JSON object with simple key/value pairs for each property.</p>
</div>
<div class="paragraph">
<p>The contents of any collections are also eagerly returned, consisting of an array of elements of each referenced
object. Each such element contains key/value pairs of each property (in other words, a grid of data is returned).
Each element also has a special <code>href` property (so that the client can easily navigate to a resource for that
object) and a `title</code> property (to use as a label, eg the hyperlink text).</p>
</div>
<div class="paragraph">
<p>In addition, the representation defined by the RO spec is also included, under a special <code>$$ro</code> property.</p>
</div>
<div class="paragraph">
<p>For example, in a todo app, accessing this resource:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code>http://localhost:8080/restful/objects/TODO/45</code></pre>
</div>
</div>
<div class="paragraph">
<p>with an <code>Accept</code> request header of:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code>Accept: application/json;profile="urn:org.apache.isis/v1"</code></pre>
</div>
</div>
<div class="paragraph">
<p>returns the following representation:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code>{
"$$href" : "http://localhost:8080/restful/objects/TODO/45", <i class="conum" data-value="1"></i><b>(1)</b>
"$$instanceId" : "45", <i class="conum" data-value="2"></i><b>(2)</b>
"$$title" : "Buy bread due by 2015-12-04", <i class="conum" data-value="3"></i><b>(3)</b>
"description" : "Buy bread", <i class="conum" data-value="4"></i><b>(4)</b>
"category" : "Domestic",
"subcategory" : "Shopping",
"complete" : false,
"atPath" : "/users/sven",
...
"similarTo" : [ { <i class="conum" data-value="5"></i><b>(5)</b>
"$$href" : "http://localhost:8080/restful/objects/TODO/46",
"$$instanceId" : "46",
"$$title" : "Buy milk due by 2015-12-04",
"description" : "Buy milk",
"category" : "Domestic",
...
}, {
"$$href" : "http://localhost:8080/restful/objects/TODO/47",
"$$instanceId" : "47",
"$$title" : "Buy stamps due by 2015-12-04",
"description" : "Buy stamps",
"category" : "Domestic",
...
},
...
} ],
"dependencies" : [ ],
"$$ro" : { <i class="conum" data-value="6"></i><b>(6)</b>
"links" : [ ... ],
"extensions" : { /* ... */ },
"title" : "Buy bread due by 2015-12-04",
"domainType" : "TODO",
"instanceId" : "45",
"members" : { /* ... */ }
}
}</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>hyperlink to the representation</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>instance id of the domain object (unique within its type)</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>title of the domain object</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>all the properties of the domain object (to which the caller has access), as key/value pairs</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>contents of each collection</td>
</tr>
<tr>
<td><i class="conum" data-value="6"></i><b>6</b></td>
<td>special <code>$$ro</code> json-prop, being the normal RO Spec representation for this object</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>with a <code>Content-Type</code> header:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code>Content-Type: application/json;
profile="urn:org.apache.isis/v1";repr-type="object"</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="object-collection"><a class="anchor" href="#object-collection"></a>Domain Object Collection</h2>
<div class="sectionbody">
<div class="paragraph">
<p>If a domain object collection (section 17) is accessed with this profile, then the resultant representation is as
an array of elements of key/value for each referenced object, and again each element the containing the key/value
pairs of the properties of that object (a grid, again).<br></p>
</div>
<div class="paragraph">
<p>In addition, the representation defined by the RO spec is also included, as a special object with a single <code>$$ro</code>
property.</p>
</div>
<div class="paragraph">
<p>For example, in a todo app, accessing this resource:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code>http://localhost:8080/restful/objects/TODO/45/collections/similarTo</code></pre>
</div>
</div>
<div class="paragraph">
<p>with an <code>Accept</code> request header of:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code>Accept: application/json;profile="urn:org.apache.isis/v1"</code></pre>
</div>
</div>
<div class="paragraph">
<p>returns the following representation:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code>[ <i class="conum" data-value="1"></i><b>(1)</b>
{
"$$href" : "http://localhost:8080/restful/objects/TODO/46", <i class="conum" data-value="2"></i><b>(2)</b>
"$$instanceId" : "46", <i class="conum" data-value="3"></i><b>(3)</b>
"$$title" : "Buy milk due by 2015-12-04", <i class="conum" data-value="4"></i><b>(4)</b>
"description" : "Buy milk", <i class="conum" data-value="5"></i><b>(5)</b>
"category" : "Domestic",
...
}, {
"$$href" : "http://localhost:8080/restful/objects/TODO/47",
"$$title" : "Buy stamps due by 2015-12-04",
"description" : "Buy stamps",
"category" : "Domestic",
...
}, {
"$$href" : "http://localhost:8080/restful/objects/TODO/48",
"$$title" : "Mow lawn due by 2015-12-10",
"description" : "Mow lawn",
"category" : "Domestic",
...
},
...
, {
"$$ro" : { <i class="conum" data-value="6"></i><b>(6)</b>
"id" : "similarTo",
"memberType" : "collection",
"links" : [ ... ],
"extensions" : { /* ... */ },
"value" : [ ... ]
}
}
]</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>returns a JSON array, not a JSON object</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>hyperlink to the representation</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>instance id of the domain object (unique within its type)</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>title of the domain object</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>all the properties of the domain object (to which the caller has access), as key/value pairs</td>
</tr>
<tr>
<td><i class="conum" data-value="6"></i><b>6</b></td>
<td>last element is a special object with a single <code>$$ro</code> json-prop, being the normal RO Spec representation for this object</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>with a <code>Content-Type</code> header:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code>Content-Type: application/json;profile="urn:org.apache.isis/v1";repr-type="object-collection"</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="action-invocation"><a class="anchor" href="#action-invocation"></a>Action Invocation</h2>
<div class="sectionbody">
<div class="paragraph">
<p>When an action is invoked, it can return a domain object, a list, a scalar, or return nothing.</p>
</div>
<div class="sect2">
<h3 id="returning-an-object"><a class="anchor" href="#returning-an-object"></a>Returning an Object</h3>
<div class="paragraph">
<p>If the action returned an object, then the <a href="#domain-object">domain object representation</a> is returned.</p>
</div>
<div class="paragraph">
<p>For example, in a todo app, accessing this resource:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code>http://localhost:8080/restful/objects/TODO/45/actions/updateCost/invoke</code></pre>
</div>
</div>
<div class="paragraph">
<p>with an <code>Accept</code> request header of:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code>Accept: application/json;profile="urn:org.apache.isis/v1"</code></pre>
</div>
</div>
<div class="paragraph">
<p>returns the following representation:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code>{
"$$href" : "http://localhost:8080/restful/objects/TODO/45",
"$$instanceId" : "45",
"$$title" : "Buy bread due by 2015-12-04",
"description" : "Buy bread",
"category" : "Domestic",
"subcategory" : "Shopping",
"complete" : false,
...
"similarTo" : [ ... ]
...
"$$ro" : { /* ... */ }
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>with a <code>Content-Type</code> of:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code>Content-Type: application/json;profile="urn:org.apache.isis/v1";repr-type="object"</code></pre>
</div>
</div>
<div class="paragraph">
<p>... in other words no different to a representation obtained of the returned domain object directly.</p>
</div>
</div>
<div class="sect2">
<h3 id="returning-a-list"><a class="anchor" href="#returning-a-list"></a>Returning a List</h3>
<div class="paragraph">
<p>On the other hand if the action returned a list (a "standalone" collection, then an array representation is returned.
This is very similar to that returned by a <a href="#object-collection">(parented) object collection</a>, though with a slightly different <code>Content-Type</code> to distinguish.</p>
</div>
<div class="paragraph">
<p>For example, in a todo app, accessing this resource:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code>http://localhost:8080/restful/services/ToDoItems/actions/notYetComplete/invoke</code></pre>
</div>
</div>
<div class="paragraph">
<p>with an <code>Accept</code> request header of:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code>Accept: application/json;profile="urn:org.apache.isis/v1"</code></pre>
</div>
</div>
<div class="paragraph">
<p>returns the following representation:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code>[ {
"$$href" : "http://localhost:8080/restful/objects/TODO/45",
"$$instanceId" : "45",
"$$title" : "Buy bread due by 2015-12-04",
"description" : "Buy bread",
"category" : "Domestic",
...
}, {
"$$href" : "http://localhost:8080/restful/objects/TODO/46",
"$$instanceId" : "46",
"$$title" : "Buy milk due by 2015-12-04",
"description" : "Buy milk",
"category" : "Domestic",
...
},
...
, {
"$$ro" : {
"links" : [ ... ]
"resulttype" : "list",
"result" : { /* ... */ }
"value" : [ ... ],
"links" : [ ... ],
"extensions" : { }
}
}
} ]</code></pre>
</div>
</div>
<div class="paragraph">
<p>with a <code>Content-Type</code> header:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code>Content-Type: application/json;profile="urn:org.apache.isis/v1";repr-type="list"</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="returning-scalarnothing"><a class="anchor" href="#returning-scalarnothing"></a>Returning Scalar/Nothing</h3>
<div class="paragraph">
<p>Note that actions returning scalar values or nothing (which includes <code>void</code> actions) are not supported; for these the
regular RO spec representation will be returned.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="other-representations"><a class="anchor" href="#other-representations"></a>Other Representations</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Sometimes though you may want to extend or change the representations generated. This might be because you want to
write a RESTful client that uses a particular library (say a Javascript library or web components) that can only handle representations in a certain form.</p>
</div>
<div class="paragraph">
<p>Or, you might want to have Apache Isis generate representations according to some other "standard", of which there are
many:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Mike Kelly&#8217;s <a href="http://stateless.co/hal_specification.html">HAL</a> specification</p>
</li>
<li>
<p>Mike Amundsen&#8217;s <a href="http://amundsen.com/media-types/collection/">Collection+JSON</a> specification</p>
</li>
<li>
<p>Kevin Swiber&#8217;s <a href="https://github.com/kevinswiber/siren">Siren</a> specification</p>
</li>
<li>
<p>Steve Klabnik&#8217;s <a href="http://jsonapi.org/">JSON API</a> specification</p>
</li>
<li>
<p>Gregg Cainus' <a href="https://github.com/cainus/hyper-json-spec">Hyper+JSON</a> specification</p>
</li>
<li>
<p>the W3C&#8217;s <a href="https://www.w3.org/TR/json-ld/">JSON-LD</a> specification</p>
</li>
<li>
<p>Markus Lanthaler&#8217;s <a href="http://www.markus-lanthaler.com/hydra/">Hydra</a> specification.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>A good discussion about the relative merits of several of these different hypermedia formats can be found <a href="https://groups.google.com/forum/#!msg/api-craft/NgjzQYVOE4s/EAB2jxtU_TMJ">here</a>.</p>
</div>
<div class="paragraph">
<p>Or, of course, you may have your own internal specification that you wish to use.</p>
</div>
<div class="paragraph">
<p>Supporting any of these alternative representations can be achieved by providing a suitable implementation of
<code>ContentNegotiationService</code>. The existing implementations (eg <code>ContentNegotiationServiceSimplified</code>) can be used as a
starting point.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>These will, admittedly, need to access the internal APIs for the Apache Isis metamodel, and you should be aware that
these are not formal API; they may change over time. That said, they are very stable and have not changed
significantly over the last few years.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="configuration-properties"><a class="anchor" href="#configuration-properties"></a>Global Config Props (Deprecated)</h2>
<div class="sectionbody">
<div class="paragraph">
<p>If all that is required is a very simple representations (of objects), you can configure the Restful Objects viewer
to provide a simplified output, then this can be done with a number of (global) configuration properties.</p>
</div>
<div class="paragraph">
<p>These configuration properties pre-date the support for the Apache Isis profile, and
are limited by the fact that they are global configuration settings, so cannot be influenced on a request-by-request
basis (as is the case with the <code>Accept</code> header used for the Apache Isis profile). They have therefore been
deprecated, and may be removed in the future.</p>
</div>
<div class="paragraph">
<p>Details can be found in <a href="configuration-properties.html#deprecated" class="page">here</a>.</p>
</div>
</div>
</div>
</article>
<aside class="article-aside toc" role="navigation">
<p class="toc-title">On this page</p>
<div id="article-toc"></div>
</aside>
</main>
</div>
<footer class="footer">
<div class="content">
<div class="copyright">
<p>
Copyright © 2010~2020 The Apache Software Foundation, licensed under the Apache License, v2.0.
<br/>
Apache, the Apache feather logo, Apache Isis, and the Apache Isis project logo are all trademarks of The Apache Software Foundation.
</p>
</div>
<div class="revision">
<p>Revision: SNAPSHOT</p>
</div>
</div>
</footer>
<script src="../../_/js/site.js"></script>
<script async src="../../_/js/vendor/highlight.js"></script>
<script src="../../_/js/vendor/jquery-3.4.1.min.js"></script>
<script src="../../_/js/vendor/jquery-ui-1.12.1.custom.widget-only.min.js"></script>
<script src="../../_/js/vendor/jquery.tocify.min.js"></script>
<script>
$(function() {
$("#article-toc").tocify( {
showEffect: "slideDown",
hashGenerator: "pretty",
hideEffect: "slideUp",
selectors: "h2, h3",
scrollTo: 120,
smoothScroll: true,
theme: "jqueryui",
highlightOnScroll: true
} );
});
</script>
</body>
</html>