Search in sources :

Example 6 with ShadowAttributesType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method dumpAttributes.

protected void dumpAttributes(ShadowType shadowType) {
    ShadowAttributesType attributes = shadowType.getAttributes();
    System.out.println("Attributes for " + shadowType.getObjectClass().getLocalPart() + " " + getOrig(shadowType.getName()) + " {" + attributes.getAny().size() + " entries):");
    for (Object item : attributes.getAny()) {
        if (item instanceof Element) {
            Element e = (Element) item;
            System.out.println(" - " + e.getLocalName() + ": " + e.getTextContent());
        } else if (item instanceof JAXBElement) {
            JAXBElement je = (JAXBElement) item;
            String typeInfo = je.getValue() instanceof String ? "" : (" (" + je.getValue().getClass().getSimpleName() + ")");
            System.out.println(" - " + je.getName().getLocalPart() + ": " + je.getValue() + typeInfo);
        } else {
            System.out.println(" - " + item);
        }
    }
}
Also used : JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) ShadowAttributesType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType) JAXBElement(javax.xml.bind.JAXBElement)

Example 7 with ShadowAttributesType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method getAttributesAsMap.

protected Map<String, Object> getAttributesAsMap(ShadowType shadowType) {
    Map<String, Object> rv = new HashMap<>();
    ShadowAttributesType attributes = shadowType.getAttributes();
    for (Object item : attributes.getAny()) {
        if (item instanceof Element) {
            Element e = (Element) item;
            put(rv, e.getLocalName(), e.getTextContent());
        } else if (item instanceof JAXBElement) {
            JAXBElement je = (JAXBElement) item;
            put(rv, je.getName().getLocalPart(), je.getValue());
        } else {
        // nothing to do here
        }
    }
    return rv;
}
Also used : HashMap(java.util.HashMap) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) ShadowAttributesType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType) JAXBElement(javax.xml.bind.JAXBElement)

Example 8 with ShadowAttributesType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method createGlobalAddressList.

protected String createGlobalAddressList(String name, String valueToExpect) throws FaultMessage {
    Document doc = ModelClientUtil.getDocumnent();
    ShadowType shadow = new ShadowType();
    shadow.setName(ModelClientUtil.createPolyStringType(name, doc));
    shadow.setResourceRef(createObjectReferenceType(ResourceType.class, getResourceOid()));
    shadow.setObjectClass(OC_GLOBAL_ADDRESS_LIST);
    shadow.setKind(ShadowKindType.GENERIC);
    shadow.setIntent("global-address-list");
    ShadowAttributesType attributes = new ShadowAttributesType();
    attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_ICFS, "name"), name, doc));
    attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_RI, "RecipientFilter"), galFilter(valueToExpect), doc));
    shadow.setAttributes(attributes);
    return createShadow(shadow);
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) QName(javax.xml.namespace.QName) ShadowAttributesType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) Document(org.w3c.dom.Document)

Example 9 with ShadowAttributesType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType in project midpoint by Evolveum.

the class TestExchangeConnectorLow method test220ModifyingNonexistingAccount.

@Test
public void test220ModifyingNonexistingAccount() throws Exception {
    // create shadow with non-existing GUID
    System.out.println("Creating shadow with non-existing GUID...");
    Document doc = ModelClientUtil.getDocumnent();
    String name = "Wrong GUID shadow";
    ShadowType shadow = new ShadowType();
    shadow.setName(ModelClientUtil.createPolyStringType(name, doc));
    shadow.setResourceRef(createObjectReferenceType(ResourceType.class, getResourceOid()));
    shadow.setObjectClass(OC_ACCOUNT);
    shadow.setKind(ShadowKindType.ACCOUNT);
    ShadowAttributesType attributes = new ShadowAttributesType();
    attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_ICFS, "name"), name, doc));
    attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_ICFS, "uid"), "CN=wrong-GUID," + getContainer(), doc));
    shadow.setAttributes(attributes);
    String oid = createObject(ShadowType.class, shadow, createRaw());
    System.out.println("Done, reading it back...");
    ShadowType shadowReadAgain = getObjectNoFetch(ShadowType.class, oid);
    dumpAttributes(shadowReadAgain);
    System.out.println("Now launching modifyObject operation...");
    ObjectDeltaOperationType odo = modifyObject(ShadowType.class, oid, "attributes/sn", ModificationTypeType.REPLACE, "xxxxxx", null, false);
    OperationResultType r = odo.getExecutionResult();
    System.out.println("Done: " + r.getStatus() + ":" + r.getMessage());
    OperationResultType found = findOperationResult(r, new OperationResultMatcher() {

        @Override
        public boolean match(OperationResultType r) {
            return r.getDetails() != null && r.getDetails().contains("UnknownUidException");
        }
    });
    AssertJUnit.assertNotNull("UnknownUidException was not detected", found);
    System.out.println("======================================================================================================");
    System.out.println("Details: " + found.getDetails());
}
Also used : ObjectDeltaOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) QName(javax.xml.namespace.QName) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ShadowAttributesType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) Document(org.w3c.dom.Document) Test(org.testng.annotations.Test)

Example 10 with ShadowAttributesType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method createAddressList.

protected String createAddressList(String name, String valueToExpect, AddressListType type) throws FaultMessage {
    Document doc = ModelClientUtil.getDocumnent();
    ShadowType shadow = new ShadowType();
    shadow.setName(ModelClientUtil.createPolyStringType(name, doc));
    shadow.setResourceRef(createObjectReferenceType(ResourceType.class, getResourceOid()));
    shadow.setObjectClass(OC_ADDRESS_LIST);
    shadow.setKind(ShadowKindType.GENERIC);
    shadow.setIntent(type.getIntent());
    ShadowAttributesType attributes = new ShadowAttributesType();
    attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_ICFS, "name"), name, doc));
    attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_RI, "RecipientFilter"), type.createFilter(valueToExpect), doc));
    shadow.setAttributes(attributes);
    return createShadow(shadow);
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) QName(javax.xml.namespace.QName) ShadowAttributesType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) Document(org.w3c.dom.Document)

Aggregations

ShadowAttributesType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType)15 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)13 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)12 QName (javax.xml.namespace.QName)11 Document (org.w3c.dom.Document)9 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 HashMap (java.util.HashMap)3 Test (org.testng.annotations.Test)3 ObjectDeltaOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType)2 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)2 ShadowKindType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)2 Map (java.util.Map)2 JAXBElement (javax.xml.bind.JAXBElement)2 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)2 Element (org.w3c.dom.Element)2 RefinedAttributeDefinition (com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition)1 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)1 Item (com.evolveum.midpoint.prism.Item)1 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)1 PrismProperty (com.evolveum.midpoint.prism.PrismProperty)1