private void extractOperationExtension(HasOperationDeclarer declarer, ComponentModel operationModel, DirectedGraph<String, DefaultEdge> directedGraph, XmlDslModel xmlDslModel) { String operationName = operationModel.getNameAttribute(); OperationDeclarer operationDeclarer = declarer.withOperation(operationName); ComponentModel bodyComponentModel = operationModel.getInnerComponents() .stream() .filter(child -> child.getIdentifier().equals(OPERATION_BODY_IDENTIFIER)).findFirst() .orElseThrow(() -> new IllegalArgumentException(format("The operation '%s' is missing the <body> statement", operationName))); directedGraph.addVertex(operationName); fillGraphWithTnsReferences(directedGraph, operationName, bodyComponentModel.getInnerComponents()); operationDeclarer.withModelProperty(new OperationComponentModelModelProperty(operationModel, bodyComponentModel)); operationDeclarer.describedAs(getDescription(operationModel)); operationDeclarer.getDeclaration().setDisplayModel(getDisplayModel(operationModel)); extractOperationParameters(operationDeclarer, operationModel); extractOutputType(operationDeclarer.withOutput(), OPERATION_OUTPUT_IDENTIFIER, operationModel, getDeclarationOutputFor(operationName)); extractOutputType(operationDeclarer.withOutputAttributes(), OPERATION_OUTPUT_ATTRIBUTES_IDENTIFIER, operationModel, getDeclarationOutputAttributesFor(operationName)); declareErrorModels(operationDeclarer, xmlDslModel, operationName, operationModel); }
/** * Declares the invoke operation. * * @param configDeclarer the soap config declarer * @param loader a {@link ClassTypeLoader} to load some parameters types. * @param soapErrors the {@link ErrorModel}s that this operation can throw. */ void declare(ConfigurationDeclarer configDeclarer, ClassTypeLoader loader, Set<ErrorModel> soapErrors) { ReflectionCache reflectionCache = new ReflectionCache(); OperationDeclarer operation = configDeclarer.withOperation(OPERATION_NAME) .describedAs(OPERATION_DESCRIPTION) .requiresConnection(true) .blocking(true) .withModelProperty(new ComponentExecutorModelProperty(new SoapOperationExecutorFactory())) .withModelProperty(new ConnectivityModelProperty(ForwardingSoapClient.class)); soapErrors.forEach(operation::withErrorModel); declareMetadata(operation, loader); declareOutput(operation, loader); declareMetadataKeyParameters(operation, loader, reflectionCache); declareRequestParameters(operation, loader); }
private void declareRemoveVariable(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { OperationDeclarer removeVariable = extensionDeclarer.withOperation("removeVariable") .describedAs("A processor that remove variables by name or regular expression."); removeVariable.withOutput().ofType(typeLoader.load(void.class)); removeVariable.withOutputAttributes().ofType(typeLoader.load(void.class)); removeVariable.onDefaultParameterGroup() .withOptionalParameter("variableName") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The variable name."); }
private void declareFlowRef(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { OperationDeclarer flowRef = extensionDeclarer.withOperation("flowRef") .describedAs("Allows a \u0027flow\u0027 to be referenced such that the message processing will continue in the referenced flow " + "before returning. Message processing in the referenced \u0027flow\u0027 will occur within the context of the " + "referenced flow and will therefore use its exception strategy etc.") .withErrorModel(routingError); flowRef.withOutput().ofType(BaseTypeBuilder.create(JAVA).anyType().build()); flowRef.withOutputAttributes().ofType(BaseTypeBuilder.create(JAVA).anyType().build()); flowRef.onDefaultParameterGroup() .withRequiredParameter("name") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The name of the flow to call"); }
private void declareRaiseError(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { OperationDeclarer raiseError = extensionDeclarer.withOperation("raiseError") .describedAs("Throws an error with the specified type and description."); raiseError.withOutput().ofType(typeLoader.load(void.class)); raiseError.withOutputAttributes().ofType(typeLoader.load(void.class)); raiseError.onDefaultParameterGroup() .withRequiredParameter("type") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The error type to raise."); raiseError.onDefaultParameterGroup() .withOptionalParameter("description") .ofType(typeLoader.load(String.class)) .describedAs("The description of this error."); }
private void declareParseTemplate(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { OperationDeclarer parseTemplate = extensionDeclarer.withOperation("parseTemplate") .describedAs("A transformer that parses a template defined inline."); parseTemplate.withOutput().ofType(typeLoader.load(String.class)); parseTemplate.withOutputAttributes().ofType(typeLoader.load(void.class)); parseTemplate.onDefaultParameterGroup() .withOptionalParameter("content") .ofType(typeLoader.load(String.class)) .withRole(ParameterRole.PRIMARY_CONTENT) .withExpressionSupport(SUPPORTED) .describedAs("Template to be processed."); parseTemplate.onDefaultParameterGroup() .withOptionalParameter("location") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The location of the template. The order in which the transformer will attempt to load the file are: from the file system, from a URL or from the classpath."); }
private void declareSetPayload(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { OperationDeclarer setPayload = extensionDeclarer.withOperation("setPayload") .describedAs("A transformer that sets the payload with the provided value."); setPayload.withOutput().ofType(typeLoader.load(void.class)); setPayload.withOutputAttributes().ofType(typeLoader.load(void.class)); setPayload.onDefaultParameterGroup() .withOptionalParameter("encoding") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The encoding of the value assigned to the payload."); setPayload.onDefaultParameterGroup() .withRequiredParameter("value") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The value to be set on the payload. Supports expressions."); setPayload.onDefaultParameterGroup() .withOptionalParameter("mimeType") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The mime type, e.g. text/plain or application/json"); }
private void declareLogger(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { OperationDeclarer logger = extensionDeclarer.withOperation("logger") .describedAs("Performs logging using an expression that determines what should be logged. By default the current messages is logged " + "using the DEBUG level to the \u0027org.mule.runtime.core.api.processor.LoggerMessageProcessor\u0027 category but " + "the level and category can both be configured to suit your needs. message is specified then the current message is used."); logger.withOutput().ofType(typeLoader.load(void.class)); logger.withOutputAttributes().ofType(typeLoader.load(void.class)); logger.onDefaultParameterGroup() .withOptionalParameter("message") .ofType(typeLoader.load(String.class)) .describedAs("Message that will be logged. Embedded expressions can be used to extract value from the current message. " + "If no message is specified then the current message is used."); logger.onDefaultParameterGroup() .withOptionalParameter("level") .defaultingTo("DEBUG") .ofType(BaseTypeBuilder.create(JAVA).stringType() .enumOf("ERROR", "WARN", "INFO", "DEBUG", "TRACE").build()) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The logging level to be used. Default is DEBUG."); logger.onDefaultParameterGroup() .withOptionalParameter("category") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The log category to be used"); }
private void declareSetVariable(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { OperationDeclarer setVariable = extensionDeclarer.withOperation("setVariable") .describedAs("A processor that adds variables."); setVariable.withOutput().ofType(typeLoader.load(void.class)); setVariable.withOutputAttributes().ofType(typeLoader.load(void.class)); setVariable.onDefaultParameterGroup() .withOptionalParameter("variableName") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The variable name."); setVariable.onDefaultParameterGroup() .withRequiredParameter("value") .ofType(typeLoader.load(String.class)) .withExpressionSupport(SUPPORTED) .describedAs("The variable value."); setVariable.onDefaultParameterGroup() .withOptionalParameter("encoding") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The encoding of the value assigned to the payload."); setVariable.onDefaultParameterGroup() .withOptionalParameter("mimeType") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The mime type, e.g. text/plain or application/json"); }
private void declareIdempotentValidator(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { OperationDeclarer validator = extensionDeclarer .withOperation("idempotentMessageValidator") .describedAs("Ensures that only unique messages are received by a service by checking the unique ID of the incoming message. " + "Note that the ID used can be generated from the message using an expression defined in the 'idExpression' " + "attribute. Otherwise, a 'DUPLICATE_MESSAGE' error is generated.");
.describedAs("Authorize users against a required set of authorities."); authorizationFilter.withOutput().ofType(typeBuilder.voidType().build()); authorizationFilter.withOutputAttributes().ofType(typeBuilder.voidType().build());