org.apache.sling.hapi

## Interface HApiUtil

All Known Implementing Classes:
  HApiUtilImpl

    @ProviderType
    public interface HApiUtil

### Field Summary

Fields
`static String` `COLLECTION_RESOURCE_TYPE`
`static String` `COLLECTION_RESOURCE_TYPE_DESC`
`static String` `DEFAULT_COLLECTION_RESOURCE_TYPE`
`static boolean` `DEFAULT_ENABLED`
`static String` `DEFAULT_RESOURCE_TYPE`
`static String` `DEFAULT_SEARCH_PATH`
`static String` `DEFAULT_SERVER_URL`
`static String` `ENABLED`
`static String` `ENABLED_DESC`
`static String` `EXTERNAL_URL`
`static String` `EXTERNAL_URL_DESC`
`static String` `RESOURCE_TYPE`
`static String` `RESOURCE_TYPE_DESC`
`static String` `SEARCH_PATHS`
`static String` `SEARCH_PATHS_DESC`

### Method Summary

All Methods Instance Methods Abstract Methods Deprecated Methods
`HApiTypesCollection` `collectionFromPath(org.apache.sling.api.resource.ResourceResolver resolver, String collectionPath)` Get a `HApiTypesCollection` object from a path String.
`HApiTypesCollection` `collectionFromResource(org.apache.sling.api.resource.ResourceResolver resolver, org.apache.sling.api.resource.Resource collectionResource)` Get a `HApiTypesCollection` object from a `Resource`.
`HApiType` `fromNode(org.apache.sling.api.resource.ResourceResolver resolver, javax.jcr.Node typeNode)` Deprecated.
`HApiType` `fromPath(org.apache.sling.api.resource.ResourceResolver resolver, String type)` Get a HApi type object from a type identifier.
`HApiType` `fromResource(org.apache.sling.api.resource.ResourceResolver resolver, org.apache.sling.api.resource.Resource typeResource)` Get a HApi type object from the `Resource`.
`MicrodataAttributeHelper` `getHelper(org.apache.sling.api.resource.ResourceResolver resolver, String type)` Get a new instance of AttributeHelper for the type identified by 'type'
`org.apache.sling.api.resource.Resource` `getTypeCollectionResource(org.apache.sling.api.resource.ResourceResolver resolver, String collection)` Get a HApi type collection Resource from a collection identifier.
`javax.jcr.Node` `getTypeNode(org.apache.sling.api.resource.ResourceResolver resolver, String type)` Deprecated.
`org.apache.sling.api.resource.Resource` `getTypeResource(org.apache.sling.api.resource.ResourceResolver resolver, String type)` Get a HApi type Resource from a type identifier.

### Field Detail

#### DEFAULT_RESOURCE_TYPE

    static final String DEFAULT_RESOURCE_TYPE

See Also:
  Constant Field Values

#### RESOURCE_TYPE

    static final String RESOURCE_TYPE

See Also:
  Constant Field Values

#### RESOURCE_TYPE_DESC

    static final String RESOURCE_TYPE_DESC

See Also:
  Constant Field Values

#### DEFAULT_COLLECTION_RESOURCE_TYPE

    static final String DEFAULT_COLLECTION_RESOURCE_TYPE

See Also:
  Constant Field Values

#### COLLECTION_RESOURCE_TYPE

    static final String COLLECTION_RESOURCE_TYPE

See Also:
  Constant Field Values

#### COLLECTION_RESOURCE_TYPE_DESC

    static final String COLLECTION_RESOURCE_TYPE_DESC

See Also:
  Constant Field Values

#### DEFAULT_SEARCH_PATH

    static final String DEFAULT_SEARCH_PATH

See Also:
  Constant Field Values

#### SEARCH_PATHS

    static final String SEARCH_PATHS

See Also:
  Constant Field Values

#### SEARCH_PATHS_DESC

    static final String SEARCH_PATHS_DESC

See Also:
  Constant Field Values

#### DEFAULT_SERVER_URL

    static final String DEFAULT_SERVER_URL

See Also:
  Constant Field Values

#### EXTERNAL_URL

    static final String EXTERNAL_URL

See Also:
  Constant Field Values

#### EXTERNAL_URL_DESC

    static final String EXTERNAL_URL_DESC

