use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class SchemaStep method createXmlEditorModel.
private IModel<String> createXmlEditorModel() {
return new IModel<String>() {
@Override
public void detach() {
}
@Override
public String getObject() {
PrismObject<ResourceType> resource = model.getObject();
PrismContainer xmlSchema = resource.findContainer(ResourceType.F_SCHEMA);
if (xmlSchema == null) {
return null;
}
PageBase page = (PageBase) SchemaStep.this.getPage();
try {
return page.getPrismContext().xmlSerializer().serialize(xmlSchema.getValue(), SchemaConstantsGenerated.C_SCHEMA);
} catch (SchemaException | RuntimeException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't serialize resource schema", ex);
return WebComponentUtil.exceptionToString("Couldn't serialize resource schema", ex);
}
}
@Override
public void setObject(String object) {
// ignore (it's interesting that this is called sometimes, even when the ACE is set to be read only)
}
};
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class ConfigurationStep method createConfigContainerWrappers.
@NotNull
private List<ContainerWrapper> createConfigContainerWrappers() throws SchemaException {
PrismObject<ResourceType> resource = resourceModelNoFetch.getObject();
PrismContainer<ConnectorConfigurationType> configuration = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
List<ContainerWrapper> containerWrappers = new ArrayList<>();
if (configuration == null) {
PrismObject<ConnectorType> connector = ResourceTypeUtil.getConnectorIfPresent(resource);
if (connector == null) {
throw new IllegalStateException("No resolved connector object in resource object");
}
ConnectorType connectorType = connector.asObjectable();
PrismSchema schema;
try {
schema = ConnectorTypeUtil.parseConnectorSchema(connectorType, parentPage.getPrismContext());
} catch (SchemaException e) {
throw new SystemException("Couldn't parse connector schema: " + e.getMessage(), e);
}
PrismContainerDefinition<ConnectorConfigurationType> definition = ConnectorTypeUtil.findConfigurationContainerDefinition(connectorType, schema);
// Fixing (errorneously) set maxOccurs = unbounded. See MID-2317 and related issues.
PrismContainerDefinition<ConnectorConfigurationType> definitionFixed = definition.clone();
((PrismContainerDefinitionImpl) definitionFixed).setMaxOccurs(1);
configuration = definitionFixed.instantiate();
}
List<PrismContainerDefinition> containerDefinitions = getSortedConfigContainerDefinitions(configuration);
for (PrismContainerDefinition<?> containerDef : containerDefinitions) {
ItemPath containerPath = new ItemPath(ResourceType.F_CONNECTOR_CONFIGURATION, containerDef.getName());
PrismContainer container = configuration.findContainer(containerDef.getName());
ContainerWrapperFactory cwf = new ContainerWrapperFactory(parentPage);
ContainerWrapper containerWrapper;
if (container != null) {
containerWrapper = cwf.createContainerWrapper(container, ContainerStatus.MODIFYING, containerPath, parentPage.isReadOnly());
} else {
container = containerDef.instantiate();
containerWrapper = cwf.createContainerWrapper(container, ContainerStatus.ADDING, containerPath, parentPage.isReadOnly());
}
containerWrappers.add(containerWrapper);
}
return containerWrappers;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class PageTaskAdd method createResourceList.
private List<TaskAddResourcesDto> createResourceList() {
OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCES);
Task task = createSimpleTask(OPERATION_LOAD_RESOURCES);
List<PrismObject<ResourceType>> resources = null;
List<TaskAddResourcesDto> resourceList = new ArrayList<TaskAddResourcesDto>();
try {
resources = getModelService().searchObjects(ResourceType.class, new ObjectQuery(), null, task, result);
result.recomputeStatus();
} catch (Exception ex) {
result.recordFatalError("Couldn't get resource list.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get resource list", ex);
}
// }
if (resources != null) {
ResourceType item = null;
for (PrismObject<ResourceType> resource : resources) {
item = resource.asObjectable();
resourceList.add(new TaskAddResourcesDto(item.getOid(), WebComponentUtil.getOrigStringFromPoly(item.getName())));
}
}
return resourceList;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class ValidateExecutor method execute.
@Override
public PipelineData execute(ActionExpressionType expression, PipelineData input, ExecutionContext context, OperationResult globalResult) throws ScriptExecutionException {
PipelineData output = PipelineData.createEmpty();
for (PipelineItem item : input.getData()) {
PrismValue value = item.getValue();
OperationResult result = operationsHelper.createActionResult(item, this, context, globalResult);
context.checkTaskStop();
if (value instanceof PrismObjectValue && ((PrismObjectValue) value).asObjectable() instanceof ResourceType) {
PrismObject<ResourceType> resourceTypePrismObject = ((PrismObjectValue) value).asPrismObject();
ResourceType resourceType = resourceTypePrismObject.asObjectable();
long started = operationsHelper.recordStart(context, resourceType);
try {
ValidationResult validationResult = resourceValidator.validate(resourceTypePrismObject, Scope.THOROUGH, null, context.getTask(), result);
PrismContainer pc = prismContext.getSchemaRegistry().findContainerDefinitionByElementName(SchemaConstantsGenerated.C_VALIDATION_RESULT).instantiate();
pc.add(validationResult.toValidationResultType().asPrismContainerValue());
context.println("Validated " + resourceTypePrismObject + ": " + validationResult.getIssues().size() + " issue(s)");
operationsHelper.recordEnd(context, resourceType, started, null);
output.add(new PipelineItem(pc.getValue(), item.getResult()));
} catch (SchemaException | RuntimeException e) {
operationsHelper.recordEnd(context, resourceType, started, e);
context.println("Error validation " + resourceTypePrismObject + ": " + e.getMessage());
//noinspection ThrowableNotThrown
processActionException(e, NAME, value, context);
output.add(item);
}
} else {
//noinspection ThrowableNotThrown
processActionException(new ScriptExecutionException("Item is not a PrismObject<ResourceType>"), NAME, value, context);
}
operationsHelper.trimAndCloneResult(result, globalResult, context);
}
return output;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class CorrelationConfirmationEvaluator method findFocusesByCorrelationRule.
public <F extends FocusType> List<PrismObject<F>> findFocusesByCorrelationRule(Class<F> focusType, ShadowType currentShadow, List<ConditionalSearchFilterType> conditionalFilters, ResourceType resourceType, SystemConfigurationType configurationType, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
if (conditionalFilters == null || conditionalFilters.isEmpty()) {
LOGGER.warn("Correlation rule for resource '{}' doesn't contain query, " + "returning empty list of users.", resourceType);
return null;
}
List<PrismObject<F>> users = null;
if (conditionalFilters.size() == 1) {
if (satisfyCondition(currentShadow, conditionalFilters.get(0), resourceType, configurationType, "Condition expression", task, result)) {
LOGGER.trace("Condition {} in correlation expression evaluated to true", conditionalFilters.get(0).getCondition());
users = findUsersByCorrelationRule(focusType, currentShadow, conditionalFilters.get(0), resourceType, configurationType, task, result);
}
} else {
for (ConditionalSearchFilterType conditionalFilter : conditionalFilters) {
//TODO: better description
if (satisfyCondition(currentShadow, conditionalFilter, resourceType, configurationType, "Condition expression", task, result)) {
LOGGER.trace("Condition {} in correlation expression evaluated to true", conditionalFilter.getCondition());
List<PrismObject<F>> foundUsers = findUsersByCorrelationRule(focusType, currentShadow, conditionalFilter, resourceType, configurationType, task, result);
if (foundUsers == null && users == null) {
continue;
}
if (foundUsers != null && foundUsers.isEmpty() && users == null) {
users = new ArrayList<PrismObject<F>>();
}
if (users == null && foundUsers != null) {
users = foundUsers;
}
if (users != null && !users.isEmpty() && foundUsers != null && !foundUsers.isEmpty()) {
for (PrismObject<F> foundUser : foundUsers) {
if (!contains(users, foundUser)) {
users.add(foundUser);
}
}
}
}
}
}
if (users != null) {
LOGGER.debug("SYNCHRONIZATION: CORRELATION: expression for {} returned {} users: {}", new Object[] { currentShadow, users.size(), PrettyPrinter.prettyPrint(users, 3) });
if (users.size() > 1) {
// remove duplicates
Set<PrismObject<F>> usersWithoutDups = new HashSet<>();
usersWithoutDups.addAll(users);
users.clear();
users.addAll(usersWithoutDups);
LOGGER.debug("SYNCHRONIZATION: CORRELATION: found {} users without duplicates", users.size());
}
}
return users;
}
Aggregations