1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.bremersee.dccon.repository.ldap;
18
19 import static org.bremersee.data.ldaptive.LdaptiveEntryMapper.getAttributeValue;
20
21 import org.bremersee.data.ldaptive.LdaptiveEntryMapper;
22 import org.bremersee.dccon.config.DomainControllerProperties;
23 import org.bremersee.dccon.model.DnsZone;
24 import org.ldaptive.AttributeModification;
25 import org.ldaptive.LdapEntry;
26 import org.ldaptive.io.StringValueTranscoder;
27
28
29
30
31
32
33 public class DnsZoneLdapMapper extends AbstractLdapMapper implements LdaptiveEntryMapper<DnsZone> {
34
35 private static final StringValueTranscoder STRING_VALUE_TRANSCODER = new StringValueTranscoder();
36
37
38
39
40
41
42 public DnsZoneLdapMapper(DomainControllerProperties properties) {
43 super(properties);
44 }
45
46 @Override
47 public String[] getObjectClasses() {
48 return new String[0];
49 }
50
51 @Override
52 public String mapDn(final DnsZone dnsZone) {
53 return createDn(
54 getProperties().getDnsZoneRdn(),
55 dnsZone.getName(),
56 getProperties().getDnsZoneBaseDn());
57 }
58
59 @Override
60 public DnsZone map(final LdapEntry ldapEntry) {
61 if (ldapEntry == null) {
62 return null;
63 }
64 final DnsZone destination = new DnsZone();
65 map(ldapEntry, destination);
66 return destination;
67 }
68
69 @Override
70 public void map(
71 final LdapEntry ldapEntry,
72 final DnsZone dnsZone) {
73 if (ldapEntry == null) {
74 return;
75 }
76 mapCommonAttributes(ldapEntry, dnsZone);
77 dnsZone.setName(getAttributeValue(ldapEntry, "name", STRING_VALUE_TRANSCODER, null));
78 dnsZone.setDefaultZone(dnsZone.getName() != null
79 && dnsZone.getName().equalsIgnoreCase(getProperties().getDefaultZone()));
80 dnsZone.setReverseZone(getProperties().isReverseZone(dnsZone.getName()));
81 }
82
83 @Override
84 public AttributeModification[] mapAndComputeModifications(
85 final DnsZone source,
86 final LdapEntry destination) {
87 return new AttributeModification[0];
88 }
89
90 }