Search in sources :

Example 1 with MessageMetadataTypeBuilder

use of org.mule.metadata.message.api.MessageMetadataTypeBuilder in project mule by mulesoft.

the class MetadataOutputDelegate method wrapInMessageType.

private MetadataType wrapInMessageType(MetadataType type, Object key, MetadataContext context, Optional<MetadataType> staticAttributes) throws MetadataResolvingException {
    MessageMetadataTypeBuilder message = new MessageMetadataTypeBuilder().payload(type);
    staticAttributes.ifPresent(message::attributes);
    if (((HasOutputModel) component).getOutputAttributes().hasDynamicType()) {
        MetadataResult<MetadataType> attributes = resolveOutputAttributesMetadata(context, key, Objects::nonNull);
        if (!attributes.isSuccess()) {
            throw new MetadataResolvingException("Could not resolve attributes of List<Message> output", attributes.getFailures().stream().map(MetadataFailure::getFailureCode).findFirst().orElse(UNKNOWN));
        }
        message.attributes(attributes.get());
    }
    return message.build();
}
Also used : MetadataResolvingException(org.mule.runtime.api.metadata.MetadataResolvingException) MessageMetadataType(org.mule.metadata.message.api.MessageMetadataType) MetadataType(org.mule.metadata.api.model.MetadataType) Objects(java.util.Objects) MessageMetadataTypeBuilder(org.mule.metadata.message.api.MessageMetadataTypeBuilder)

Aggregations

Objects (java.util.Objects)1 MetadataType (org.mule.metadata.api.model.MetadataType)1 MessageMetadataType (org.mule.metadata.message.api.MessageMetadataType)1 MessageMetadataTypeBuilder (org.mule.metadata.message.api.MessageMetadataTypeBuilder)1 MetadataResolvingException (org.mule.runtime.api.metadata.MetadataResolvingException)1