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.liferay.usercreatehook.ws.ModelPortWrapper.java

private static RoleType searchRoleByName(ModelPortType modelPort, String roleName)
        throws SAXException, IOException, FaultMessage, JAXBException {
    // WARNING: in a real case make sure that the username 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);/*from www .ja v  a  2 s .  co m*/
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();

    modelPort.searchObjects(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");
}

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

private static UserType searchUserByName(ModelPortType modelPort, String username)
        throws SAXException, IOException, FaultMessage, JAXBException {

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

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

    ObjectListType objectList = objectListHolder.value;
    List<ObjectType> objects = objectList.getObject();
    if (objects.isEmpty()) {
        return null;
    }/*from   w ww .  java 2  s.  c om*/
    if (objects.size() == 1) {
        return (UserType) objects.get(0);
    }
    throw new IllegalStateException("Expected to find a single user with username '" + username + "' but found "
            + objects.size() + " users instead");
}

From source file:com.evolveum.liferay.usercreatehook.ws.ModelPortWrapper.java

@SuppressWarnings({ "unchecked", "rawtypes" })
private static Collection<RoleType> listRequestableRoles(ModelPortType modelPort)
        throws SAXException, IOException, FaultMessage, JAXBException {
    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:requestable</path>" + "<value>true</value>" + "</equal>");
    QueryType query = new QueryType();
    query.setFilter(filter);/*from  ww  w  . j a v a  2 s .  c  om*/
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();

    modelPort.searchObjects(getTypeQName(RoleType.class), query, options, objectListHolder, resultHolder);

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

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

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);//from w  ww.  j a  v a  2 s .c om
    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");
}

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

private static Collection<RoleType> listRequestableRoles(ModelPortType modelPort)
        throws SAXException, IOException, FaultMessage, JAXBException {
    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:requestable</path>" + "<value>true</value>" + "</equal>");
    QueryType query = new QueryType();
    query.setFilter(filter);//from  www. j a va 2s. c o  m
    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;
    return (Collection) objectList.getObject();
}

From source file:com.evolveum.midpoint.testing.consistency.ConsistencyTest.java

/**
 * Add account to user. This should result in account provisioning. Check if
 * that happens in repo and in LDAP.//from  ww  w .j  a  va2 s.  c  o m
 */
