Skip to content

Commit b26f849

Browse files
authored
Merge branch 'main' into issues/729
2 parents a4b6378 + a5d34a7 commit b26f849

File tree

5 files changed

+44
-25
lines changed

5 files changed

+44
-25
lines changed

.github/workflows/frontend_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323

2424
- uses: pnpm/action-setup@v4.0.0
2525
with:
26-
version: 9.15.0
26+
version: 9.15.4
2727

2828
- name: Install node
2929
uses: actions/setup-node@v4.0.2

api/src/main/java/io/kafbat/ui/model/rbac/Role.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.kafbat.ui.model.rbac;
22

3-
import com.google.common.base.Preconditions;
3+
import static com.google.common.base.Preconditions.checkArgument;
4+
45
import java.util.List;
56
import lombok.Data;
67

@@ -13,9 +14,11 @@ public class Role {
1314
List<Permission> permissions;
1415

1516
public void validate() {
16-
Preconditions.checkArgument(!clusters.isEmpty(), "Role clusters cannot be empty");
17+
checkArgument(!clusters.isEmpty(), "Role clusters cannot be empty");
18+
checkArgument(!subjects.isEmpty(), "Role subjects cannot be empty");
1719
permissions.forEach(Permission::transform);
1820
permissions.forEach(Permission::validate);
21+
subjects.forEach(Subject::validate);
1922
}
2023

2124
}

api/src/main/java/io/kafbat/ui/model/rbac/Subject.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package io.kafbat.ui.model.rbac;
22

3+
import static com.google.common.base.Preconditions.checkArgument;
4+
import static com.google.common.base.Preconditions.checkNotNull;
5+
36
import io.kafbat.ui.model.rbac.provider.Provider;
47
import lombok.Getter;
58

@@ -21,4 +24,12 @@ public void setType(String type) {
2124
public void setValue(String value) {
2225
this.value = value;
2326
}
27+
28+
public void validate() {
29+
checkNotNull(type, "Subject type cannot be null");
30+
checkNotNull(value, "Subject value cannot be null");
31+
32+
checkArgument(!type.isEmpty(), "Subject type cannot be empty");
33+
checkArgument(!value.isEmpty(), "Subject value cannot be empty");
34+
}
2435
}

api/src/main/java/io/kafbat/ui/util/DynamicConfigOperations.java

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.yaml.snakeyaml.nodes.Tag;
3939
import org.yaml.snakeyaml.representer.Representer;
4040
import reactor.core.publisher.Mono;
41+
import reactor.core.scheduler.Schedulers;
4142

4243
@Slf4j
4344
@RequiredArgsConstructor
@@ -125,26 +126,30 @@ public Mono<Path> uploadConfigRelatedFile(FilePart file) {
125126
String targetDirStr = ctx.getEnvironment()
126127
.getProperty(CONFIG_RELATED_UPLOADS_DIR_PROPERTY, CONFIG_RELATED_UPLOADS_DIR_DEFAULT);
127128

128-
Path targetDir = Path.of(targetDirStr);
129-
if (!Files.exists(targetDir)) {
130-
try {
131-
Files.createDirectories(targetDir);
132-
} catch (IOException e) {
133-
return Mono.error(
134-
new FileUploadException("Error creating directory for uploads %s".formatted(targetDir), e));
129+
Mono<Path> directoryCreationMono = Mono.fromCallable(() -> {
130+
Path targetDir = Path.of(targetDirStr);
131+
if (!Files.exists(targetDir)) {
132+
try {
133+
Files.createDirectories(targetDir);
134+
} catch (IOException e) {
135+
throw new FileUploadException("Error creating directory for uploads %s".formatted(targetDir), e);
136+
}
137+
}
138+
return targetDir;
139+
}).subscribeOn(Schedulers.boundedElastic());
140+
141+
return directoryCreationMono.flatMap(dir -> {
142+
Path targetFilePath = dir.resolve(file.filename() + "-" + Instant.now().getEpochSecond());
143+
log.info("Uploading config-related file {}", targetFilePath);
144+
if (Files.exists(targetFilePath)) {
145+
log.info("File {} already exists, it will be overwritten", targetFilePath);
135146
}
136-
}
137-
138-
Path targetFilePath = targetDir.resolve(file.filename() + "-" + Instant.now().getEpochSecond());
139-
log.info("Uploading config-related file {}", targetFilePath);
140-
if (Files.exists(targetFilePath)) {
141-
log.info("File {} already exists, it will be overwritten", targetFilePath);
142-
}
143147

144-
return file.transferTo(targetFilePath)
145-
.thenReturn(targetFilePath)
146-
.doOnError(th -> log.error("Error uploading file {}", targetFilePath, th))
147-
.onErrorMap(th -> new FileUploadException(targetFilePath, th));
148+
return file.transferTo(targetFilePath)
149+
.thenReturn(targetFilePath)
150+
.doOnError(th -> log.error("Error uploading file {}", targetFilePath, th))
151+
.onErrorMap(th -> new FileUploadException(targetFilePath, th));
152+
});
148153
}
149154

150155
private void checkIfDynamicConfigEnabled() {
@@ -163,8 +168,8 @@ private void writeYamlToFile(String yaml, Path path) {
163168
if (!Files.exists(path.getParent())) {
164169
Files.createDirectories(path.getParent());
165170
}
166-
if (Files.exists(path) && !Files.isWritable(path)) {
167-
throw new ValidationException("File already exists and is not writable");
171+
if (Files.exists(path) && (!Files.isReadable(path) || !Files.isWritable(path))) {
172+
throw new ValidationException("File already exists and is not readable or writable");
168173
}
169174
try {
170175
Files.writeString(

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<apache.commons.version>2.12.0</apache.commons.version>
3535
<assertj.version>3.25.3</assertj.version>
3636
<avro.version>1.11.4</avro.version>
37-
<byte-buddy.version>1.14.19</byte-buddy.version>
37+
<byte-buddy.version>1.15.11</byte-buddy.version>
3838
<confluent.version>7.8.0</confluent.version>
3939
<datasketches-java.version>3.1.0</datasketches-java.version>
4040
<groovy.version>3.0.13</groovy.version>
@@ -59,7 +59,7 @@
5959

6060
<!-- Frontend dependency versions -->
6161
<node.version>v22.12.0</node.version>
62-
<pnpm.version>v9.15.0</pnpm.version>
62+
<pnpm.version>v9.15.4</pnpm.version>
6363

6464
<!-- Plugin versions -->
6565
<fabric8-maven-plugin.version>0.45.1</fabric8-maven-plugin.version>

0 commit comments

Comments
 (0)