Class ResourceTypeFactory


  • public final class ResourceTypeFactory
    extends Object
    author Pascal Knueppel
    created at: 03.10.2019 - 23:11

    this class is used to register and get resource types. With this utility class the SCIM endpoints can be extended by additional resource types, resource schemata and resource extensions
    • Constructor Detail

      • ResourceTypeFactory

        public ResourceTypeFactory()
        will register the default resource types
    • Method Detail

      • registerResourceType

        public ResourceType registerResourceType​(ResourceHandler resourceHandler,
                                                 com.fasterxml.jackson.databind.JsonNode resourceType,
                                                 com.fasterxml.jackson.databind.JsonNode resourceSchema,
                                                 com.fasterxml.jackson.databind.JsonNode... resourceSchemaExtensions)
        this method will register a new resource type
        Parameters:
        resourceType - the resource type as json document
        resourceSchema - the resource schema definition as json object this object will additionally be registered within the SchemaFactory. This is the resource that is referenced under the "schema" attribute within the resourceType document
        resourceSchemaExtensions - the extensions that will be appended to the resourceSchema definition
      • registerResourceType

        public void registerResourceType​(ResourceHandler resourceHandler,
                                         String id,
                                         String name,
                                         String description,
                                         String schema,
                                         String endpoint,
                                         com.fasterxml.jackson.databind.JsonNode resourceSchema,
                                         com.fasterxml.jackson.databind.JsonNode... resourceSchemaExtensions)
        Parameters:
        id - the id of the resource type
        name - the name of the resource type
        description - the description of the resource type
        schema - the resource type schema that describes this resource type
        endpoint - the endpoint under which this resource should be reachable
        resourceSchema - the resource schema definition as json object these object will also be registered
        resourceSchemaExtensions - the extensions that will be appended to the resourceSchema definition
      • getResourceType

        public ResourceType getResourceType​(String endpoint)
        tries to get a resource type by the endpoint path under which it is accessible
        Parameters:
        endpoint - the endpoint of the resource type
      • isResourceRegistered

        protected boolean isResourceRegistered​(String resourceName)
        checks if a resource type with the given name does exist
        Parameters:
        resourceName - the name of the resource
        Returns:
        true if a resource type with the given name was already registered, false else
      • getResourceTypeByName

        public Optional<ResourceType> getResourceTypeByName​(String name)
        gets a resource type by its name value
        Parameters:
        name - the name value of the given resource type
        Returns:
        the resource type or an empty if no resource type with the given name exists
      • getAllResourceTypes

        public Collection<ResourceType> getAllResourceTypes()
        Returns:
        returns all registered resource types