Search in sources :

Example 1 with DummyAttributeDefinition

use of com.evolveum.icf.dummy.resource.DummyAttributeDefinition in project midpoint by Evolveum.

the class DummyConnector method createConnectorObjectBuilderCommon.

private ConnectorObjectBuilder createConnectorObjectBuilderCommon(DummyObject dummyObject, DummyObjectClass objectClass, Collection<String> attributesToGet, boolean supportActivation) {
    ConnectorObjectBuilder builder = new ConnectorObjectBuilder();
    if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_NAME)) {
        builder.setUid(dummyObject.getName());
    } else if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_UUID)) {
        builder.setUid(dummyObject.getId());
    } else {
        throw new IllegalStateException("Unknown UID mode " + configuration.getUidMode());
    }
    builder.addAttribute(Name.NAME, dummyObject.getName());
    for (String name : dummyObject.getAttributeNames()) {
        DummyAttributeDefinition attrDef = dummyObject.getAttributeDefinition(name);
        if (attrDef == null) {
            throw new IllegalArgumentException("Unknown account attribute '" + name + "'");
        }
        if (!attrDef.isReturnedByDefault()) {
            if (attributesToGet != null && !attributesToGet.contains(name)) {
                continue;
            }
        }
        // Return all attributes that are returned by default. We will filter them out later.
        Set<Object> values = dummyObject.getAttributeValues(name, Object.class);
        if (configuration.isVaryLetterCase()) {
            name = varyLetterCase(name);
        }
        if (values != null && !values.isEmpty()) {
            builder.addAttribute(name, values);
        }
    }
    if (supportActivation) {
        if (attributesToGet == null || attributesToGet.contains(OperationalAttributes.ENABLE_NAME)) {
            builder.addAttribute(OperationalAttributes.ENABLE_NAME, dummyObject.isEnabled());
        }
        if (dummyObject.getValidFrom() != null && (attributesToGet == null || attributesToGet.contains(OperationalAttributes.ENABLE_DATE_NAME))) {
            builder.addAttribute(OperationalAttributes.ENABLE_DATE_NAME, convertToLong(dummyObject.getValidFrom()));
        }
        if (dummyObject.getValidTo() != null && (attributesToGet == null || attributesToGet.contains(OperationalAttributes.DISABLE_DATE_NAME))) {
            builder.addAttribute(OperationalAttributes.DISABLE_DATE_NAME, convertToLong(dummyObject.getValidTo()));
        }
    }
    if (configuration.isAddConnectorStateAttributes()) {
        builder.addAttribute(DummyResource.ATTRIBUTE_CONNECTOR_TO_STRING, this.toString());
        builder.addAttribute(DummyResource.ATTRIBUTE_CONNECTOR_STATIC_VAL, staticVal);
        builder.addAttribute(DummyResource.ATTRIBUTE_CONNECTOR_CONFIGURATION_TO_STRING, configuration.toString());
    }
    if (!dummyObject.getAuxiliaryObjectClassNames().isEmpty()) {
        builder.addAttribute(PredefinedAttributes.AUXILIARY_OBJECT_CLASS_NAME, dummyObject.getAuxiliaryObjectClassNames());
    }
    return builder;
}
Also used : DummyObject(com.evolveum.icf.dummy.resource.DummyObject) GuardedString(org.identityconnectors.common.security.GuardedString) DummyAttributeDefinition(com.evolveum.icf.dummy.resource.DummyAttributeDefinition)

Example 2 with DummyAttributeDefinition

use of com.evolveum.icf.dummy.resource.DummyAttributeDefinition in project midpoint by Evolveum.

the class DummyResourceContoller method addAttrDef.

public DummyAttributeDefinition addAttrDef(DummyObjectClass objectClass, String attrName, Class<?> type, boolean isRequired, boolean isMulti) {
    isExtendedSchema = true;
    DummyAttributeDefinition attrDef = new DummyAttributeDefinition(attrName, type, isRequired, isMulti);
    objectClass.add(attrDef);
    return attrDef;
}
Also used : DummyAttributeDefinition(com.evolveum.icf.dummy.resource.DummyAttributeDefinition)

