use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CapabilityType in project midpoint by Evolveum.
the class AddCapabilityDialog method initLayout.
private void initLayout(WebMarkupContainer container) {
List<IColumn<CapabilityDto<CapabilityType>, String>> columns = initColumns();
TablePanel<CapabilityDto<CapabilityType>> table = new TablePanel<>(ID_TABLE, createProvider(), columns);
table.setOutputMarkupId(true);
table.setShowPaging(false);
container.add(table);
AjaxButton cancelButton = new AjaxButton(ID_CANCEL, createStringResource("addCapabilityDialog.button.cancel")) {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
cancelPerformed(ajaxRequestTarget);
}
};
container.add(cancelButton);
AjaxButton addButton = new AjaxButton(ID_ADD, createStringResource("addCapabilityDialog.button.Add")) {
@Override
public void onClick(AjaxRequestTarget target) {
addPerformed(target);
}
};
container.add(addButton);
}
use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CapabilityType in project midpoint by Evolveum.
the class ResourceManager method supportsCapability.
private <T extends CapabilityType> boolean supportsCapability(ConnectorInstanceSpecificationType additionalConnectorType, Collection<Object> nativeCapabilities, Class<T> capabilityClass) {
CapabilitiesType specifiedCapabilitiesType = additionalConnectorType.getCapabilities();
if (specifiedCapabilitiesType != null) {
CapabilityCollectionType configuredCapCollectionType = specifiedCapabilitiesType.getConfigured();
if (configuredCapCollectionType != null) {
T configuredCap = CapabilityUtil.getCapability(configuredCapCollectionType.getAny(), capabilityClass);
if (configuredCap != null && !CapabilityUtil.isCapabilityEnabled(configuredCap)) {
return false;
}
}
}
T cap = CapabilityUtil.getCapability(nativeCapabilities, capabilityClass);
if (cap == null) {
return false;
}
return CapabilityUtil.isCapabilityEnabled(cap);
}
use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CapabilityType 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.resource.capabilities_3.CapabilityType in project midpoint by Evolveum.
the class AddCapabilityDialog method loadModel.
private List<CapabilityDto<CapabilityType>> loadModel(IModel<CapabilityStepDto> capabilityModel) {
List<Class<? extends CapabilityType>> existingCapabilityClasses = new ArrayList<>();
for (CapabilityDto cap : capabilityModel.getObject().getCapabilities()) {
existingCapabilityClasses.add(cap.getCapability().getClass());
}
List<CapabilityDto<CapabilityType>> rv = new ArrayList<>();
for (Capability supportedCapability : Capability.values()) {
if (!existingCapabilityClasses.contains(supportedCapability.getClazz())) {
// 'among natives' doesn't matter here
rv.add(new CapabilityDto<>(CapabilityStep.fillDefaults(supportedCapability.newInstance()), false));
}
}
return rv;
}
Aggregations