mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-09 15:02:05 -03:30
Fix representation so that workflows can be properly disabled/enabled.
- also removes empty 'with' configurations from the steps when retrieving the workflow. Closes #44163 Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>
This commit is contained in:
parent
7acf2ceccb
commit
5ff2e22f18
@ -24,7 +24,7 @@ public abstract class AbstractWorkflowComponentRepresentation {
|
||||
|
||||
public AbstractWorkflowComponentRepresentation(String id, MultivaluedHashMap<String, String> config) {
|
||||
this.id = id;
|
||||
this.config = config;
|
||||
this.setConfig(config);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
@ -40,10 +40,12 @@ public abstract class AbstractWorkflowComponentRepresentation {
|
||||
}
|
||||
|
||||
public void setConfig(MultivaluedHashMap<String, String> config) {
|
||||
if (this.config == null) {
|
||||
this.config = config;
|
||||
if (config != null) {
|
||||
if (this.config == null) {
|
||||
this.config = new MultivaluedHashMap<>();
|
||||
}
|
||||
this.config.putAll(config);
|
||||
}
|
||||
this.config.putAll(config);
|
||||
}
|
||||
|
||||
public void setConfig(String key, String value) {
|
||||
|
||||
@ -50,6 +50,12 @@ public final class MultivaluedHashMapValueSerializer extends JsonSerializer<Mult
|
||||
gen.writeEndObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty(SerializerProvider provider, MultivaluedHashMap<String, String> value) {
|
||||
// if all properties are ignored, consider the map as empty
|
||||
return getIgnoredProperties(provider.getGenerator()).containsAll(value.keySet());
|
||||
}
|
||||
|
||||
private static Set<String> getIgnoredProperties(JsonGenerator gen) {
|
||||
Class<?> parentClazz = gen.currentValue().getClass();
|
||||
return Arrays.stream(parentClazz.getDeclaredMethods())
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package org.keycloak.representations.workflows;
|
||||
|
||||
import static org.keycloak.representations.workflows.WorkflowConstants.CONFIG_CANCEL_IF_RUNNING;
|
||||
import static org.keycloak.representations.workflows.WorkflowConstants.CONFIG_CONCURRENCY;
|
||||
import static org.keycloak.representations.workflows.WorkflowConstants.CONFIG_CONDITIONS;
|
||||
import static org.keycloak.representations.workflows.WorkflowConstants.CONFIG_ENABLED;
|
||||
@ -108,11 +109,21 @@ public final class WorkflowRepresentation extends AbstractWorkflowComponentRepre
|
||||
}
|
||||
|
||||
public WorkflowConcurrencyRepresentation getConcurrency() {
|
||||
return concurrency;
|
||||
if (this.concurrency == null) {
|
||||
Boolean cancelIfRunning = getConfigValue(CONFIG_CANCEL_IF_RUNNING, Boolean.class);
|
||||
if (cancelIfRunning != null) {
|
||||
this.concurrency = new WorkflowConcurrencyRepresentation();
|
||||
this.concurrency.setCancelIfRunning(cancelIfRunning);
|
||||
}
|
||||
}
|
||||
return this.concurrency;
|
||||
}
|
||||
|
||||
public void setConcurrency(WorkflowConcurrencyRepresentation concurrency) {
|
||||
this.concurrency = concurrency;
|
||||
if (concurrency != null) {
|
||||
setConfigValue(CONFIG_CANCEL_IF_RUNNING, concurrency.isCancelIfRunning());
|
||||
}
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
|
||||
@ -9,12 +9,14 @@ import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import org.keycloak.common.util.MultivaluedHashMap;
|
||||
|
||||
@JsonPropertyOrder({"id", CONFIG_USES, CONFIG_AFTER, CONFIG_PRIORITY, CONFIG_WITH})
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public final class WorkflowStepRepresentation extends AbstractWorkflowComponentRepresentation {
|
||||
|
||||
private final String uses;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user