public Class<? extends AttributedType> getSupportedTypeByBaseDN(String entryDN, List<String> objectClasses) { String entryBaseDN = entryDN.substring(entryDN.indexOf(COMMA) + 1); for (LDAPMappingConfiguration mappingConfig : this.mappingConfig.values()) { if (mappingConfig.getBaseDN() != null) { if (!Relationship.class.isAssignableFrom(mappingConfig.getMappedClass())) { if (mappingConfig.getBaseDN().equalsIgnoreCase(entryDN) || mappingConfig.getParentMapping().values().contains(entryDN)) { return mappingConfig.getMappedClass(); } if (mappingConfig.getBaseDN().equalsIgnoreCase(entryBaseDN) || mappingConfig.getParentMapping().values().contains(entryBaseDN)) { return mappingConfig.getMappedClass(); } } } } for (LDAPMappingConfiguration mappingConfig : this.mappingConfig.values()) { if (!Relationship.class.isAssignableFrom(mappingConfig.getMappedClass())) { for (String objectClass : objectClasses) { if (mappingConfig.getObjectClasses().contains(objectClass)) { return mappingConfig.getMappedClass(); } } } } throw new IdentityManagementException("No type found with Base DN [" + entryDN + "] or objectClasses [" + objectClasses + "."); }
public Class<? extends AttributedType> getSupportedTypeByBaseDN(String entryDN, List<String> objectClasses) { String entryBaseDN = entryDN.substring(entryDN.indexOf(COMMA) + 1); for (LDAPMappingConfiguration mappingConfig : this.mappingConfig.values()) { if (mappingConfig.getBaseDN() != null) { if (!Relationship.class.isAssignableFrom(mappingConfig.getMappedClass())) { if (mappingConfig.getBaseDN().equalsIgnoreCase(entryDN) || mappingConfig.getParentMapping().values().contains(entryDN)) { return mappingConfig.getMappedClass(); } if (mappingConfig.getBaseDN().equalsIgnoreCase(entryBaseDN) || mappingConfig.getParentMapping().values().contains(entryBaseDN)) { return mappingConfig.getMappedClass(); } } } } for (LDAPMappingConfiguration mappingConfig : this.mappingConfig.values()) { if (!Relationship.class.isAssignableFrom(mappingConfig.getMappedClass())) { for (String objectClass : objectClasses) { if (mappingConfig.getObjectClasses().contains(objectClass)) { return mappingConfig.getMappedClass(); } } } } throw new IdentityManagementException("No type found with Base DN [" + entryDN + "] or objectClasses [" + objectClasses + "."); }
@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; }