String message = format("%s '%s' has a %s type output but doesn't specify a default mime type. Please annotate it with @%s", capitalize(componentType), model.getName(), outputMetadataType instanceof StringType ? "String" : "InputStream", org.mule.runtime.extension.api.annotation.param.MediaType.class.getSimpleName()); "given to your Type Builder. You can still use the @%s annotation to set `strict=false` " + "and keep letting the user configure the outputMimeType parameter.", capitalize(componentType), model.getName(), MediaType.class.getSimpleName(), org.mule.metadata.api.model.MetadataFormat.class.getName(), MediaType.class.getSimpleName()); problemsReporter.addError(new Problem(model, message)); format("%s '%s' has a %s type output but doesn't specify a default mime type. " + "Please give a value to the @%s annotation", capitalize(componentType), model.getName(), outputMetadataType instanceof StringType ? "String" : "InputStream", org.mule.runtime.extension.api.annotation.param.MediaType.class.getSimpleName());
private void validateVoidOperationsDontDeclareOutputResolver(ConnectableComponentModel component, ProblemsReporter problemsReporter, OutputTypeResolver<Object> outputResolver, MetadataType modelOutputType) { if (modelOutputType instanceof VoidType) { problemsReporter .addError(new Problem(component, format("A Metadata OutputResolver named '%s' in category '%s' was defined for the Void Operation '%s'. " + "Output resolvers cannot be used on Void Operations, since they produce no output.", outputResolver.getResolverName(), outputResolver.getCategoryName(), component.getName()))); } else if (isCustomStaticType(modelOutputType)) { component.getModelProperty(ExtensionOperationDescriptorModelProperty.class) .map(mp -> mp.getOperationElement().getOperationReturnMetadataType()) .filter(t -> t instanceof VoidType) .ifPresent(t -> problemsReporter.addError(new Problem(component, format("An Static Metadata OutputResolver was defined for the Void Operation '%s'. " + "Output resolvers cannot be used on Void Operations, since they produce no output.", component.getName())))); } }
private void checkValidType(ConnectableComponentModel componentModel, ExtensionModel extensionModel, MetadataType metadataType, ProblemsReporter problemsReporter) { String componentTypeName = getComponentModelTypeName(componentModel); getType(metadataType).ifPresent(type -> { String declarationMessageModifier = ""; MetadataType modelType = componentModel.getOutput().getType(); if (modelType instanceof ArrayType) { declarationMessageModifier = "a collection of "; } else if (modelType instanceof ObjectType && ((ObjectType) modelType).isOpen()) { declarationMessageModifier = "a map of "; } if (Object.class.equals(type)) { problemsReporter.addError(new Problem(extensionModel, format("%s '%s' declares %s'%s' as its return type. Components that return a type " + "such as Object or Map (or a collection of any of those) must have defined an OutputResolver", capitalize(componentTypeName), componentModel.getName(), declarationMessageModifier, type))); } else if (isInvalidInterface(metadataType, type)) { problemsReporter.addError(new Problem(extensionModel, format("%s '%s' declares %s'%s' as its return type. Components that return an interface " + "(or a collection of interfaces) must have defined an OutputResolver", capitalize(componentTypeName), componentModel.getName(), declarationMessageModifier, type))); } }); }
private void validateMetadataOutputAttributes(ConnectableComponentModel component, MetadataResolverFactory resolverFactory, ProblemsReporter problemsReporter) { if (isVoid(component.getOutputAttributes().getType()) && !(resolverFactory.getOutputAttributesResolver() instanceof NullMetadataResolver) && (!isCollection(component.getOutput().getType()))) { problemsReporter .addError(new Problem(component, format("%s '%s' has an AttributesTypeResolver defined but it doesn't declare any attributes as part of its output.", capitalize(getComponentModelTypeName(component)), component.getName()))); } }
private void validateMetadataOutputAttributes(ConnectableComponentModel component, MetadataResolverFactory resolverFactory, ProblemsReporter problemsReporter) { if (isVoid(component.getOutputAttributes().getType()) && !(resolverFactory.getOutputAttributesResolver() instanceof NullMetadataResolver) && (!isCollection(component.getOutput().getType()))) { problemsReporter.addError(new Problem(component, String .format("%s '%s' has an attributes metadata resolver defined but it doesn't set any attributes", getComponentModelTypeName(component), component.getName()))); } }