Skip to content

Commit edfb480

Browse files
committed
Merge branch 'main' into fileformat_transform_things_new
2 parents 316e5ae + 3fb76c9 commit edfb480

File tree

6 files changed

+29
-12
lines changed

6 files changed

+29
-12
lines changed

.github/dependabot.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ updates:
1717
schedule:
1818
interval: "weekly"
1919
open-pull-requests-limit: 10
20-
labels:
21-
- dependencies
20+
labels: [ ]
21+
allow:
22+
- dependency-type: "development"

.github/workflows/ci-build.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ on:
1111
- 'main'
1212
paths-ignore:
1313
- '.github/**/*.md'
14+
types: [opened,synchronize,reopened,labeled]
1415
workflow_dispatch:
1516

1617
jobs:
1718
build:
19+
if: ${{ (github.event_name == 'pull_request' && github.event.action != 'labeled') || github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.label.name == 'rebuild' }}
1820
strategy:
1921
fail-fast: false
2022
matrix:
@@ -181,3 +183,11 @@ jobs:
181183
title: CheckStyle Violations
182184
path: '**/checkstyle-result.xml'
183185
mode: inline
186+
187+
- name: Remove Label
188+
if: ${{ always() && github.event.label.name == 'rebuild' }}
189+
env:
190+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
191+
PR: ${{ github.event.number }}
192+
run: |
193+
gh pr edit $PR --remove-label rebuild

bundles/org.openhab.core.io.http.auth/pages/authorize.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
<input class="field" type="{repeatPasswordFieldType}" placeholder="{repeatPasswordPlaceholder}" name="password_repeat" />
115115
</div>
116116
<div>
117-
<input class="field" type="{tokenNameFieldType}" placeholder="{tokenNamePlaceholder}" name="token_name" />
117+
<input class="field" type="{tokenNameFieldType}" placeholder="{tokenNamePlaceholder}" name="token_name" required pattern="[a-zA-Z0-9]+" />
118118
</div>
119119
<div>
120120
<input class="field" type="{tokenScopeFieldType}" placeholder="{tokenScopePlaceholder}" name="token_scope" />

bundles/org.openhab.core.io.http.auth/src/main/resources/messages.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ auth.placeholder.username = User Name
1616
auth.placeholder.password = Password
1717
auth.placeholder.newpassword = New Password
1818
auth.placeholder.repeatpassword = Confirm New Password
19-
auth.placeholder.tokenname = Token Name
19+
auth.placeholder.tokenname = Token Name (alphanumeric)
2020
auth.placeholder.tokenscope = Token Scope (optional)
2121
2222
auth.button.signin = Sign In

bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/internal/YamlModelRepositoryImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ public class YamlModelRepositoryImpl implements WatchService.WatchEventListener,
9494
getElementName(YamlThingDTO.class) // "things"
9595
);
9696

97+
private static final String UNWANTED_EXCEPTION_TEXT = "at [Source: UNKNOWN; byte offset: #UNKNOWN] ";
98+
9799
private final Logger logger = LoggerFactory.getLogger(YamlModelRepositoryImpl.class);
98100

99101
private final WatchService watchService;
@@ -750,8 +752,9 @@ private <T extends YamlElement> Optional<T> parseJsonNode(JsonNode node, Class<T
750752
return Optional.of(objectMapper.treeToValue(node, elementClass));
751753
} catch (JsonProcessingException e) {
752754
if (errors != null) {
755+
String msg = e.getMessage();
753756
errors.add("Could not parse element %s to %s: %s".formatted(node.toPrettyString(),
754-
elementClass.getSimpleName(), e.getMessage()));
757+
elementClass.getSimpleName(), msg == null ? "" : msg.replace(UNWANTED_EXCEPTION_TEXT, "")));
755758
}
756759
return Optional.empty();
757760
}
@@ -784,8 +787,10 @@ private <T extends YamlElement> List<T> parseJsonMapNode(@Nullable JsonNode mapN
784787
elt.setId(id);
785788
} catch (JsonProcessingException e) {
786789
if (errors != null) {
790+
String msg = e.getMessage();
787791
errors.add("could not parse element with ID %s to %s: %s".formatted(id,
788-
elementClass.getSimpleName(), e.getMessage()));
792+
elementClass.getSimpleName(),
793+
msg == null ? "" : msg.replace(UNWANTED_EXCEPTION_TEXT, "")));
789794
}
790795
}
791796
}

bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/internal/things/YamlThingProvider.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,7 @@ public void updatedModel(String modelName, Collection<YamlThingDTO> elements) {
241241
@Override
242242
public void removedModel(String modelName, Collection<YamlThingDTO> elements) {
243243
List<Thing> removed = elements.stream().map(this::mapThing).filter(Objects::nonNull).toList();
244-
Collection<Thing> modelThings = Objects
245-
.requireNonNull(thingsMap.computeIfAbsent(modelName, k -> new ArrayList<>()));
244+
Collection<Thing> modelThings = thingsMap.getOrDefault(modelName, List.of());
246245
removed.forEach(t -> {
247246
modelThings.stream().filter(th -> th.getUID().equals(t.getUID())).findFirst().ifPresentOrElse(oldThing -> {
248247
modelThings.remove(oldThing);
@@ -252,6 +251,9 @@ public void removedModel(String modelName, Collection<YamlThingDTO> elements) {
252251
}
253252
}, () -> logger.debug("model {} thing {} not found", modelName, t.getUID()));
254253
});
254+
if (modelThings.isEmpty()) {
255+
thingsMap.remove(modelName);
256+
}
255257
}
256258

257259
@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
@@ -373,8 +375,7 @@ private List<Channel> createChannels(ThingTypeUID thingTypeUID, ThingUID thingUI
373375
Map<String, YamlChannelDTO> channelsDto, List<ChannelDefinition> channelDefinitions) {
374376
Set<String> addedChannelIds = new HashSet<>();
375377
List<Channel> channels = new ArrayList<>();
376-
channelsDto.entrySet().forEach(entry -> {
377-
YamlChannelDTO channelDto = entry.getValue();
378+
channelsDto.forEach((channelId, channelDto) -> {
378379
ChannelTypeUID channelTypeUID = null;
379380
ChannelKind kind = channelDto.getKind();
380381
String itemType = channelDto.getItemType();
@@ -402,11 +403,11 @@ private List<Channel> createChannels(ThingTypeUID thingTypeUID, ThingUID thingUI
402403
}
403404
}
404405

405-
Channel channel = ChannelBuilder.create(new ChannelUID(thingUID, entry.getKey()), itemType).withKind(kind)
406+
Channel channel = ChannelBuilder.create(new ChannelUID(thingUID, channelId), itemType).withKind(kind)
406407
.withConfiguration(configuration).withType(channelTypeUID).withLabel(label)
407408
.withAutoUpdatePolicy(autoUpdatePolicy).build();
408409
channels.add(channel);
409-
addedChannelIds.add(entry.getKey());
410+
addedChannelIds.add(channelId);
410411
});
411412

412413
channelDefinitions.forEach(channelDef -> {

0 commit comments

Comments
 (0)