Class HrefHelper
java.lang.Object
org.eclipse.persistence.jpa.rs.util.HrefHelper
A collection of static methods used to build 'href' attribute values for REST 'link' elements.
- Since:
- EclipseLink 2.6.0
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
buildBaseRestSchemaRef
(String type) Returns a link to standard base schema of given type.static String
buildEntityDescribesHref
(PersistenceContext context, String entityName) Returns a href to single entity resource without primary key.static String
buildEntityFieldHref
(PersistenceContext context, String entityName, String entityId, String fieldName) Builds a link to an entity field.static String
buildEntityHref
(PersistenceContext context, String entityName, String entityId) Returns a href to single entity resource.static String
buildEntityMetadataHref
(PersistenceContext context, String entityName) Returns a href to entity resource metadata.static String
Returns a href to metadata catalog.static String
buildQueryDescribesHref
(PersistenceContext context, String queryName) Returns a href to single entity resource without primary key.static String
buildQueryHref
(PersistenceContext context, String queryName, String queryParams) Returns a href to query resource.static String
buildQueryMetadataHref
(PersistenceContext context, String queryName) Returns a href to query resource.static StringBuilder
getEntityRoot
(PersistenceContext context, String entityName) Returns StringBuilder containing entity root: http(s)://root:port/persistence/version/context/entity/entityNamestatic StringBuilder
getMetadataRoot
(PersistenceContext context) Returns StringBuilder containing metadata-catalog root: http(s)://root:port/persistence/version/context/metadata-catalogstatic StringBuilder
getQueryRoot
(PersistenceContext context, String queryName) Returns StringBuilder containing query root: http(s)://root:port/persistence/version/context/query/queryNamestatic StringBuilder
Returns StringBuilder containing application root: http(s)://root:port/persistence/version/contextstatic StringBuilder
getRoot
(PersistenceContext context) Returns StringBuilder containing application root: http(s)://root:port/persistence/version/context
-
Field Details
-
BASE_REST_SCHEMAS_URL
URL to base REST schemas- See Also:
-
-
Constructor Details
-
HrefHelper
public HrefHelper()
-
-
Method Details
-
getRoot
Returns StringBuilder containing application root: http(s)://root:port/persistence/version/context- Parameters:
baseUri
- the base URIversion
- the service versioncontext
- the persistent unit name- Returns:
- StringBuilder
-
getRoot
Returns StringBuilder containing application root: http(s)://root:port/persistence/version/context- Parameters:
context
- the persistence context- Returns:
- StringBuilder
-
getMetadataRoot
Returns StringBuilder containing metadata-catalog root: http(s)://root:port/persistence/version/context/metadata-catalog- Parameters:
context
- the persistence context- Returns:
- StringBuilder
-
getEntityRoot
Returns StringBuilder containing entity root: http(s)://root:port/persistence/version/context/entity/entityName- Parameters:
context
- the persistence contextentityName
- the entity name- Returns:
- StringBuilder
-
getQueryRoot
Returns StringBuilder containing query root: http(s)://root:port/persistence/version/context/query/queryName- Parameters:
context
- the persistence contextqueryName
- the query name- Returns:
- StringBuilder
-
buildBaseRestSchemaRef
Returns a link to standard base schema of given type.- Parameters:
type
- the schema type- Returns:
- URL in string
-
buildEntityHref
public static String buildEntityHref(PersistenceContext context, String entityName, String entityId) Returns a href to single entity resource. http(s)://root:port/persistence/version/context/entity/id- Parameters:
context
- persistence context.entityName
- entity name.entityId
- entity ID.- Returns:
- href to given entity.
-
buildEntityFieldHref
public static String buildEntityFieldHref(PersistenceContext context, String entityName, String entityId, String fieldName) Builds a link to an entity field. http(s)://root:port/persistence/version/context/entity/id/attribute- Parameters:
context
- persistence context.entityName
- entity name.entityId
- entity ID.fieldName
- entity field name.- Returns:
- href
-
buildEntityMetadataHref
Returns a href to entity resource metadata. http(s)://root:port/persistence/version/context/metadata-catalog/entity- Parameters:
context
- persistence context.entityName
- entity name.- Returns:
- href to given entity.
-
buildEntityDescribesHref
Returns a href to single entity resource without primary key. Used in 'describes' links in resource metadata. http(s)://root:port/persistence/version/context/entity/entityName- Parameters:
context
- persistence context.entityName
- entity name.- Returns:
- href to given entity resource.
-
buildQueryDescribesHref
Returns a href to single entity resource without primary key. Used in 'describes' links in resource metadata. http(s)://root:port/persistence/version/context/query/queryName- Parameters:
context
- persistence context.queryName
- query name.- Returns:
- href to given entity resource.
-
buildMetadataCatalogHref
Returns a href to metadata catalog. http(s)://root:port/persistence/version/context/metadata-catalog- Parameters:
context
- persistence context.- Returns:
- href to resource catalog.
-
buildQueryHref
public static String buildQueryHref(PersistenceContext context, String queryName, String queryParams) Returns a href to query resource. http(s)://root:port/persistence/version/context/query/queryName+queryParams- Parameters:
context
- persistence context.queryName
- name of the queryqueryParams
- query parameters. Optional.- Returns:
- href to resource catalog.
-
buildQueryMetadataHref
Returns a href to query resource. http(s)://root:port/persistence/version/context/query/queryName- Parameters:
context
- persistence context.queryName
- name of the query- Returns:
- href to resource catalog.
-