Class HrefHelper


  • public final class HrefHelper
    extends Object
    A collection of static methods used to build 'href' attribute values for REST 'link' elements.
    Author:
    Dmitry Kornilov
    Since:
    EclipseLink 2.6.0
    • Constructor Detail

      • HrefHelper

        public HrefHelper()
    • Method Detail

      • getRoot

        public static StringBuilder getRoot​(String baseUri,
                                            String version,
                                            String context)
        Returns StringBuilder containing application root: http(s)://root:port/persistence/version/context
        Parameters:
        baseUri - the base URI
        version - the service version
        context - the persistent unit name
        Returns:
        StringBuilder
      • getRoot

        public static StringBuilder getRoot​(PersistenceContext context)
        Returns StringBuilder containing application root: http(s)://root:port/persistence/version/context
        Parameters:
        context - the persistence context
        Returns:
        StringBuilder
      • getMetadataRoot

        public static StringBuilder getMetadataRoot​(PersistenceContext context)
        Returns StringBuilder containing metadata-catalog root: http(s)://root:port/persistence/version/context/metadata-catalog
        Parameters:
        context - the persistence context
        Returns:
        StringBuilder
      • getEntityRoot

        public static StringBuilder getEntityRoot​(PersistenceContext context,
                                                  String entityName)
        Returns StringBuilder containing entity root: http(s)://root:port/persistence/version/context/entity/entityName
        Parameters:
        context - the persistence context
        entityName - the entity name
        Returns:
        StringBuilder
      • getQueryRoot

        public static StringBuilder getQueryRoot​(PersistenceContext context,
                                                 String queryName)
        Returns StringBuilder containing query root: http(s)://root:port/persistence/version/context/query/queryName
        Parameters:
        context - the persistence context
        queryName - the query name
        Returns:
        StringBuilder
      • buildBaseRestSchemaRef

        public static String buildBaseRestSchemaRef​(String type)
        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

        public static String buildEntityMetadataHref​(PersistenceContext context,
                                                     String entityName)
        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

        public static String buildEntityDescribesHref​(PersistenceContext context,
                                                      String entityName)
        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

        public static String buildQueryDescribesHref​(PersistenceContext context,
                                                     String queryName)
        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

        public static String buildMetadataCatalogHref​(PersistenceContext context)
        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 query
        queryParams - query parameters. Optional.
        Returns:
        href to resource catalog.
      • buildQueryMetadataHref

        public static String buildQueryMetadataHref​(PersistenceContext context,
                                                    String queryName)
        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.