Package com.evolveum.midpoint.schema
Class CapabilityUtil
- java.lang.Object
-
- com.evolveum.midpoint.schema.CapabilityUtil
-
public class CapabilityUtil extends Object
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 (likegetCapability(CapabilitiesType, Class)
) or explicitly mention "enabled" if enabled capabilities are to be returned, likegetEnabledActivationStatus(ActivationCapabilityType)
.- Author:
- semancik
-
-
Constructor Summary
Constructors Constructor Description CapabilityUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static @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, @Nullable ResourceObjectDefinition objectDefinition, @NotNull Class<T> capabilityClass)
Gets a specific capability from resource/connectors/object-class.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)
static ActivationLockoutStatusCapabilityType
getEnabledActivationLockoutStatus(ActivationCapabilityType act)
static ActivationLockoutStatusCapabilityType
getEnabledActivationLockoutStrict(ActivationCapabilityType act)
AsgetEnabledActivationLockoutStatus(ActivationCapabilityType)
but checks also if the "root" capability is enabled.static ActivationStatusCapabilityType
getEnabledActivationStatus(ActivationCapabilityType act)
static ActivationStatusCapabilityType
getEnabledActivationStatusStrict(ActivationCapabilityType act)
AsgetEnabledActivationStatus(ActivationCapabilityType)
but checks also if the "root" capability is enabled.static ActivationValidityCapabilityType
getEnabledActivationValidFrom(ActivationCapabilityType act)
static ActivationValidityCapabilityType
getEnabledActivationValidTo(ActivationCapabilityType act)
static Collection<Class<? extends CapabilityType>>
getNativeCapabilityClasses(@Nullable CapabilitiesType capabilities)
Returns a set of classes of native capabilities.static boolean
isActivationLockoutStatusReturnedByDefault(ActivationCapabilityType capability)
static boolean
isActivationStatusCapabilityEnabled(@NotNull ResourceType resource, @Nullable ResourceObjectDefinition objectDefinition)
static boolean
isActivationStatusReturnedByDefault(ActivationCapabilityType capability)
static boolean
isActivationValidFromReturnedByDefault(ActivationCapabilityType capability)
static boolean
isActivationValidToReturnedByDefault(ActivationCapabilityType capability)
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
isPasswordReadable(CredentialsCapabilityType capabilityType)
static boolean
isPasswordReturnedByDefault(CredentialsCapabilityType capability)
static int
size(CapabilityCollectionType capabilities)
-
-
-
Method Detail
-
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
public static boolean isCapabilityEnabled(@Nullable @Nullable CapabilityType capability)
-
getCapabilityDisplayName
public static String getCapabilityDisplayName(@NotNull @NotNull CapabilityType capability)
-
isPasswordReturnedByDefault
public static boolean isPasswordReturnedByDefault(CredentialsCapabilityType capability)
-
isPasswordReadable
public static boolean isPasswordReadable(CredentialsCapabilityType capabilityType)
-
isActivationStatusReturnedByDefault
public static boolean isActivationStatusReturnedByDefault(ActivationCapabilityType capability)
-
isActivationLockoutStatusReturnedByDefault
public static boolean isActivationLockoutStatusReturnedByDefault(ActivationCapabilityType capability)
-
isActivationValidFromReturnedByDefault
public static boolean isActivationValidFromReturnedByDefault(ActivationCapabilityType capability)
-
isActivationValidToReturnedByDefault
public static boolean isActivationValidToReturnedByDefault(ActivationCapabilityType capability)
-
getNativeCapabilityClasses
public static Collection<Class<? extends CapabilityType>> getNativeCapabilityClasses(@Nullable @Nullable CapabilitiesType capabilities)
Returns a set of classes of native capabilities.
-
fillDefaults
public static void fillDefaults(@NotNull @NotNull CapabilityType capability)
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.
-
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
@VisibleForTesting public static boolean isEmpty(CapabilityCollectionType capabilities)
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
public static int size(CapabilityCollectionType capabilities)
-
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.
-
isActivationStatusCapabilityEnabled
public static boolean isActivationStatusCapabilityEnabled(@NotNull @NotNull ResourceType resource, @Nullable @Nullable ResourceObjectDefinition objectDefinition)
-
-