use of com.walmartlabs.concord.process.loader.model.ProcessDefinition 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);
}
use of com.walmartlabs.concord.process.loader.model.ProcessDefinition in project concord by walmartlabs.
the class ProjectRepositoryManager method validateRepository.
public ProjectValidator.Result validateRepository(UUID projectId, RepositoryEntry repo) {
try {
ProcessDefinition pd = repositoryManager.withLock(repo.getUrl(), () -> {
Repository repository = repositoryManager.fetch(projectId, repo);
ProjectLoader.Result result = projectLoader.loadProject(repository.path(), importsNormalizerFactory.forProject(repo.getProjectId()), ImportsListener.NOP_LISTENER);
return result.projectDefinition();
});
return ProjectValidator.validate(pd);
} catch (Exception e) {
throw new RepositoryValidationException("Validation failed: " + repo.getName(), e);
}
}
Aggregations