1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.client.console.wizards.resources;
20
21 import java.util.List;
22 import java.util.stream.Collectors;
23 import org.apache.syncope.common.lib.to.ConnIdBundle;
24 import org.apache.syncope.common.lib.to.ConnInstanceTO;
25 import org.apache.syncope.common.lib.types.ConnConfProperty;
26 import org.apache.wicket.model.LoadableDetachableModel;
27
28 public abstract class ConnectorConfPanel extends AbstractConnConfPanel<ConnInstanceTO> {
29
30 private static final long serialVersionUID = -2025535531121434050L;
31
32 private final List<ConnIdBundle> bundles;
33
34 public ConnectorConfPanel(final ConnInstanceTO connInstanceTO, final List<ConnIdBundle> bundles) {
35 super(connInstanceTO);
36 this.bundles = bundles;
37
38 model = new LoadableDetachableModel<>() {
39
40 private static final long serialVersionUID = -2965284931860212687L;
41
42 @Override
43 protected List<ConnConfProperty> load() {
44 List<ConnConfProperty> properties = getConnProperties(ConnectorConfPanel.this.modelObject);
45 ConnectorConfPanel.this.modelObject.getConf().clear();
46
47
48 properties.sort((o1, o2) -> o1 == null ? -1 : o1.compareTo(o2));
49
50 ConnectorConfPanel.this.modelObject.getConf().addAll(properties);
51 return properties;
52 }
53 };
54
55 setConfPropertyListView(model, true);
56 }
57
58
59
60
61
62
63
64 @Override
65 protected final List<ConnConfProperty> getConnProperties(final ConnInstanceTO instance) {
66 return ConnectorWizardBuilder.getBundle(instance, bundles).getProperties().stream().
67 map(key -> {
68 ConnConfProperty property = new ConnConfProperty();
69 property.setSchema(key);
70
71 instance.getConf(key.getName()).ifPresent(conf -> {
72 if (conf.getValues() != null) {
73 property.getValues().addAll(conf.getValues());
74 property.setOverridable(conf.isOverridable());
75 }
76 });
77
78 if (property.getValues().isEmpty() && !key.getDefaultValues().isEmpty()) {
79 property.getValues().addAll(key.getDefaultValues());
80 }
81 return property;
82 }).collect(Collectors.toList());
83 }
84 }