List<String> attributeNames = Collections.list(adapter.getAttributes().getIDs()); for (String attributeName : attributeNames) { try {
public NamingEnumeration<String> getIDs() { return wrapped.getIDs(); }
/** * Retrieves the map of attributes for this search entry. The values are splitted at ":" and then trimmed for whitespace. * * @param sr * @param resultMap * @return a map of attributes for this search entry. Each attribute could possibly contain more than one value, hence the list. * @throws NamingException * @author Shilo Banihit */ private Map<String, List< String>> getAllAttrValue(SearchResult sr, Map<String, List<String>> resultMap) throws NamingException { // Get all attributes Attributes entry = sr.getAttributes(); NamingEnumeration<String> ids = entry.getIDs(); while(ids.hasMore()) { String id = ids.next(); String value = entry.get(id).toString().split(":")[1].trim(); List<String> valList = resultMap.get(id); if (valList == null) { valList = new ArrayList<String>(); resultMap.put(id, valList); } valList.add(value); } return resultMap; } /**
protected String[] keysSpi() throws BackingStoreException { Attributes attrs = null; ArrayList keys = new ArrayList(); try { attrs = ctx.getAttributes( "" ); NamingEnumeration ids = attrs.getIDs(); while ( ids.hasMore() ) { String id = ( String ) ids.next(); if ( id.equals( "objectClass" ) || id.equals( "prefNodeName" ) ) { continue; } keys.add( id ); } } catch ( NamingException e ) { throw new BackingStoreException( e ); } return ( String[] ) keys.toArray( EMPTY_STRINGS ); }
return (null); NamingEnumeration attributeEnum = attributes.getIDs(); try { while (attributeEnum.hasMore()) {
return (null); NamingEnumeration attributeEnum = attributes.getIDs(); try { while (attributeEnum.hasMore()) {
return (null); NamingEnumeration<String> attributeEnum = attributes.getIDs(); try { while (attributeEnum.hasMore()) {
return (null); NamingEnumeration<String> attributeEnum = attributes.getIDs(); try { while (attributeEnum.hasMore()) {
return (null); NamingEnumeration<String> attributeEnum = attributes.getIDs(); try { while (attributeEnum.hasMore()) {
/** * Find the Rdn with the requested key in the supplied Name. * * @param name the Name in which to search for the key. * @param key the attribute key to search for. * @return the rdn corresponding to the <b>first</b> occurrence of the requested key. * @throws NoSuchElementException if no corresponding entry is found. * @since 2.0 */ public static Rdn getRdn(Name name, String key) { Assert.notNull(name, "name must not be null"); Assert.hasText(key, "key must not be blank"); LdapName ldapName = returnOrConstructLdapNameFromName(name); List<Rdn> rdns = ldapName.getRdns(); for (Rdn rdn : rdns) { NamingEnumeration<String> ids = rdn.toAttributes().getIDs(); while (ids.hasMoreElements()) { String id = ids.nextElement(); if(key.equalsIgnoreCase(id)) { return rdn; } } } throw new NoSuchElementException("No Rdn with the requested key: '" + key + "'"); }
/** * Find the Rdn with the requested key in the supplied Name. * * @param name the Name in which to search for the key. * @param key the attribute key to search for. * @return the rdn corresponding to the <b>first</b> occurrence of the requested key. * @throws NoSuchElementException if no corresponding entry is found. * @since 2.0 */ public static Rdn getRdn(Name name, String key) { Assert.notNull(name, "name must not be null"); Assert.hasText(key, "key must not be blank"); LdapName ldapName = returnOrConstructLdapNameFromName(name); List<Rdn> rdns = ldapName.getRdns(); for (Rdn rdn : rdns) { NamingEnumeration<String> ids = rdn.toAttributes().getIDs(); while (ids.hasMoreElements()) { String id = ids.nextElement(); if(key.equalsIgnoreCase(id)) { return rdn; } } } throw new NoSuchElementException("No Rdn with the requested key: '" + key + "'"); }
/** * Find the Rdn with the requested key in the supplied Name. * * @param name the Name in which to search for the key. * @param key the attribute key to search for. * @return the rdn corresponding to the <b>first</b> occurrence of the requested key. * @throws NoSuchElementException if no corresponding entry is found. * @since 2.0 */ public static Rdn getRdn(Name name, String key) { Assert.notNull(name, "name must not be null"); Assert.hasText(key, "key must not be blank"); LdapName ldapName = returnOrConstructLdapNameFromName(name); List<Rdn> rdns = ldapName.getRdns(); for (Rdn rdn : rdns) { NamingEnumeration<String> ids = rdn.toAttributes().getIDs(); while (ids.hasMoreElements()) { String id = ids.nextElement(); if(key.equalsIgnoreCase(id)) { return rdn; } } } throw new NoSuchElementException("No Rdn with the requested key: '" + key + "'"); }
/** * Find the Rdn with the requested key in the supplied Name. * * @param name the Name in which to search for the key. * @param key the attribute key to search for. * @return the rdn corresponding to the <b>first</b> occurrence of the requested key. * @throws NoSuchElementException if no corresponding entry is found. * @since 2.0 */ public static Rdn getRdn(Name name, String key) { Assert.notNull(name, "name must not be null"); Assert.hasText(key, "key must not be blank"); LdapName ldapName = returnOrConstructLdapNameFromName(name); List<Rdn> rdns = ldapName.getRdns(); for (Rdn rdn : rdns) { NamingEnumeration<String> ids = rdn.toAttributes().getIDs(); while (ids.hasMoreElements()) { String id = ids.nextElement(); if(key.equalsIgnoreCase(id)) { return rdn; } } } throw new NoSuchElementException("No Rdn with the requested key: '" + key + "'"); }
/** * Check if an entry contains some collective attributes or not * * @param entry The entry to be checked * @return <code>true</code> if the entry contains a collective attribute, <code>false</code> otherwise * @throws NamingException If something went wrong */ private boolean containsAnyCollectiveAttributes( Attributes entry ) throws NamingException { NamingEnumeration allIDs = entry.getIDs(); while ( allIDs.hasMoreElements() ) { String attrTypeStr = ( String ) allIDs.nextElement(); AttributeType attrType = attrTypeRegistry.lookup( attrTypeStr ); if ( attrType.isCollective() ) { return true; } } return false; } }
NamingEnumeration list = entry.getIDs();
/** * @see Partition#lookup(org.apache.directory.shared.ldap.name.LdapDN,String[]) */ public Attributes lookup( LdapDN dn, String[] attrIds ) throws NamingException { if ( dn.size() == 0 ) { Attributes retval = new LockableAttributesImpl(); NamingEnumeration list = rootDSE.getIDs(); while ( list.hasMore() ) { String id = ( String ) list.next(); Attribute attr = rootDSE.get( id ); retval.put( ( Attribute ) attr.clone() ); } return retval; } Partition backend = getBackend( dn ); return backend.lookup( dn, attrIds ); }
@Override public final DefaultIncrementalAttributesMapper mapFromAttributes(Attributes attributes) throws NamingException { if (!hasMore()) { throw new IllegalStateException("No more attributes!"); } // Reset the affected attributes. rangedAttributesInNextIteration = new HashSet<String>(); NamingEnumeration<String> attributeNameEnum = attributes.getIDs(); while (attributeNameEnum.hasMore()) { String attributeName = attributeNameEnum.next(); String[] attributeNameSplit = attributeName.split(";"); IncrementalAttributeState state = getState(attributeNameSplit[0]); if (attributeNameSplit.length == 1) { // No range specification for this attribute state.processValues(attributes, attributeName); } else { for (String option : attributeNameSplit) { RangeOption responseRange = RangeOption.parse(option); if (responseRange != null) { state.processValues(attributes, attributeName); state.calculateNextRange(responseRange); if (state.hasMore()) { rangedAttributesInNextIteration.add(state.getRequestedAttributeName()); } } } } } return this; }
@Override public final DefaultIncrementalAttributesMapper mapFromAttributes(Attributes attributes) throws NamingException { if (!hasMore()) { throw new IllegalStateException("No more attributes!"); } // Reset the affected attributes. rangedAttributesInNextIteration = new HashSet<String>(); NamingEnumeration<String> attributeNameEnum = attributes.getIDs(); while (attributeNameEnum.hasMore()) { String attributeName = attributeNameEnum.next(); String[] attributeNameSplit = attributeName.split(";"); IncrementalAttributeState state = getState(attributeNameSplit[0]); if (attributeNameSplit.length == 1) { // No range specification for this attribute state.processValues(attributes, attributeName); } else { for (String option : attributeNameSplit) { RangeOption responseRange = RangeOption.parse(option); if (responseRange != null) { state.processValues(attributes, attributeName); state.calculateNextRange(responseRange); if (state.hasMore()) { rangedAttributesInNextIteration.add(state.getRequestedAttributeName()); } } } } } return this; }
/** * Filters out the operational attributes within a search results attributes. The attributes are directly * modified. * * @param attributes the resultant attributes to filter * @return true always */ private boolean filter( Attributes attributes ) throws NamingException { NamingEnumeration list = attributes.getIDs(); while ( list.hasMore() ) { String attrId = ( String ) list.next(); AttributeType type = null; if ( registry.hasAttributeType( attrId ) ) { type = registry.lookup( attrId ); } if ( type != null && type.getUsage() != UsageEnum.USERAPPLICATIONS ) { // just make sure we do not remove the ref attribute if ( ! type.getOid().equals( refAttrOid.getOid() ) ) { attributes.remove( attrId ); } } } return true; }
/** * Marshals a RecordStoreEntry from an Attributes object. * * @param attrs the attributes of the DNS question * @return the entry for the question * @throws NamingException if there are any access problems */ private ResourceRecord getRecord( Attributes attrs ) throws NamingException { ResourceRecordModifier modifier = new ResourceRecordModifier(); String dnsName = getAttrOrNull( attrs, DnsAttribute.NAME ); String dnsType = getAttrOrNull( attrs, DnsAttribute.TYPE ); String dnsClass = getAttrOrNull( attrs, DnsAttribute.CLASS ); String dnsTtl = getAttrOrNull( attrs, DnsAttribute.TTL ); modifier.setDnsName( dnsName ); modifier.setDnsType( RecordType.valueOf( dnsType ) ); modifier.setDnsClass( RecordClass.valueOf( dnsClass ) ); modifier.setDnsTtl( Integer.parseInt( dnsTtl ) ); NamingEnumeration<String> ids = attrs.getIDs(); while ( ids.hasMore() ) { String id = ids.next(); modifier.put( id, ( String ) attrs.get( id ).get() ); } return modifier.getEntry(); }