@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)
    }
@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) {
				
					processActionException(e, NAME, value, context);	
				}
            } else {
			
				processActionException(new ScriptExecutionException("Input item is not a PrismObject<ConnectorHost>"), NAME, value, context);
            }
            operationsHelper.trimAndCloneResult(result, globalResult, context);
        }
        return output;     
    }
@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) { processactionexception(e, name, value, context); } } else { processactionexception(new scriptexecutionexception("input item is not a prismobject<connectorhost>"), name, value, context); } operationshelper.trimandcloneresult(result, globalresult, context); } return output; }