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());
}
}
}
Aggregations