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
-
-
-
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)
-
-