-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into add-subflow-test
- Loading branch information
Showing
15 changed files
with
476 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/formflow/library/config/DisabledFlowInterceptorConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package formflow.library.config; | ||
|
||
|
||
import static formflow.library.interceptors.DisabledFlowInterceptor.PATH_FORMAT; | ||
|
||
import formflow.library.interceptors.DisabledFlowInterceptor; | ||
import java.util.List; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
/*** | ||
* Adds DisabledFlowInterceptorConfiguration to the Interceptor registry. | ||
*/ | ||
@Configuration | ||
public class DisabledFlowInterceptorConfiguration implements WebMvcConfigurer { | ||
|
||
DisabledFlowPropertyConfiguration disabledFlowPropertyConfiguration; | ||
|
||
public DisabledFlowInterceptorConfiguration(DisabledFlowPropertyConfiguration disabledFlowPropertyConfiguration) { | ||
this.disabledFlowPropertyConfiguration = disabledFlowPropertyConfiguration; | ||
} | ||
|
||
/** | ||
* Adds the DisabledFlowInterceptor to the Interceptor registry. | ||
* @param registry The Interceptor registry. | ||
*/ | ||
@Override | ||
public void addInterceptors(InterceptorRegistry registry) { | ||
registry.addInterceptor(new DisabledFlowInterceptor(disabledFlowPropertyConfiguration)) | ||
.addPathPatterns(List.of(PATH_FORMAT)); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/formflow/library/config/DisabledFlowPropertyConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package formflow.library.config; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
//@ConditionalOnProperty(name = "form-flow.disabled-flows") | ||
@ConfigurationProperties(prefix = "form-flow") | ||
@Getter | ||
@Setter | ||
public class DisabledFlowPropertyConfiguration { | ||
private List<Map<String, String>> disabledFlows = new ArrayList<>(); | ||
|
||
|
||
/** | ||
* Checks if the flow with flowName is disabled. | ||
* @param flowName the name of the flow to check. | ||
* @return true if the flow is disabled, false otherwise. | ||
*/ | ||
public boolean isFlowDisabled(String flowName) { | ||
return this.disabledFlows.stream().anyMatch(flow -> flow.get("flow").equals(flowName)); | ||
} | ||
|
||
/** | ||
* Gets the static redirect page for a disabled flow. | ||
* @param flowName the name of the flow to check. | ||
* @return the static redirect page for the flow if disabled flows are configured and the flow is disabled. | ||
*/ | ||
public String getDisabledFlowRedirect(String flowName) { | ||
return disabledFlows.stream() | ||
.filter(flow -> flow.get("flow").equals(flowName)) | ||
.map(flow -> flow.getOrDefault("staticRedirectPage", "")) | ||
.findFirst() | ||
.orElse(null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 12 additions & 1 deletion
13
src/main/java/formflow/library/config/FlowsConfigurationFactoryConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.