Search in sources :

Example 11 with SchemaViolationException

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

the class DummyConnector method convertToPriv.

private DummyPrivilege convertToPriv(Set<Attribute> createAttributes) throws ConnectException, FileNotFoundException, ConflictException {
    String icfName = Utils.getMandatoryStringAttribute(createAttributes, Name.NAME);
    if (configuration.getUpCaseName()) {
        icfName = StringUtils.upperCase(icfName);
    }
    final DummyPrivilege newPriv = new DummyPrivilege(icfName);
    for (Attribute attr : createAttributes) {
        if (attr.is(Uid.NAME)) {
            throw new IllegalArgumentException("UID explicitly specified in the group attributes");
        } else if (attr.is(Name.NAME)) {
        // Skip, already processed
        } else if (attr.is(OperationalAttributeInfos.PASSWORD.getName())) {
            throw new IllegalArgumentException("Password specified for a privilege");
        } else if (attr.is(OperationalAttributeInfos.ENABLE.getName())) {
            throw new IllegalArgumentException("Unsupported ENABLE attribute in privilege");
        } else {
            String name = attr.getName();
            try {
                newPriv.replaceAttributeValues(name, attr.getValue());
            } catch (SchemaViolationException e) {
                throw new IllegalArgumentException(e.getMessage(), e);
            }
        }
    }
    return newPriv;
}
Also used : GuardedString(org.identityconnectors.common.security.GuardedString) DummyPrivilege(com.evolveum.icf.dummy.resource.DummyPrivilege) SchemaViolationException(com.evolveum.icf.dummy.resource.SchemaViolationException)

Example 12 with SchemaViolationException

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

the class DummyConnector method schema.

/**
     * {@inheritDoc}
     */
public Schema schema() {
    log.info("schema::begin");
    if (!configuration.getSupportSchema()) {
        log.info("schema::unsupported operation");
        throw new UnsupportedOperationException();
    }
    SchemaBuilder builder = new SchemaBuilder(DummyConnector.class);
    try {
        builder.defineObjectClass(createAccountObjectClass(configuration.getSupportActivation()));
        builder.defineObjectClass(createGroupObjectClass(configuration.getSupportActivation()));
        builder.defineObjectClass(createPrivilegeObjectClass());
        builder.defineObjectClass(createOrgObjectClass());
        for (ObjectClassInfo auxObjectClass : createAuxiliaryObjectClasses()) {
            builder.defineObjectClass(auxObjectClass);
        }
    } catch (SchemaViolationException e) {
        throw new InvalidAttributeValueException(e.getMessage(), e);
    } catch (ConflictException e) {
        throw new AlreadyExistsException(e);
    }
    if (configuration.isSupportReturnDefaultAttributes()) {
        builder.defineOperationOption(OperationOptionInfoBuilder.buildReturnDefaultAttributes(), SearchOp.class, SyncOp.class);
    }
    log.info("schema::end");
    return builder.build();
}
Also used : AlreadyExistsException(org.identityconnectors.framework.common.exceptions.AlreadyExistsException) ObjectAlreadyExistsException(com.evolveum.icf.dummy.resource.ObjectAlreadyExistsException) ConflictException(com.evolveum.icf.dummy.resource.ConflictException) SchemaViolationException(com.evolveum.icf.dummy.resource.SchemaViolationException) InvalidAttributeValueException(org.identityconnectors.framework.common.exceptions.InvalidAttributeValueException)

Aggregations

SchemaViolationException (com.evolveum.icf.dummy.resource.SchemaViolationException)12 GuardedString (org.identityconnectors.common.security.GuardedString)11 ConflictException (com.evolveum.icf.dummy.resource.ConflictException)8 ObjectAlreadyExistsException (com.evolveum.icf.dummy.resource.ObjectAlreadyExistsException)8 AlreadyExistsException (org.identityconnectors.framework.common.exceptions.AlreadyExistsException)8 InvalidAttributeValueException (org.identityconnectors.framework.common.exceptions.InvalidAttributeValueException)8 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)7 DummyGroup (com.evolveum.icf.dummy.resource.DummyGroup)7 DummyOrg (com.evolveum.icf.dummy.resource.DummyOrg)7 DummyPrivilege (com.evolveum.icf.dummy.resource.DummyPrivilege)7 FileNotFoundException (java.io.FileNotFoundException)7 ConnectException (java.net.ConnectException)7 ConnectionFailedException (org.identityconnectors.framework.common.exceptions.ConnectionFailedException)7 ConnectorIOException (org.identityconnectors.framework.common.exceptions.ConnectorIOException)7 ConnectorException (org.identityconnectors.framework.common.exceptions.ConnectorException)6 DummyObject (com.evolveum.icf.dummy.resource.DummyObject)4 UnknownUidException (org.identityconnectors.framework.common.exceptions.UnknownUidException)4 ArrayList (java.util.ArrayList)3 ObjectDoesNotExistException (com.evolveum.icf.dummy.resource.ObjectDoesNotExistException)2 DummyDelta (com.evolveum.icf.dummy.resource.DummyDelta)1