Class LinkableView<T extends Linkable>

java.lang.Object
com.emc.documentum.rest.view.LegacyLinkableView
com.emc.documentum.rest.view.LinkableView<T>
Type Parameters:
T - resource model class extended from by Linkable, e.g. PersistentObject
Direct Known Subclasses:
EntryableView

public abstract class LinkableView<T extends Linkable> extends LegacyLinkableView
Abstract class for resource representation views that contain link relations. Implementation class of the LinkableView controls the links rendering for the resource model. The implementation class must define an annotation DataViewBinding.
  • Field Details

    • serializableData

      protected T extends Linkable serializableData
    • uriInfo

      protected UriInfo uriInfo
    • repositoryName

      protected String repositoryName
    • otherParams

      protected Map<String,Object> otherParams
    • linkBuilder

      protected com.emc.documentum.rest.utils.LinkRelationBuilder linkBuilder
  • Constructor Details

    • LinkableView

      public LinkableView(T serializableData, UriInfo uriInfo, String repositoryName, Boolean returnLinks, Map<String,Object> others)
      Constructor of the linkable view.
      Parameters:
      serializableData - the resource data model extended from by Linkable
      uriInfo - the URI info of the request. This is typically obtained from the resource controller where the controller method has an annotated parameter for RequestUri
      repositoryName - the repository name
      returnLinks - indicates whether to return links for this model instance
      others - other parameters
  • Method Details

    • resolveUriTemplateVariables

      protected abstract Map<String,Object> resolveUriTemplateVariables(Map<String,String> valueMapping)
      Resolve the property values for the URI template variables mapping passed from the YAML file. This class must be implemented for a resource which supports link customization through the YAML file.
      Parameters:
      valueMapping - variable to property name mapping where the key is a URI path variable and the value is the property name
      Returns:
      variable to actual property value mapping where the key is a URI path variable and the value is the the property value of the corresponding model
      See Also:
    • customize

      public abstract void customize()
      Change the model representation with this method. This is the generic customization interface for the resource data model.
    • canonicalResourceUri

      public abstract String canonicalResourceUri(boolean validate)
      Get the canonical resource URI dynamically with an validation option. A data model object can be used as the returning body of more than one resource controllers. When the same object is accessible through multiple resources, the canonical resource URI represents the primary resource URI for this object. The implementation of this method should return the most meaningful resource URI for this model object. The implementation can call ResourceUriBuilder to build the resource URI. The canonical resource URI will also be used by EntryableView.entryId() to produce the atom ID, so this value should not be null.
      Parameters:
      validate - explicitly specify whether to enforce validation on resource URI. When the validation is ON, the canonical URI is BaseUriFactory.INACTIVE_URL if the corresponding resource is inactive regardless of the designed resource URI. When the validation is OFF, the canonical URI is the designed resource URI.
      Returns:
      the canonical resource URI
    • canonicalResourceUri

      public String canonicalResourceUri()
      Get the canonical resource URI. The canonical resource URI represents the primary resource URI for the data object. The validation of the resource URI is implicitly controlled by the global setting HttpConfig.validateLinkRelation()
      Returns:
      the canonical resource URI
      See Also:
    • makeLink

      public boolean makeLink(String rel, String href)
      Write a link relation to the data model.
      Parameters:
      rel - link relation name
      href - link href url
      Returns:
      true if the new link is added
    • makeLink

      public boolean makeLink(String rel, String href, String title)
      Write a link relation to the data model.
      Parameters:
      rel - link relation name
      href - link href url
      title - title of the link
      Returns:
      true if the new link is added
    • makeLinkTemplate

      public boolean makeLinkTemplate(String rel, String href)
      Write a link template to the data model.
      Parameters:
      rel - link relation name
      href - link href url
      Returns:
      true if the new link is added
    • makeLinkIf

      public boolean makeLinkIf(boolean when, String rel, String href)
      Write a link relation to the data model.
      Parameters:
      when - true indicates to make the link; false does nothing
      rel - link relation name
      href - link href url
      Returns:
      true if the new link is added
    • makeLinkIf

      public boolean makeLinkIf(boolean when, String rel, String href, String title)
      Write a link relation to the data model with a condition.
      Parameters:
      when - true indicates to make the link; false does nothing
      rel - link relation name
      href - link href url
      title - title of the link
      Returns:
      true if the new link is added
    • makeLinkTemplateIf

      public boolean makeLinkTemplateIf(boolean when, String rel, String href, String title)
      Write a link relation to the data model with a condition.
      Parameters:
      when - true indicates to make the link; false does nothing
      rel - link relation name
      href - link href url
      title - title of the link
      Returns:
      true if the new link is added
    • removeLink

      public boolean removeLink(String rel, String title)
      Remove a link relation or link template from the data model.
      Parameters:
      rel - link relation name
      title - title of the link
      Returns:
      true if the link is removed; false if the link does not exist or is not removed.
    • clearLinks

      public void clearLinks()
      Clear all links on the data model including the self link relation.
    • canonical

      public boolean canonical()
      Return true if the request URL from the constructor parameter UriInfo matches to the the canonical() of this view definition.
      Returns:
      true if the request URL is matching the view canonical URI
    • data

      public T data()
      Return the link resolved resource model instance.
      Returns:
      the resource model instance
    • currentRequestUri

      protected String currentRequestUri()
      Get the current request URI from the constructor parameter UriInfo.
      Returns:
      the request URI
    • getDataInternal

      protected T getDataInternal()
      Get the internal data model instance without customize() called.
      Returns:
      the internal data model
    • getOtherParams

      public Map<String,?> getOtherParams()
      Return other parameters from the constructor parameter.
      Returns:
      other parameters
    • inFeed

      public boolean inFeed()
      Indicate whether the view instance is created from AtomFeedFactory.
      Returns:
      true if the view is generated from a feed factory.
    • getWorkingController

      public Class<? extends AbstractController> getWorkingController()
      Return the working resource controller class of this view instance
      Returns:
      the controller class
    • postFromCollection

      protected boolean postFromCollection()
      Indicate whether the view instance is created from a post method on a collection.
      Returns:
      true if the view is generated from a post method on a collection.
    • makeDefaultCustomization

      protected void makeDefaultCustomization()
      Make default links on the resource model instance. This is the link customization made to the resource model instance. The default customization adds the self link by default and custom links from the YAML file. This method can be overridden to add or remove links to change the default resource representation.
    • selfLinks

      protected void selfLinks()
      Construct self link(s) and add to the data model.
    • handleCustomYamlLinks

      protected void handleCustomYamlLinks()
      Construct custom adding link relations from the YAML file and add to the data model.
    • idUri

      protected String idUri(String resource, String id)
      Get resource URI for the specified resource and id attribute.
      Parameters:
      resource - the resource name
      id - the id value as the resource path variable
      Returns:
      the resource URI
    • nameUri

      protected String nameUri(String resource, String name)
      Get resource URI for specified resource and name attribute.
      Parameters:
      resource - the resource name
      name - the name value as the resource path variable with safe encoding
      Returns:
      the resource URI
    • idUriBuilder

      protected ResourceUriBuilder idUriBuilder(String resource, String id)
      Get resource URI builder for id attribute as the path variable.
      Parameters:
      resource - the resource name
      id - the id value as the resource path variable
      Returns:
      the resource URI builder
    • nameUriBuilder

      protected ResourceUriBuilder nameUriBuilder(String resource, String name)
      Get resource URI builder for name attribute as the path variable.
      Parameters:
      resource - the resource name
      name - the name value as the resource path variable with safe encoding
      Returns:
      the resource URI builder
    • uriBuilder

      protected ResourceUriBuilder uriBuilder(String resource)
      Get resource URI builder for a resource.
      Parameters:
      resource - the resource name
      Returns:
      the resource URI builder