Search in sources :

Example 1 with NamedTypeResolver

use of org.mule.runtime.api.metadata.resolving.NamedTypeResolver in project mule by mulesoft.

the class MetadataComponentModelValidator method validateResolversName.

private void validateResolversName(ComponentModel model, MetadataResolverFactory resolverFactory, Table<String, String, Class<?>> names, ProblemsReporter problemsReporter) {
    List<NamedTypeResolver> resolvers = new LinkedList<>();
    resolvers.addAll(getAllInputResolvers(model, resolverFactory));
    resolvers.add(resolverFactory.getOutputResolver());
    resolvers.stream().filter(r -> !r.getClass().equals(NullMetadataResolver.class)).forEach(r -> {
        if (isBlank(r.getResolverName())) {
            problemsReporter.addError(new Problem(model, format(EMPTY_RESOLVER_NAME, getComponentModelTypeName(model), model.getName(), r.getClass().getSimpleName(), "resolver")));
        } else {
            if (names.get(r.getCategoryName(), r.getResolverName()) != null && names.get(r.getCategoryName(), r.getResolverName()) != r.getClass()) {
                problemsReporter.addError(new Problem(model, format("%s [%s] specifies metadata resolvers with repeated name [%s] for the same category [%s]. Resolver names should be unique for a given category. Affected resolvers are '%s' and '%s'", getComponentModelTypeName(model), model.getName(), r.getResolverName(), r.getCategoryName(), names.get(r.getCategoryName(), r.getResolverName()).getSimpleName(), r.getClass().getSimpleName())));
            }
            names.put(r.getCategoryName(), r.getResolverName(), r.getClass());
        }
    });
}
Also used : OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) Message(org.mule.runtime.api.message.Message) NamedObject(org.mule.runtime.api.meta.NamedObject) HashBasedTable(com.google.common.collect.HashBasedTable) MetadataKeyIdModelProperty(org.mule.runtime.extension.api.property.MetadataKeyIdModelProperty) SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) ModelLoaderUtils.isScope(org.mule.runtime.module.extension.internal.loader.utils.ModelLoaderUtils.isScope) ArrayType(org.mule.metadata.api.model.ArrayType) MetadataKeyPartModelProperty(org.mule.runtime.extension.api.property.MetadataKeyPartModelProperty) Map(java.util.Map) StringUtils(org.mule.runtime.core.api.util.StringUtils) Collectors.toSet(java.util.stream.Collectors.toSet) ConnectableComponentModel(org.mule.runtime.api.meta.model.ConnectableComponentModel) ExtensionMetadataTypeUtils.isMap(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.isMap) ObjectType(org.mule.metadata.api.model.ObjectType) OutputTypeResolver(org.mule.runtime.api.metadata.resolving.OutputTypeResolver) ProblemsReporter(org.mule.runtime.extension.api.loader.ProblemsReporter) InputTypeResolver(org.mule.runtime.api.metadata.resolving.InputTypeResolver) Set(java.util.Set) String.format(java.lang.String.format) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor) MuleExtensionUtils(org.mule.runtime.module.extension.internal.util.MuleExtensionUtils) Serializable(java.io.Serializable) List(java.util.List) HasOperationModels(org.mule.runtime.api.meta.model.operation.HasOperationModels) NameUtils.getComponentModelTypeName(org.mule.runtime.extension.api.util.NameUtils.getComponentModelTypeName) MetadataType(org.mule.metadata.api.model.MetadataType) Optional(java.util.Optional) ExtensionOperationDescriptorModelProperty(org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionOperationDescriptorModelProperty) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) ComponentModel(org.mule.runtime.api.meta.model.ComponentModel) ExtensionTypeDescriptorModelProperty(org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionTypeDescriptorModelProperty) CustomDefinedStaticTypeAnnotation(org.mule.runtime.module.extension.internal.loader.annotations.CustomDefinedStaticTypeAnnotation) StringUtils.join(org.apache.commons.lang3.StringUtils.join) NullMetadataResolver(org.mule.runtime.extension.api.metadata.NullMetadataResolver) Problem(org.mule.runtime.extension.api.loader.Problem) LinkedList(java.util.LinkedList) MetadataResolverUtils.isNullResolver(org.mule.runtime.extension.api.metadata.MetadataResolverUtils.isNullResolver) ExtensionModelValidator(org.mule.runtime.extension.api.loader.ExtensionModelValidator) MetadataTypeUtils.isVoid(org.mule.metadata.api.utils.MetadataTypeUtils.isVoid) MetadataResolverUtils.getAllResolvers(org.mule.runtime.extension.api.metadata.MetadataResolverUtils.getAllResolvers) MetadataTypeUtils.isCollection(org.mule.metadata.api.utils.MetadataTypeUtils.isCollection) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) ModelLoaderUtils.isRouter(org.mule.runtime.module.extension.internal.loader.utils.ModelLoaderUtils.isRouter) Collectors.toList(java.util.stream.Collectors.toList) ExtensionMetadataTypeUtils.getType(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.getType) ExtensionMetadataTypeUtils(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils) StringUtils.isBlank(org.apache.commons.lang3.StringUtils.isBlank) ExtensionWalker(org.mule.runtime.api.meta.model.util.ExtensionWalker) MetadataResolverFactory(org.mule.runtime.extension.api.metadata.MetadataResolverFactory) NamedTypeResolver(org.mule.runtime.api.metadata.resolving.NamedTypeResolver) Table(com.google.common.collect.Table) HasSourceModels(org.mule.runtime.api.meta.model.source.HasSourceModels) NullMetadataResolver(org.mule.runtime.extension.api.metadata.NullMetadataResolver) NamedTypeResolver(org.mule.runtime.api.metadata.resolving.NamedTypeResolver) Problem(org.mule.runtime.extension.api.loader.Problem) LinkedList(java.util.LinkedList)

Aggregations

HashBasedTable (com.google.common.collect.HashBasedTable)1 Table (com.google.common.collect.Table)1 Serializable (java.io.Serializable)1 String.format (java.lang.String.format)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors.toList (java.util.stream.Collectors.toList)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 StringUtils.isBlank (org.apache.commons.lang3.StringUtils.isBlank)1 StringUtils.join (org.apache.commons.lang3.StringUtils.join)1 ArrayType (org.mule.metadata.api.model.ArrayType)1 MetadataType (org.mule.metadata.api.model.MetadataType)1 ObjectType (org.mule.metadata.api.model.ObjectType)1 MetadataTypeUtils.isCollection (org.mule.metadata.api.utils.MetadataTypeUtils.isCollection)1 MetadataTypeUtils.isVoid (org.mule.metadata.api.utils.MetadataTypeUtils.isVoid)1 MetadataTypeVisitor (org.mule.metadata.api.visitor.MetadataTypeVisitor)1 Message (org.mule.runtime.api.message.Message)1