mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-10 15:32:05 -03:30
Improve WorkflowRepresentation.Builder, changing concurrency(true) to concurrency().cancelIfRunning() for better clarity
Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>
This commit is contained in:
parent
c4edb97e68
commit
657105bb41
@ -22,6 +22,10 @@ public class WorkflowConcurrencyRepresentation {
|
||||
return cancelIfRunning;
|
||||
}
|
||||
|
||||
public void setCancelIfRunning(Boolean cancelIfRunning) {
|
||||
this.cancelIfRunning = cancelIfRunning;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return cancelIfRunning != null ? cancelIfRunning.hashCode() : 0;
|
||||
|
||||
@ -180,8 +180,17 @@ public final class WorkflowRepresentation extends AbstractWorkflowComponentRepre
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder concurrency(boolean cancelIfRunning) {
|
||||
representation.setConcurrency(new WorkflowConcurrencyRepresentation(cancelIfRunning));
|
||||
public Builder concurrency() {
|
||||
representation.setConcurrency(new WorkflowConcurrencyRepresentation());
|
||||
return this;
|
||||
}
|
||||
|
||||
// move this to its own builder if we expand the capabilities of the concurrency settings.
|
||||
public Builder cancelIfRunning() {
|
||||
if (representation.getConcurrency() == null) {
|
||||
representation.setConcurrency(new WorkflowConcurrencyRepresentation());
|
||||
}
|
||||
representation.getConcurrency().setCancelIfRunning(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ -92,7 +92,7 @@ public class UserSessionRefreshTimeWorkflowTest {
|
||||
managedRealm.admin().workflows().create(WorkflowRepresentation.create()
|
||||
.of(UserSessionRefreshTimeWorkflowProviderFactory.ID)
|
||||
.onEvent(ResourceOperationType.USER_LOGIN.toString())
|
||||
.concurrency(true) // this setting enables restarting the workflow
|
||||
.concurrency().cancelIfRunning() // this setting enables restarting the workflow
|
||||
.withSteps(
|
||||
WorkflowStepRepresentation.create().of(NotifyUserStepProviderFactory.ID)
|
||||
.after(Duration.ofDays(5))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user