Example usage for javax.xml.ws Holder Holder

List of usage examples for javax.xml.ws Holder Holder

Introduction

In this page you can find the example usage for javax.xml.ws Holder Holder.

Prototype

public Holder() 

Source Link

Document

Creates a new holder with a null value.

Usage

From source file:com.evolveum.midpoint.testing.model.client.sample.AbstractTestForExchangeConnector.java

protected Collection<UserType> listUsers() throws SAXException, IOException, FaultMessage {
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();

    // let's say we want to get first 3 users, sorted alphabetically by user name
    QueryType queryType = new QueryType(); // holds search query + paging options
    PagingType pagingType = new PagingType();
    pagingType.setMaxSize(3);// ww  w  .ja  va 2  s.c  om
    pagingType.setOrderBy(ModelClientUtil.createItemPathType("name"));
    pagingType.setOrderDirection(OrderDirectionType.ASCENDING);
    queryType.setPaging(pagingType);

    modelPort.searchObjects(ModelClientUtil.getTypeQName(UserType.class), queryType, options, objectListHolder,
            resultHolder);

    ObjectListType objectList = objectListHolder.value;
    return (Collection) objectList.getObject();
}

From source file:com.evolveum.midpoint.testing.model.client.sample.AbstractTestForExchangeConnector.java

protected Collection<TaskType> listTasks() throws SAXException, IOException, FaultMessage {
    SelectorQualifiedGetOptionsType operationOptions = new SelectorQualifiedGetOptionsType();

    // Let's say we want to retrieve tasks' next scheduled time (because this may be a costly operation if
    // JDBC based quartz scheduler is used, the fetching of this attribute has to be explicitly requested)
    SelectorQualifiedGetOptionType getNextScheduledTimeOption = new SelectorQualifiedGetOptionType();

    // prepare a selector (described by path) + options (saying to retrieve that attribute)
    ObjectSelectorType selector = new ObjectSelectorType();
    selector.setPath(ModelClientUtil.createItemPathType("nextRunStartTimestamp"));
    getNextScheduledTimeOption.setSelector(selector);
    GetOperationOptionsType selectorOptions = new GetOperationOptionsType();
    selectorOptions.setRetrieve(RetrieveOptionType.INCLUDE);
    getNextScheduledTimeOption.setOptions(selectorOptions);

    // add newly created option to the list of operation options
    operationOptions.getOption().add(getNextScheduledTimeOption);

    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();

    modelPort.searchObjects(ModelClientUtil.getTypeQName(TaskType.class), null, operationOptions,
            objectListHolder, resultHolder);

    ObjectListType objectList = objectListHolder.value;
    return (Collection) objectList.getObject();
}

From source file:com.evolveum.midpoint.testing.sanity.TestSanity.java

License:asdf

@Test
public void test004Capabilities()
        throws ObjectNotFoundException, CommunicationException, SchemaException, FaultMessage {
    TestUtil.displayTestTile("test004Capabilities");

    // GIVEN// w  ww.ja va 2s  .  c om

    checkRepoOpenDjResource();

    assertNoRepoCache();

    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    Holder<ObjectType> objectHolder = new Holder<ObjectType>();
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();

    // WHEN
    modelWeb.getObject(ObjectTypes.RESOURCE.getTypeQName(), RESOURCE_OPENDJ_OID, options, objectHolder,
            resultHolder);

    ResourceType resource = (ResourceType) objectHolder.value;

    // THEN
    display("Resource", resource);

    assertNoRepoCache();

    CapabilityCollectionType nativeCapabilities = resource.getCapabilities().getNative();
    List<Object> capabilities = nativeCapabilities.getAny();
    assertFalse("Empty capabilities returned", capabilities.isEmpty());

    for (Object capability : nativeCapabilities.getAny()) {
        System.out.println("Native Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : "
                + capability);
    }

    if (resource.getCapabilities() != null) {
        for (Object capability : resource.getCapabilities().getConfigured().getAny()) {
            System.out.println("Configured Capability: " + CapabilityUtil.getCapabilityDisplayName(capability)
                    + " : " + capability);
        }
    }

    List<Object> effectiveCapabilities = ResourceTypeUtil.getEffectiveCapabilities(resource);
    for (Object capability : effectiveCapabilities) {
        System.out.println("Efective Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : "
                + capability);
    }

    CredentialsCapabilityType capCred = CapabilityUtil.getCapability(capabilities,
            CredentialsCapabilityType.class);
    assertNotNull("password capability not present", capCred.getPassword());
    // Connector cannot do activation, this should be null
    ActivationCapabilityType capAct = CapabilityUtil.getCapability(capabilities,
            ActivationCapabilityType.class);
    assertNull("Found activation capability while not expecting it", capAct);

    capCred = ResourceTypeUtil.getEffectiveCapability(resource, CredentialsCapabilityType.class);
    assertNotNull("password capability not found", capCred.getPassword());
    // Although connector does not support activation, the resource specifies a way how to simulate it.
    // Therefore the following should succeed
    capAct = ResourceTypeUtil.getEffectiveCapability(resource, ActivationCapabilityType.class);
    assertNotNull("activation capability not found", capAct);

}

From source file:com.evolveum.midpoint.testing.model.client.sample.AbstractTestForExchangeConnector.java

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);/*from   ww  w  .ja  v  a2s .com*/
    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");
}

