Search in sources :

Example 21 with SelectorQualifiedGetOptionsType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.SelectorQualifiedGetOptionsType in project midpoint by Evolveum.

the class Main method listResources.

private static Collection<ResourceType> listResources(ModelPortType modelPort) throws SAXException, IOException, FaultMessage {
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    modelPort.searchObjects(ModelClientUtil.getTypeQName(ResourceType.class), null, options, objectListHolder, resultHolder);
    ObjectListType objectList = objectListHolder.value;
    return (Collection) objectList.getObject();
}
Also used : OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) Collection(java.util.Collection) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 22 with SelectorQualifiedGetOptionsType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.SelectorQualifiedGetOptionsType in project midpoint by Evolveum.

the class Main method searchRoleByName.

private static RoleType searchRoleByName(ModelPortType modelPort, String roleName) throws SAXException, IOException, FaultMessage, JAXBException {
    // WARNING: in a real case make sure that the role name is properly escaped before putting it in XML
    SearchFilterType filter = ModelClientUtil.parseSearchFilterType("<equal xmlns='http://prism.evolveum.com/xml/ns/public/query-3' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3' >" + "<path>c:name</path>" + "<value>" + roleName + "</value>" + "</equal>");
    QueryType query = new QueryType();
    query.setFilter(filter);
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    modelPort.searchObjects(ModelClientUtil.getTypeQName(RoleType.class), query, options, objectListHolder, resultHolder);
    ObjectListType objectList = objectListHolder.value;
    List<ObjectType> objects = objectList.getObject();
    if (objects.isEmpty()) {
        return null;
    }
    if (objects.size() == 1) {
        return (RoleType) objects.get(0);
    }
    throw new IllegalStateException("Expected to find a single role with name '" + roleName + "' but found " + objects.size() + " users instead");
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) Holder(javax.xml.ws.Holder) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 23 with SelectorQualifiedGetOptionsType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.SelectorQualifiedGetOptionsType in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method getShadowByName.

protected ShadowType getShadowByName(String resourceOid, QName objectClass, String name) throws JAXBException, SAXException, IOException, FaultMessage {
    // WARNING: in a real case make sure that the username is properly escaped before putting it in XML
    SearchFilterType filter = ModelClientUtil.parseSearchFilterType("                        <q:and xmlns:q='http://prism.evolveum.com/xml/ns/public/query-3' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3'>\n" + "                            <q:ref>\n" + "                                <q:path>resourceRef</q:path>\n" + "                                <q:value>\n" + "                                    <oid>" + resourceOid + "</oid>\n" + "                                    <type>ResourceType</type>\n" + "                                </q:value>\n" + "                            </q:ref>\n" + "                            <q:equal>\n" + "                                <q:path>objectClass</q:path>\n" + "                                <q:value xmlns:a=\"" + objectClass.getNamespaceURI() + "\">a:" + objectClass.getLocalPart() + "</q:value>\n" + "                            </q:equal>\n" + "                            <q:equal>\n" + "                                <q:path>attributes/name</q:path>\n" + "                                <q:value>" + name + "</q:value>\n" + "                            </q:equal>\n" + "                        </q:and>\n");
    QueryType query = new QueryType();
    query.setFilter(filter);
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    Holder<ObjectListType> objectListHolder = new Holder<>();
    Holder<OperationResultType> resultHolder = new Holder<>();
    modelPort.searchObjects(ModelClientUtil.getTypeQName(ShadowType.class), query, options, objectListHolder, resultHolder);
    ObjectListType objectList = objectListHolder.value;
    List<ObjectType> objects = objectList.getObject();
    if (objects.isEmpty()) {
        return null;
    }
    if (objects.size() == 1) {
        return (ShadowType) objects.get(0);
    }
    throw new IllegalStateException("Expected to find a single shadow with name '" + name + "' but found " + objects.size() + " ones instead");
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) Holder(javax.xml.ws.Holder) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 24 with SelectorQualifiedGetOptionsType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.SelectorQualifiedGetOptionsType in project midpoint by Evolveum.

the class ResolveExecutor method execute.

@Override
public PipelineData execute(ActionExpressionType action, PipelineData input, ExecutionContext context, OperationResult globalResult) throws ScriptExecutionException, SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, SecurityViolationException, ExpressionEvaluationException {
    Collection<SelectorOptions<GetOperationOptions>> options;
    if (action instanceof ResolveReferenceActionExpressionType) {
        SelectorQualifiedGetOptionsType optionsBean = ((ResolveReferenceActionExpressionType) action).getOptions();
        options = GetOperationOptionsUtil.optionsBeanToOptions(optionsBean);
    } else {
        boolean noFetch = expressionHelper.getArgumentAsBoolean(action.getParameter(), PARAM_NO_FETCH, input, context, false, NAME, globalResult);
        options = schemaService.getOperationOptionsBuilder().noFetch(noFetch).build();
    }
    PipelineData output = PipelineData.createEmpty();
    iterateOverItems(input, context, globalResult, (value, item, result) -> resolveReference(context, options, output, item, value, result), (value, exception) -> context.println("Couldn't resolve reference: " + value + exceptionSuffix(exception)));
    return output;
}
Also used : SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) PipelineData(com.evolveum.midpoint.model.impl.scripting.PipelineData) ResolveReferenceActionExpressionType(com.evolveum.midpoint.xml.ns._public.model.scripting_3.ResolveReferenceActionExpressionType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 25 with SelectorQualifiedGetOptionsType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.SelectorQualifiedGetOptionsType in project midpoint by Evolveum.

the class GetOperationOptionsUtil method optionsToOptionsBean.

@SuppressWarnings("WeakerAccess")
@NotNull
public static SelectorQualifiedGetOptionsType optionsToOptionsBean(@NotNull Collection<SelectorOptions<GetOperationOptions>> options) {
    SelectorQualifiedGetOptionsType optionsType = new SelectorQualifiedGetOptionsType();
    List<SelectorQualifiedGetOptionType> retval = new ArrayList<>();
    for (SelectorOptions<GetOperationOptions> option : options) {
        retval.add(selectorOptionToSelectorQualifiedGetOptionType(option));
    }
    optionsType.getOption().addAll(retval);
    return optionsType;
}
Also used : ArrayList(java.util.ArrayList) SelectorQualifiedGetOptionType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)39 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)34 Holder (javax.xml.ws.Holder)34 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)25 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)19 GenericObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType)15 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)15 Test (org.testng.annotations.Test)14 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)13 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)12 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)11 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)10 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)9 Collection (java.util.Collection)9 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)8 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)8 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)7 SelectorQualifiedGetOptionType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionType)6 SearchFilterType (com.evolveum.prism.xml.ns._public.query_3.SearchFilterType)5 QName (javax.xml.namespace.QName)5