From d3387a9ab362bcc3eeb0108d5fafd4ec24cf1843 Mon Sep 17 00:00:00 2001 From: Hylke van der Schaaf Date: Wed, 28 Aug 2024 14:31:17 +0200 Subject: [PATCH] Allow .:,; in batch request id --- .../batchprocessing/json/JsonBatchProcessor.java | 4 ++-- docs/extensions/JsonBatchRequest.md | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Plugins/BatchProcessing/src/main/java/de/fraunhofer/iosb/ilt/frostserver/plugin/batchprocessing/json/JsonBatchProcessor.java b/Plugins/BatchProcessing/src/main/java/de/fraunhofer/iosb/ilt/frostserver/plugin/batchprocessing/json/JsonBatchProcessor.java index 0a2fa8495..5a1420fb1 100644 --- a/Plugins/BatchProcessing/src/main/java/de/fraunhofer/iosb/ilt/frostserver/plugin/batchprocessing/json/JsonBatchProcessor.java +++ b/Plugins/BatchProcessing/src/main/java/de/fraunhofer/iosb/ilt/frostserver/plugin/batchprocessing/json/JsonBatchProcessor.java @@ -56,9 +56,9 @@ public class JsonBatchProcessor implements Iterator { private static final Logger LOGGER = LoggerFactory.getLogger(JsonBatchProcessor.class.getName()); - private static final String REFERENCE_URL_REGEX = "^" + Pattern.quote("$") + "([a-zA-Z0-9_-]+)"; + private static final String REFERENCE_URL_REGEX = "^" + Pattern.quote("$") + "([a-zA-Z0-9_.:,;-]+)"; private static final Pattern REFERENCE_URL_PATTERN = Pattern.compile(REFERENCE_URL_REGEX); - private static final String REFERENCE_JSON_REGEX = Pattern.quote("\"$") + "([a-zA-Z0-9_-]+)" + Pattern.quote("\""); + private static final String REFERENCE_JSON_REGEX = Pattern.quote("\"$") + "([a-zA-Z0-9_.:,;-]+)" + Pattern.quote("\""); private static final Pattern REFERENCE_JSON_PATTERN = Pattern.compile(REFERENCE_JSON_REGEX); private final Service service; diff --git a/docs/extensions/JsonBatchRequest.md b/docs/extensions/JsonBatchRequest.md index 4fce6579b..9cd82f885 100644 --- a/docs/extensions/JsonBatchRequest.md +++ b/docs/extensions/JsonBatchRequest.md @@ -67,10 +67,11 @@ The following example shows a Batch Request that contains the following operatio ## Referencing new entities in a change set example -Actions can reference entities previously created. To make a created entity referenceable, the POST that creates the entity must have -a id property, the content of which can be any string. Subsequent requests in the same -change set can now use the value of this property, prefixed with a $, in places where the ID of the -created entity is required. +Actions can reference entities previously created or fetched. +To make a created entity referenceable, the POST that creates the entity must have a id property, +the content of which must be a string limited to the characters `a-zA-Z0-9_.:,;-`. +Subsequent requests in the same change set can now use the value of this property, prefixed with a $, +in places where the ID of the created entity is required. Example: A Batch Request that containing a single change set that contains the following requests: @@ -157,7 +158,7 @@ If the result of the GET is an entity set, the first entity of the set is used. ### Skipping requests in a batch Requests in a batch can be skipped using the `if` property. -The value of `if` is a reference a preceding request, optionally prefixed with `not `. +The value of `if` is a reference to a preceding request, optionally prefixed with `not `. An example, creating an ObservedProperty only if no ObservedProperty with a name `Temperature` already exists: ```