private void declareOutputEncodingParameter(ParameterGroupDeclaration group, boolean shouldAddSinceMuleVersionModelProperty) { group.addParameter(newParameter(ENCODING_PARAMETER_NAME, "The encoding of the payload that this operation outputs.", shouldAddSinceMuleVersionModelProperty)); }
private void declareOutputMimeTypeParameter(ParameterGroupDeclaration group, boolean shouldAddSinceMuleVersionModelProperty) { group.addParameter(newParameter(MIME_TYPE_PARAMETER_NAME, "The mime type of the payload that this operation outputs.", shouldAddSinceMuleVersionModelProperty)); }
private void assertEnrichment(boolean runsOnPrimaryNodeOnly, boolean parameterAdded, boolean defaultParameterValue) { enricher.enrich(extensionLoadingContext); verify(sourceDeclaration).setRunsOnPrimaryNodeOnly(runsOnPrimaryNodeOnly); if (parameterAdded) { ArgumentCaptor<ParameterDeclaration> captor = ArgumentCaptor.forClass(ParameterDeclaration.class); verify(parameterGroup).addParameter(captor.capture()); ParameterDeclaration parameter = captor.getValue(); assertThat(parameter.getName(), equalTo(PRIMARY_NODE_ONLY_PARAMETER_NAME)); assertThat(parameter.getDefaultValue(), is(defaultParameterValue)); } else { verify(parameterGroup, never()).addParameter(any()); } }
private void addBackPressureParameter(ExtensionDeclaration extensionDeclaration, SourceDeclaration sourceDeclaration, BackPressureStrategyModelProperty property) { ParameterDeclaration parameter = new ParameterDeclaration(BACK_PRESSURE_STRATEGY_PARAMETER_NAME); parameter.setDescription(BACK_PRESSURE_STRATEGY_PARAMETER_DESCRIPTION); parameter.setRequired(false); parameter.setDefaultValue(property.getDefaultMode()); parameter.setExpressionSupport(NOT_SUPPORTED); parameter.setLayoutModel(LayoutModel.builder().tabName(ADVANCED_TAB).build()); MetadataType type = BaseTypeBuilder.create(JAVA).stringType() .id(format("%s-%s-backPressureStrategy", extensionDeclaration.getName(), sourceDeclaration.getName())) .with(new EnumAnnotation<>(property.getSupportedModes().stream().map(BackPressureMode::name).toArray(String[]::new))) .build(); parameter.setType(type, false); sourceDeclaration.getParameterGroup(DEFAULT_GROUP_NAME).addParameter(parameter); }
@Override protected void onSource(SourceDeclaration source) { extractType(source).ifPresent(type -> { if (type.isAssignableTo(PollingSource.class)) { source.setRunsOnPrimaryNodeOnly(true); ParameterDeclaration parameter = new ParameterDeclaration(SCHEDULING_STRATEGY_PARAMETER_NAME); parameter.setDescription(SCHEDULING_STRATEGY_PARAMETER_DESCRIPTION); parameter.setRequired(true); parameter.setType(loader.load(Scheduler.class), false); parameter.setExpressionSupport(NOT_SUPPORTED); parameter.addModelProperty(new InfrastructureParameterModelProperty(10)); parameter.addModelProperty(new QNameModelProperty(new QName(CORE_NAMESPACE, SCHEDULING_STRATEGY_ELEMENT_IDENTIFIER, CORE_PREFIX))); parameter.setDslConfiguration(ParameterDslConfiguration.builder() .allowsInlineDefinition(true) .allowsReferences(false) .allowTopLevelDefinition(false) .build()); thereArePollingSources.set(true); source.getParameterGroup(DEFAULT_GROUP_NAME).addParameter(parameter); } }); } }.walk(extensionDeclarer.getDeclaration());
private void declareOutputEncodingParameter(ParameterGroupDeclaration group) { group.addParameter(newParameter(ENCODING_PARAMETER_NAME, "The encoding of the payload that this operation outputs.")); }
private void declareOutputMimeTypeParameter(ParameterGroupDeclaration group) { group.addParameter(newParameter(MIME_TYPE_PARAMETER_NAME, "The mime type of the payload that this operation outputs.")); }
private OperationDeclaration buildUnauthorizeOperation() { OperationDeclaration operation = new OperationDeclaration(UNAUTHORIZE_OPERATION_NAME); operation.setDescription("Deletes all the access token information of a given resource owner id so that it's impossible to " + "execute any operation for that user without doing the authorization dance again"); operation.setBlocking(true); operation.setExecutionType(BLOCKING); operation.setOutput(toDeclaration(voidType)); operation.setOutputAttributes(toDeclaration(voidType)); operation.setRequiresConnection(false); operation.setSupportsStreaming(false); operation.setTransactional(false); operation.addModelProperty(new ComponentExecutorModelProperty((model, params) -> new UnauthorizeOperationExecutor())); ParameterGroupDeclaration group = operation.getParameterGroup(DEFAULT_GROUP_NAME); group.showInDsl(false); ParameterDeclaration parameter = new ParameterDeclaration(RESOURCE_OWNER_ID_PARAMETER_NAME); parameter.setDescription("The id of the resource owner which access should be invalidated"); parameter.setExpressionSupport(SUPPORTED); parameter.setLayoutModel(LayoutModel.builder().build()); parameter.setRequired(false); parameter.setParameterRole(BEHAVIOUR); parameter.setType(stringType, false); group.addParameter(parameter); return operation; }
private void addBackPressureParameter(ExtensionDeclaration extensionDeclaration, SourceDeclaration sourceDeclaration, BackPressureStrategyModelProperty property) { ParameterDeclaration parameter = new ParameterDeclaration(BACK_PRESSURE_STRATEGY_PARAMETER_NAME); parameter.setDescription(BACK_PRESSURE_STRATEGY_PARAMETER_DESCRIPTION); parameter.setRequired(false); parameter.setDefaultValue(property.getDefaultMode()); parameter.setExpressionSupport(NOT_SUPPORTED); parameter.setLayoutModel(LayoutModel.builder().tabName(ADVANCED_TAB).build()); MetadataType type = BaseTypeBuilder.create(JAVA).stringType() .id(format("%s-%s-backPressureStrategy", extensionDeclaration.getName(), sourceDeclaration.getName())) .with(new EnumAnnotation<>(property.getSupportedModes().stream().map(BackPressureMode::name).toArray(String[]::new))) .build(); parameter.setType(type, false); sourceDeclaration.getParameterGroup(DEFAULT_GROUP_NAME).addParameter(parameter); }
@Override protected void onSource(SourceDeclaration source) { extractType(source).ifPresent(type -> { if (type.isAssignableTo(PollingSource.class)) { source.setRunsOnPrimaryNodeOnly(true); ParameterDeclaration parameter = new ParameterDeclaration(SCHEDULING_STRATEGY_PARAMETER_NAME); parameter.setDescription(SCHEDULING_STRATEGY_PARAMETER_DESCRIPTION); parameter.setRequired(true); parameter.setType(loader.load(Scheduler.class), false); parameter.setExpressionSupport(NOT_SUPPORTED); parameter.addModelProperty(new InfrastructureParameterModelProperty(10)); parameter.addModelProperty(new QNameModelProperty(new QName(CORE_NAMESPACE, SCHEDULING_STRATEGY_ELEMENT_IDENTIFIER, CORE_PREFIX))); parameter.setDslConfiguration(ParameterDslConfiguration.builder() .allowsInlineDefinition(true) .allowsReferences(false) .allowTopLevelDefinition(false) .build()); thereArePollingSources.set(true); source.getParameterGroup(DEFAULT_GROUP_NAME).addParameter(parameter); } }); } }.walk(extensionDeclarer.getDeclaration());
private OperationDeclaration buildUnauthorizeOperation() { OperationDeclaration operation = new OperationDeclaration(UNAUTHORIZE_OPERATION_NAME); operation.setDescription("Deletes all the access token information of a given resource owner id so that it's impossible to " + "execute any operation for that user without doing the authorization dance again"); operation.setBlocking(true); operation.setExecutionType(BLOCKING); operation.setOutput(toDeclaration(voidType)); operation.setOutputAttributes(toDeclaration(voidType)); operation.setRequiresConnection(false); operation.setSupportsStreaming(false); operation.setTransactional(false); operation.addModelProperty(new ComponentExecutorModelProperty((model, params) -> new UnauthorizeOperationExecutor())); ParameterGroupDeclaration group = operation.getParameterGroup(DEFAULT_GROUP_NAME); group.showInDsl(false); ParameterDeclaration parameter = new ParameterDeclaration(RESOURCE_OWNER_ID_PARAMETER_NAME); parameter.setDescription("The id of the resource owner which access should be invalidated"); parameter.setExpressionSupport(SUPPORTED); parameter.setLayoutModel(LayoutModel.builder().build()); parameter.setRequired(false); parameter.setParameterRole(BEHAVIOUR); parameter.setType(stringType, false); group.addParameter(parameter); return operation; }