* @throws Exception if there are failures accessing the underlying store
*/
@SuppressWarnings("unchecked")
public Entry getAttributes( Store<Object, Long> store, Long id ) throws Exception
{
Entry entry = new DefaultClientEntry();
// Get the distinguishedName to id mapping
entry.put( "_nDn", store.getEntryDn( id ) );
entry.put( "_upDn", store.getEntryUpdn( id ) );
entry.put( "_parent", Long.toString( store.getParentId( id ) ) );
// Get all standard index attribute to value mappings
for ( Index index : store.getUserIndices() )
{
Cursor<ForwardIndexEntry> list = index.reverseCursor();
ForwardIndexEntry recordForward = new ForwardIndexEntry();
recordForward.setId( id );
list.before( recordForward );
while ( list.next() )
{
IndexEntry rec = list.get();
String val = rec.getValue().toString();
String attrId = index.getAttribute().getName();
EntryAttribute attr = entry.get( attrId );
if ( attr == null )
{
attr = new DefaultClientAttribute( attrId );
}
attr.add( val );
entry.put( attr );
}
}
// Get all existence mappings for this id creating a special key
// that looks like so 'existence[attribute]' and the value is set to id
IndexCursor<String, Object, Long> list = store.getPresenceIndex().reverseCursor();
ForwardIndexEntry recordForward = new ForwardIndexEntry();
recordForward.setId( id );
list.before( recordForward );
StringBuffer val = new StringBuffer();
while ( list.next() )
{
IndexEntry rec = list.get();
val.append( "_existence[" );
val.append( rec.getValue().toString() );
val.append( "]" );
String valStr = val.toString();
EntryAttribute attr = entry.get( valStr );
if ( attr == null )
{
attr = new DefaultClientAttribute( valStr );
}
attr.add( rec.getId().toString() );
entry.put( attr );
val.setLength( 0 );
}
// Get all parent child mappings for this entry as the parent using the
// key 'child' with many entries following it.
IndexCursor<Long, Object, Long> children = store.getOneLevelIndex().forwardCursor();
ForwardIndexEntry longRecordForward = new ForwardIndexEntry();
recordForward.setId( id );
children.before( longRecordForward );
EntryAttribute childAttr = new DefaultClientAttribute( "_child" );
entry.put( childAttr );
while ( children.next() )
{
IndexEntry rec = children.get();
childAttr.add( rec.getId().toString() );