use of com.evolveum.midpoint.prism.PrismContainerDefinition in project midpoint by Evolveum.
the class SchemaTestUtil method assertFocusDefinition.
public static void assertFocusDefinition(ComplexTypeDefinition complexTypeDefinition, String defDesc) {
assertNotNull("No " + defDesc + " definition", complexTypeDefinition);
PrismAsserts.assertPropertyDefinition(complexTypeDefinition, ObjectType.F_NAME, PolyStringType.COMPLEX_TYPE, 0, 1);
PrismAsserts.assertItemDefinitionDisplayName(complexTypeDefinition, ObjectType.F_NAME, "ObjectType.name");
PrismAsserts.assertItemDefinitionDisplayOrder(complexTypeDefinition, ObjectType.F_NAME, 0);
PrismAsserts.assertPropertyDefinition(complexTypeDefinition, ObjectType.F_DESCRIPTION, DOMUtil.XSD_STRING, 0, 1);
PrismAsserts.assertItemDefinitionDisplayName(complexTypeDefinition, ObjectType.F_DESCRIPTION, "ObjectType.description");
PrismAsserts.assertItemDefinitionDisplayOrder(complexTypeDefinition, ObjectType.F_DESCRIPTION, 10);
assertFalse("" + defDesc + " definition is marked as runtime", complexTypeDefinition.isRuntimeSchema());
PrismContainerDefinition extensionContainer = complexTypeDefinition.findContainerDefinition(UserType.F_EXTENSION);
PrismAsserts.assertDefinition(extensionContainer, UserType.F_EXTENSION, ExtensionType.COMPLEX_TYPE, 0, 1);
assertTrue("Extension is NOT runtime", extensionContainer.isRuntimeSchema());
assertTrue("Extension is NOT dynamic", extensionContainer.isDynamic());
assertEquals("Extension size", 0, extensionContainer.getDefinitions().size());
PrismAsserts.assertItemDefinitionDisplayName(complexTypeDefinition, UserType.F_EXTENSION, "ObjectType.extension");
PrismAsserts.assertItemDefinitionDisplayOrder(complexTypeDefinition, UserType.F_EXTENSION, 1000);
PrismContainerDefinition<ActivationType> activationContainer = complexTypeDefinition.findContainerDefinition(UserType.F_ACTIVATION);
PrismAsserts.assertDefinition(activationContainer, UserType.F_ACTIVATION, ActivationType.COMPLEX_TYPE, 0, 1);
assertFalse("Activation is runtime", activationContainer.isRuntimeSchema());
assertEquals("Activation size", 12, activationContainer.getDefinitions().size());
PrismAsserts.assertPropertyDefinition(activationContainer, ActivationType.F_ADMINISTRATIVE_STATUS, SchemaConstants.C_ACTIVATION_STATUS_TYPE, 0, 1);
PrismContainerDefinition<AssignmentType> assignmentContainer = complexTypeDefinition.findContainerDefinition(UserType.F_ASSIGNMENT);
PrismAsserts.assertDefinition(assignmentContainer, UserType.F_ASSIGNMENT, AssignmentType.COMPLEX_TYPE, 0, -1);
assertFalse("Assignment is runtime", assignmentContainer.isRuntimeSchema());
assertEquals("Assignment definition size", 21, assignmentContainer.getDefinitions().size());
PrismContainerDefinition<ConstructionType> constructionContainer = assignmentContainer.findContainerDefinition(AssignmentType.F_CONSTRUCTION);
PrismAsserts.assertDefinition(constructionContainer, AssignmentType.F_CONSTRUCTION, ConstructionType.COMPLEX_TYPE, 0, 1);
assertFalse("Construction is runtime", constructionContainer.isRuntimeSchema());
PrismReferenceDefinition accountRefDef = complexTypeDefinition.findItemDefinition(UserType.F_LINK_REF, PrismReferenceDefinition.class);
PrismAsserts.assertDefinition(accountRefDef, UserType.F_LINK_REF, ObjectReferenceType.COMPLEX_TYPE, 0, -1);
assertEquals("Wrong target type in accountRef", ShadowType.COMPLEX_TYPE, accountRefDef.getTargetTypeName());
assertEquals("Wrong composite object element name in accountRef", UserType.F_LINK, accountRefDef.getCompositeObjectElementName());
PrismContainerDefinition<MetadataType> metadataContainer = complexTypeDefinition.findContainerDefinition(UserType.F_METADATA);
PrismAsserts.assertDefinition(extensionContainer, UserType.F_EXTENSION, ExtensionType.COMPLEX_TYPE, 0, 1);
assertFalse("Metadata is runtime", metadataContainer.isRuntimeSchema());
assertFalse("Metadata is dynamic", metadataContainer.isDynamic());
assertTrue("Metadata is NOT operational", metadataContainer.isOperational());
assertEquals("Metadata size", 12, metadataContainer.getDefinitions().size());
PrismReferenceDefinition tenantRefDef = complexTypeDefinition.findItemDefinition(UserType.F_TENANT_REF, PrismReferenceDefinition.class);
PrismAsserts.assertDefinition(tenantRefDef, UserType.F_TENANT_REF, ObjectReferenceType.COMPLEX_TYPE, 0, 1);
assertEquals("Wrong target type in tenantRef", ShadowType.COMPLEX_TYPE, accountRefDef.getTargetTypeName());
}
use of com.evolveum.midpoint.prism.PrismContainerDefinition in project midpoint by Evolveum.
the class UserProfileServiceImpl method initializePrincipalFromAssignments.
private void initializePrincipalFromAssignments(MidPointPrincipal principal, PrismObject<SystemConfigurationType> systemConfiguration) throws SchemaException {
UserType userType = principal.getUser();
Collection<Authorization> authorizations = principal.getAuthorities();
List<AdminGuiConfigurationType> adminGuiConfigurations = new ArrayList<>();
Task task = taskManager.createTaskInstance(UserProfileServiceImpl.class.getName() + ".initializePrincipalFromAssignments");
OperationResult result = task.getResult();
principal.setApplicableSecurityPolicy(securityHelper.locateSecurityPolicy(userType.asPrismObject(), systemConfiguration, task, result));
if (!userType.getAssignment().isEmpty()) {
LensContext<UserType> lensContext = new LensContextPlaceholder<>(userType.asPrismObject(), prismContext);
AssignmentEvaluator.Builder<UserType> builder = new AssignmentEvaluator.Builder<UserType>().repository(repositoryService).focusOdo(new ObjectDeltaObject<>(userType.asPrismObject(), null, userType.asPrismObject())).channel(null).objectResolver(objectResolver).systemObjectCache(systemObjectCache).prismContext(prismContext).mappingFactory(mappingFactory).mappingEvaluator(mappingEvaluator).activationComputer(activationComputer).now(clock.currentTimeXMLGregorianCalendar()).loginMode(true).lensContext(lensContext);
AssignmentEvaluator<UserType> assignmentEvaluator = builder.build();
try {
RepositoryCache.enter();
for (AssignmentType assignmentType : userType.getAssignment()) {
try {
ItemDeltaItem<PrismContainerValue<AssignmentType>, PrismContainerDefinition<AssignmentType>> assignmentIdi = new ItemDeltaItem<>();
assignmentIdi.setItemOld(LensUtil.createAssignmentSingleValueContainerClone(assignmentType));
assignmentIdi.recompute();
EvaluatedAssignment<UserType> assignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userType, userType.toString(), task, result);
if (assignment.isValid()) {
authorizations.addAll(assignment.getAuthorizations());
adminGuiConfigurations.addAll(assignment.getAdminGuiConfigurations());
}
for (EvaluatedAssignmentTarget target : assignment.getRoles().getNonNegativeValues()) {
if (target.getTarget() != null && target.getTarget().asObjectable() instanceof UserType && DeputyUtils.isDelegationPath(target.getAssignmentPath())) {
List<OtherPrivilegesLimitationType> limitations = DeputyUtils.extractLimitations(target.getAssignmentPath());
principal.addDelegatorWithOtherPrivilegesLimitations(new DelegatorWithOtherPrivilegesLimitations((UserType) target.getTarget().asObjectable(), limitations));
}
}
} catch (SchemaException e) {
LOGGER.error("Schema violation while processing assignment of {}: {}; assignment: {}", userType, e.getMessage(), assignmentType, e);
} catch (ObjectNotFoundException e) {
LOGGER.error("Object not found while processing assignment of {}: {}; assignment: {}", userType, e.getMessage(), assignmentType, e);
} catch (ExpressionEvaluationException e) {
LOGGER.error("Evaluation error while processing assignment of {}: {}; assignment: {}", userType, e.getMessage(), assignmentType, e);
} catch (PolicyViolationException e) {
LOGGER.error("Policy violation while processing assignment of {}: {}; assignment: {}", userType, e.getMessage(), assignmentType, e);
}
}
} finally {
RepositoryCache.exit();
}
}
if (userType.getAdminGuiConfiguration() != null) {
// config from the user object should go last (to be applied as the last one)
adminGuiConfigurations.add(userType.getAdminGuiConfiguration());
}
principal.setAdminGuiConfiguration(AdminGuiConfigTypeUtil.compileAdminGuiConfiguration(adminGuiConfigurations, systemConfiguration));
}
use of com.evolveum.midpoint.prism.PrismContainerDefinition in project midpoint by Evolveum.
the class LoggingConfigurationTabPanel method initLayout.
protected void initLayout() {
try {
ItemPanelSettingsBuilder builder = new ItemPanelSettingsBuilder();
builder.visibilityHandler(itemWrapper -> getLoggingVisibility(itemWrapper.getPath()));
Panel loggingPanel = getPageBase().initItemPanel(ID_LOGGING, LoggingConfigurationType.COMPLEX_TYPE, getModel(), builder.build());
add(loggingPanel);
} catch (SchemaException e) {
LOGGER.error("Cannot create panel for logging: {}", e.getMessage(), e);
getSession().error("Cannot create panle for logging");
}
PrismContainerWrapperModel<LoggingConfigurationType, ClassLoggerConfigurationType> loggerModel = PrismContainerWrapperModel.fromContainerWrapper(getModel(), LoggingConfigurationType.F_CLASS_LOGGER);
MultivalueContainerListPanel<ClassLoggerConfigurationType> loggersMultivalueContainerListPanel = new MultivalueContainerListPanel<ClassLoggerConfigurationType>(ID_LOGGERS, ClassLoggerConfigurationType.class) {
private static final long serialVersionUID = 1L;
@Override
protected List<SearchItemDefinition> initSearchableItems(PrismContainerDefinition<ClassLoggerConfigurationType> containerDef) {
List<SearchItemDefinition> defs = new ArrayList<>();
SearchFactory.addSearchPropertyDef(containerDef, ClassLoggerConfigurationType.F_APPENDER, defs);
SearchFactory.addSearchPropertyDef(containerDef, ClassLoggerConfigurationType.F_PACKAGE, defs);
defs.addAll(SearchFactory.createExtensionDefinitionList(containerDef));
return defs;
}
@Override
protected void newItemPerformed(AjaxRequestTarget target, AssignmentObjectRelation relation) {
PrismContainerValue<ClassLoggerConfigurationType> newLogger = loggerModel.getObject().getItem().createNewValue();
PrismContainerValueWrapper<ClassLoggerConfigurationType> newLoggerWrapper = getLoggersMultivalueContainerListPanel().createNewItemContainerValueWrapper(newLogger, loggerModel.getObject(), target);
loggerEditPerformed(target, Model.of(newLoggerWrapper), null);
}
@Override
protected boolean isCreateNewObjectVisible() {
return true;
}
@Override
protected IModel<PrismContainerWrapper<ClassLoggerConfigurationType>> getContainerModel() {
return loggerModel;
}
@Override
protected String getStorageKey() {
return SessionStorage.KEY_LOGGING_TAB_LOGGER_TABLE;
}
@Override
protected UserProfileStorage.TableId getTableId() {
return UserProfileStorage.TableId.LOGGING_TAB_LOGGER_TABLE;
}
@Override
protected List<IColumn<PrismContainerValueWrapper<ClassLoggerConfigurationType>, String>> createDefaultColumns() {
return initLoggersBasicColumns(loggerModel);
}
@Override
protected void editItemPerformed(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<ClassLoggerConfigurationType>> rowModel, List<PrismContainerValueWrapper<ClassLoggerConfigurationType>> listItems) {
loggerEditPerformed(target, rowModel, listItems);
}
};
add(loggersMultivalueContainerListPanel);
PrismContainerWrapperModel<LoggingConfigurationType, AppenderConfigurationType> appenderModel = PrismContainerWrapperModel.fromContainerWrapper(getModel(), LoggingConfigurationType.F_APPENDER);
MultivalueContainerListPanelWithDetailsPanel<AppenderConfigurationType> appendersMultivalueContainerListPanel = new MultivalueContainerListPanelWithDetailsPanel<AppenderConfigurationType>(ID_APPENDERS, AppenderConfigurationType.class) {
private static final long serialVersionUID = 1L;
@Override
protected void newItemPerformed(AjaxRequestTarget target, AssignmentObjectRelation relation) {
newAppendersClickPerformed(target, appenderModel);
}
@Override
protected boolean isCreateNewObjectVisible() {
return true;
}
@Override
protected IModel<PrismContainerWrapper<AppenderConfigurationType>> getContainerModel() {
return appenderModel;
}
@Override
protected boolean isHeaderVisible() {
return false;
}
@Override
protected String getStorageKey() {
return SessionStorage.KEY_LOGGING_TAB_APPENDER_TABLE;
}
@Override
protected UserProfileStorage.TableId getTableId() {
return UserProfileStorage.TableId.LOGGING_TAB_APPENDER_TABLE;
}
@Override
protected List<IColumn<PrismContainerValueWrapper<AppenderConfigurationType>, String>> createDefaultColumns() {
return initAppendersBasicColumns(appenderModel);
}
@Override
protected MultivalueContainerDetailsPanel<AppenderConfigurationType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<AppenderConfigurationType>> item) {
return LoggingConfigurationTabPanel.this.getAppendersMultivalueContainerDetailsPanel(item);
}
@Override
protected List<Component> createToolbarButtonsList(String idButton) {
List<Component> bar = new ArrayList<>();
// MidpointForm appenderTypeForm = new MidpointForm(ID_CHOICE_APPENDER_TYPE_FORM);
AjaxSubmitButton newObjectIcon = new AjaxSubmitButton(idButton, new Model<>("<i class=\"fa fa-plus\"></i>")) {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target) {
newItemPerformed(target, null);
}
};
newObjectIcon.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isCreateNewObjectVisible();
}
@Override
public boolean isEnabled() {
return isNewObjectButtonEnabled();
}
});
newObjectIcon.add(AttributeModifier.append("class", createStyleClassModelForNewObjectIcon()));
// appenderTypeForm.add(newObjectIcon);
bar.add(newObjectIcon);
List<QName> appendersChoicesList = new ArrayList<>();
appendersChoicesList.add(FileAppenderConfigurationType.COMPLEX_TYPE);
appendersChoicesList.add(SyslogAppenderConfigurationType.COMPLEX_TYPE);
DropDownChoicePanel<QName> appenderChoice = new DropDownChoicePanel<>(idButton, new Model<>(FileAppenderConfigurationType.COMPLEX_TYPE), Model.ofList(appendersChoicesList), new QNameIChoiceRenderer("LoggingConfigurationTabPanel.appendersChoice"));
appenderChoice.setOutputMarkupId(true);
LoggingConfigurationTabPanel.this.appenderChoice = appenderChoice;
bar.add(appenderChoice);
// bar.add(appenderTypeForm);
return bar;
}
};
add(appendersMultivalueContainerListPanel);
IModel<PrismContainerWrapper<LoggingAuditingConfigurationType>> auditModel = PrismContainerWrapperModel.fromContainerWrapper(getModel(), LoggingConfigurationType.F_AUDITING);
try {
Panel auditPanel = getPageBase().initItemPanel(ID_AUDITING, LoggingAuditingConfigurationType.COMPLEX_TYPE, auditModel, new ItemPanelSettingsBuilder().build());
add(auditPanel);
} catch (SchemaException e) {
LOGGER.error("Cannot create panel for auditing: {}", e.getMessage(), e);
getSession().error("Cannot create panel for auditing.");
}
setOutputMarkupId(true);
}
use of com.evolveum.midpoint.prism.PrismContainerDefinition in project midpoint by Evolveum.
the class ItemPathPanel method initItemPathPanel.
private void initItemPathPanel() {
WebMarkupContainer itemPathPanel = new WebMarkupContainer(ID_ITEM_PATH);
itemPathPanel.setOutputMarkupId(true);
add(itemPathPanel);
itemPathPanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !getModelObject().isPathDefined();
}
});
WebMarkupContainer namespaceModeContainer = new WebMarkupContainer(ID_NAMESPACE_MODE_CONTAINER);
namespaceModeContainer.setOutputMarkupId(true);
namespaceModeContainer.add(new VisibleBehaviour(() -> ItemPathPanelMode.NAMESPACE_MODE.equals(panelMode)));
itemPathPanel.add(namespaceModeContainer);
ItemPathSegmentPanel itemDefPanel = new ItemPathSegmentPanel(ID_DEFINITION, getModel()) {
private static final long serialVersionUID = 1L;
@Override
protected Map<QName, Collection<ItemDefinition<?>>> getSchemaDefinitionMap() {
return initNamspaceDefinitionMap();
}
@Override
protected void onUpdateAutoCompletePanel(AjaxRequestTarget target) {
ItemPathPanel.this.onUpdate(ItemPathPanel.this.getModelObject());
}
};
itemDefPanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
itemDefPanel.setOutputMarkupId(true);
namespaceModeContainer.add(itemDefPanel);
AjaxButton plusButton = new AjaxButton(ID_PLUS) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
refreshItemPathPanel(new ItemPathDto(ItemPathPanel.this.getModelObject()), true, target);
}
};
plusButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
if (getModelObject().getParentPath() == null || getModelObject().getParentPath().toItemPath() == null) {
return true;
}
return (getModelObject().getParentPath().getItemDef() instanceof PrismContainerDefinition);
}
});
plusButton.setOutputMarkupId(true);
namespaceModeContainer.add(plusButton);
AjaxButton minusButton = new AjaxButton(ID_MINUS) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
ItemPathDto path = ItemPathPanel.this.getModelObject();
refreshItemPathPanel(path, false, target);
}
};
minusButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getModelObject().getParentPath() != null && getModelObject().getParentPath().toItemPath() != null;
}
});
minusButton.setOutputMarkupId(true);
namespaceModeContainer.add(minusButton);
DropDownChoicePanel<QName> namespacePanel = new DropDownChoicePanel<>(ID_NAMESPACE, new PropertyModel<>(getModel(), "objectType"), new ListModel<>(WebComponentUtil.createObjectTypeList()), new QNameChoiceRenderer());
namespacePanel.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
refreshItemPath(ItemPathPanel.this.getModelObject(), target);
}
});
namespacePanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getModelObject().getParentPath() == null || getModelObject().getParentPath().toItemPath() == null;
}
});
namespacePanel.setOutputMarkupId(true);
namespaceModeContainer.add(namespacePanel);
TextPanel<String> itemPathTextField = new TextPanel<String>(ID_ITEM_PATH_TEXT_FIELD, new PropertyModel<>(getModel(), "pathStringValue"));
itemPathTextField.add(new VisibleBehaviour(() -> switchToTextFieldEnabled && ItemPathPanelMode.TEXT_MODE.equals(panelMode)));
itemPathTextField.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
itemPathPanel.add(itemPathTextField);
AjaxButton switchButton = new AjaxButton(ID_SWITCH_TO_TEXT_FIELD_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
switchButtonClickPerformed(target);
}
};
switchButton.setOutputMarkupId(true);
switchButton.add(AttributeAppender.append("title", new LoadableModel<String>() {
@Override
protected String load() {
return ItemPathPanelMode.NAMESPACE_MODE.equals(panelMode) ? getPageBase().createStringResource("ItemPathPanel.switchToTextModeTitle").getString() : getPageBase().createStringResource("ItemPathPanel.switchToNamespaceModeTitle").getString();
}
}));
switchButton.add(new VisibleBehaviour(() -> switchToTextFieldEnabled));
itemPathPanel.add(switchButton);
}
use of com.evolveum.midpoint.prism.PrismContainerDefinition in project midpoint by Evolveum.
the class SearchPropertiesConfigPanel method getAvailablePropertiesListModel.
private LoadableModel<List<Property>> getAvailablePropertiesListModel() {
return new LoadableModel<List<Property>>() {
@Override
protected List<Property> load() {
Class<?> type = getType();
if (ObjectType.class.isAssignableFrom(type)) {
PrismObjectDefinition objectDef = SearchFactory.findObjectDefinition(getType(), null, getPageBase());
List<SearchItemDefinition> availableDefs = SearchFactory.getAvailableDefinitions(objectDef, null, true, getPageBase());
List<Property> propertiesList = new ArrayList<>();
availableDefs.forEach(searchItemDef -> {
if (!isPropertyAlreadyAdded(searchItemDef.getPath())) {
propertiesList.add(new Property(searchItemDef.getDef(), searchItemDef.getPath()));
}
});
return propertiesList;
}
if (AuditEventRecordType.class.isAssignableFrom(type)) {
PrismContainerDefinition<AuditEventRecordType> auditDefs = getPrismContext().getSchemaRegistry().findContainerDefinitionByCompileTimeClass(AuditEventRecordType.class);
List<Property> propertiesList = auditDefs.getDefinitions().stream().map(def -> new Property(def, def.getItemName())).collect(Collectors.toList());
return propertiesList;
}
return Collections.emptyList();
}
};
}
Aggregations