Stream.toList was introduced in Java 16 and creates an unmodifiable List so it can be used to simplify code whenever the List is not expected to be modified.
Signed-off-by: Wouter Born <github@maindrain.net>
* Closes#3329.
This implements a new optional `cacheable` parameter for these REST endpoints:
- `/rest/items`
- `/rest/things`
- `/rest/rules`
When this parameter is set, a flat list of all elements excluding
non-cacheable fields (e.g. "state", "transformedState", "stateDescription",
"commandDescription" for items, "statusInfo", "firmwareStatus",
"properties" for things, "status" for rules) will be retrieved along with
a `Last-Modified` HTTP response header. When unknown, the Last-Modified
header will be set to the date of the request.
Also only when this parameter is set, and a `If-Modified-Since` header is
found in the request, that header will be compared to the last known
modified date for the corresponding cacheable list. The last modified date
will be reset when any change is made on the elements of the underlying
registry. If the `If-Modified-Since` date is equal or more recent than the
last modified date, then a 304 Not Modified response with no content will
be served instead of the usual 200 OK, informing the client that its
cache is still valid at the provided date.
All other request parameters will be ignored except for "metadata" in the
`/rest/items` endpoint. When a metadata selector is set, the resulting
item list will be considered like a completely different resource, i.e.
it will have its own last modified date. Regarding metadata, the approach
to invalidating last modified dates is very conservative: when any metadata
is changed, all cacheable lists of items will have their last modified date
reset even if the change was in a metadata namespace that wasn't requested.
This also implements the abovedescribed behavior for the
`/rest/ui/components/{namespace}` endpoint, but no `cacheable` parameter
is necessary. The last modified date is tracked by namespace.
Signed-off-by: Yannick Schaus <github@schaus.net>
* Add more null annotations to automation bundles. This adds null annotations to many classes in the automation bundles and a few dimension classes.
* Further cleanup AutomationCommandExport
* Remove null from RuleStatusInfo JavaDocs. This should be clear from how the class is now annotated.
* Validate deserialized RuleStatusInfo
* Allow TriggerHandlerCallback to be triggered without providing a context
Signed-off-by: Wouter Born <github@maindrain.net>
* Added marker interface for TriggerHandler to indicate if they are time based and thus can be used to simulate execution times.
* Added marker interface for ConditionHandler to indicate, if they are time based and thus can be checked during rule execution for a certain time.
* Moved CronAdjuster to common, so it can be used for the rule simulation
* Created RuleExecutionSimulator that allows simulation of rules
* Added method in RuleManger to create simulation
* Added rest endpoint for rule simulation.
* Changed marker interface to return TemporalAdjuster instead of cron expression. This better hides the internals of the TriggerHandler (i.e. the cron expression) and is more clear and flexible for other handlers to implement
Fixes#2044Fixes#2266
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
The /things, /rules, /ui/components endpoints retrieve all objects
in their entirety, which can become very big, i.e. channels, config
parameters, script rule modules or trees of UI components can
quickly add up to the size.
When the UI simply displays a list of those objects it retrieves all
this extra information but does nothing with it.
This introduces an optional ?summary=true query parameter for the
above resources to limit the output to pre-defined fields which are
deemed most relevant for displaying these lists, omitting the rest.
When the option is not set, the behavior remains unchanged so this
change is not API breaking. The API version has therefore not been
incremented. The client is responsible for adding the option to
retrieve summarized collections instead of the entire objects.
Signed-off-by: Yannick Schaus <github@schaus.net>
Also added "org.eclipse.jdt.annotation" to the test BOM so we can use "org.eclipse.jdt.annotation.Checks" in itests.
That class has many useful methods that help with writing more readable test code when using the Eclipse JDT null analysis annotations.
After running the resolver on the itests a lot of bundles were removed from the itest.bndrun files.
Signed-off-by: Wouter Born <github@maindrain.net>