@Test
public void test110PrepareOpenDjWithAccounts() throws Exception {
    final String TEST_NAME = "test110PrepareOpenDjWithAccounts";
    TestUtil.displayTestTile(TEST_NAME);
    OperationResult parentResult = new OperationResult(TEST_NAME);

    ShadowType jackeAccount = unmarshallValueFromFile(REQUEST_ADD_ACCOUNT_JACKIE, ShadowType.class);

    Task task = taskManager.createTaskInstance();
    String oid = provisioningService.addObject(jackeAccount.asPrismObject(), null, null, task, parentResult);
    PrismObject<ShadowType> jackFromRepo = repositoryService.getObject(ShadowType.class, oid, null,
            parentResult);
    LOGGER.debug("account jack after provisioning: {}", jackFromRepo.debugDump());

    PrismObject<UserType> jackUser = repositoryService.getObject(UserType.class, USER_JACK_OID, null,
            parentResult);
    ObjectReferenceType ort = new ObjectReferenceType();
    ort.setOid(oid);
    ort.setType(ShadowType.COMPLEX_TYPE);

    jackUser.asObjectable().getLinkRef().add(ort);

    PrismObject<UserType> jackUserRepo = repositoryService.getObject(UserType.class, USER_JACK_OID, null,
            parentResult);
    ObjectDelta delta = DiffUtil.diff(jackUserRepo, jackUser);

    repositoryService.modifyObject(UserType.class, USER_JACK_OID, delta.getModifications(), parentResult);

    // GIVEN

    OperationResult repoResult = new OperationResult("getObject");

    // Check if user object was modified in the repo
    accountShadowOidOpendj = assertUserOneAccountRef(USER_JACK_OID);
    assertFalse(accountShadowOidOpendj.isEmpty());

    // Check if shadow was created in the repo

    repoResult = new OperationResult("getObject");

    PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountShadowOidOpendj,
            null, repoResult);
    ShadowType repoShadowType = repoShadow.asObjectable();
    repoResult.computeStatus();
    TestUtil.assertSuccess("getObject has failed", repoResult);
    display("Shadow (repository)", repoShadow);
    assertNotNull(repoShadowType);
    assertEquals(RESOURCE_OPENDJ_OID, repoShadowType.getResourceRef().getOid());

    assertNotNull("Shadow stored in repository has no name", repoShadowType.getName());
    // Check the "name" property, it should be set to DN, not entryUUID
    assertEquals("Wrong name property", USER_JACK_LDAP_DN.toLowerCase(),
            repoShadowType.getName().getOrig().toLowerCase());

    // check attributes in the shadow: should be only identifiers (ICF UID)
    String uid = checkRepoShadow(repoShadow);

    // check if account was created in LDAP

    Entry entry = openDJController.searchAndAssertByEntryUuid(uid);

    display("LDAP account", entry);

    OpenDJController.assertAttribute(entry, "uid", "jackie");
    OpenDJController.assertAttribute(entry, "givenName", "Jack");
    OpenDJController.assertAttribute(entry, "sn", "Sparrow");
    OpenDJController.assertAttribute(entry, "cn", "Jack Sparrow");

    assertNoRepoCache();

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

    // WHEN
    PropertyReferenceListType resolve = new PropertyReferenceListType();
    //      List<ObjectOperationOptions> options = new ArrayList<ObjectOperationOptions>();
    modelWeb.getObject(ObjectTypes.SHADOW.getTypeQName(), accountShadowOidOpendj, null, objectHolder,
            resultHolder);

    // THEN
    assertNoRepoCache();
    displayJaxb("getObject result", resultHolder.value, SchemaConstants.C_RESULT);
    TestUtil.assertSuccess("getObject has failed", resultHolder.value);

    ShadowType modelShadow = (ShadowType) objectHolder.value;
    display("Shadow (model)", modelShadow);

    AssertJUnit.assertNotNull(modelShadow);
    AssertJUnit.assertEquals(RESOURCE_OPENDJ_OID, modelShadow.getResourceRef().getOid());

    assertAttributeNotNull(modelShadow, getOpenDjPrimaryIdentifierQName());
    assertAttributes(modelShadow, "jackie", "Jack", "Sparrow", "Jack Sparrow");
    // "middle of nowhere");
    assertNull("carLicense attribute sneaked to LDAP", OpenDJController.getAttributeValue(entry, "carLicense"));

    assertNotNull("Activation is null", modelShadow.getActivation());
    assertNotNull("No 'enabled' in the shadow", modelShadow.getActivation().getAdministrativeStatus());
    assertEquals("The account is not enabled in the shadow", ActivationStatusType.ENABLED,
            modelShadow.getActivation().getAdministrativeStatus());

    TestUtil.displayTestTile("test013prepareOpenDjWithAccounts - add second account");

    OperationResult secondResult = new OperationResult("test013prepareOpenDjWithAccounts - add second account");

    ShadowType shadow = unmarshallValueFromFile(ACCOUNT_DENIELS_FILENAME, ShadowType.class);

    provisioningService.addObject(shadow.asPrismObject(), null, null, task, secondResult);

    repoAddObjectFromFile(USER_DENIELS_FILENAME, UserType.class, secondResult);

}

From source file:com.evolveum.midpoint.testing.wstest.AbstractWebserviceTest.java

private <O extends ObjectType> void cleanObjects(Class<O> type, boolean raw, String... protectedOids)
        throws FaultMessage {
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();

    SelectorQualifiedGetOptionsType rootOpts = null;
    ModelExecuteOptionsType execOpts = null;
    if (raw) {/*from   ww w .java2 s  .  c  om*/
        rootOpts = ModelClientUtil.createRootGetOptions(ModelClientUtil.createRawGetOption());
        execOpts = ModelClientUtil.createRawExecuteOption();
    }

    modelPort.searchObjects(getTypeQName(type), null, rootOpts, objectListHolder, resultHolder);

    List<String> protectedOidList = Arrays.asList(protectedOids);
    ObjectListType objectList = objectListHolder.value;
    for (ObjectType object : objectList.getObject()) {
        if (!protectedOidList.contains(object.getOid())) {
            display("Deleting " + type.getSimpleName() + " " + ModelClientUtil.toString(object));
            deleteObject(type, object.getOid(), execOpts);
        }
    }
}

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

protected 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.model.client.sample.AbstractTestForExchangeConnector.java

protected 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 w w w  .  j av a2s. c  om

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

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

protected <T extends ObjectType> T getObject(Class<T> clazz, String oid,
        SelectorQualifiedGetOptionsType options) throws SAXException, IOException, FaultMessage {
    Holder<ObjectType> objectHolder = new Holder<>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();

    modelPort.getObject(ModelClientUtil.getTypeQName(clazz), oid, options, objectHolder, resultHolder);

    return (T) objectHolder.value;
}