Skip to content

Commit

Permalink
MID-7442 notification legacy configuration working again
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Mar 3, 2022
1 parent 51656cc commit 2eb0d4c
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ boolean skipCreateWrapper(ItemDefinition<?> def, ItemStatus status, WrapperConte
}

if (ItemProcessing.IGNORE == def.getProcessing()) {
LOGGER.trace("Skip creating wrapper for {}, because item processig is set to IGNORE.", def);
LOGGER.trace("Skip creating wrapper for {}, because item processing is set to IGNORE.", def);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import com.evolveum.midpoint.gui.impl.component.form.TriStateFormGroup;
import com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder;
import com.evolveum.midpoint.gui.impl.factory.panel.ItemRealValueModel;
import com.evolveum.midpoint.gui.impl.page.admin.systemconfiguration.component.DeprecatedPropertyWrapperModel;
import com.evolveum.midpoint.gui.impl.prism.panel.PrismPropertyHeaderPanel;
import com.evolveum.midpoint.gui.impl.prism.wrapper.PrismPropertyValueWrapper;
import com.evolveum.midpoint.prism.PrismPropertyValue;
Expand Down Expand Up @@ -140,7 +141,7 @@ protected void initLayout() {

add(createHeader(ID_FILE_CONFIG_HEADER, FileConfigurationType.COMPLEX_TYPE.getLocalPart() + ".details"));

IModel<PrismPropertyWrapper<FileConfigurationType>> fileConfig = PrismPropertyWrapperModel.fromContainerWrapper(getModel(), NotificationConfigurationType.F_FILE);
IModel<PrismPropertyWrapper<FileConfigurationType>> fileConfig = new DeprecatedPropertyWrapperModel<>(this, getModel(), NotificationConfigurationType.F_FILE);

WebMarkupContainer files = new WebMarkupContainer(ID_FILE_CONFIG);
files.setOutputMarkupId(true);
Expand Down Expand Up @@ -304,7 +305,7 @@ private Label createHeader(String id, String displayName) {
return header;
}

private void newItemPerformed(AjaxRequestTarget target, List<MailServerConfiguration> mailServers, PropertyModel<MailConfigurationType> mailConfigType) {
private void newItemPerformed(AjaxRequestTarget target, List<MailServerConfiguration> mailServers, IModel<MailConfigurationType> mailConfigType) {
MailServerConfigurationType newServerType = new MailServerConfigurationType();
mailConfigType.getObject().server(newServerType);
MailServerConfiguration newServer = new MailServerConfiguration(newServerType);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright (c) 2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.gui.impl.page.admin.systemconfiguration.component;

import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.factory.wrapper.ItemWrapperFactory;
import com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismPropertyWrapper;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.PrismPropertyDefinition;
import com.evolveum.midpoint.prism.path.ItemName;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.web.model.PrismPropertyWrapperModel;

/**
* Created by Viliam Repan (lazyman).
*/
@Deprecated
public class DeprecatedPropertyWrapperModel<C extends Containerable, P> implements IModel<PrismPropertyWrapper<P>> {

private BasePanel panel;

private IModel<PrismContainerWrapper<C>> model;

private ItemName propertyName;

public DeprecatedPropertyWrapperModel(BasePanel panel, IModel<PrismContainerWrapper<C>> model, ItemName propertyName) {
this.panel = panel;
this.model = model;
this.propertyName = propertyName;
}

@Override
public PrismPropertyWrapper getObject() {
PrismContainerWrapper container = model.getObject();

try {
PrismContainerValueWrapper value = (PrismContainerValueWrapper) container.getValue();
PrismPropertyWrapper fileConfiguration = value.findProperty(propertyName);
if (fileConfiguration != null) {
return fileConfiguration;
}

PrismPropertyDefinition def = container.findPropertyDefinition(ItemPath.create(propertyName));
ItemWrapperFactory factory = panel.getPageBase().getRegistry().findWrapperFactory(def, value.getNewValue());

Task task = panel.getPageBase().createSimpleTask("Create child containers");
WrapperContext ctx = new WrapperContext(task, task.getResult());
ctx.setCreateIfEmpty(true);

PrismPropertyWrapper child = (PrismPropertyWrapper) factory.createWrapper(value, def, ctx);
value.addItem(child);

return child;
} catch (SchemaException ex) {
throw new SystemException(ex);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -802,9 +802,10 @@
<xsd:element name="file" type="tns:FileConfigurationType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:appinfo>
<a:deprecated>true</a:deprecated>
<a:deprecatedSince>4.5</a:deprecatedSince>
<a:plannedRemoval>4.6</a:plannedRemoval>
<!-- TODO: not deprecated yet because it breaks old GUI, see comments in NotificationConfigTabPanel -->
<!--<a:deprecated>true</a:deprecated>-->
<!--<a:deprecatedSince>4.5</a:deprecatedSince>-->
<!--<a:plannedRemoval>4.6</a:plannedRemoval>-->
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
Expand Down

0 comments on commit 2eb0d4c

Please sign in to comment.