You can remove links from the response by either excluding or filtering the link.

Exclude Link Relations

While building the RepresentationModel object, you can specify which relations should be excluded from the response. The following example excludes the self and submitMyOrder links:

RepresentationModel model = new RepresentationModel.Builder().state(order).
    excludeLinkRelation("self","submitMyOrder");
Filter Links

You can implement the LinkFilter in a resource class to remove links that are not required in the response. The endpoint implements this interface by overriding the filterLinks method.

For example:

@Path("/test/orders")
public class OrderRESTResource implements LinkFilter {
  @Override  public void filterLinks(RepresentationModel pModel) {
  Link[] links = // Links not to be included   pModel.removeLinks(links);
  }
}

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