// TODO better message
@Override
    public PipelineData execute(ActionExpressionType expression, PipelineData input, ExecutionContext context, OperationResult globalResult) throws ScriptExecutionException {
        boolean rebind = expressionHelper.getArgumentAsBoolean(expression.getParameter(), PARAM_REBIND_RESOURCES, input, context, false, PARAM_REBIND_RESOURCES, globalResult);
        PipelineData output = PipelineData.createEmpty();
        for (PipelineItem item: input.getData()) {
            PrismValue value = item.getValue();
            OperationResult result = operationsHelper.createActionResult(item, this, context, globalResult);
            context.checkTaskStop();
            if (value instanceof PrismObjectValue && ((PrismObjectValue) value).asObjectable() instanceof ConnectorHostType) {
                PrismObject<ConnectorHostType> connectorHostTypePrismObject = ((PrismObjectValue) value).asPrismObject();
                Set<ConnectorType> newConnectors;
                long started = operationsHelper.recordStart(context, connectorHostTypePrismObject.asObjectable());
                Throwable exception = null;
                try {
					newConnectors = modelService.discoverConnectors(connectorHostTypePrismObject.asObjectable(), context.getTask(), result);
                    operationsHelper.recordEnd(context, connectorHostTypePrismObject.asObjectable(), started, null);
                } catch (CommunicationException | SecurityViolationException | SchemaException | ConfigurationException | ObjectNotFoundException | RuntimeException e) {
                    operationsHelper.recordEnd(context, connectorHostTypePrismObject.asObjectable(), started, e);
					exception = processActionException(e, NAME, value, context);
					newConnectors = Collections.emptySet();
				}
                context.println((exception != null ? "Attempted to discover " : "Discovered " + newConnectors.size())
						+ " new connector(s) from " + connectorHostTypePrismObject + exceptionSuffix(exception));
                for (ConnectorType connectorType : newConnectors) {
                    output.addValue(connectorType.asPrismObject().getValue(), item.getResult());
                }
                try {
					if (rebind) {
						rebindConnectors(newConnectors, context, result);
					}
				} catch (ScriptExecutionException e) {
					//noinspection ThrowableNotThrown
					processActionException(e, NAME, value, context);		// TODO better message
				}
            } else {
				//noinspection ThrowableNotThrown
				processActionException(new ScriptExecutionException("Input item is not a PrismObject<ConnectorHost>"), NAME, value, context);
            }
            operationsHelper.trimAndCloneResult(result, globalResult, context);
        }
        return output;      // TODO configurable output (either connector hosts or discovered connectors)
    }
} catch (ScriptExecutionException e) {
//noinspection ThrowableNotThrown
processActionException(e, NAME, value, context); // TODO better message
}
} else {
+ " new connector(s) from " + connectorHostTypePrismObject + exceptionSuffix(exception));
for (ConnectorType connectorType : newConnectors) {
output.addValue(connectorType.asPrismObject().getValue(), item.getResult());
}
try {
if (rebind) {
rebindConnectors(newConnectors, context, result);
}
} catch (ScriptExecutionException e) {
//noinspection ThrowableNotThrown
processActionException(e, NAME, value, context); // TODO better message
}
} else {
//noinspection ThrowableNotThrown
processActionException(new ScriptExecutionException("Input item is not a PrismObject<ConnectorHost>"), NAME, value, context);
}
operationsHelper.trimAndCloneResult(result, globalResult, context);
}
return output; // TODO configurable output (either connector hosts or discovered connectors)
}
Throwable exception = null;
try {
newConnectors = modelService.discoverConnectors(connectorHostTypePrismObject.asObjectable(), context.getTask(), result);
operationsHelper.recordEnd(context, connectorHostTypePrismObject.asObjectable(), started, null);
} catch (CommunicationException | SecurityViolationException | SchemaException | ConfigurationException | ObjectNotFoundException | RuntimeException e) {
operationsHelper.recordEnd(context, connectorHostTypePrismObject.asObjectable(), started, e);
exception = processActionException(e, NAME, value, context);
newConnectors = Collections.emptySet();
}
context.println((exception != null ? "Attempted to discover " : "Discovered " + newConnectors.size())
+ " new connector(s) from " + connectorHostTypePrismObject + exceptionSuffix(exception));
for (ConnectorType connectorType : newConnectors) {
output.addValue(connectorType.asPrismObject().getValue(), item.getResult());
}
try {
if (rebind) {
rebindConnectors(newConnectors, context, result);
}
} catch (ScriptExecutionException e) {
//noinspection ThrowableNotThrown
processActionException(e, NAME, value, context); // TODO better message
}
} else {
//noinspection ThrowableNotThrown
processActionException(new ScriptExecutionException("Input item is not a PrismObject<ConnectorHost>"), NAME, value, context);
}
operationsHelper.trimAndCloneResult(result, globalResult, context);
}
return output; // TODO configurable output (either connector hosts or discovered connectors)
}