Search in sources :

Example 11 with ProcessDefinition

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);
}
Also used : ProcessDefinition(com.walmartlabs.concord.process.loader.model.ProcessDefinition) Profile(com.walmartlabs.concord.process.loader.model.Profile)

Example 12 with ProcessDefinition

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);
    }
}
Also used : Repository(com.walmartlabs.concord.repository.Repository) ProcessDefinition(com.walmartlabs.concord.process.loader.model.ProcessDefinition) ProjectLoader(com.walmartlabs.concord.process.loader.ProjectLoader) ValidationErrorsException(org.sonatype.siesta.ValidationErrorsException)

Aggregations

ProcessDefinition (com.walmartlabs.concord.process.loader.model.ProcessDefinition)12 ProjectLoader (com.walmartlabs.concord.process.loader.ProjectLoader)4 Snapshot (com.walmartlabs.concord.repository.Snapshot)3 ValidationErrorsException (org.sonatype.siesta.ValidationErrorsException)3 Repository (com.walmartlabs.concord.repository.Repository)2 ProcessException (com.walmartlabs.concord.server.process.ProcessException)2 ConcordApplicationException (com.walmartlabs.concord.server.sdk.ConcordApplicationException)2 CliImportsListener (com.walmartlabs.concord.cli.runner.CliImportsListener)1 ImportProcessingException (com.walmartlabs.concord.imports.ImportProcessingException)1 NoopImportManager (com.walmartlabs.concord.imports.NoopImportManager)1 Options (com.walmartlabs.concord.process.loader.model.Options)1 Profile (com.walmartlabs.concord.process.loader.model.Profile)1 ProcessDefinitionV1 (com.walmartlabs.concord.process.loader.v1.ProcessDefinitionV1)1 ProcessDefinitionV2 (com.walmartlabs.concord.process.loader.v2.ProcessDefinitionV2)1 ProjectValidator (com.walmartlabs.concord.server.org.project.ProjectValidator)1 RepositoryUtils.assertRepository (com.walmartlabs.concord.server.org.project.RepositoryUtils.assertRepository)1 ProcessKey (com.walmartlabs.concord.server.sdk.ProcessKey)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1