Package com.evolveum.midpoint.schema
Class CapabilityUtil
java.lang.Object
com.evolveum.midpoint.schema.CapabilityUtil
Various useful methods related to capabilities.
Notes:
- To minimize confusion, the term "effective" has been removed from the methods' names, as it somehow implied that
the capability in question is enabled. We now use either names without adjective (like
getCapability(CapabilitiesType, Class)
) or explicitly mention "enabled" if enabled capabilities are to be returned, like
getEnabledActivationStatus(ActivationCapabilityType)
.- Author:
- semancik
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull CapabilityCollectionType
createCapabilityCollection
(@NotNull List<CapabilityType> capabilities) CreatesCapabilityCollectionType
from a plain list of capabilities.static void
fillDefaults
(@NotNull CapabilityType capability) TODO what's the use of this method? It is currently called only from the Resource wizard.static @NotNull List<CapabilityType>
getAllCapabilities
(@Nullable CapabilityCollectionType capabilityCollection) Returns all the capabilities from particularCapabilityCollectionType
.static @NotNull List<CapabilityType>
getCapabilities
(@Nullable CapabilitiesType capabilities, boolean includeDisabled) Returns a combination of native and configured capabilities from givenCapabilitiesType
bean.static <T extends CapabilityType>
TgetCapability
(@NotNull ResourceType resource, @NotNull Class<T> capabilityClass) static <T extends CapabilityType>
TgetCapability
(@NotNull ResourceType resource, @Nullable ResourceObjectDefinition objectDefinition, @NotNull Class<T> capabilityClass) Gets a specific capability from resource/connectors/object-class.static <T extends CapabilityType>
TgetCapability
(@NotNull ResourceType resource, @Nullable CapabilityCollectionType specificObjectTypeOrClassCapabilities, @NotNull Class<T> capabilityClass) static <T extends CapabilityType>
TgetCapability
(@NotNull List<CapabilityCollectionType> capabilityCollectionsList, @NotNull Class<T> capabilityClass) Returns the first matching capability in given list of capability collections.static <T extends CapabilityType>
TgetCapability
(@Nullable CapabilitiesType capabilities, @NotNull Class<T> capabilityClass) Selects a matching capability: 1.static <T extends CapabilityType>
TgetCapability
(@Nullable CapabilityCollectionType capabilityCollection, @NotNull Class<T> capabilityClass) Selects a capability of given type from aCapabilityCollectionType
.static String
getCapabilityDisplayName
(@NotNull CapabilityType capability) AsgetEnabledActivationLockoutStatus(ActivationCapabilityType)
but checks also if the "root" capability is enabled.AsgetEnabledActivationStatus(ActivationCapabilityType)
but checks also if the "root" capability is enabled.static <T extends CapabilityType>
TgetEnabledCapability
(@NotNull ResourceType resource, @Nullable ResourceObjectDefinition objectDefinition, @NotNull Class<T> capabilityClass) static <T extends CapabilityType>
TgetEnabledOrNull
(T capability) static @Nullable PasswordCapabilityType
getEnabledPasswordCapability
(CredentialsCapabilityType credentialsCapability) static Collection<Class<? extends CapabilityType>>
getNativeCapabilityClasses
(@Nullable CapabilitiesType capabilities) Returns a set of classes of native capabilities.static boolean
static boolean
isActivationStatusCapabilityEnabled
(@NotNull ResourceType resource, @Nullable ResourceObjectDefinition objectDefinition) static boolean
static boolean
static boolean
static boolean
isCapabilityEnabled
(@Nullable CapabilityType capability) static boolean
isEmpty
(CapabilityCollectionType capabilities) Normally, `null` and empty states are substantially different: the former means "unknown", the latter "none".static boolean
isEnabled
(CapabilityType cap) static boolean
static boolean
isPasswordReadable
(CredentialsCapabilityType credentialsCapability) static boolean
isPasswordReturnedByDefault
(CredentialsCapabilityType credentialsCapability) static boolean
isReadingCachingOnly
(@NotNull ResourceType resource, @Nullable ResourceObjectDefinition objectDefinition) static int
size
(CapabilityCollectionType capabilities)
-
Constructor Details
-
CapabilityUtil
public CapabilityUtil()
-
-
Method Details
-
getCapability
@Nullable public static <T extends CapabilityType> T getCapability(@Nullable @Nullable CapabilityCollectionType capabilityCollection, @NotNull @NotNull Class<T> capabilityClass) Selects a capability of given type from aCapabilityCollectionType
. NOTE: Instead of calling this method with a specific capabilityClass, it is now easier to simply call the appropriate getter method on theCapabilityCollectionType
(after a non-null check).- Throws:
IllegalArgumentException
- in the case of ambiguity, because this means that either the capabilityClass is too "wide", and matches multiple capabilities. Or the capabilityCollection is malformed, and contains multiple values of the given capability type. (Although this is currently not possible according to the schema.)
-
getCapability
@Nullable public static <T extends CapabilityType> T getCapability(@NotNull @NotNull List<CapabilityCollectionType> capabilityCollectionsList, @NotNull @NotNull Class<T> capabilityClass) Returns the first matching capability in given list of capability collections. -
getCapability
@Nullable public static <T extends CapabilityType> T getCapability(@Nullable @Nullable CapabilitiesType capabilities, @NotNull @NotNull Class<T> capabilityClass) Selects a matching capability: 1. first from configured capabilities, 2. if not present, then from native capabilities. -
getAllCapabilities
@NotNull public static @NotNull List<CapabilityType> getAllCapabilities(@Nullable @Nullable CapabilityCollectionType capabilityCollection) Returns all the capabilities from particularCapabilityCollectionType
. -
getCapabilities
@NotNull public static @NotNull List<CapabilityType> getCapabilities(@Nullable @Nullable CapabilitiesType capabilities, boolean includeDisabled) Returns a combination of native and configured capabilities from givenCapabilitiesType
bean.- Parameters:
includeDisabled
- Whether we want to obtain also capabilities with `enabled` set to `false`.
-
isCapabilityEnabled
-
getEnabledOrNull
-
getCapabilityDisplayName
-
getEnabledPasswordCapability
@Nullable public static @Nullable PasswordCapabilityType getEnabledPasswordCapability(CredentialsCapabilityType credentialsCapability) -
isPasswordReturnedByDefault
-
isPasswordReadable
-
isActivationStatusReturnedByDefault
-
isActivationLockoutStatusReturnedByDefault
public static boolean isActivationLockoutStatusReturnedByDefault(ActivationCapabilityType capability) -
isActivationValidFromReturnedByDefault
-
isActivationValidToReturnedByDefault
-
isLastLoginTimestampReturnedByDefault
-
getNativeCapabilityClasses
public static Collection<Class<? extends CapabilityType>> getNativeCapabilityClasses(@Nullable @Nullable CapabilitiesType capabilities) Returns a set of classes of native capabilities. -
fillDefaults
TODO what's the use of this method? It is currently called only from the Resource wizard. We should perhaps delete it. -
getEnabledActivationStatus
public static ActivationStatusCapabilityType getEnabledActivationStatus(ActivationCapabilityType act) -
getEnabledActivationStatusStrict
public static ActivationStatusCapabilityType getEnabledActivationStatusStrict(ActivationCapabilityType act) AsgetEnabledActivationStatus(ActivationCapabilityType)
but checks also if the "root" capability is enabled. -
isEnabled
-
getEnabledLastLoginCapabilityStrict
public static LastLoginTimestampCapabilityType getEnabledLastLoginCapabilityStrict(BehaviorCapabilityType act) -
getEnabledActivationValidFrom
public static ActivationValidityCapabilityType getEnabledActivationValidFrom(ActivationCapabilityType act) -
getEnabledActivationValidTo
public static ActivationValidityCapabilityType getEnabledActivationValidTo(ActivationCapabilityType act) -
getEnabledActivationLockoutStatus
public static ActivationLockoutStatusCapabilityType getEnabledActivationLockoutStatus(ActivationCapabilityType act) -
getEnabledActivationLockoutStrict
public static ActivationLockoutStatusCapabilityType getEnabledActivationLockoutStrict(ActivationCapabilityType act) AsgetEnabledActivationLockoutStatus(ActivationCapabilityType)
but checks also if the "root" capability is enabled. -
createCapabilityCollection
@NotNull public static @NotNull CapabilityCollectionType createCapabilityCollection(@NotNull @NotNull List<CapabilityType> capabilities) CreatesCapabilityCollectionType
from a plain list of capabilities. TODO consider whether we shouldn't return `null` if the list is empty. -
isEmpty
Normally, `null` and empty states are substantially different: the former means "unknown", the latter "none". So this method should be used only for testing, e.g. to check that there are _some_ capabilities present. -
size
-
getCapability
public static <T extends CapabilityType> T getCapability(@NotNull @NotNull ResourceType resource, @NotNull @NotNull Class<T> capabilityClass) -
getCapability
public static <T extends CapabilityType> T getCapability(@NotNull @NotNull ResourceType resource, @Nullable @Nullable ResourceObjectDefinition objectDefinition, @NotNull @NotNull Class<T> capabilityClass) Gets a specific capability from resource/connectors/object-class. Notes: - Resource vs connector: The capability from specific connector is used only if it's enabled. TODO allow configured capabilities also for refined object classes -
getCapability
public static <T extends CapabilityType> T getCapability(@NotNull @NotNull ResourceType resource, @Nullable @Nullable CapabilityCollectionType specificObjectTypeOrClassCapabilities, @NotNull @NotNull Class<T> capabilityClass) -
isReadingCachingOnly
public static boolean isReadingCachingOnly(@NotNull @NotNull ResourceType resource, @Nullable @Nullable ResourceObjectDefinition objectDefinition) -
getEnabledCapability
public static <T extends CapabilityType> T getEnabledCapability(@NotNull @NotNull ResourceType resource, @Nullable @Nullable ResourceObjectDefinition objectDefinition, @NotNull @NotNull Class<T> capabilityClass) -
isActivationStatusCapabilityEnabled
public static boolean isActivationStatusCapabilityEnabled(@NotNull @NotNull ResourceType resource, @Nullable @Nullable ResourceObjectDefinition objectDefinition)
-