From source file:com.evolveum.midpoint.testing.model.client.sample.TestExchangeConnector.java

private SystemConfigurationType getConfiguration() throws FaultMessage {

    Holder<ObjectType> objectHolder = new Holder<ObjectType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();

    modelPort.getObject(ModelClientUtil.getTypeQName(SystemConfigurationType.class),
            SystemObjectsType.SYSTEM_CONFIGURATION.value(), options, objectHolder, resultHolder);

    return (SystemConfigurationType) objectHolder.value;
}

From source file:com.evolveum.midpoint.testing.sanity.TestSanity.java

License:asdf

@Test
public void test005resolveConnectorRef() throws Exception {

    TestUtil.displayTestTile("test005resolveConnectorRef");

    PrismObject<ResourceType> resource = PrismTestUtil.parseObject(new File(RESOURCE_DUMMY_FILENAME));

    ModelExecuteOptionsType options = new ModelExecuteOptionsType();
    options.setIsImport(Boolean.TRUE);
    addObjectViaModelWS(resource.asObjectable(), options, new Holder<String>(),
            new Holder<OperationResultType>());

    OperationResult repoResult = new OperationResult("getObject");

    PrismObject<ResourceType> uObject = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID,
            null, repoResult);//from www .j a  va2s.  c o  m
    assertNotNull(uObject);

    ResourceType resourceType = uObject.asObjectable();
    assertNotNull("Reference on the connector must not be null in resource.", resourceType.getConnectorRef());
    assertNotNull("Missing oid reference on the connector", resourceType.getConnectorRef().getOid());

}

From source file:com.evolveum.midpoint.testing.model.client.sample.TestExchangeConnector.java

private Collection<ResourceType> listResources() 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);//from  ww  w .  j  a  v a  2s.  co m

    ObjectListType objectList = objectListHolder.value;
    return (Collection) objectList.getObject();
}

From source file:com.evolveum.midpoint.testing.model.client.sample.TestExchangeConnector.java

private ResourceType getResource(String oid) throws SAXException, IOException, FaultMessage {
    Holder<ObjectType> objectHolder = new Holder<>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();

    modelPort.getObject(ModelClientUtil.getTypeQName(ResourceType.class), oid, options, objectHolder,
            resultHolder);/*from  ww  w .j a  v a2s  .  c om*/

    return (ResourceType) objectHolder.value;
}

From source file:com.evolveum.midpoint.testing.sanity.TestSanity.java

License:asdf

@Test
public void test006reimportResourceDummy() throws Exception {

    TestUtil.displayTestTile("test006reimportResourceDummy");

    //get object from repo (with version set and try to add it - it should be re-added, without error)
    OperationResult repoResult = new OperationResult("getObject");

    PrismObject<ResourceType> resource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID,
            null, repoResult);/*w ww  . j a v  a  2s .  c o  m*/
    assertNotNull(resource);

    ModelExecuteOptionsType options = new ModelExecuteOptionsType();
    options.setOverwrite(Boolean.TRUE);
    options.setIsImport(Boolean.TRUE);
    addObjectViaModelWS(resource.asObjectable(), options, new Holder<String>(),
            new Holder<OperationResultType>());

    //TODO: add some asserts

    //parse object from file again and try to add it - this should fail, becasue the same object already exists)
    resource = PrismTestUtil.parseObject(new File(RESOURCE_DUMMY_FILENAME));

    try {
        Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
        options = new ModelExecuteOptionsType();
        options.setIsImport(Boolean.TRUE);
        addObjectViaModelWS(resource.asObjectable(), options, new Holder<String>(), resultHolder);

        OperationResultType result = resultHolder.value;
        TestUtil.assertFailure(result);

        fail("Expected object already exists exception, but haven't got one.");
    } catch (FaultMessage ex) {
        LOGGER.info("fault {}", ex.getFaultInfo());
        LOGGER.info("fault {}", ex.getCause());
        if (ex.getFaultInfo() instanceof ObjectAlreadyExistsFaultType) {
            // this is OK, we expect this
        } else {
            fail("Expected object already exists exception, but haven't got one.");
        }

    }

    //         ResourceType resourceType = uObject.asObjectable();
    //         assertNotNull("Reference on the connector must not be null in resource.",resourceType.getConnectorRef());
    //         assertNotNull("Missing oid reference on the connector",resourceType.getConnectorRef().getOid());

}

From source file:com.evolveum.midpoint.testing.model.client.sample.TestExchangeConnector.java

private Collection<UserType> listUsers() throws SAXException, IOException, FaultMessage {
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();

    // let's say we want to get first 3 users, sorted alphabetically by user name
    QueryType queryType = new QueryType(); // holds search query + paging options
    PagingType pagingType = new PagingType();
    pagingType.setMaxSize(3);//www. j a  v a 2 s  .  co m
    pagingType.setOrderBy(ModelClientUtil.createItemPathType("name"));
    pagingType.setOrderDirection(OrderDirectionType.ASCENDING);
    queryType.setPaging(pagingType);

    modelPort.searchObjects(ModelClientUtil.getTypeQName(UserType.class), queryType, options, objectListHolder,
            resultHolder);

    ObjectListType objectList = objectListHolder.value;
    return (Collection) objectList.getObject();
}