Class ResourceTypeFactory

java.lang.Object
de.captaingoldfish.scim.sdk.server.schemas.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 Details

    • ResourceTypeFactory

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

    • 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
    • getResourceTypes

      protected Map<String,ResourceType> getResourceTypes()
      the resource type registry.
      The key will be the uri to the resource schema that represents the resource type. Like this the resource type can be easier found if a request comes in
    • getSchemaFactory

      public SchemaFactory getSchemaFactory()
      this instance is hold in order for unit tests to be able to write tests without polluting the whole application context which might lead to unpredictable unit test errors