use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.
the class MacroExpansionModuleModel method lookForOperation.
/**
* Looks for an operation checking if it is defined within the scope of a {@link ConfigurationModel} or the
* {@link ExtensionModel}.
*
* @param operationIdentifier element to look for in the current {@link #extensionModel}
* @param prefix to check if the {@code operationIdentifier} namespace targets an operation of the <module/> (usually maps to
* the {@link ExtensionModel} prefix, or the {@link #TNS_PREFIX}.
* @return an {@link OperationModel} if found, {@link Optional#empty()} otherwise.
*/
private Optional<OperationModel> lookForOperation(ComponentIdentifier operationIdentifier, String prefix) {
Optional<OperationModel> result = Optional.empty();
final String operationName = operationIdentifier.getName();
if (operationIdentifier.getNamespace().equals(prefix)) {
// As the operation can be inside the extension or the config, it has to be looked up in both elements.
final HasOperationModels hasOperationModels = getConfigurationModel().map(configurationModel -> (HasOperationModels) configurationModel).orElse(extensionModel);
result = hasOperationModels.getOperationModel(operationName);
}
// If the operation is not present, it might be a private one and it must be looked inside of the model property
if (!result.isPresent() && extensionModel.getModelProperty(PrivateOperationsModelProperty.class).isPresent()) {
result = extensionModel.getModelProperty(PrivateOperationsModelProperty.class).get().getOperationModel(operationName);
}
return result;
}
use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.
the class ModuleOperationMessageProcessorChainFactoryBean method getOperationModelOrFail.
private OperationModel getOperationModelOrFail(ExtensionModel extensionModel) {
OperationSeeker operationSeeker = new OperationSeeker();
operationSeeker.walk(extensionModel);
final OperationModel operationModel = operationSeeker.operationModel.orElseGet(() -> extensionModel.getModelProperty(PrivateOperationsModelProperty.class).get().getOperationModel(moduleOperation).orElseThrow(() -> new IllegalArgumentException(format("Could not find any operation under the name of [%s] for the extension [%s]", moduleOperation, moduleName))));
return operationModel;
}
use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.
the class CoreExtensionModelTestCase method flowRef.
@Test
public void flowRef() {
final OperationModel flowRefModel = coreExtensionModel.getOperationModel("flowRef").get();
assertThat(flowRefModel.getStereotype(), is(PROCESSOR));
assertAssociatedProcessorsChangeOutput(flowRefModel);
assertThat(flowRefModel.getAllParameterModels(), hasSize(3));
assertThat(flowRefModel.getAllParameterModels().get(0).getName(), is("name"));
assertThat(flowRefModel.getAllParameterModels().get(0).getExpressionSupport(), is(NOT_SUPPORTED));
assertThat(flowRefModel.getAllParameterModels().get(0).getType(), instanceOf(DefaultStringType.class));
assertThat(flowRefModel.getAllParameterModels().get(0).isRequired(), is(true));
assertTarget(flowRefModel.getAllParameterModels().get(1));
}
use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.
the class DefaultExtensionSchemaGenerator method generate.
/**
* {@inheritDoc}
*/
@Override
public String generate(ExtensionModel extensionModel, DslResolvingContext dslContext) {
XmlDslModel xmlDslModel = extensionModel.getXmlDslModel();
validate(extensionModel, xmlDslModel);
SchemaBuilder schemaBuilder = SchemaBuilder.newSchema(extensionModel, xmlDslModel, dslContext);
new IdempotentExtensionWalker() {
@Override
public void onConfiguration(ConfigurationModel model) {
schemaBuilder.registerConfigElement(model);
}
@Override
protected void onConstruct(ConstructModel model) {
schemaBuilder.registerOperation(model);
}
@Override
public void onOperation(OperationModel model) {
schemaBuilder.registerOperation(model);
}
@Override
public void onConnectionProvider(ConnectionProviderModel model) {
schemaBuilder.registerConnectionProviderElement(model);
}
@Override
public void onSource(SourceModel model) {
schemaBuilder.registerMessageSource(model);
}
}.walk(extensionModel);
schemaBuilder.registerEnums();
// Make sure the XML libs use the container classloader internally
return withContextClassLoader(DefaultExtensionSchemaGenerator.class.getClassLoader(), () -> renderSchema(schemaBuilder.build()));
}
use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.
the class SoapOperationExecutor method execute.
/**
* {@inheritDoc}
*/
@Override
public Publisher<Object> execute(ExecutionContext<OperationModel> context) {
try {
String serviceId = context.getParameter(SERVICE_PARAM);
ForwardingSoapClient connection = (ForwardingSoapClient) connectionResolver.resolve(context).get();
Map<String, String> customHeaders = connection.getCustomHeaders(serviceId, getOperation(context));
SoapRequest request = getRequest(context, customHeaders);
SoapClient soapClient = connection.getSoapClient(serviceId);
SoapResponse response = connection.getExtensionsClientDispatcher(() -> new ExtensionsClientArgumentResolver(registry, policyManager).resolve(context).get()).map(d -> soapClient.consume(request, d)).orElseGet(() -> soapClient.consume(request));
return justOrEmpty(response.getAsResult(streamingHelperArgumentResolver.resolve(context).get()));
} catch (MessageTransformerException | TransformerException e) {
return error(e);
} catch (Exception e) {
return error(soapExceptionEnricher.enrich(e));
} catch (Throwable t) {
return error(wrapFatal(t));
}
}
Aggregations