Schema operation
The Schema Operation interface enables the connector to describe the types of objects that it can handle on the target system, and the operations and options that the connector supports for each object type.
The operation has one method, schema()
, which returns the types of objects on the target system that the connector supports. The method should return the object class name, its description, and a set of attribute definitions.
The implementation of this operation includes a mapping between the native object class and the corresponding connector object. The special Uid
attribute should not be returned, because it is not a true attribute of the object, but a reference to it. For more information about special attributes in ICF, refer to ICF Special Attributes.
If your resource object class has a writable unique ID attribute that is different to its Name
, your schema should contain a resource-specific attribute that represents this unique ID. For example, a Unix account object might contain a unix_uid
.
Use the ICF schema operation
@Test
public void schemaTest() {
logger.info("Running Schema Test");
final ConnectorFacade facade = createConnectorFacade(BasicConnector.class, null);
Schema schema = facade.schema();
Assert.assertNotNull(schema.findObjectClassInfo(ObjectClass.ACCOUNT_NAME));
}
Implement the schema operation
public Schema schema() {
if (null == schema) {
final SchemaBuilder builder = new SchemaBuilder(BasicConnector.class);
// Account
ObjectClassInfoBuilder accountInfoBuilder = new ObjectClassInfoBuilder();
accountInfoBuilder.addAttributeInfo(Name.INFO);
accountInfoBuilder.addAttributeInfo(OperationalAttributeInfos.PASSWORD);
accountInfoBuilder.addAttributeInfo(PredefinedAttributeInfos.GROUPS);
accountInfoBuilder.addAttributeInfo(AttributeInfoBuilder.build("firstName"));
accountInfoBuilder.addAttributeInfo(AttributeInfoBuilder.define("lastName")
.setRequired(true).build());
builder.defineObjectClass(accountInfoBuilder.build());
// Group
ObjectClassInfoBuilder groupInfoBuilder = new ObjectClassInfoBuilder();
groupInfoBuilder.setType(ObjectClass.GROUP_NAME);
groupInfoBuilder.addAttributeInfo(Name.INFO);
groupInfoBuilder.addAttributeInfo(PredefinedAttributeInfos.DESCRIPTION);
groupInfoBuilder.addAttributeInfo(AttributeInfoBuilder.define("members").setCreatable(
false).setUpdateable(false).setMultiValued(true).build());
// Only the CRUD operations
builder.defineObjectClass(groupInfoBuilder.build(), CreateOp.class, SearchOp.class,
UpdateOp.class, DeleteOp.class);
// Operation Options
builder.defineOperationOption(OperationOptionInfoBuilder.buildAttributesToGet(),
SearchOp.class);
// Support paged Search
builder.defineOperationOption(OperationOptionInfoBuilder.buildPageSize(),
SearchOp.class);
builder.defineOperationOption(OperationOptionInfoBuilder.buildPagedResultsCookie(),
SearchOp.class);
// Support to execute operation with provided credentials
builder.defineOperationOption(OperationOptionInfoBuilder.buildRunWithUser());
builder.defineOperationOption(OperationOptionInfoBuilder.buildRunWithPassword());
schema = builder.build();
}
return schema;
}