Class Resource


  • public final class Resource
    extends Object
    Defines the characteristics of a resource, including its properties, inheritance, and sub-resources.

    In particular, a resource defines how LDAP entries map to JSON. To that end, it describes:

    • a "schema" of the JSON object it represents, including inheritance and its properties
    • a mapping to the equivalent LDAP objectClasses
    • a mapping of the JSON properties to the LDAP attribute names in the objectClass, and a set of constraints for each properties that must match the LDAP schema
    • CREST sub paths that are accessible under this resource, and which resources they represent. These are specified as sub-resources.
    • Method Detail

      • description

        public void description​(LocalizableMessage description)
        Sets the description of this resource.
        Parameters:
        description - the description of this resource
      • toString

        public String toString()
        Returns the resource ID of this resource.
        Overrides:
        toString in class Object
        Returns:
        The resource ID of this resource.
      • equals

        public boolean equals​(Object o)
        Returns true if the provided parameter is a Resource having the same resource ID as this resource.
        Overrides:
        equals in class Object
        Parameters:
        o - The object to compare.
        Returns:
        true if the provided parameter is a Resource having the same resource ID as this resource.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • superType

        public Resource superType​(String resourceId)
        Specifies the resource ID of the resource which is a super-type of this resource. This resource will inherit the properties and sub-resources of the super-type, and may optionally override them.
        Parameters:
        resourceId - The resource ID of the resource which is a super-type of this resource, or null if there is no super-type.
        Returns:
        A reference to this object.
      • allowedAuxiliaryTypes

        public Resource allowedAuxiliaryTypes​(String... resourceIds)
        Specifies the resource IDs of any auxiliary resources which are allowed to be combined, or "mixed in", with this resource. This mechanism is equivalent to multiple inheritance and is implemented in LDAP through the use of auxiliary object classes. Auxiliary resource types can be added to and removed from resources after creation using update and patch operations. The properties of an auxiliary resource will be merged with the properties of the resource and the auxiliary resource ID will be listed in the auxiliary resource type property.
        Parameters:
        resourceIds - The resource IDs of the auxiliary resources which may be combined with this resource.
        Returns:
        A reference to this object.
      • allowedAuxiliaryTypes

        public Resource allowedAuxiliaryTypes​(Collection<String> resourceIds)
        Specifies the resource IDs of any auxiliary resources which are allowed to be combined, or "mixed in", with this resource. This mechanism is equivalent to multiple inheritance and is implemented in LDAP through the use of auxiliary object classes. Auxiliary resource types can be added to and removed from resources after creation using update and patch operations. The properties of an auxiliary resource will be merged with the properties of the resource and the auxiliary resource ID will be listed in the auxiliary resource type property.
        Parameters:
        resourceIds - The resource IDs of the auxiliary resources which may be combined with this resource.
        Returns:
        A reference to this object.
      • isAbstract

        public Resource isAbstract​(boolean isAbstract)
        Specifies whether this resource is an abstract type and therefore cannot be created. Only non-abstract sub-types can be created.
        Parameters:
        isAbstract - true if this resource is abstract.
        Returns:
        A reference to this object.
      • property

        public Resource property​(String name,
                                 PropertyMapper mapper)
        Specifies a mapping for a property contained in this JSON resource. Properties are inherited and sub-types may override them. Properties are optional: a resource that does not have any properties cannot be created, read, or modified, and may only be used for accessing sub-resources. These resources usually represent API "endpoints".
        Parameters:
        name - The name of the JSON property to be mapped.
        mapper - The property mapper responsible for mapping the JSON property to LDAP attribute(s).
        Returns:
        A reference to this object.
      • includeAllUserAttributesByDefault

        public Resource includeAllUserAttributesByDefault​(boolean include)
        Specifies whether all LDAP user attributes should be mapped by default using the default schema based mapping rules. Individual attributes can be excluded using excludedDefaultUserAttributes(java.lang.String...) in order to prevent attributes with explicit mappings being mapped twice.
        Parameters:
        include - true if all LDAP user attributes be mapped by default.
        Returns:
        A reference to this object.
      • excludedDefaultUserAttributes

        public Resource excludedDefaultUserAttributes​(String... attributeNames)
        Specifies zero or more user attributes which will be excluded from the default user attribute mappings when enabled using includeAllUserAttributesByDefault(boolean). Attributes which have explicit mappings should be excluded in order to prevent duplication.
        Parameters:
        attributeNames - The list of attributes to be excluded.
        Returns:
        A reference to this object.
      • excludedDefaultUserAttributes

        public Resource excludedDefaultUserAttributes​(Collection<String> attributeNames)
        Specifies zero or more user attributes which will be excluded from the default user attribute mappings when enabled using includeAllUserAttributesByDefault(boolean). Attributes which have explicit mappings should be excluded in order to prevent duplication.
        Parameters:
        attributeNames - The list of attributes to be excluded.
        Returns:
        A reference to this object.
      • objectClass

        public Resource objectClass​(String objectClass)
        Specifies an LDAP object class which is to be associated with this resource. Multiple object classes may be specified. The object classes are used for determining the type of resource being accessed during all requests other than create. Object classes are inherited by sub-types and must be defined for any resources that are non-abstract and which can be created.
        Parameters:
        objectClass - An LDAP object class associated with this resource's LDAP representation.
        Returns:
        A reference to this object.
      • objectClasses

        public Resource objectClasses​(String... objectClasses)
        Specifies LDAP object classes which are to be associated with this resource. Multiple object classes may be specified. The object classes are used for determining the type of resource being accessed during all requests other than create. Object classes are inherited by sub-types and must be defined for any resources that are non-abstract and which can be created.
        Parameters:
        objectClasses - The LDAP object classes associated with this resource's LDAP representation.
        Returns:
        A reference to this object.
      • supportedAction

        public Resource supportedAction​(Action action)
        Registers an action which should be supported by this resource. By default, no actions are supported.
        Parameters:
        action - The action supported by this resource.
        Returns:
        A reference to this object.
      • supportedActions

        public Resource supportedActions​(Action... actions)
        Registers zero or more actions which should be supported by this resource. By default, no actions are supported.
        Parameters:
        actions - The actions supported by this resource.
        Returns:
        A reference to this object.
      • subResource

        public Resource subResource​(SubResource subResource)
        Specifies a parent-child relationship with another resource. Sub-resources are inherited by sub-types and may be overridden.
        Parameters:
        subResource - The sub-resource definition.
        Returns:
        A reference to this object.
      • subResources

        public Resource subResources​(SubResource... subResources)
        Specifies a parent-child relationship with zero or more resources. Sub-resources are inherited by sub-types and may be overridden.
        Parameters:
        subResources - The sub-resource definitions.
        Returns:
        A reference to this object.