Package com.emc.documentum.rest.view
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 byLinkable
, e.g.PersistentObject
- Direct Known Subclasses:
EntryableView
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 Summary
Modifier and TypeFieldDescriptionprotected com.emc.documentum.rest.utils.LinkRelationBuilder
protected String
protected boolean
protected T
protected UriInfo
Fields inherited from class com.emc.documentum.rest.view.LegacyLinkableView
uriFactory, uriFactoryNoValidation
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Return true if the request URL from the constructor parameterUriInfo
matches to the thecanonical()
of this view definition.Get the canonical resource URI.abstract String
canonicalResourceUri
(boolean validate) Get the canonical resource URI dynamically with an validation option.void
Clear all links on the data model including the self link relation.protected String
Get the current request URI from the constructor parameterUriInfo
.abstract void
Change the model representation with this method.data()
Return the link resolved resource model instance.protected T
Get the internal data model instance withoutcustomize()
called.Return other parameters from the constructor parameter.Class<? extends AbstractController>
Return the working resource controller class of this view instanceprotected void
Construct custom adding link relations from the YAML file and add to the data model.protected String
Get resource URI for the specified resource and id attribute.protected ResourceUriBuilder
idUriBuilder
(String resource, String id) Get resource URI builder for id attribute as the path variable.boolean
inFeed()
Indicate whether the view instance is created fromAtomFeedFactory
.protected void
Make default links on the resource model instance.boolean
Write a link relation to the data model.boolean
Write a link relation to the data model.boolean
makeLinkIf
(boolean when, String rel, String href) Write a link relation to the data model.boolean
makeLinkIf
(boolean when, String rel, String href, String title) Write a link relation to the data model with a condition.boolean
makeLinkTemplate
(String rel, String href) Write a link template to the data model.boolean
makeLinkTemplateIf
(boolean when, String rel, String href, String title) Write a link relation to the data model with a condition.protected String
Get resource URI for specified resource and name attribute.protected ResourceUriBuilder
nameUriBuilder
(String resource, String name) Get resource URI builder for name attribute as the path variable.protected boolean
Indicate whether the view instance is created from a post method on a collection.boolean
removeLink
(String rel, String title) Remove a link relation or link template from the data model.resolveUriTemplateVariables
(Map<String, String> valueMapping) Resolve the property values for the URI template variables mapping passed from the YAML file.protected void
Construct self link(s) and add to the data model.protected ResourceUriBuilder
uriBuilder
(String resource) Get resource URI builder for a resource.Methods inherited from class com.emc.documentum.rest.view.LegacyLinkableView
getUriFactory, getUriFactory, getUriFactoryWithoutValidation
-
Field Details
-
serializableData
-
uriInfo
-
repositoryName
-
returnLinks
protected boolean returnLinks -
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 byLinkable
uriInfo
- the URI info of the request. This is typically obtained from the resource controller where the controller method has an annotated parameter forRequestUri
repositoryName
- the repository namereturnLinks
- indicates whether to return links for this model instanceothers
- other parameters
-
-
Method Details
-
resolveUriTemplateVariables
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
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 callResourceUriBuilder
to build the resource URI. The canonical resource URI will also be used byEntryableView.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 isBaseUriFactory.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
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 settingHttpConfig.validateLinkRelation()
- Returns:
- the canonical resource URI
- See Also:
-
makeLink
Write a link relation to the data model.- Parameters:
rel
- link relation namehref
- link href url- Returns:
- true if the new link is added
-
makeLink
Write a link relation to the data model.- Parameters:
rel
- link relation namehref
- link href urltitle
- title of the link- Returns:
- true if the new link is added
-
makeLinkTemplate
Write a link template to the data model.- Parameters:
rel
- link relation namehref
- link href url- Returns:
- true if the new link is added
-
makeLinkIf
Write a link relation to the data model.- Parameters:
when
- true indicates to make the link; false does nothingrel
- link relation namehref
- link href url- Returns:
- true if the new link is added
-
makeLinkIf
Write a link relation to the data model with a condition.- Parameters:
when
- true indicates to make the link; false does nothingrel
- link relation namehref
- link href urltitle
- title of the link- Returns:
- true if the new link is added
-
makeLinkTemplateIf
Write a link relation to the data model with a condition.- Parameters:
when
- true indicates to make the link; false does nothingrel
- link relation namehref
- link href urltitle
- title of the link- Returns:
- true if the new link is added
-
removeLink
Remove a link relation or link template from the data model.- Parameters:
rel
- link relation nametitle
- 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 parameterUriInfo
matches to the thecanonical()
of this view definition.- Returns:
- true if the request URL is matching the view canonical URI
-
data
Return the link resolved resource model instance.- Returns:
- the resource model instance
-
currentRequestUri
Get the current request URI from the constructor parameterUriInfo
.- Returns:
- the request URI
-
getDataInternal
Get the internal data model instance withoutcustomize()
called.- Returns:
- the internal data model
-
getOtherParams
Return other parameters from the constructor parameter.- Returns:
- other parameters
-
inFeed
public boolean inFeed()Indicate whether the view instance is created fromAtomFeedFactory
.- Returns:
- true if the view is generated from a feed factory.
-
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
Get resource URI for the specified resource and id attribute.- Parameters:
resource
- the resource nameid
- the id value as the resource path variable- Returns:
- the resource URI
-
nameUri
Get resource URI for specified resource and name attribute.- Parameters:
resource
- the resource namename
- the name value as the resource path variable with safe encoding- Returns:
- the resource URI
-
idUriBuilder
Get resource URI builder for id attribute as the path variable.- Parameters:
resource
- the resource nameid
- the id value as the resource path variable- Returns:
- the resource URI builder
-
nameUriBuilder
Get resource URI builder for name attribute as the path variable.- Parameters:
resource
- the resource namename
- the name value as the resource path variable with safe encoding- Returns:
- the resource URI builder
-
uriBuilder
Get resource URI builder for a resource.- Parameters:
resource
- the resource name- Returns:
- the resource URI builder
-