Class GetGlobalConfigurationContribution
- java.lang.Object
-
- com.sodius.oslc.server.config.requests.GetGlobalConfigurationContribution
-
- All Implemented Interfaces:
ResourceRequest<Optional<Configuration>>
,Callable<Optional<Configuration>>
public class GetGlobalConfigurationContribution extends Object implements ResourceRequest<Optional<Configuration>>
Inspects the contributions to a Global Configuration in order to extract the best suited Local Configuration.Contributions are inspected in the order defined by the
oslc_config:contributionOrder
property.Hierarchies of Global Configurations are supported.
All contributions whose URI matches the context path of the current server are potential candidates. The chosen one is the first that can be obtained with the provided
Function
and that matches the acceptance criteria of the providedPredicate
.The contract of the Function is to return a Configuration instance from its URI. If the configuration cannot be accessed (e.g: the configuration no longer exists, the user does not have the permission to access it...), return an empty
Optional
instead.The contract of the Predicate is to return true if the configuration matches the acceptance criteria (e.g: the configuration is part of the required Component), false otherwise.
Note that configurations are cached for 10 seconds to avoid querying the GC and the local application too often.
- Since:
- 1.10.0
-
-
Constructor Summary
Constructors Constructor Description GetGlobalConfigurationContribution(HttpServletRequest request, URI globalConfiguration, Function<URI,Optional<Configuration>> getConfiguration, Predicate<Configuration> acceptConfiguration)
Creates a request to extract the best suited Local Configuration from the given Global Configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<Configuration>
call()
Executes the request and parse the response content in the specified format.
-
-
-
Constructor Detail
-
GetGlobalConfigurationContribution
public GetGlobalConfigurationContribution(HttpServletRequest request, URI globalConfiguration, Function<URI,Optional<Configuration>> getConfiguration, Predicate<Configuration> acceptConfiguration)
Creates a request to extract the best suited Local Configuration from the given Global Configuration.- Parameters:
request
- the HTTP requestglobalConfiguration
- the global configuration to extract the local configuration fromgetConfiguration
- the function to get a local configuration instance from its URI (see this class documentation for more details)acceptConfiguration
- the predicate to determine whether or not a local configuration is acceptable for the current request (see this class documentation for more details)
-
-
Method Detail
-
call
public Optional<Configuration> call()
Description copied from interface:ResourceRequest
Executes the request and parse the response content in the specified format. Throws aClientWebException
in case the HTTP response status is not20x
.- Specified by:
call
in interfaceCallable<Optional<Configuration>>
- Specified by:
call
in interfaceResourceRequest<Optional<Configuration>>
-
-