use of org.mule.runtime.api.meta.model.operation.HasOperationModels 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.HasOperationModels in project mule by mulesoft.
the class MetadataComponentModelValidator method validate.
@Override
public void validate(ExtensionModel extensionModel, ProblemsReporter problemsReporter) {
// TODO - MULE-14397 - Improve Dynamic Metadata Enricher to enrich without requiring Classes
// This is skipped if the extension is loaded with java, but it doesn't have classes which means AST Mode
Optional<ExtensionTypeDescriptorModelProperty> property = extensionModel.getModelProperty(ExtensionTypeDescriptorModelProperty.class);
if (property.isPresent()) {
if (!property.get().getType().getDeclaringClass().isPresent()) {
return;
}
}
final Table<String, String, Class<?>> names = HashBasedTable.create();
new ExtensionWalker() {
@Override
public void onOperation(HasOperationModels owner, OperationModel model) {
validateComponent(model);
}
@Override
public void onSource(HasSourceModels owner, SourceModel model) {
validateComponent(model);
}
private void validateComponent(ConnectableComponentModel model) {
validateMetadataReturnType(extensionModel, model, problemsReporter);
MetadataResolverFactory resolverFactory = MuleExtensionUtils.getMetadataResolverFactory(model);
validateMetadataOutputAttributes(model, resolverFactory, problemsReporter);
validateMetadataKeyId(model, resolverFactory, problemsReporter);
validateCategoriesInScope(model, resolverFactory, problemsReporter);
validateResolversName(model, resolverFactory, names, problemsReporter);
}
}.walk(extensionModel);
}
Aggregations