use of com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType in project midpoint by Evolveum.
the class TestDummySchemaless method test107Capabilities.
@Test
public void test107Capabilities() throws Exception {
final String TEST_NAME = "test107Capabilities";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME);
// WHEN
TestUtil.displayWhen(TEST_NAME);
ResourceType resourceType = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_STATIC_SCHEMA_OID, null, null, result).asObjectable();
// THEN
TestUtil.displayThen(TEST_NAME);
assertSuccess(result);
// Check native capabilities
CapabilityCollectionType nativeCapabilities = resourceType.getCapabilities().getNative();
System.out.println("Native capabilities: " + PrismTestUtil.serializeAnyDataWrapped(nativeCapabilities));
System.out.println("resource: " + resourceType.asPrismObject().debugDump());
List<Object> nativeCapabilitiesList = nativeCapabilities.getAny();
assertFalse("Empty capabilities returned", nativeCapabilitiesList.isEmpty());
TestConnectionCapabilityType capTest = CapabilityUtil.getCapability(nativeCapabilitiesList, TestConnectionCapabilityType.class);
assertNotNull("native test capability not present", capTest);
ScriptCapabilityType capScript = CapabilityUtil.getCapability(nativeCapabilitiesList, ScriptCapabilityType.class);
assertNotNull("native script capability not present", capScript);
assertNotNull("No host in native script capability", capScript.getHost());
assertFalse("No host in native script capability", capScript.getHost().isEmpty());
CredentialsCapabilityType capCred = CapabilityUtil.getCapability(nativeCapabilitiesList, CredentialsCapabilityType.class);
assertNull("Unexpected native credentials capability", capCred);
ActivationCapabilityType capAct = CapabilityUtil.getCapability(nativeCapabilitiesList, ActivationCapabilityType.class);
assertNull("Unexpected native activation capability", capAct);
// Check effective capabilites
capCred = ResourceTypeUtil.getEffectiveCapability(resourceType, CredentialsCapabilityType.class);
assertNotNull("password 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(resourceType, ActivationCapabilityType.class);
assertNotNull("activation capability not found", capCred.getPassword());
List<Object> effectiveCapabilities = ResourceTypeUtil.getEffectiveCapabilities(resourceType);
for (Object capability : effectiveCapabilities) {
display("Capability " + CapabilityUtil.getCapabilityDisplayName(capability), capability);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType in project midpoint by Evolveum.
the class CapabilityStep method savePerformed.
private void savePerformed() {
Task task = getPageBase().createSimpleTask(OPERATION_SAVE_CAPABILITIES);
OperationResult result = task.getResult();
ModelService modelService = getPageBase().getModelService();
boolean saved = false;
try {
PrismObject<ResourceType> oldResource;
final PrismObject<ResourceType> resourceObject = resourceModel.getObject();
ResourceType resource = resourceObject.asObjectable();
List<Object> unsupportedCapabilities = new ArrayList<>();
if (resource.getCapabilities().getConfigured() != null) {
for (Object o : resource.getCapabilities().getConfigured().getAny()) {
CapabilityType capabilityType = CapabilityUtil.asCapabilityType(o);
if (!Capability.supports(capabilityType.getClass())) {
unsupportedCapabilities.add(o);
}
}
}
// AnyArrayList that is used to implement getAny() is really strange (e.g. doesn't support iterator.remove();
// and its support for clear() is questionable) -- so let's recreate it altogether
resource.getCapabilities().setConfigured(new CapabilityCollectionType());
resource.getCapabilities().getConfigured().getAny().addAll(unsupportedCapabilities);
ObjectFactory capabilityFactory = new ObjectFactory();
for (CapabilityDto dto : dtoModel.getObject().getCapabilities()) {
JAXBElement<? extends CapabilityType> jaxbCapability = createJAXBCapability(dto.getCapability(), capabilityFactory);
if (jaxbCapability != null) {
resource.getCapabilities().getConfigured().getAny().add(jaxbCapability);
}
}
oldResource = WebModelServiceUtils.loadObject(ResourceType.class, resource.getOid(), getPageBase(), task, result);
if (oldResource != null) {
ObjectDelta<ResourceType> delta = parentPage.computeDiff(oldResource, resourceObject);
if (!delta.isEmpty()) {
parentPage.logDelta(delta);
@SuppressWarnings("unchecked") Collection<ObjectDelta<? extends ObjectType>> deltas = WebComponentUtil.createDeltaCollection(delta);
modelService.executeChanges(deltas, null, getPageBase().createSimpleTask(OPERATION_SAVE_CAPABILITIES), result);
parentPage.resetModels();
saved = true;
}
}
} catch (CommonException | RuntimeException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save capabilities", e);
result.recordFatalError("Couldn't save capabilities", e);
} finally {
result.computeStatusIfUnknown();
setResult(result);
}
if (parentPage.showSaveResultInPage(saved, result)) {
getPageBase().showResult(result);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType in project midpoint by Evolveum.
the class TestSanityLegacy method test004Capabilities.
@Test
public void test004Capabilities() throws ObjectNotFoundException, CommunicationException, SchemaException, FaultMessage {
TestUtil.displayTestTile("test004Capabilities");
// GIVEN
checkRepoOpenDjResource();
assertNoRepoCache();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
Holder<ObjectType> objectHolder = new Holder<ObjectType>();
SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
// WHEN
modelWeb.getObject(ObjectTypes.RESOURCE.getTypeQName(), RESOURCE_OPENDJ_OID, options, objectHolder, resultHolder);
ResourceType resource = (ResourceType) objectHolder.value;
// THEN
display("Resource", resource);
assertNoRepoCache();
CapabilityCollectionType nativeCapabilities = resource.getCapabilities().getNative();
List<Object> capabilities = nativeCapabilities.getAny();
assertFalse("Empty capabilities returned", capabilities.isEmpty());
for (Object capability : nativeCapabilities.getAny()) {
System.out.println("Native Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
}
if (resource.getCapabilities() != null) {
for (Object capability : resource.getCapabilities().getConfigured().getAny()) {
System.out.println("Configured Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
}
}
List<Object> effectiveCapabilities = ResourceTypeUtil.getEffectiveCapabilities(resource);
for (Object capability : effectiveCapabilities) {
System.out.println("Efective Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
}
CredentialsCapabilityType capCred = CapabilityUtil.getCapability(capabilities, CredentialsCapabilityType.class);
assertNotNull("password capability not present", capCred.getPassword());
// Connector cannot do activation, this should be null
ActivationCapabilityType capAct = CapabilityUtil.getCapability(capabilities, ActivationCapabilityType.class);
assertNull("Found activation capability while not expecting it", capAct);
capCred = ResourceTypeUtil.getEffectiveCapability(resource, CredentialsCapabilityType.class);
assertNotNull("password 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);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType in project midpoint by Evolveum.
the class AbstractManualResourceTest method test006Capabilities.
@Test
public void test006Capabilities() throws Exception {
final String TEST_NAME = "test006Capabilities";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName() + "." + TEST_NAME);
// WHEN
ResourceType resource = modelService.getObject(ResourceType.class, getResourceOid(), null, null, 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());
CreateCapabilityType capCreate = CapabilityUtil.getCapability(nativeCapabilitiesList, CreateCapabilityType.class);
assertNotNull("Missing create capability", capCreate);
assertManual(capCreate);
ActivationCapabilityType capAct = CapabilityUtil.getCapability(nativeCapabilitiesList, ActivationCapabilityType.class);
assertNotNull("Missing activation capability", capAct);
ReadCapabilityType capRead = CapabilityUtil.getCapability(nativeCapabilitiesList, ReadCapabilityType.class);
assertNotNull("Missing read capability", capRead);
assertEquals("Wrong caching-only setting in read capability", Boolean.TRUE, capRead.isCachingOnly());
List<Object> effectiveCapabilities = ResourceTypeUtil.getEffectiveCapabilities(resource);
for (Object capability : effectiveCapabilities) {
System.out.println("Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType in project midpoint by Evolveum.
the class AbstractCsvTest method test006Capabilities.
@Test
public void test006Capabilities() throws Exception {
final String TEST_NAME = "test006Capabilities";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestOpenDj.class.getName() + "." + TEST_NAME);
// WHEN
ResourceType resource = provisioningService.getObject(ResourceType.class, getResourceOid(), null, null, 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());
// 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());
assertScriptHost(capScript, ProvisioningScriptHostType.CONNECTOR);
List<Object> effectiveCapabilities = ResourceTypeUtil.getEffectiveCapabilities(resource);
for (Object capability : effectiveCapabilities) {
System.out.println("Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
}
}
Aggregations