See Also:
  Constant Field Values

#### DEFAULT_ENABLED

    static final boolean DEFAULT_ENABLED

See Also:
  Constant Field Values

#### ENABLED

    static final String ENABLED

See Also:
  Constant Field Values

#### ENABLED_DESC

    static final String ENABLED_DESC

See Also:
  Constant Field Values

### Method Detail

#### getTypeNode

    @Deprecated
    javax.jcr.Node getTypeNode(org.apache.sling.api.resource.ResourceResolver resolver,
                                           String type)
                                    throws javax.jcr.RepositoryException

Deprecated.

Get a HApi type jcr node from a type identifier.

The JCR node must be [nt:unstructured], a descendant of any of the HAPi search path defined by the `HAPI_PATHS` config and the sling:resourceType should be set to the value defined by the `HAPI_RESOURCE_TYPE` config

The first result is returned

Parameters:
  `resolver` - The sling resource resolver object
  `type` - The type identifier, which is either in the form of a jcr path, same as the path for . If the path cannot be resolved, type is treated like a fully qualified domain name, which has to match the "fqdn" property on the JCR node which represents the type.
Returns:
  The first node that matches that type or null if none is found.
Throws:
  `javax.jcr.RepositoryException`

#### getTypeResource

    org.apache.sling.api.resource.Resource getTypeResource(org.apache.sling.api.resource.ResourceResolver resolver,
                                                           String type)
                                                    throws javax.jcr.RepositoryException

Get a HApi type Resource from a type identifier.

The Resource must be [nt:unstructured], a descendant of any of the HAPi search path defined by the `HAPI_PATHS` config and the sling:resourceType should be set to the value defined by the `HapiUtil#RESOURCE_TYPE` config

The first result is returned

Parameters:
  `resolver` - The sling resource resolver object
  `type` - The type identifier, which is either in the form of a jcr path, same as the path for . If the path cannot be resolved, type is treated like a fully qualified domain name, which has to match the "fqdn" property on the Resource which represents the type.
Returns:
  The first Resource that matches that type or null if none is found.
Throws:
  `javax.jcr.RepositoryException`

#### getTypeCollectionResource

    org.apache.sling.api.resource.Resource getTypeCollectionResource(org.apache.sling.api.resource.ResourceResolver resolver,
                                                                     String collection)
                                                              throws javax.jcr.RepositoryException

Get a HApi type collection Resource from a collection identifier.

The Resource must be [nt:unstructured], a descendant of any of the HAPi search path defined by the `HAPI_PATHS` config and the sling:resourceType should be set to the value defined by the `HapiUtil#COLLECTION_RESOURCE_TYPE` config

The first result is returned

Parameters:
  `resolver` - The sling resource resolver object
  `collection` - The collection identifier, which is either in the form of a jcr path, same as the path for . If the path cannot be resolved, collection is treated like a fully qualified domain name, which has to match the "fqdn" property on the Resource which represents the type.
Returns:
  The first Resource that matches that collection or null if none is found.
Throws:
  `javax.jcr.RepositoryException`

#### fromPath

    HApiType fromPath(org.apache.sling.api.resource.ResourceResolver resolver,
                      String type)
               throws javax.jcr.RepositoryException

Get a HApi type object from a type identifier.

The type identifier is resolved to a `Node` and then `fromNode(org.apache.sling.api.resource.ResourceResolver, javax.jcr.Node)` is called.

For restrictions on the `Node` see `getTypeNode(org.apache.sling.api.resource.ResourceResolver, String)`

Parameters:
  `resolver` - The sling resource resolver object
  `type` - The type identifier, which is either in the form of a jcr path, same as the path for. If the path cannot be resolved, type is treated like a fully qualified domain name, which has to match the "fqdn" property on the JCR node which represents the type.
Returns:
  The HApiType resolved from the type identifier
Throws:
  `javax.jcr.RepositoryException`

#### fromNode

    @Deprecated
    HApiType fromNode(org.apache.sling.api.resource.ResourceResolver resolver,
                                  javax.jcr.Node typeNode)
                           throws javax.jcr.RepositoryException

Deprecated.

Get a HApi type object from the `Node`.

The Node has the following properties:

- name: A 'Name' of the type (mandatory)
- description: A 'String' with the description text for this type (mandatory)
- fqdn: A 'String' with the fully qualified domain name; A namespace like a java package (mandatory)
- extends: A type identifier (either a path or a fqdn); (optional). This defines the parent type of this type
- parameter: A multivalue property to define a list of java-like generic types that can be used as types for properties; (optional)

The properties of this type are defined as children nodes.

The name of property node defines the name of the property for this type.

The children property nodes have the following properties:

- type: The type identifier (mandatory). Can be of type 'Name' or 'Path' See `getTypeNode(org.apache.sling.api.resource.ResourceResolver, String)` for the format of this value
- description: A 'String' with the description for this property (mandatory)
- multiple: A 'Boolean' that defines whether this property can exist multiple times on an object of this type (optional)

Parameters:
  `resolver` - The resource resolver
  `typeNode` - The jcr node of the HApi type
Returns:
  The HApiType
Throws:
  `javax.jcr.RepositoryException`

#### fromResource

    HApiType fromResource(org.apache.sling.api.resource.ResourceResolver resolver,
                          org.apache.sling.api.resource.Resource typeResource)
                   throws javax.jcr.RepositoryException

Get a HApi type object from the `Resource`.

The Resource has the following properties:

- name: A 'Name' of the type (mandatory)
- description: A 'String' with the description text for this type (mandatory)
- fqdn: A 'String' with the fully qualified domain name; A namespace like a java package (mandatory)
- extends: A type identifier (either a path or a fqdn); (optional). This defines the parent type of this type
- parameter: A multivalue property to define a list of java-like generic types that can be used as types for properties; (optional)

The properties of this type are defined as children resources.

The name of property resource defines the name of the property for this type.

The children property nodes have the following properties:

- type: The type identifier (mandatory). Can be of type 'Name' or 'Path' See `getTypeNode(org.apache.sling.api.resource.ResourceResolver, String)` for the format of this value
- description: A 'String' with the description for this property (mandatory)
- multiple: A 'Boolean' that defines whether this property can exist multiple times on an object of this type (optional)

Parameters:
  `resolver` - The resource resolver
  `typeResource` - The sling Resource of the HApi type
Returns:
  The HApiType
Throws:
  `javax.jcr.RepositoryException`

#### collectionFromResource

    HApiTypesCollection collectionFromResource(org.apache.sling.api.resource.ResourceResolver resolver,
                                               org.apache.sling.api.resource.Resource collectionResource)
                                        throws javax.jcr.RepositoryException

Get a `HApiTypesCollection` object from a `Resource`.

The Resource has the following properties:

- name: A 'Name' of the type collection (mandatory)
- description: A 'String' with the description text for this type collection (mandatory)
- fqdn: A 'String' with the fully qualified domain name; A namespace like a java package (mandatory)

The types collection will be populated with direct child Resources of the {{collectionResource}}, which have the resourceType equal to the value of the `RESOURCE_TYPE` property

Parameters:
  `resolver` - The resource resolver
  `collectionResource` - The sling Resource of the HApi type collection
Returns:
  The HApiTypesCollection
Throws:
  `javax.jcr.RepositoryException`

#### collectionFromPath

    HApiTypesCollection collectionFromPath(org.apache.sling.api.resource.ResourceResolver resolver,
                                           String collectionPath)
                                    throws javax.jcr.RepositoryException

Get a `HApiTypesCollection` object from a path String.

`collectionFromResource(org.apache.sling.api.resource.ResourceResolver, org.apache.sling.api.resource.Resource)`

Parameters:
  `resolver` - The resource resolver
  `collectionPath` - The sling resource path of the HApi type collection
Returns:
  The HApiTypesCollection
Throws:
  `javax.jcr.RepositoryException`

#### getHelper

    MicrodataAttributeHelper getHelper(org.apache.sling.api.resource.ResourceResolver resolver,
                                       String type)
                                throws javax.jcr.RepositoryException

Get a new instance of AttributeHelper for the type identified by 'type'

Parameters:
  `resolver` -
  `type` - See `getTypeNode(org.apache.sling.api.resource.ResourceResolver, String)` for the format of the type identifier
Returns:
Throws:
  `javax.jcr.RepositoryException`