Example 3 with DummyAttributeDefinition

use of com.evolveum.icf.dummy.resource.DummyAttributeDefinition in project midpoint by Evolveum.

the class DummyConnector method buildAttributes.

private void buildAttributes(ObjectClassInfoBuilder icfObjClassBuilder, DummyObjectClass dummyObjectClass) {
    for (DummyAttributeDefinition dummyAttrDef : dummyObjectClass.getAttributeDefinitions()) {
        AttributeInfoBuilder attrBuilder = new AttributeInfoBuilder(dummyAttrDef.getAttributeName(), dummyAttrDef.getAttributeType());
        attrBuilder.setMultiValued(dummyAttrDef.isMulti());
        attrBuilder.setRequired(dummyAttrDef.isRequired());
        attrBuilder.setReturnedByDefault(dummyAttrDef.isReturnedByDefault());
        icfObjClassBuilder.addAttributeInfo(attrBuilder.build());
    }
}
Also used : DummyAttributeDefinition(com.evolveum.icf.dummy.resource.DummyAttributeDefinition)

Example 4 with DummyAttributeDefinition

use of com.evolveum.icf.dummy.resource.DummyAttributeDefinition in project midpoint by Evolveum.

the class DummyResourceContoller method extendSchemaPirate.

/**
 * Extend schema in piratey fashion. Arr! This is used in many tests. Lots of attributes, various combination of types, etc.
 */
public void extendSchemaPirate() throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
    populateWithDefaultSchema();
    DummyObjectClass accountObjectClass = dummyResource.getAccountObjectClass();
    addAttrDef(accountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, String.class, false, true);
    addAttrDef(accountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, String.class, false, false);
    addAttrDef(accountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, String.class, false, false);
    DummyAttributeDefinition lootAttrDef = addAttrDef(accountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME, Integer.class, false, false);
    lootAttrDef.setReturnedByDefault(false);
    DummyAttributeDefinition treasureAttrDef = addAttrDef(accountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_TREASURE_NAME, String.class, false, false);
    treasureAttrDef.setReturnedByDefault(false);
    addAttrDef(accountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_WEALTH_NAME, Integer.class, false, false);
    addAttrDef(accountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, String.class, false, true);
    addAttrDef(accountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, String.class, false, true);
    addAttrDef(accountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME, String.class, false, true);
    addAttrDef(accountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, String.class, false, true);
    addAttrDef(accountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_WATER_NAME, String.class, false, false);
    addAttrDef(accountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_ENLIST_TIMESTAMP_NAME, ZonedDateTime.class, false, false);
    DummyObjectClass groupObjectClass = dummyResource.getGroupObjectClass();
    addAttrDef(groupObjectClass, DUMMY_GROUP_ATTRIBUTE_DESCRIPTION, String.class, false, false);
    addAttrDef(groupObjectClass, DUMMY_GROUP_ATTRIBUTE_CC, String.class, false, false);
    DummyObjectClass privilegeObjectClass = dummyResource.getPrivilegeObjectClass();
    addAttrDef(privilegeObjectClass, DUMMY_PRIVILEGE_ATTRIBUTE_POWER, Integer.class, false, false);
}
Also used : DummyObjectClass(com.evolveum.icf.dummy.resource.DummyObjectClass) DummyAttributeDefinition(com.evolveum.icf.dummy.resource.DummyAttributeDefinition)

Aggregations

DummyAttributeDefinition (com.evolveum.icf.dummy.resource.DummyAttributeDefinition)4 DummyObject (com.evolveum.icf.dummy.resource.DummyObject)1 DummyObjectClass (com.evolveum.icf.dummy.resource.DummyObjectClass)1 GuardedString (org.identityconnectors.common.security.GuardedString)1