@Override protected Builder<LDAPMappingConfiguration> readFrom(LDAPMappingConfiguration fromConfiguration) { this.mappedClass = fromConfiguration.getMappedClass(); this.objectClasses.addAll(fromConfiguration.getObjectClasses()); this.baseDN = fromConfiguration.getBaseDN(); if (fromConfiguration.getIdProperty() != null) { this.idPropertyName = fromConfiguration.getIdProperty().getName(); } this.mappedProperties.putAll(fromConfiguration.getMappedProperties()); this.readOnlyAttributes.addAll(fromConfiguration.getReadOnlyAttributes()); this.parentMapping.putAll(fromConfiguration.getParentMapping()); this.relatedAttributedType = fromConfiguration.getRelatedAttributedType(); this.parentMembershipAttributeName = fromConfiguration.getParentMembershipAttributeName(); this.hierarchySearchDepth = fromConfiguration.getHierarchySearchDepth(); return this; }
@Override protected Builder<LDAPMappingConfiguration> readFrom(LDAPMappingConfiguration fromConfiguration) { this.mappedClass = fromConfiguration.getMappedClass(); this.objectClasses.addAll(fromConfiguration.getObjectClasses()); this.baseDN = fromConfiguration.getBaseDN(); if (fromConfiguration.getIdProperty() != null) { this.idPropertyName = fromConfiguration.getIdProperty().getName(); } this.mappedProperties.putAll(fromConfiguration.getMappedProperties()); this.readOnlyAttributes.addAll(fromConfiguration.getReadOnlyAttributes()); this.parentMapping.putAll(fromConfiguration.getParentMapping()); this.relatedAttributedType = fromConfiguration.getRelatedAttributedType(); this.parentMembershipAttributeName = fromConfiguration.getParentMembershipAttributeName(); this.hierarchySearchDepth = fromConfiguration.getHierarchySearchDepth(); return this; }
private String getBaseDN(AttributedType attributedType) { LDAPMappingConfiguration mappingConfig = getMappingConfig(attributedType.getClass()); String baseDN = mappingConfig.getBaseDN(); String parentDN = mappingConfig.getParentMapping().get(mappingConfig.getIdProperty().getValue(attributedType)); if (parentDN != null) { baseDN = parentDN; } else { Property<AttributedType> parentProperty = PropertyQueries .<AttributedType>createQuery(attributedType.getClass()) .addCriteria(new TypedPropertyCriteria(attributedType.getClass())).getFirstResult(); if (parentProperty != null) { AttributedType parentType = parentProperty.getValue(attributedType); if (parentType != null) { Property<String> parentIdProperty = getMappingConfig(parentType.getClass()).getIdProperty(); String parentId = parentIdProperty.getValue(parentType); String parentBaseDN = mappingConfig.getParentMapping().get(parentId); if (parentBaseDN != null) { baseDN = parentBaseDN; } else { baseDN = getBaseDN(parentType); } } } } if (baseDN == null) { baseDN = getConfig().getBaseDN(); } return baseDN; }
private String getBaseDN(AttributedType attributedType) { LDAPMappingConfiguration mappingConfig = getMappingConfig(attributedType.getClass()); String baseDN = mappingConfig.getBaseDN(); String parentDN = mappingConfig.getParentMapping().get(mappingConfig.getIdProperty().getValue(attributedType)); if (parentDN != null) { baseDN = parentDN; } else { Property<AttributedType> parentProperty = PropertyQueries .<AttributedType>createQuery(attributedType.getClass()) .addCriteria(new TypedPropertyCriteria(attributedType.getClass())).getFirstResult(); if (parentProperty != null) { AttributedType parentType = parentProperty.getValue(attributedType); if (parentType != null) { Property<String> parentIdProperty = getMappingConfig(parentType.getClass()).getIdProperty(); String parentId = parentIdProperty.getValue(parentType); String parentBaseDN = mappingConfig.getParentMapping().get(parentId); if (parentBaseDN != null) { baseDN = parentBaseDN; } else { baseDN = getBaseDN(parentType); } } } } if (baseDN == null) { baseDN = getConfig().getBaseDN(); } return baseDN; }
public String getBindingDN(AttributedType attributedType, boolean appendBaseDN) { LDAPMappingConfiguration mappingConfig = getMappingConfig(attributedType.getClass()); Property<String> idProperty = mappingConfig.getIdProperty(); String baseDN; if (mappingConfig.getBaseDN() == null || !appendBaseDN) { baseDN = ""; } else { baseDN = COMMA + getBaseDN(attributedType); } Property<String> bindingProperty = mappingConfig.getBindingProperty(); String bindingAttribute; String dn; if (bindingProperty == null) { bindingAttribute = mappingConfig.getMappedProperties().get(idProperty.getName()); dn = idProperty.getValue(attributedType); } else { bindingAttribute = mappingConfig.getMappedProperties().get(bindingProperty.getName()); dn = mappingConfig.getBindingProperty().getValue(attributedType); } return bindingAttribute + EQUAL + dn + baseDN; }
public String getBindingDN(AttributedType attributedType, boolean appendBaseDN) { LDAPMappingConfiguration mappingConfig = getMappingConfig(attributedType.getClass()); Property<String> idProperty = mappingConfig.getIdProperty(); String baseDN; if (mappingConfig.getBaseDN() == null || !appendBaseDN) { baseDN = ""; } else { baseDN = COMMA + getBaseDN(attributedType); } Property<String> bindingProperty = mappingConfig.getBindingProperty(); String bindingAttribute; String dn; if (bindingProperty == null) { bindingAttribute = mappingConfig.getMappedProperties().get(idProperty.getName()); dn = idProperty.getValue(attributedType); } else { bindingAttribute = mappingConfig.getMappedProperties().get(bindingProperty.getName()); dn = mappingConfig.getBindingProperty().getValue(attributedType); } return bindingAttribute + EQUAL + dn + baseDN; }