Search in sources :

Example 1 with RepositoryDefinition

use of org.alien4cloud.tosca.model.definitions.RepositoryDefinition in project alien4cloud by alien4cloud.

the class AbstractArtifactPostProcessor method process.

@Override
public void process(AbstractArtifact instance) {
    Node node = ParsingContextExecution.getObjectToNodeMap().get(instance);
    postProcessArtifactRef(node, instance.getArtifactRef());
    ArchiveRoot archiveRoot = ParsingContextExecution.getRootObj();
    // If archive name is already defined (by the type for example then don't override it)
    if (StringUtils.isBlank(instance.getArchiveName())) {
        instance.setArchiveName(archiveRoot.getArchive().getName());
        instance.setArchiveVersion(archiveRoot.getArchive().getVersion());
    }
    if (instance.getArtifactType() == null) {
        // try to get type from extension
        instance.setArtifactType(getArtifactTypeByExtension(instance.getArtifactRef(), node, archiveRoot));
    } else {
        // check the type reference
        referencePostProcessor.process(new ReferencePostProcessor.TypeReference(instance, instance.getArtifactType(), ArtifactType.class));
    }
    if (instance.getRepositoryName() != null) {
        RepositoryDefinition repositoryDefinition = archiveRoot.getRepositories() != null ? archiveRoot.getRepositories().get(instance.getRepositoryName()) : null;
        if (repositoryDefinition == null) {
            // Sometimes the information about repository has already been filled in the parent type
            if (instance.getRepositoryURL() == null) {
                ParsingContextExecution.getParsingErrors().add(new ParsingError(ErrorCode.UNKNOWN_REPOSITORY, "Implementation artifact", node.getStartMark(), "Repository definition not found", node.getEndMark(), instance.getArtifactRepository()));
            }
        } else {
            instance.setRepositoryURL(repositoryDefinition.getUrl());
            instance.setRepositoryCredential(repositoryDefinition.getCredential() != null ? repositoryDefinition.getCredential().getValue() : null);
            instance.setRepositoryName(repositoryDefinition.getId());
            instance.setArtifactRepository(repositoryDefinition.getType());
        }
    }
}
Also used : RepositoryDefinition(org.alien4cloud.tosca.model.definitions.RepositoryDefinition) ArchiveRoot(alien4cloud.tosca.model.ArchiveRoot) ParsingError(alien4cloud.tosca.parser.ParsingError) ArtifactType(org.alien4cloud.tosca.model.types.ArtifactType) Node(org.yaml.snakeyaml.nodes.Node)

Aggregations

ArchiveRoot (alien4cloud.tosca.model.ArchiveRoot)1 ParsingError (alien4cloud.tosca.parser.ParsingError)1 RepositoryDefinition (org.alien4cloud.tosca.model.definitions.RepositoryDefinition)1 ArtifactType (org.alien4cloud.tosca.model.types.ArtifactType)1 Node (org.yaml.snakeyaml.nodes.Node)1