Search in sources :

Example 1 with Profile

use of com.walmartlabs.concord.process.loader.model.Profile in project concord by walmartlabs.

the class EntryPointProcessor method isValidEntryPoint.

/**
 * Determines validity of a given {@code entryPoint} based on
 * the currently active profiles.
 *
 * @param payload    payload containing public flows definition
 * @param entryPoint process {@code entryPoint} flow
 * @return true if {@code entryPoint} is a valid value
 */
private static boolean isValidEntryPoint(Payload payload, String entryPoint) {
    ProcessDefinition pd = payload.getHeader(Payload.PROJECT_DEFINITION);
    Set<String> publicFlows = new HashSet<>(pd.publicFlows() != null ? pd.publicFlows() : Collections.emptySet());
    List<String> activeProfiles = payload.getHeader(Payload.ACTIVE_PROFILES);
    if (activeProfiles != null) {
        for (String profileName : activeProfiles) {
            Profile p = pd.profiles().get(profileName);
            if (p == null || p.publicFlows() == null) {
                continue;
            }
            publicFlows.addAll(p.publicFlows());
        }
    }
    if (publicFlows.isEmpty()) {
        // all flows are public when public definition not provided
        return true;
    }
    return publicFlows.contains(entryPoint);
}
Also used : ProcessDefinition(com.walmartlabs.concord.process.loader.model.ProcessDefinition) Profile(com.walmartlabs.concord.process.loader.model.Profile)

Aggregations

ProcessDefinition (com.walmartlabs.concord.process.loader.model.ProcessDefinition)1 Profile (com.walmartlabs.concord.process.loader.model.Profile)1