use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.UpdateCapabilityType in project midpoint by Evolveum.
the class ConnectorInstanceConnIdImpl method processOperationCapabilities.
private boolean processOperationCapabilities(OperationResult parentResult) {
capabilities = new ArrayList<>();
// Create capabilities from supported connector operations
InternalMonitor.recordConnectorOperation("getSupportedOperations");
Set<Class<? extends APIOperation>> supportedOperations = connIdConnectorFacade.getSupportedOperations();
LOGGER.trace("Connector supported operations: {}", supportedOperations);
boolean supportsSchema = false;
if (supportedOperations.contains(SchemaApiOp.class)) {
SchemaCapabilityType capSchema = new SchemaCapabilityType();
capabilities.add(CAPABILITY_OBJECT_FACTORY.createSchema(capSchema));
supportsSchema = true;
}
if (supportedOperations.contains(SyncApiOp.class)) {
LiveSyncCapabilityType capSync = new LiveSyncCapabilityType();
capabilities.add(CAPABILITY_OBJECT_FACTORY.createLiveSync(capSync));
}
if (supportedOperations.contains(TestApiOp.class)) {
TestConnectionCapabilityType capTest = new TestConnectionCapabilityType();
capabilities.add(CAPABILITY_OBJECT_FACTORY.createTestConnection(capTest));
}
if (supportedOperations.contains(CreateApiOp.class)) {
CreateCapabilityType capCreate = new CreateCapabilityType();
capabilities.add(CAPABILITY_OBJECT_FACTORY.createCreate(capCreate));
}
if (supportedOperations.contains(GetApiOp.class) || supportedOperations.contains(SearchApiOp.class)) {
ReadCapabilityType capRead = new ReadCapabilityType();
capabilities.add(CAPABILITY_OBJECT_FACTORY.createRead(capRead));
}
if (supportedOperations.contains(UpdateApiOp.class)) {
UpdateCapabilityType capUpdate = new UpdateCapabilityType();
capabilities.add(CAPABILITY_OBJECT_FACTORY.createUpdate(capUpdate));
}
if (supportedOperations.contains(DeleteApiOp.class)) {
DeleteCapabilityType capDelete = new DeleteCapabilityType();
capabilities.add(CAPABILITY_OBJECT_FACTORY.createDelete(capDelete));
}
if (supportedOperations.contains(ScriptOnResourceApiOp.class) || supportedOperations.contains(ScriptOnConnectorApiOp.class)) {
ScriptCapabilityType capScript = new ScriptCapabilityType();
if (supportedOperations.contains(ScriptOnResourceApiOp.class)) {
Host host = new Host();
host.setType(ProvisioningScriptHostType.RESOURCE);
capScript.getHost().add(host);
// language is unknown here
}
if (supportedOperations.contains(ScriptOnConnectorApiOp.class)) {
Host host = new Host();
host.setType(ProvisioningScriptHostType.CONNECTOR);
capScript.getHost().add(host);
// language is unknown here
}
capabilities.add(CAPABILITY_OBJECT_FACTORY.createScript(capScript));
}
return supportsSchema;
}
use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.UpdateCapabilityType in project midpoint by Evolveum.
the class TestOpenDj method test005Capabilities.
@Test
public void test005Capabilities() throws Exception {
final String TEST_NAME = "test005Capabilities";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
// WHEN
ResourceType resource = provisioningService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result).asObjectable();
// THEN
display("Resource from provisioninig", resource);
display("Resource from provisioninig (XML)", PrismTestUtil.serializeObjectToString(resource.asPrismObject(), PrismContext.LANG_XML));
CapabilityCollectionType nativeCapabilities = resource.getCapabilities().getNative();
List<Object> nativeCapabilitiesList = nativeCapabilities.getAny();
assertFalse("Empty capabilities returned", nativeCapabilitiesList.isEmpty());
CredentialsCapabilityType capCred = CapabilityUtil.getCapability(nativeCapabilitiesList, CredentialsCapabilityType.class);
assertNotNull("credentials capability not found", capCred);
PasswordCapabilityType capPassword = capCred.getPassword();
assertNotNull("password capability not present", capPassword);
assertPasswordCapability(capPassword);
// Connector cannot do activation, this should be null
ActivationCapabilityType capAct = CapabilityUtil.getCapability(nativeCapabilitiesList, ActivationCapabilityType.class);
assertNull("Found activation capability while not expecting it", capAct);
ScriptCapabilityType capScript = CapabilityUtil.getCapability(nativeCapabilitiesList, ScriptCapabilityType.class);
assertNotNull("No script capability", capScript);
List<Host> scriptHosts = capScript.getHost();
assertEquals("Wrong number of script hosts", 1, scriptHosts.size());
Host scriptHost = scriptHosts.get(0);
assertEquals("Wrong script host type", ProvisioningScriptHostType.CONNECTOR, scriptHost.getType());
// assertEquals("Wrong script host language", ....., scriptHost.getLanguage());
CreateCapabilityType capCreate = CapabilityUtil.getCapability(nativeCapabilitiesList, CreateCapabilityType.class);
assertNotNull("No create capability", capCreate);
ReadCapabilityType capRead = CapabilityUtil.getCapability(nativeCapabilitiesList, ReadCapabilityType.class);
assertNotNull("No read capability", capRead);
UpdateCapabilityType capUpdate = CapabilityUtil.getCapability(nativeCapabilitiesList, UpdateCapabilityType.class);
assertNotNull("No update capability", capUpdate);
DeleteCapabilityType capDelete = CapabilityUtil.getCapability(nativeCapabilitiesList, DeleteCapabilityType.class);
assertNotNull("No delete capability", capDelete);
List<Object> effectiveCapabilities = ResourceTypeUtil.getEffectiveCapabilities(resource);
for (Object capability : effectiveCapabilities) {
System.out.println("Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
}
capCred = ResourceTypeUtil.getEffectiveCapability(resource, CredentialsCapabilityType.class);
assertNotNull("credentials effective capability not found", capCred);
assertNotNull("password effective capability not found", capCred.getPassword());
// Although connector does not support activation, the resource specifies a way how to simulate it.
// Therefore the following should succeed
capAct = ResourceTypeUtil.getEffectiveCapability(resource, ActivationCapabilityType.class);
assertNotNull("activation capability not found", capAct);
PagedSearchCapabilityType capPage = ResourceTypeUtil.getEffectiveCapability(resource, PagedSearchCapabilityType.class);
assertNotNull("paged search capability not present", capPage);
assertShadows(1);
}
use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.UpdateCapabilityType in project midpoint by Evolveum.
the class AbstractManualConnectorInstance method fetchCapabilities.
@Override
public Collection<Object> fetchCapabilities(OperationResult parentResult) throws CommunicationException, GenericFrameworkException, ConfigurationException {
Collection<Object> capabilities = new ArrayList<>();
// caching-only read capabilities
ReadCapabilityType readCap = new ReadCapabilityType();
readCap.setCachingOnly(true);
capabilities.add(CAPABILITY_OBJECT_FACTORY.createRead(readCap));
CreateCapabilityType createCap = new CreateCapabilityType();
setManual(createCap);
capabilities.add(CAPABILITY_OBJECT_FACTORY.createCreate(createCap));
UpdateCapabilityType updateCap = new UpdateCapabilityType();
setManual(updateCap);
capabilities.add(CAPABILITY_OBJECT_FACTORY.createUpdate(updateCap));
DeleteCapabilityType deleteCap = new DeleteCapabilityType();
setManual(deleteCap);
capabilities.add(CAPABILITY_OBJECT_FACTORY.createDelete(deleteCap));
ActivationCapabilityType activationCap = new ActivationCapabilityType();
ActivationStatusCapabilityType activationStatusCap = new ActivationStatusCapabilityType();
activationCap.setStatus(activationStatusCap);
capabilities.add(CAPABILITY_OBJECT_FACTORY.createActivation(activationCap));
CredentialsCapabilityType credentialsCap = new CredentialsCapabilityType();
PasswordCapabilityType passwordCapabilityType = new PasswordCapabilityType();
credentialsCap.setPassword(passwordCapabilityType);
capabilities.add(CAPABILITY_OBJECT_FACTORY.createCredentials(credentialsCap));
return capabilities;
}
Aggregations