public List<LDAPMappingConfiguration> getRelationshipConfigs() { ArrayList<LDAPMappingConfiguration> result = new ArrayList<LDAPMappingConfiguration>(); for (LDAPMappingConfiguration mappingConfig : this.mappingConfig.values()) { if (mappingConfig.getRelatedAttributedType() != null) { result.add(mappingConfig); } } return result; }
public List<LDAPMappingConfiguration> getRelationshipConfigs() { ArrayList<LDAPMappingConfiguration> result = new ArrayList<LDAPMappingConfiguration>(); for (LDAPMappingConfiguration mappingConfig : this.mappingConfig.values()) { if (mappingConfig.getRelatedAttributedType() != null) { result.add(mappingConfig); } } return result; }
private List<String> getReturningAttributes(final LDAPMappingConfiguration mappingConfiguration) { List<String> returningAttributes = new ArrayList<String>(); if (mappingConfiguration != null) { returningAttributes.addAll(mappingConfiguration.getMappedProperties().values()); returningAttributes.add(mappingConfiguration.getParentMembershipAttributeName()); for (LDAPMappingConfiguration relationshipConfig : this.config.getRelationshipConfigs()) { if (relationshipConfig.getRelatedAttributedType().equals(mappingConfiguration.getMappedClass())) { returningAttributes.addAll(relationshipConfig.getMappedProperties().values()); } } } else { returningAttributes.add("*"); } returningAttributes.add(getUniqueIdentifierAttributeName()); returningAttributes.add(CREATE_TIMESTAMP); returningAttributes.add(LDAPConstants.OBJECT_CLASS); return returningAttributes; } }
private List<String> getReturningAttributes(final LDAPMappingConfiguration mappingConfiguration) { List<String> returningAttributes = new ArrayList<String>(); if (mappingConfiguration != null) { returningAttributes.addAll(mappingConfiguration.getMappedProperties().values()); returningAttributes.add(mappingConfiguration.getParentMembershipAttributeName()); for (LDAPMappingConfiguration relationshipConfig : this.config.getRelationshipConfigs()) { if (relationshipConfig.getRelatedAttributedType().equals(mappingConfiguration.getMappedClass())) { returningAttributes.addAll(relationshipConfig.getMappedProperties().values()); } } } else { returningAttributes.add("*"); } returningAttributes.add(getUniqueIdentifierAttributeName()); returningAttributes.add(CREATE_TIMESTAMP); returningAttributes.add(LDAPConstants.OBJECT_CLASS); return returningAttributes; } }
private AttributedType getRelationshipOwner(final Relationship relationship) { Class<? extends AttributedType> ownertType = getMappingConfig(relationship.getClass()).getRelatedAttributedType(); Property<AttributedType> property = PropertyQueries .<AttributedType>createQuery(relationship.getClass()) .addCriteria(new TypedPropertyCriteria(ownertType)) .getSingleResult(); return property.getValue(relationship); }
private AttributedType getRelationshipOwner(final Relationship relationship) { Class<? extends AttributedType> ownertType = getMappingConfig(relationship.getClass()).getRelatedAttributedType(); Property<AttributedType> property = PropertyQueries .<AttributedType>createQuery(relationship.getClass()) .addCriteria(new TypedPropertyCriteria(ownertType)) .getSingleResult(); return property.getValue(relationship); }
@Override protected void removeFromRelationships(final IdentityContext context, final IdentityType identityType) { String bindingDN = getBindingDN(identityType, true); for (LDAPMappingConfiguration relationshipConfig : getConfig().getRelationshipConfigs()) { for (String attributeName : relationshipConfig.getMappedProperties().values()) { StringBuilder filter = new StringBuilder(); filter.append("(&(").append(attributeName).append(EQUAL).append("").append(bindingDN).append("))"); try { List<SearchResult> search = this.operationManager.search(getMappingConfig(relationshipConfig.getRelatedAttributedType()).getBaseDN(), filter.toString(), getMappingConfig(relationshipConfig.getRelatedAttributedType())); for (SearchResult result : search) { Attributes attributes = result.getAttributes(); Attribute relationshipAttribute = attributes.get(attributeName); if (relationshipAttribute != null && relationshipAttribute.contains(bindingDN)) { relationshipAttribute.remove(bindingDN); if (relationshipAttribute.size() == 0) { relationshipAttribute.add(EMPTY_ATTRIBUTE_VALUE); } this.operationManager.modifyAttribute(result.getNameInNamespace(), relationshipAttribute); } } } catch (NamingException e) { throw new IdentityManagementException("Could not remove " + identityType + " from relationship " + relationshipConfig.getMappedClass(), e); } } } }
@Override protected void removeFromRelationships(final IdentityContext context, final IdentityType identityType) { String bindingDN = getBindingDN(identityType, true); for (LDAPMappingConfiguration relationshipConfig : getConfig().getRelationshipConfigs()) { for (String attributeName : relationshipConfig.getMappedProperties().values()) { StringBuilder filter = new StringBuilder(); filter.append("(&(").append(attributeName).append(EQUAL).append("").append(bindingDN).append("))"); try { List<SearchResult> search = this.operationManager.search(getMappingConfig(relationshipConfig.getRelatedAttributedType()).getBaseDN(), filter.toString(), getMappingConfig(relationshipConfig.getRelatedAttributedType())); for (SearchResult result : search) { Attributes attributes = result.getAttributes(); Attribute relationshipAttribute = attributes.get(attributeName); if (relationshipAttribute != null && relationshipAttribute.contains(bindingDN)) { relationshipAttribute.remove(bindingDN); if (relationshipAttribute.size() == 0) { relationshipAttribute.add(EMPTY_ATTRIBUTE_VALUE); } this.operationManager.modifyAttribute(result.getNameInNamespace(), relationshipAttribute); } } } catch (NamingException e) { throw new IdentityManagementException("Could not remove " + identityType + " from relationship " + relationshipConfig.getMappedClass(), e); } } } }
@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; }
Class<V> relationshipClass = (Class<V>) mappingConfig.getMappedClass(); Map<QueryParameter, Object[]> parameters = query.getParameters(); LDAPMappingConfiguration relatedTypeConfig = getMappingConfig(mappingConfig.getRelatedAttributedType()); StringBuilder filter = new StringBuilder(); IdentityType identityType = (IdentityType) values[0]; if (!mappingConfig.getRelatedAttributedType().isInstance(identityType)) { attributeName = getRelationshipMappedProperty(identityType.getClass(), mappingConfig); .addCriteria(new TypedPropertyCriteria(mappingConfig.getRelatedAttributedType())) .getSingleResult();
Class<V> relationshipClass = (Class<V>) mappingConfig.getMappedClass(); Map<QueryParameter, Object[]> parameters = query.getParameters(); LDAPMappingConfiguration relatedTypeConfig = getMappingConfig(mappingConfig.getRelatedAttributedType()); StringBuilder filter = new StringBuilder(); IdentityType identityType = (IdentityType) values[0]; if (!mappingConfig.getRelatedAttributedType().isInstance(identityType)) { attributeName = getRelationshipMappedProperty(identityType.getClass(), mappingConfig); .addCriteria(new TypedPropertyCriteria(mappingConfig.getRelatedAttributedType())) .getSingleResult();