When a resource URI has been embedded in a RepresentationModel, the framework message body writer invokes the URI to get the resource representation to embed. Note that an embedded resource will only appear in the response if the payloadSchema.xml includes an embedded tag for the embedded relation name. The use-validator-id attribute of the embedded tag identifies the validator to use for the embedded resource.

Embedded collection resources members can be added to the RepresentationModel by calling the members method and passing the array of string URIs or the links that contain the self link to each individual member of the collection.

When retrieving embedded resources, if the client request does not specify that an Etag should be generated by using the generateEtags query parameter, the framework will set the parameter to false so that Etags will not be generated. For additional information, refer to the Working with Client-Side Caching section.

To embed a resource, add the URI of the resource to the model. You can find the URI of the resource by using the LinkUtils class. To obtain an instance of LinkUtils, use the static LinkUtils.getLinkUtils() method, or resolve the global Nucleus component.

The LinkUtils class contains the following methods that can be used to find the resource’s URI:

Method

Description

buildResourceUri

Provides support for generating a URI for any resource for a given resource ID.

buildMemberUris

Provides support for generating member URIs for collection resources.

selfLinkFromContext

Provides a way to generate a self link based on the data in context. Normally this is invoked automatically by the framework and does not need to be invoked by an endpoint. However, if an endpoint needs a custom self link, it can call this method. Note: If a collection resource endpoint needs to respond with a singular resource representation, then the endpoint must invoke the overloaded version of the method selfLinkFromContext (true, singular ID) to generate the self link for the singular resource.


Copyright © 1997, 2017 Oracle and/or its affiliates. All rights reserved. Legal Notices