You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2006/02/10 11:49:57 UTC
svn commit: r376623 [13/38] - in /directory/sandbox/akarasulu/rc1/apacheds:
core-plugin/src/main/java/org/apache/directory/server/core/tools/schema/
core-plugin/src/test/java/org/apache/directory/server/core/tools/schema/
core-shared/src/main/java/org/...
Modified: directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java Fri Feb 10 02:48:07 2006
@@ -86,7 +86,7 @@
*/
public class PartitionFrame extends JFrame
{
- private static final Logger log = LoggerFactory.getLogger(PartitionFrame.class);
+ private static final Logger log = LoggerFactory.getLogger( PartitionFrame.class );
private static final long serialVersionUID = 4049353102291513657L;
@@ -120,8 +120,7 @@
/**
* Creates new form JFrame
*/
- public PartitionFrame( BTreeDirectoryPartition db, SearchEngine eng )
- throws NamingException
+ public PartitionFrame(BTreeDirectoryPartition db, SearchEngine eng) throws NamingException
{
partition = db;
this.eng = eng;
@@ -169,9 +168,9 @@
// --------------------------------------------------------------------
// 'Backend' Menu
// --------------------------------------------------------------------
-
+
JMenu backendMenu = new JMenu( "Backend" );
- backendMenu.setText("Partition");
+ backendMenu.setText( "Partition" );
backendMenu.setBackground( new java.awt.Color( 205, 205, 205 ) );
backendMenu.setMnemonic( 'B' );
@@ -182,7 +181,7 @@
add.setBackground( new java.awt.Color( 205, 205, 205 ) );
add.addActionListener( new ActionListener()
{
- public void actionPerformed( ActionEvent e )
+ public void actionPerformed( ActionEvent e )
{
doAddDialog();
}
@@ -195,7 +194,7 @@
importItem.setBackground( new java.awt.Color( 205, 205, 205 ) );
importItem.addActionListener( new ActionListener()
{
- public void actionPerformed( ActionEvent e )
+ public void actionPerformed( ActionEvent e )
{
doImport();
}
@@ -208,7 +207,7 @@
exit.setBackground( new java.awt.Color( 205, 205, 205 ) );
exit.addActionListener( new ActionListener()
{
- public void actionPerformed( ActionEvent e )
+ public void actionPerformed( ActionEvent e )
{
exitForm();
}
@@ -219,23 +218,22 @@
helpMenu.setMnemonic( 'H' );
JMenuItem about = new JMenuItem( "About" );
about.setMnemonic( 'A' );
- about.setBackground( new java.awt.Color( 205,205,205 ) );
+ about.setBackground( new java.awt.Color( 205, 205, 205 ) );
about.addActionListener( new ActionListener()
{
- public void actionPerformed( ActionEvent e )
+ public void actionPerformed( ActionEvent e )
{
- AboutDialog aboutDialog =
- new AboutDialog ( PartitionFrame.this, true );
+ AboutDialog aboutDialog = new AboutDialog( PartitionFrame.this, true );
PartitionFrame.this.centerOnScreen( aboutDialog );
aboutDialog.setVisible( true );
}
} );
- helpMenu.setBackground( new java.awt.Color( 205,205,205 ) );
+ helpMenu.setBackground( new java.awt.Color( 205, 205, 205 ) );
helpMenu.add( about );
-
+
// create Save menu item
// create Print menu item
- menuBar.setBackground( new java.awt.Color( 196,197,203 ) );
+ menuBar.setBackground( new java.awt.Color( 196, 197, 203 ) );
menuBar.add( backendMenu );
menuBar.add( searchMenu );
menuBar.add( indices );
@@ -243,26 +241,25 @@
// sets menu bar
setJMenuBar( menuBar );
setBounds( new java.awt.Rectangle( 0, 0, 802, 515 ) );
- setSize( new java.awt.Dimension( 802,515 ) );
+ setSize( new java.awt.Dimension( 802, 515 ) );
setResizable( true );
-
- addWindowListener( new java.awt.event.WindowAdapter()
+
+ addWindowListener( new java.awt.event.WindowAdapter()
{
- public void windowClosing( java.awt.event.WindowEvent evt )
+ public void windowClosing( java.awt.event.WindowEvent evt )
{
exitForm();
}
} );
-
+
treePane.getViewport().add( tree );
- tree.setBounds( new java.awt.Rectangle( 6,184,82,80 ) );
+ tree.setBounds( new java.awt.Rectangle( 6, 184, 82, 80 ) );
tree.setShowsRootHandles( true );
tree.setToolTipText( "DB DIT" );
tree.setScrollsOnExpand( true );
- tree.getSelectionModel().addTreeSelectionListener(
- new TreeSelectionListener()
+ tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener()
{
- public void valueChanged( TreeSelectionEvent e )
+ public void valueChanged( TreeSelectionEvent e )
{
TreePath path = e.getNewLeadSelectionPath();
@@ -272,15 +269,14 @@
}
Object last = path.getLastPathComponent();
- try
+ try
{
if ( last instanceof EntryNode )
{
- displayEntry( ( ( EntryNode ) last ).getEntryId(),
- ( ( EntryNode ) last).getLdapEntry() );
+ displayEntry( ( ( EntryNode ) last ).getEntryId(), ( ( EntryNode ) last ).getLdapEntry() );
}
- }
- catch( Exception ex )
+ }
+ catch ( Exception ex )
{
ex.printStackTrace();
}
@@ -288,31 +284,31 @@
} );
entryPane.getViewport().add( entryTbl );
- entryTbl.setBounds( new java.awt.Rectangle( 321,103,32,32 ) );
+ entryTbl.setBounds( new java.awt.Rectangle( 321, 103, 32, 32 ) );
idxPane.getViewport().add( idxTbl );
- idxTbl.setBounds( new java.awt.Rectangle( 429,134,32,32 ) );
+ idxTbl.setBounds( new java.awt.Rectangle( 429, 134, 32, 32 ) );
treePane.setSize( new java.awt.Dimension( 285, 435 ) );
treePane.setPreferredSize( new java.awt.Dimension( 285, 403 ) );
searchMenu.setText( "Search" );
- searchMenu.setBackground( new java.awt.Color( 205,205,205 ) );
+ searchMenu.setBackground( new java.awt.Color( 205, 205, 205 ) );
searchMenu.add( run );
searchMenu.add( debug );
searchMenu.add( annotate );
ActionListener searchHandler = new ActionListener()
{
- public void actionPerformed( ActionEvent an_event )
+ public void actionPerformed( ActionEvent an_event )
{
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
log.debug( "action command = " + an_event.getActionCommand() );
try
{
doFilterDialog( an_event.getActionCommand() );
}
- catch( NamingException e )
+ catch ( NamingException e )
{
e.printStackTrace();
}
@@ -321,17 +317,17 @@
annotate.setText( FilterDialog.ANNOTATE_MODE );
annotate.setActionCommand( FilterDialog.ANNOTATE_MODE );
- annotate.setBackground( new java.awt.Color( 205,205,205 ) );
+ annotate.setBackground( new java.awt.Color( 205, 205, 205 ) );
annotate.addActionListener( searchHandler );
run.setText( FilterDialog.RUN_MODE );
run.setActionCommand( FilterDialog.RUN_MODE );
- run.setBackground( new java.awt.Color( 205,205,205 ) );
+ run.setBackground( new java.awt.Color( 205, 205, 205 ) );
run.addActionListener( searchHandler );
debug.setText( FilterDialog.DEBUG_MODE );
debug.setActionCommand( FilterDialog.DEBUG_MODE );
- debug.setBackground( new java.awt.Color( 205,205,205 ) );
+ debug.setBackground( new java.awt.Color( 205, 205, 205 ) );
debug.addActionListener( searchHandler );
indices.setText( "Indices" );
@@ -343,22 +339,19 @@
{
Dimension frameSize = window.getSize();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
-
- frameSize.height = ( ( frameSize.height > screenSize.height )
- ? screenSize.height : frameSize.height );
- frameSize.width = ( ( frameSize.width > screenSize.width )
- ? screenSize.width : frameSize.width );
- window.setLocation( ( screenSize.width - frameSize.width ) / 2,
- ( screenSize.height - frameSize.height ) / 2 );
+
+ frameSize.height = ( ( frameSize.height > screenSize.height ) ? screenSize.height : frameSize.height );
+ frameSize.width = ( ( frameSize.width > screenSize.width ) ? screenSize.width : frameSize.width );
+ window.setLocation( ( screenSize.width - frameSize.width ) / 2, ( screenSize.height - frameSize.height ) / 2 );
}
-
+
/**
* Displays a entry addition dialog.
*/
public void doAddDialog()
{
- try
+ try
{
TreePath path = tree.getSelectionModel().getSelectionPath();
String parentDn = partition.getSuffix( false ).toString();
@@ -367,22 +360,21 @@
{
Object last = path.getLastPathComponent();
- if( last instanceof EntryNode )
+ if ( last instanceof EntryNode )
{
parentDn = ( ( EntryNode ) last ).getEntryDn();
- }
+ }
}
-
+
if ( null == parentDn )
{
- JOptionPane.showMessageDialog( this,
- "Must select a parent entry to add a child to!" );
+ JOptionPane.showMessageDialog( this, "Must select a parent entry to add a child to!" );
return;
}
-
+
AddEntryDialog dialog = new AddEntryDialog( this, false );
dialog.setParentDn( parentDn );
-
+
centerOnScreen( dialog );
dialog.setEnabled( true );
dialog.setVisible( true );
@@ -392,7 +384,7 @@
e.printStackTrace();
}
}
-
+
/**
* Gets the DN of the DIT node selected in the tree view.
@@ -403,16 +395,16 @@
public String getSelectedDn() throws NamingException
{
TreePath path = tree.getSelectionModel().getSelectionPath();
-
+
if ( null == path )
{
return partition.getSuffix( false ).toString();
- }
-
+ }
+
Object last = path.getLastPathComponent();
String base = null;
-
- if( last instanceof EntryNode )
+
+ if ( last instanceof EntryNode )
{
try
{
@@ -422,15 +414,15 @@
{
e.printStackTrace();
}
- }
- else
+ }
+ else
{
base = partition.getSuffix( false ).toString();
}
-
+
return base;
}
-
+
public void doImport()
{
@@ -440,25 +432,24 @@
JFileChooser chooser = new JFileChooser();
int choice = chooser.showOpenDialog( this );
File selected = chooser.getSelectedFile();
-
+
if ( JFileChooser.APPROVE_OPTION != choice )
{
return;
}
- try
+ try
{
in = new FileReader( selected );
list = new LdifIterator( in );
-
+
while ( list.hasNext() )
{
String dif = ( String ) list.next();
LockableAttributesImpl attrs = new LockableAttributesImpl();
parser.parse( attrs, dif );
String updn = ( String ) attrs.get( "dn" ).get();
- LdapName ndn =
- new LdapName( StringTools.deepTrimToLower( updn ) );
+ LdapName ndn = new LdapName( StringTools.deepTrimToLower( updn ) );
attrs.remove( "dn" );
if ( null == partition.getEntryId( ndn.toString() ) )
@@ -468,25 +459,25 @@
}
}
}
- catch( NamingException e )
+ catch ( NamingException e )
{
// @todo display popup with error here!
e.printStackTrace();
return;
- }
- catch( FileNotFoundException e )
+ }
+ catch ( FileNotFoundException e )
{
// @todo display popup with error here!
e.printStackTrace();
return;
}
- catch( IOException e )
+ catch ( IOException e )
{
// @todo display popup with error here!
e.printStackTrace();
return;
}
- catch( Exception e )
+ catch ( Exception e )
{
// @todo display popup with error here!
e.printStackTrace();
@@ -498,7 +489,7 @@
/**
* Exit the Application
*/
- private void exitForm()
+ private void exitForm()
{
setEnabled( false );
setVisible( false );
@@ -516,39 +507,37 @@
e.printStackTrace();
}
- System.exit( 0 );
+ System.exit( 0 );
}
}
-
-
+
+
public void doRunDebugAnnotate( FilterDialog dialog, String mode )
{
- try
+ try
{
if ( mode == FilterDialog.RUN_MODE )
{
- doRun( dialog.getFilter(), dialog.getScope(),
- dialog.getBase(), dialog.getLimit() );
- }
+ doRun( dialog.getFilter(), dialog.getScope(), dialog.getBase(), dialog.getLimit() );
+ }
else if ( mode == FilterDialog.DEBUG_MODE )
{
- doDebug( dialog.getFilter(), dialog.getScope(),
- dialog.getBase(), dialog.getLimit() );
- }
+ doDebug( dialog.getFilter(), dialog.getScope(), dialog.getBase(), dialog.getLimit() );
+ }
else if ( mode == FilterDialog.ANNOTATE_MODE )
{
if ( doAnnotate( dialog.getFilter() ) )
{
// continue
- }
- else
+ }
+ else
{
// We failed don't loose users filter buf
// allow user to make edits.
return;
}
- }
- else
+ }
+ else
{
throw new RuntimeException( "Unrecognized mode." );
}
@@ -568,34 +557,33 @@
if ( tree.getSelectionModel().getSelectionPath() != null )
{
dialog.setBase( getSelectedDn() );
- }
- else
+ }
+ else
{
dialog.setBase( partition.getSuffix( false ).toString() );
}
dialog.addActionListener( new ActionListener()
{
- public void actionPerformed( ActionEvent an_event )
+ public void actionPerformed( ActionEvent an_event )
{
String cmd = an_event.getActionCommand();
if ( cmd.equals( FilterDialog.SEARCH_CMD ) )
{
doRunDebugAnnotate( dialog, mode );
- }
- else if ( cmd.equals(FilterDialog.CANCEL_CMD ) )
+ }
+ else if ( cmd.equals( FilterDialog.CANCEL_CMD ) )
{
// Do nothing! Just exit dialog.
- }
- else
+ }
+ else
{
- throw new RuntimeException(
- "Unrecognized FilterDialog command: " + cmd );
+ throw new RuntimeException( "Unrecognized FilterDialog command: " + cmd );
}
- dialog.setVisible( false );
- dialog.dispose();
+ dialog.setVisible( false );
+ dialog.dispose();
}
} );
@@ -604,28 +592,25 @@
centerOnScreen( dialog );
dialog.setEnabled( true );
dialog.setVisible( true );
- }
+ }
- public boolean doRun( String filter, String scope, String base,
- String limit )
- throws Exception
+ public boolean doRun( String filter, String scope, String base, String limit ) throws Exception
{
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug( "Search attempt using filter '" + filter + "' "
- + "with scope '" + scope + "' and a return limit of '" + limit
- + "'" );
+ log.debug( "Search attempt using filter '" + filter + "' " + "with scope '" + scope
+ + "' and a return limit of '" + limit + "'" );
}
FilterParser parser = new FilterParserImpl();
ExprNode root = null;
- try
+ try
{
root = parser.parse( filter );
- }
- catch ( Exception e )
+ }
+ catch ( Exception e )
{
e.printStackTrace();
JTextArea text = new JTextArea();
@@ -638,8 +623,7 @@
text.setText( msg );
text.setEnabled( false );
- JOptionPane.showMessageDialog( null, text, "Syntax Error",
- JOptionPane.ERROR_MESSAGE );
+ JOptionPane.showMessageDialog( null, text, "Syntax Error", JOptionPane.ERROR_MESSAGE );
return false;
}
@@ -647,38 +631,37 @@
if ( scope == FilterDialog.BASE_SCOPE )
{
- ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
- }
+ ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
+ }
else if ( scope == FilterDialog.SINGLE_SCOPE )
{
ctls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
- }
+ }
else if ( scope == FilterDialog.SUBTREE_SCOPE )
{
ctls.setSearchScope( SearchControls.SUBTREE_SCOPE );
- } else {
- throw new RuntimeException( "Unexpected scope parameter: " +
- scope );
+ }
+ else
+ {
+ throw new RuntimeException( "Unexpected scope parameter: " + scope );
}
int limitMax = Integer.MAX_VALUE;
- if ( ! limit.equals( FilterDialog.UNLIMITED ) )
+ if ( !limit.equals( FilterDialog.UNLIMITED ) )
{
limitMax = Integer.parseInt( limit );
}
Hashtable env = new Hashtable();
- env.put( DerefAliasesEnum.JNDI_PROP,
- DerefAliasesEnum.DEREFALWAYS_NAME );
+ env.put( DerefAliasesEnum.JNDI_PROP, DerefAliasesEnum.DEREFALWAYS_NAME );
- NamingEnumeration cursor = eng.search( new LdapName( base ),
- env, root, ctls );
- String [] cols = new String [2];
+ NamingEnumeration cursor = eng.search( new LdapName( base ), env, root, ctls );
+ String[] cols = new String[2];
cols[0] = "id";
cols[1] = "dn";
DefaultTableModel tableModel = new DefaultTableModel( cols, 0 );
- Object [] row = new Object[2];
+ Object[] row = new Object[2];
int count = 0;
while ( cursor.hasMore() && count < limitMax )
{
@@ -718,14 +701,12 @@
}
- public void doDebug( String filter, String scope, String base,
- String limit )
+ public void doDebug( String filter, String scope, String base, String limit )
{
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug( "Search attempt using filter '" + filter + "' "
- + "with scope '" + scope + "' and a return limit of '" + limit
- + "'" );
+ log.debug( "Search attempt using filter '" + filter + "' " + "with scope '" + scope
+ + "' and a return limit of '" + limit + "'" );
}
}
@@ -733,7 +714,7 @@
public void selectTreeNode( BigInteger id )
{
Stack stack = new Stack();
- Object [] comps = null;
+ Object[] comps = null;
TreeNode parent = ( EntryNode ) nodes.get( id );
while ( parent != null && ( parent != parent.getParent() ) )
@@ -746,8 +727,8 @@
{
comps = new Object[1];
comps[0] = root;
- }
- else
+ }
+ else
{
comps = new Object[stack.size()];
}
@@ -764,17 +745,16 @@
}
- public boolean doAnnotate( String filter )
- throws Exception
+ public boolean doAnnotate( String filter ) throws Exception
{
- FilterParser parser = new FilterParserImpl();
+ FilterParser parser = new FilterParserImpl();
ExprNode root = null;
- try
+ try
{
root = parser.parse( filter );
- }
- catch( Exception e )
+ }
+ catch ( Exception e )
{
JTextArea text = new JTextArea();
String msg = e.getMessage();
@@ -786,19 +766,17 @@
text.setText( msg );
text.setEnabled( false );
- JOptionPane.showMessageDialog( null, text, "Syntax Error",
- JOptionPane.ERROR_MESSAGE );
+ JOptionPane.showMessageDialog( null, text, "Syntax Error", JOptionPane.ERROR_MESSAGE );
return false;
}
- AnnotatedFilterTreeDialog treeDialog = new
- AnnotatedFilterTreeDialog( PartitionFrame.this, false );
- treeDialog.setFilter( filter );
+ AnnotatedFilterTreeDialog treeDialog = new AnnotatedFilterTreeDialog( PartitionFrame.this, false );
+ treeDialog.setFilter( filter );
eng.getOptimizer().annotate( root );
- TreeNode astRoot = new ASTNode( null, root );
- TreeModel model = new DefaultTreeModel( astRoot, true );
- treeDialog.setModel( model );
+ TreeNode astRoot = new ASTNode( null, root );
+ TreeModel model = new DefaultTreeModel( astRoot, true );
+ treeDialog.setModel( model );
treeDialog.setVisible( true );
return true;
}
@@ -810,17 +788,16 @@
* @param idxAttr the name of the index or its attribute
* @throws Exception if the indices cannot be accessed
*/
- public void showIndexDialog( String idxAttr )
- throws Exception
+ public void showIndexDialog( String idxAttr ) throws Exception
{
Index index = null;
boolean isSystem = partition.hasSystemIndexOn( idxAttr );
-
+
if ( isSystem )
{
index = partition.getSystemIndex( idxAttr );
}
- else
+ else
{
index = partition.getUserIndex( idxAttr );
}
@@ -838,16 +815,16 @@
public void buildIndicesMenu( BTreeDirectoryPartition partition )
{
JMenuItem item = null;
-
+
ActionListener listener = new ActionListener()
{
public void actionPerformed( ActionEvent event )
{
- try
+ try
{
showIndexDialog( event.getActionCommand() );
- }
- catch ( Exception e )
+ }
+ catch ( Exception e )
{
e.printStackTrace();
}
@@ -871,7 +848,7 @@
while ( list.hasNext() )
{
String idx = ( String ) list.next();
- item = new JMenuItem();
+ item = new JMenuItem();
item.setBackground( new java.awt.Color( 205, 205, 205 ) );
indices.add( item );
item.setText( idx );
@@ -881,16 +858,13 @@
}
- void displayEntry( BigInteger id, Attributes entry )
- throws Exception
+ void displayEntry( BigInteger id, Attributes entry ) throws Exception
{
String dn = partition.getEntryUpdn( id );
- AttributesTableModel model =
- new AttributesTableModel( entry, id, dn, false );
+ AttributesTableModel model = new AttributesTableModel( entry, id, dn, false );
entryTbl.setModel( model );
- model = new AttributesTableModel(
- partition.getIndices( id ), id, dn, false );
+ model = new AttributesTableModel( partition.getIndices( id ), id, dn, false );
idxTbl.setModel( model );
validate();
@@ -903,66 +877,65 @@
nodes = new HashMap();
Attributes suffix = partition.getSuffixEntry();
- BigInteger id = partition.getEntryId(
- partition.getSuffix( false ).toString() );
+ BigInteger id = partition.getEntryId( partition.getSuffix( false ).toString() );
root = new EntryNode( id, null, partition, suffix, nodes );
/*
- int option = JOptionPane.showConfirmDialog( null,
- "Would you like to filter leaf nodes on load?", "Use Filter?",
- JOptionPane.OK_CANCEL_OPTION );
- doFiltered = option == JOptionPane.OK_OPTION;
-
- if(doFiltered) {
- SearchEngine engine = new SearchEngine();
- final FilterDialog dialog =
- new FilterDialog(FilterDialog.LOAD_MODE, this, true);
- dialog.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- dialog.setVisible(false);
- dialog.dispose();
- }
- });
-
- dialog.setBase(database.getSuffix().toString());
- dialog.setScope(FilterDialog.SUBTREE_SCOPE);
-
- //Center the frame on screen
- dialog.setSize(456, 256);
- this.centerOnScreen( dialog );
- dialog.setEnabled(true);
- dialog.setVisible(true);
-
- FilterParser parser = new FilterParserImpl();
- parser.enableLogging(logger);
- ExprNode exprNode = parser.parse(dialog.getFilter());
-
- int scope = -1;
- String scopeStr = dialog.getScope();
- if(scopeStr == FilterDialog.BASE_SCOPE) {
- scope = Backend.BASE_SCOPE;
- } else if(scopeStr == FilterDialog.SINGLE_SCOPE) {
- scope = Backend.SINGLE_SCOPE;
- } else if(scopeStr == FilterDialog.SUBTREE_SCOPE) {
- scope = Backend.SUBTREE_SCOPE;
- } else {
- throw new RuntimeException("Unrecognized scope");
- }
-
- exprNode =
- engine.addScopeNode(exprNode, dialog.getBase(), scope);
- root = new EntryNode(null, database,
- database.getSuffixEntry(), nodes, exprNode, engine);
- } else {
- root = new EntryNode(null, database,
- database.getSuffixEntry(), nodes);
- }
- */
+ int option = JOptionPane.showConfirmDialog( null,
+ "Would you like to filter leaf nodes on load?", "Use Filter?",
+ JOptionPane.OK_CANCEL_OPTION );
+ doFiltered = option == JOptionPane.OK_OPTION;
+
+ if(doFiltered) {
+ SearchEngine engine = new SearchEngine();
+ final FilterDialog dialog =
+ new FilterDialog(FilterDialog.LOAD_MODE, this, true);
+ dialog.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ dialog.setVisible(false);
+ dialog.dispose();
+ }
+ });
+
+ dialog.setBase(database.getSuffix().toString());
+ dialog.setScope(FilterDialog.SUBTREE_SCOPE);
+
+ //Center the frame on screen
+ dialog.setSize(456, 256);
+ this.centerOnScreen( dialog );
+ dialog.setEnabled(true);
+ dialog.setVisible(true);
+
+ FilterParser parser = new FilterParserImpl();
+ parser.enableLogging(logger);
+ ExprNode exprNode = parser.parse(dialog.getFilter());
+
+ int scope = -1;
+ String scopeStr = dialog.getScope();
+ if(scopeStr == FilterDialog.BASE_SCOPE) {
+ scope = Backend.BASE_SCOPE;
+ } else if(scopeStr == FilterDialog.SINGLE_SCOPE) {
+ scope = Backend.SINGLE_SCOPE;
+ } else if(scopeStr == FilterDialog.SUBTREE_SCOPE) {
+ scope = Backend.SUBTREE_SCOPE;
+ } else {
+ throw new RuntimeException("Unrecognized scope");
+ }
+
+ exprNode =
+ engine.addScopeNode(exprNode, dialog.getBase(), scope);
+ root = new EntryNode(null, database,
+ database.getSuffixEntry(), nodes, exprNode, engine);
+ } else {
+ root = new EntryNode(null, database,
+ database.getSuffixEntry(), nodes);
+ }
+ */
DefaultTreeModel model = new DefaultTreeModel( root );
tree.setModel( model );
- if ( isVisible() )
+ if ( isVisible() )
{
tree.validate();
}
Modified: directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionViewer.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionViewer.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionViewer.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionViewer.java Fri Feb 10 02:48:07 2006
@@ -14,7 +14,7 @@
* limitations under the License.
*
*/
-package org.apache.directory.server.core.partition.impl.btree.gui ;
+package org.apache.directory.server.core.partition.impl.btree.gui;
import java.awt.Dimension;
@@ -36,67 +36,63 @@
*/
public class PartitionViewer
{
- private static final Logger log = LoggerFactory.getLogger(PartitionViewer.class);
+ private static final Logger log = LoggerFactory.getLogger( PartitionViewer.class );
/** A handle on the atomic partition */
private BTreeDirectoryPartition partition;
private SearchEngine eng;
- public PartitionViewer( BTreeDirectoryPartition db, SearchEngine eng )
+ public PartitionViewer(BTreeDirectoryPartition db, SearchEngine eng)
{
this.partition = db;
this.eng = eng;
}
-// /**
-// * Viewer main is not really used.
-// *
-// * @param argv the var args
-// */
-// public static void main( String [] argv )
-// {
-// // set up system Look&Feel
-// try
-// {
-// UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() ) ;
-// }
-// catch ( Exception e )
-// {
-// System.out.println( "Could not set look and feel to use " +
-// UIManager.getSystemLookAndFeelClassName() + "." ) ;
-// e.printStackTrace() ;
-// }
-//
-// PartitionViewer viewer = new PartitionViewer( ) ;
-//
-// try
-// {
-// viewer.execute() ;
-// }
-// catch ( Exception e )
-// {
-// e.printStackTrace() ;
-// System.exit( -1 ) ;
-// }
-// }
-
+ // /**
+ // * Viewer main is not really used.
+ // *
+ // * @param argv the var args
+ // */
+ // public static void main( String [] argv )
+ // {
+ // // set up system Look&Feel
+ // try
+ // {
+ // UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() ) ;
+ // }
+ // catch ( Exception e )
+ // {
+ // System.out.println( "Could not set look and feel to use " +
+ // UIManager.getSystemLookAndFeelClassName() + "." ) ;
+ // e.printStackTrace() ;
+ // }
+ //
+ // PartitionViewer viewer = new PartitionViewer( ) ;
+ //
+ // try
+ // {
+ // viewer.execute() ;
+ // }
+ // catch ( Exception e )
+ // {
+ // e.printStackTrace() ;
+ // System.exit( -1 ) ;
+ // }
+ // }
public void execute() throws NamingException
{
- PartitionFrame frame = new PartitionFrame( partition, eng ) ;
+ PartitionFrame frame = new PartitionFrame( partition, eng );
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize() ;
- Dimension frameSize = frame.getSize() ;
- frameSize.height = ( ( frameSize.height > screenSize.height )
- ? screenSize.height : frameSize.height) ;
- frameSize.width = ( ( frameSize.width > screenSize.width )
- ? screenSize.width : frameSize.width ) ;
- frame.setLocation( ( screenSize.width - frameSize.width ) / 2,
- ( screenSize.height - frameSize.height ) / 2) ;
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ Dimension frameSize = frame.getSize();
+ frameSize.height = ( ( frameSize.height > screenSize.height ) ? screenSize.height : frameSize.height );
+ frameSize.width = ( ( frameSize.width > screenSize.width ) ? screenSize.width : frameSize.width );
+ frame.setLocation( ( screenSize.width - frameSize.width ) / 2, ( screenSize.height - frameSize.height ) / 2 );
frame.setVisible( true );
- log.debug( frameSize + "") ;
+ log.debug( frameSize + "" );
}
}
Modified: directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/SearchResultDialog.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/SearchResultDialog.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/SearchResultDialog.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/SearchResultDialog.java Fri Feb 10 02:48:07 2006
@@ -14,7 +14,7 @@
* limitations under the License.
*
*/
-package org.apache.directory.server.core.partition.impl.btree.gui ;
+package org.apache.directory.server.core.partition.impl.btree.gui;
import java.awt.Frame;
@@ -58,118 +58,133 @@
private JScrollPane jScrollPane2 = new JScrollPane();
private JTable m_resultsTbl = new JTable();
+
/** Creates new form JDialog */
- public SearchResultDialog(Frame parent, boolean modal) {
- super(parent, modal);
+ public SearchResultDialog(Frame parent, boolean modal)
+ {
+ super( parent, modal );
initGUI();
}
+
/**
* This method is called from within the constructor to initialize the form.
*/
- private void initGUI() {
- addWindowListener(
- new java.awt.event.WindowAdapter() {
- public void windowClosing(java.awt.event.WindowEvent evt) {
- closeDialog(evt);
- }
- });
+ private void initGUI()
+ {
+ addWindowListener( new java.awt.event.WindowAdapter()
+ {
+ public void windowClosing( java.awt.event.WindowEvent evt )
+ {
+ closeDialog( evt );
+ }
+ } );
pack();
- getContentPane().setLayout(new java.awt.GridBagLayout());
- getContentPane().add(jPanel1,
- new java.awt.GridBagConstraints(0, 0, 1, 1, 1.0, 0.1, java.awt.GridBagConstraints.NORTH, java.awt.GridBagConstraints.BOTH,
- new java.awt.Insets(10, 5, 5, 5), 0, 0));
- getContentPane().add(jPanel2,
- new java.awt.GridBagConstraints(0, 1, 1, 1, 1.0, 0.4, java.awt.GridBagConstraints.CENTER, java.awt.GridBagConstraints.BOTH,
- new java.awt.Insets(5, 5, 5, 5), 0, 0));
- getContentPane().add(jPanel3,
- new java.awt.GridBagConstraints(0, 3, 1, 1, 1.0, 0.1, java.awt.GridBagConstraints.SOUTH, java.awt.GridBagConstraints.BOTH,
- new java.awt.Insets(0, 0, 0, 0), 0, 0));
- getContentPane().add(jPanel4,
- new java.awt.GridBagConstraints(0, 2, 1, 1, 1.0, 0.4, java.awt.GridBagConstraints.CENTER, java.awt.GridBagConstraints.BOTH,
- new java.awt.Insets(5, 5, 5, 5), 0, 0));
- jPanel1.setLayout(new java.awt.BorderLayout(10, 10));
- jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(
- new java.awt.Color(153, 153, 153), 1), "Specifications", javax.swing.border.TitledBorder.LEADING, javax.swing.border.TitledBorder.TOP,
- new java.awt.Font("SansSerif", 0, 14), new java.awt.Color(60, 60, 60)));
- jPanel1.add(jTextArea1, java.awt.BorderLayout.CENTER);
- jScrollPane1.getViewport().add(jTree1);
- jTree1.setBounds(new java.awt.Rectangle(238,142,82,80));
- jTextArea1.setText("");
- jTextArea1.setEditable(false);
- setBounds(new java.awt.Rectangle(0, 0, 485, 434));
- setTitle("Search Results");
- jPanel2.setLayout(new java.awt.BorderLayout());
- jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(
- new java.awt.Color(153, 153, 153), 1),
- "Filter Expression Tree", javax.swing.border.TitledBorder.LEADING, javax.swing.border.TitledBorder.TOP,
- new java.awt.Font("SansSerif", 0, 14), new java.awt.Color(60, 60, 60)));
- jPanel2.add(jScrollPane1, java.awt.BorderLayout.CENTER);
- jButton1.setText("Done");
- jButton1.setActionCommand("Done");
- jButton1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- SearchResultDialog.this.setVisible(false) ;
- SearchResultDialog.this.dispose() ;
+ getContentPane().setLayout( new java.awt.GridBagLayout() );
+ getContentPane().add(
+ jPanel1,
+ new java.awt.GridBagConstraints( 0, 0, 1, 1, 1.0, 0.1, java.awt.GridBagConstraints.NORTH,
+ java.awt.GridBagConstraints.BOTH, new java.awt.Insets( 10, 5, 5, 5 ), 0, 0 ) );
+ getContentPane().add(
+ jPanel2,
+ new java.awt.GridBagConstraints( 0, 1, 1, 1, 1.0, 0.4, java.awt.GridBagConstraints.CENTER,
+ java.awt.GridBagConstraints.BOTH, new java.awt.Insets( 5, 5, 5, 5 ), 0, 0 ) );
+ getContentPane().add(
+ jPanel3,
+ new java.awt.GridBagConstraints( 0, 3, 1, 1, 1.0, 0.1, java.awt.GridBagConstraints.SOUTH,
+ java.awt.GridBagConstraints.BOTH, new java.awt.Insets( 0, 0, 0, 0 ), 0, 0 ) );
+ getContentPane().add(
+ jPanel4,
+ new java.awt.GridBagConstraints( 0, 2, 1, 1, 1.0, 0.4, java.awt.GridBagConstraints.CENTER,
+ java.awt.GridBagConstraints.BOTH, new java.awt.Insets( 5, 5, 5, 5 ), 0, 0 ) );
+ jPanel1.setLayout( new java.awt.BorderLayout( 10, 10 ) );
+ jPanel1.setBorder( javax.swing.BorderFactory.createTitledBorder( javax.swing.BorderFactory.createLineBorder(
+ new java.awt.Color( 153, 153, 153 ), 1 ), "Specifications", javax.swing.border.TitledBorder.LEADING,
+ javax.swing.border.TitledBorder.TOP, new java.awt.Font( "SansSerif", 0, 14 ), new java.awt.Color( 60, 60,
+ 60 ) ) );
+ jPanel1.add( jTextArea1, java.awt.BorderLayout.CENTER );
+ jScrollPane1.getViewport().add( jTree1 );
+ jTree1.setBounds( new java.awt.Rectangle( 238, 142, 82, 80 ) );
+ jTextArea1.setText( "" );
+ jTextArea1.setEditable( false );
+ setBounds( new java.awt.Rectangle( 0, 0, 485, 434 ) );
+ setTitle( "Search Results" );
+ jPanel2.setLayout( new java.awt.BorderLayout() );
+ jPanel2.setBorder( javax.swing.BorderFactory.createTitledBorder( javax.swing.BorderFactory.createLineBorder(
+ new java.awt.Color( 153, 153, 153 ), 1 ), "Filter Expression Tree",
+ javax.swing.border.TitledBorder.LEADING, javax.swing.border.TitledBorder.TOP, new java.awt.Font(
+ "SansSerif", 0, 14 ), new java.awt.Color( 60, 60, 60 ) ) );
+ jPanel2.add( jScrollPane1, java.awt.BorderLayout.CENTER );
+ jButton1.setText( "Done" );
+ jButton1.setActionCommand( "Done" );
+ jButton1.addActionListener( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ SearchResultDialog.this.setVisible( false );
+ SearchResultDialog.this.dispose();
}
- }) ;
- jButton1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
- jButton1.setAlignmentX(0.5f);
- jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
- jPanel3.setPreferredSize(new java.awt.Dimension(79, 41));
- jPanel3.setMinimumSize(new java.awt.Dimension(79, 41));
- jPanel3.setSize(new java.awt.Dimension(471,35));
- jPanel3.setToolTipText("");
- jPanel3.add(jButton1);
- jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(
- new java.awt.Color(153, 153, 153), 1), "Search Results", javax.swing.border.TitledBorder.LEADING, javax.swing.border.TitledBorder.TOP,
- new java.awt.Font("SansSerif", 0, 14), new java.awt.Color(60, 60, 60)));
- jPanel4.setLayout(new java.awt.BorderLayout());
- jPanel4.add(jScrollPane2, java.awt.BorderLayout.CENTER);
- jScrollPane2.getViewport().add(m_resultsTbl);
- m_resultsTbl.setSize(new java.awt.Dimension(450,10));
- m_resultsTbl.getSelectionModel().addListSelectionListener(this) ;
+ } );
+ jButton1.setHorizontalAlignment( javax.swing.SwingConstants.CENTER );
+ jButton1.setAlignmentX( 0.5f );
+ jButton1.setHorizontalTextPosition( javax.swing.SwingConstants.CENTER );
+ jPanel3.setPreferredSize( new java.awt.Dimension( 79, 41 ) );
+ jPanel3.setMinimumSize( new java.awt.Dimension( 79, 41 ) );
+ jPanel3.setSize( new java.awt.Dimension( 471, 35 ) );
+ jPanel3.setToolTipText( "" );
+ jPanel3.add( jButton1 );
+ jPanel4.setBorder( javax.swing.BorderFactory.createTitledBorder( javax.swing.BorderFactory.createLineBorder(
+ new java.awt.Color( 153, 153, 153 ), 1 ), "Search Results", javax.swing.border.TitledBorder.LEADING,
+ javax.swing.border.TitledBorder.TOP, new java.awt.Font( "SansSerif", 0, 14 ), new java.awt.Color( 60, 60,
+ 60 ) ) );
+ jPanel4.setLayout( new java.awt.BorderLayout() );
+ jPanel4.add( jScrollPane2, java.awt.BorderLayout.CENTER );
+ jScrollPane2.getViewport().add( m_resultsTbl );
+ m_resultsTbl.setSize( new java.awt.Dimension( 450, 10 ) );
+ m_resultsTbl.getSelectionModel().addListSelectionListener( this );
}
- public void valueChanged(ListSelectionEvent an_event)
- {
- ListSelectionModel selectionModel = (ListSelectionModel) an_event.getSource() ;
- int minIndex = selectionModel.getMinSelectionIndex() ;
- int maxIndex = selectionModel.getMaxSelectionIndex() ;
-
- for(int ii = minIndex ; ii <= maxIndex; ii++) {
- if(selectionModel.isSelectedIndex(ii) && !an_event.getValueIsAdjusting()) {
- BigInteger id = (BigInteger)
- m_resultsTbl.getModel().getValueAt(ii, 0) ;
- ((PartitionFrame) getParent()).selectTreeNode(id) ;
+ public void valueChanged( ListSelectionEvent an_event )
+ {
+ ListSelectionModel selectionModel = ( ListSelectionModel ) an_event.getSource();
+ int minIndex = selectionModel.getMinSelectionIndex();
+ int maxIndex = selectionModel.getMaxSelectionIndex();
+
+ for ( int ii = minIndex; ii <= maxIndex; ii++ )
+ {
+ if ( selectionModel.isSelectedIndex( ii ) && !an_event.getValueIsAdjusting() )
+ {
+ BigInteger id = ( BigInteger ) m_resultsTbl.getModel().getValueAt( ii, 0 );
+ ( ( PartitionFrame ) getParent() ).selectTreeNode( id );
}
}
}
/** Closes the dialog */
- private void closeDialog(WindowEvent evt) {
+ private void closeDialog( WindowEvent evt )
+ {
evt.getWindow();
- setVisible(false);
+ setVisible( false );
dispose();
}
- public void setTreeModel(TreeModel model)
+ public void setTreeModel( TreeModel model )
{
- this.jTree1.setModel(model) ;
+ this.jTree1.setModel( model );
}
- public void setFilter(String filter)
+ public void setFilter( String filter )
{
- this.jTextArea1.setText(filter) ;
+ this.jTextArea1.setText( filter );
}
- public void setTableModel(TableModel model)
+ public void setTableModel( TableModel model )
{
- m_resultsTbl.setModel(model) ;
+ m_resultsTbl.setModel( model );
}
}
Modified: directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDirectoryPartition.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDirectoryPartition.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDirectoryPartition.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDirectoryPartition.java Fri Feb 10 02:48:07 2006
@@ -111,7 +111,6 @@
// C O N S T R U C T O R S
// ------------------------------------------------------------------------
-
/**
* Creates a store based on JDBM B+Trees.
*/
@@ -119,30 +118,30 @@
{
}
- public synchronized void init( DirectoryServiceConfiguration factoryCfg, DirectoryPartitionConfiguration cfg ) throws NamingException
+
+ public synchronized void init( DirectoryServiceConfiguration factoryCfg, DirectoryPartitionConfiguration cfg )
+ throws NamingException
{
this.upSuffix = new LdapName( cfg.getSuffix() );
this.normSuffix = cfg.getNormalizedSuffix( factoryCfg.getGlobalRegistries().getMatchingRuleRegistry() );
- File workingDirectory = new File(
- factoryCfg.getStartupConfiguration().getWorkingDirectory().getPath() +
- File.separator + cfg.getName() );
-
+ File workingDirectory = new File( factoryCfg.getStartupConfiguration().getWorkingDirectory().getPath()
+ + File.separator + cfg.getName() );
+
workingDirectory.mkdirs();
-
+
this.workingDirectory = workingDirectory;
-
- try
+
+ try
{
String path = workingDirectory.getPath() + File.separator + "master";
BaseRecordManager base = new BaseRecordManager( path );
base.disableTransactions();
recMan = new CacheRecordManager( base, new MRU( 1000 ) );
- }
+ }
catch ( IOException e )
{
- NamingException ne = new NamingException(
- "Could not initialize RecordManager" );
+ NamingException ne = new NamingException( "Could not initialize RecordManager" );
ne.setRootCause( e );
throw ne;
}
@@ -150,12 +149,12 @@
master = new JdbmMasterTable( recMan );
indices = new HashMap();
sysIndices = new HashMap();
-
+
super.init( factoryCfg, cfg );
initialized = true;
}
-
-
+
+
public synchronized void destroy()
{
if ( !initialized )
@@ -165,12 +164,12 @@
ArrayList array = new ArrayList();
array.addAll( indices.values() );
-
+
if ( null != ndnIdx )
{
array.add( ndnIdx );
}
-
+
if ( null != updnIdx )
{
array.add( updnIdx );
@@ -200,37 +199,37 @@
{
array.add( existanceIdx );
}
-
+
Iterator list = array.iterator();
-
- while ( list.hasNext() )
+
+ while ( list.hasNext() )
{
Index index = ( Index ) list.next();
- try
+ try
{
- index.close();
- }
- catch ( Throwable t )
+ index.close();
+ }
+ catch ( Throwable t )
{
log.error( "Failed to close an index.", t );
}
}
- try
+ try
{
master.close();
- }
- catch ( Throwable t )
+ }
+ catch ( Throwable t )
{
log.error( "Failed to close the master.", t );
}
- try
+ try
{
recMan.close();
- }
- catch ( Throwable t )
+ }
+ catch ( Throwable t )
{
log.error( "Failed to close the record manager", t );
}
@@ -247,7 +246,7 @@
public synchronized void sync() throws NamingException
{
- if( !initialized )
+ if ( !initialized )
{
return;
}
@@ -261,28 +260,28 @@
array.add( subAliasIdx );
array.add( hierarchyIdx );
array.add( existanceIdx );
-
+
Iterator list = array.iterator();
// Sync all user defined indices
- while ( list.hasNext() )
+ while ( list.hasNext() )
{
Index idx = ( Index ) list.next();
idx.sync();
}
-
+
master.sync();
- try
+ try
{
recMan.commit();
}
- catch ( Throwable t )
+ catch ( Throwable t )
{
- throw ( NamingException ) new NamingException(
- "Failed to commit changes to the record manager." ).initCause( t );
- }
+ throw ( NamingException ) new NamingException( "Failed to commit changes to the record manager." )
+ .initCause( t );
+ }
}
@@ -290,19 +289,18 @@
// I N D E X M E T H O D S
// ------------------------------------------------------------------------
-
public void addIndexOn( AttributeType spec ) throws NamingException
{
Index idx = new JdbmIndex( spec, workingDirectory );
indices.put( spec.getName().toLowerCase(), idx );
}
-
- public Index getExistanceIndex()
+
+ public Index getExistanceIndex()
{
return existanceIdx;
}
-
+
public void setExistanceIndexOn( AttributeType attrType ) throws NamingException
{
@@ -316,12 +314,12 @@
sysIndices.put( attrType.getName().toLowerCase(), existanceIdx );
}
-
- public Index getHierarchyIndex()
+
+ public Index getHierarchyIndex()
{
return hierarchyIdx;
}
-
+
public void setHierarchyIndexOn( AttributeType attrType ) throws NamingException
{
@@ -335,10 +333,10 @@
sysIndices.put( attrType.getName().toLowerCase(), hierarchyIdx );
}
-
+
public Index getAliasIndex()
{
- return aliasIdx;
+ return aliasIdx;
}
@@ -352,8 +350,8 @@
aliasIdx = new JdbmIndex( attrType, workingDirectory );
sysIndices.put( attrType.getName().toLowerCase(), aliasIdx );
- }
-
+ }
+
public Index getOneAliasIndex()
{
@@ -411,12 +409,12 @@
sysIndices.put( attrType.getName().toLowerCase(), updnIdx );
}
-
- public Index getNdnIndex()
+
+ public Index getNdnIndex()
{
return ndnIdx;
}
-
+
public void setNdnIndexOn( AttributeType attrType ) throws NamingException
{
@@ -430,7 +428,7 @@
sysIndices.put( attrType.getName().toLowerCase(), ndnIdx );
}
-
+
public Iterator getUserIndices()
{
return indices.keySet().iterator();
@@ -445,15 +443,13 @@
public boolean hasUserIndexOn( String attribute )
{
- return indices.containsKey( attribute ) ||
- indices.containsKey( attribute.toLowerCase() );
+ return indices.containsKey( attribute ) || indices.containsKey( attribute.toLowerCase() );
}
public boolean hasSystemIndexOn( String attribute )
{
- return sysIndices.containsKey( attribute ) ||
- sysIndices.containsKey( attribute.toLowerCase() );
+ return sysIndices.containsKey( attribute ) || sysIndices.containsKey( attribute.toLowerCase() );
}
@@ -467,22 +463,21 @@
{
String lowerCased = attribute.toLowerCase();
- if ( indices.containsKey( attribute ) )
+ if ( indices.containsKey( attribute ) )
{
return ( Index ) indices.get( attribute );
- }
- else if ( indices.containsKey( lowerCased ) )
+ }
+ else if ( indices.containsKey( lowerCased ) )
{
return ( Index ) indices.get( lowerCased );
- }
- else
+ }
+ else
{
- throw new IndexNotFoundException( "An index on attribute " +
- attribute + " does not exist!" );
+ throw new IndexNotFoundException( "An index on attribute " + attribute + " does not exist!" );
}
}
-
-
+
+
/**
* @todo replace lookups to use the OID instead of the name. Also note
* that the OID registry can be used to go between names and oids.
@@ -493,18 +488,17 @@
{
String lowerCased = indexName.toLowerCase();
- if ( sysIndices.containsKey( indexName ) )
+ if ( sysIndices.containsKey( indexName ) )
{
return ( Index ) sysIndices.get( indexName );
- }
- else if ( sysIndices.containsKey( lowerCased ) )
+ }
+ else if ( sysIndices.containsKey( lowerCased ) )
{
return ( Index ) sysIndices.get( lowerCased );
- }
- else
+ }
+ else
{
- throw new IndexNotFoundException( "A system index by the name of " +
- indexName + " does not exist!" );
+ throw new IndexNotFoundException( "A system index by the name of " + indexName + " does not exist!" );
}
}
@@ -532,8 +526,8 @@
{
return ( BigInteger ) hierarchyIdx.reverseLookup( childId );
}
-
-
+
+
public String getEntryUpdn( BigInteger id ) throws NamingException
{
return ( String ) updnIdx.reverseLookup( id );
@@ -551,8 +545,8 @@
{
return master.count();
}
-
-
+
+
/**
* Removes the index entries for an alias before the entry is deleted from
* the master table.
@@ -568,7 +562,7 @@
String aliasDn = getEntryDn( aliasId );
Name ancestorDn = new LdapName( aliasDn ).getPrefix( 1 );
BigInteger ancestorId = getEntryId( ancestorDn.toString() );
-
+
/*
* We cannot just drop all tuples in the one level and subtree indices
* linking baseIds to the targetId. If more than one alias refers to
@@ -582,20 +576,20 @@
*/
oneAliasIdx.drop( ancestorId, targetId );
subAliasIdx.drop( ancestorId, targetId );
-
- while ( ! ancestorDn.equals( upSuffix ) )
+
+ while ( !ancestorDn.equals( upSuffix ) )
{
ancestorDn = ancestorDn.getPrefix( 1 );
ancestorId = getEntryId( ancestorDn.toString() );
-
+
subAliasIdx.drop( ancestorId, targetId );
- }
+ }
// Drops all alias tuples pointing to the id of the alias to be deleted
aliasIdx.drop( aliasId );
}
-
-
+
+
/**
* Adds indices for an aliasEntry to be added to the database while checking
* for constrained alias constructs like alias cycles and chaining.
@@ -606,19 +600,18 @@
* @throws NamingException if index addition fails, of the alias is not
* allowed due to chaining or cycle formation.
*/
- private void addAliasIndices( BigInteger aliasId, Name aliasDn,
- String aliasTarget ) throws NamingException
+ private void addAliasIndices( BigInteger aliasId, Name aliasDn, String aliasTarget ) throws NamingException
{
- Name targetDn = null; // Name value of aliasedObjectName
- BigInteger targetId = null; // Id of the aliasedObjectName
- Normalizer normalizer = null; // Temporary handle for Dn's
- Name ancestorDn = null; // Name of an alias entry relative
- BigInteger ancestorId = null; // Id of an alias entry relative
+ Name targetDn = null; // Name value of aliasedObjectName
+ BigInteger targetId = null; // Id of the aliasedObjectName
+ Normalizer normalizer = null; // Temporary handle for Dn's
+ Name ancestorDn = null; // Name of an alias entry relative
+ BigInteger ancestorId = null; // Id of an alias entry relative
// Access aliasedObjectName, normalize it and generate the Name
normalizer = oneAliasIdx.getAttribute().getEquality().getNormalizer();
targetDn = new LdapName( ( String ) normalizer.normalize( aliasTarget ) );
-
+
/*
* Check For Cycles
*
@@ -628,21 +621,19 @@
* relative of the alias entry. For detection we test if the aliased
* entry Dn starts with the target Dn. If it does then we know the
* aliased target is a relative and we have a perspecitive cycle.
- */
+ */
if ( aliasDn.startsWith( targetDn ) )
{
if ( aliasDn.equals( targetDn ) )
{
- throw new NamingException( "[36] aliasDereferencingProblem - "
- + "attempt to create alias to itself." );
+ throw new NamingException( "[36] aliasDereferencingProblem - " + "attempt to create alias to itself." );
}
-
- throw new NamingException( "[36] aliasDereferencingProblem - "
- + "attempt to create alias with cycle to relative "
- + aliasTarget + " not allowed from descendent alias "
- + aliasDn );
+
+ throw new NamingException( "[36] aliasDereferencingProblem - "
+ + "attempt to create alias with cycle to relative " + aliasTarget
+ + " not allowed from descendent alias " + aliasDn );
}
-
+
/*
* Check For Aliases External To Naming Context
*
@@ -651,13 +642,12 @@
* need to point it out to the user instead of saying the target
* does not exist when it potentially could outside of this upSuffix.
*/
- if ( ! targetDn.startsWith( upSuffix ) )
+ if ( !targetDn.startsWith( upSuffix ) )
{
// Complain specifically about aliases to outside naming contexts
throw new NamingException( "[36] aliasDereferencingProblem -"
+ " the alias points to an entry outside of the " + upSuffix
- + " namingContext to an object whose existance cannot be"
- + " determined." );
+ + " namingContext to an object whose existance cannot be" + " determined." );
}
// L O O K U P T A R G E T I D
@@ -672,12 +662,11 @@
if ( null == targetId )
{
// Complain about target not existing
- throw new NamingException( "[33] aliasProblem - "
+ throw new NamingException( "[33] aliasProblem - "
+ "the alias when dereferenced would not name a known object "
- + "the aliasedObjectName must be set to a valid existing "
- + "entry." );
+ + "the aliasedObjectName must be set to a valid existing " + "entry." );
}
-
+
/*
* Detect Direct Alias Chain Creation
*
@@ -691,14 +680,13 @@
if ( null != aliasIdx.reverseLookup( targetId ) )
{
// Complain about illegal alias chain
- throw new NamingException( "[36] aliasDereferencingProblem -"
- + " the alias points to another alias. Alias chaining is"
- + " not supported by this backend." );
+ throw new NamingException( "[36] aliasDereferencingProblem -"
+ + " the alias points to another alias. Alias chaining is" + " not supported by this backend." );
}
-
+
// Add the alias to the simple alias index
aliasIdx.add( aliasTarget, aliasId );
-
+
/*
* Handle One Level Scope Alias Index
*
@@ -708,8 +696,8 @@
*/
ancestorDn = aliasDn.getPrefix( 1 );
ancestorId = getEntryId( ancestorDn.toString() );
-
- if ( ! NamespaceTools.isSibling( targetDn, aliasDn ) )
+
+ if ( !NamespaceTools.isSibling( targetDn, aliasDn ) )
{
oneAliasIdx.add( ancestorId, targetId );
}
@@ -724,16 +712,16 @@
* ignored since everything is under its scope. The first loop
* iteration shall handle the parents.
*/
- while ( ! ancestorDn.equals( upSuffix ) && null != ancestorId )
+ while ( !ancestorDn.equals( upSuffix ) && null != ancestorId )
{
- if ( ! NamespaceTools.isDescendant( ancestorDn, targetDn ) )
+ if ( !NamespaceTools.isDescendant( ancestorDn, targetDn ) )
{
subAliasIdx.add( ancestorId, targetId );
}
-
+
ancestorDn = ancestorDn.getPrefix( 1 );
ancestorId = getEntryId( ancestorDn.toString() );
- }
+ }
}
@@ -749,12 +737,12 @@
// capped off using the zero value which no entry can have since
// entry sequences start at 1.
//
-
+
if ( dn.equals( normSuffix ) )
{
parentId = BigInteger.ZERO;
}
- else
+ else
{
parentId = getEntryId( dn.getPrefix( 1 ).toString() );
}
@@ -781,23 +769,23 @@
{
addAliasIndices( id, dn, ( String ) entry.get( DirectoryPartition.ALIAS_ATTRIBUTE ).get() );
}
-
+
ndnIdx.add( dn.toString(), id );
updnIdx.add( updn, id );
hierarchyIdx.add( parentId, id );
-
+
// Now work on the user defined indices
NamingEnumeration list = entry.getIDs();
- while ( list.hasMore() )
+ while ( list.hasMore() )
{
String attribute = ( String ) list.next();
-
- if ( hasUserIndexOn( attribute ) )
+
+ if ( hasUserIndexOn( attribute ) )
{
Index idx = getUserIndex( attribute );
NamingEnumeration values = entry.get( attribute ).getAll();
-
- while ( values.hasMore() )
+
+ while ( values.hasMore() )
{
idx.add( values.next(), id );
}
@@ -817,12 +805,12 @@
}
- public void delete( BigInteger id ) throws NamingException
+ public void delete( BigInteger id ) throws NamingException
{
Attributes entry = lookup( id );
BigInteger parentId = getParentId( id );
NamingEnumeration attrs = entry.getIDs();
-
+
if ( entry.get( "objectClass" ).contains( DirectoryPartition.ALIAS_OBJECT ) )
{
dropAliasIndices( id );
@@ -831,14 +819,14 @@
ndnIdx.drop( id );
updnIdx.drop( id );
hierarchyIdx.drop( id );
-
+
// Remove parent's reference to entry only if entry is not the upSuffix
- if ( ! parentId.equals( BigInteger.ZERO ) )
+ if ( !parentId.equals( BigInteger.ZERO ) )
{
hierarchyIdx.drop( parentId, id );
}
-
- while ( attrs.hasMore() )
+
+ while ( attrs.hasMore() )
{
String attr = ( ( String ) attrs.next() );
@@ -846,7 +834,7 @@
{
Index index = getUserIndex( attr );
NamingEnumeration values = entry.get( attr ).getAll();
-
+
while ( values.hasMore() )
{
index.drop( values.next(), id );
@@ -860,7 +848,7 @@
}
- public NamingEnumeration list( BigInteger id ) throws NamingException
+ public NamingEnumeration list( BigInteger id ) throws NamingException
{
return hierarchyIdx.listIndices( id );
}
@@ -878,7 +866,7 @@
{
return normSuffix;
}
-
+
return upSuffix;
}
@@ -896,8 +884,7 @@
}
- public void setProperty( String propertyName, String propertyValue )
- throws NamingException
+ public void setProperty( String propertyName, String propertyValue ) throws NamingException
{
master.setProperty( propertyName, propertyValue );
}
@@ -909,7 +896,7 @@
}
- public Attributes getIndices( BigInteger id ) throws NamingException
+ public Attributes getIndices( BigInteger id ) throws NamingException
{
Attributes attributes = new LockableAttributesImpl();
@@ -924,13 +911,13 @@
{
Index index = ( Index ) idxList.next();
NamingEnumeration list = index.listReverseIndices( id );
- while ( list.hasMore() )
+ while ( list.hasMore() )
{
IndexRecord rec = ( IndexRecord ) list.next();
Object val = rec.getIndexKey();
String attrId = index.getAttribute().getName();
Attribute attr = attributes.get( attrId );
- if ( attr == null)
+ if ( attr == null )
{
attr = new LockableAttributeImpl( attrId );
}
@@ -943,10 +930,10 @@
// that looks like so 'existance[attribute]' and the value is set to id
NamingEnumeration list = existanceIdx.listReverseIndices( id );
StringBuffer val = new StringBuffer();
- while ( list.hasMore() )
+ while ( list.hasMore() )
{
IndexRecord rec = ( IndexRecord ) list.next();
- val.append( "_existance[" );
+ val.append( "_existance[" );
val.append( rec.getIndexKey() );
val.append( "]" );
@@ -987,8 +974,7 @@
* @throws NamingException if index alteration or attribute addition
* fails.
*/
- private void add( BigInteger id, Attributes entry, Attribute mods )
- throws NamingException
+ private void add( BigInteger id, Attributes entry, Attribute mods ) throws NamingException
{
if ( hasUserIndexOn( mods.getID() ) )
{
@@ -996,7 +982,7 @@
idx.add( mods, id );
// If the attr didn't exist for this id add it to existance index
- if ( ! existanceIdx.hasValue( mods.getID().toLowerCase(), id ) )
+ if ( !existanceIdx.hasValue( mods.getID().toLowerCase(), id ) )
{
existanceIdx.add( mods.getID().toLowerCase(), id );
}
@@ -1019,12 +1005,11 @@
if ( mods.getID().equals( DirectoryPartition.ALIAS_ATTRIBUTE ) )
{
String ndnStr = ( String ) ndnIdx.reverseLookup( id );
- addAliasIndices( id, new LdapName( ndnStr ),
- ( String ) mods.get() );
+ addAliasIndices( id, new LdapName( ndnStr ), ( String ) mods.get() );
}
}
-
-
+
+
/**
* Completely removes the set of values for an attribute having the values
* supplied while affecting the appropriate indices. The entry is not
@@ -1039,14 +1024,13 @@
* @throws NamingException if index alteration or attribute modification
* fails.
*/
- private void remove( BigInteger id, Attributes entry, Attribute mods )
- throws NamingException
+ private void remove( BigInteger id, Attributes entry, Attribute mods ) throws NamingException
{
if ( hasUserIndexOn( mods.getID() ) )
{
Index idx = getUserIndex( mods.getID() );
idx.drop( mods, id );
-
+
/*
* If no attribute values exist for this entryId in the index then
* we remove the existance index entry for the removed attribute.
@@ -1071,11 +1055,11 @@
{
Attribute entryAttr = entry.get( mods.getID() );
NamingEnumeration values = mods.getAll();
- while ( values.hasMore() )
+ while ( values.hasMore() )
{
entryAttr.remove( values.next() );
}
-
+
// if nothing is left just remove empty attribute
if ( entryAttr.size() == 0 )
{
@@ -1103,17 +1087,16 @@
* @throws NamingException if index alteration or attribute modification
* fails.
*/
- private void replace( BigInteger id, Attributes entry, Attribute mods )
- throws NamingException
+ private void replace( BigInteger id, Attributes entry, Attribute mods ) throws NamingException
{
if ( hasUserIndexOn( mods.getID() ) )
{
Index idx = getUserIndex( mods.getID() );
-
+
// Drop all existing attribute value index entries and add new ones
idx.drop( id );
idx.add( mods, id );
-
+
/*
* If no attribute values exist for this entryId in the index then
* we remove the existance index entry for the removed attribute.
@@ -1128,15 +1111,14 @@
{
dropAliasIndices( id );
}
-
+
// Automatically replaces old attributes with new modified ones
entry.put( mods );
-
+
if ( mods.getID().equals( DirectoryPartition.ALIAS_ATTRIBUTE ) )
{
String ndnStr = ( String ) ndnIdx.reverseLookup( id );
- addAliasIndices( id, new LdapName( ndnStr ),
- ( String ) mods.get() );
+ addAliasIndices( id, new LdapName( ndnStr ), ( String ) mods.get() );
}
}
@@ -1146,77 +1128,75 @@
NamingEnumeration attrs = null;
BigInteger id = getEntryId( dn.toString() );
Attributes entry = master.get( id );
-
+
switch ( modOp )
{
- case( DirContext.ADD_ATTRIBUTE ):
+ case ( DirContext.ADD_ATTRIBUTE ):
attrs = mods.getIDs();
-
+
while ( attrs.hasMore() )
{
String attrId = ( String ) attrs.next();
Attribute attr = mods.get( attrId );
add( id, entry, attr );
}
-
+
break;
- case( DirContext.REMOVE_ATTRIBUTE ):
+ case ( DirContext.REMOVE_ATTRIBUTE ):
attrs = mods.getIDs();
-
+
while ( attrs.hasMore() )
{
String attrId = ( String ) attrs.next();
Attribute attr = mods.get( attrId );
remove( id, entry, attr );
}
-
+
break;
- case( DirContext.REPLACE_ATTRIBUTE ):
+ case ( DirContext.REPLACE_ATTRIBUTE ):
attrs = mods.getIDs();
-
+
while ( attrs.hasMore() )
{
String attrId = ( String ) attrs.next();
Attribute attr = mods.get( attrId );
replace( id, entry, attr );
}
-
+
break;
default:
- throw new NamingException(
- "Unidentified modification operation" );
+ throw new NamingException( "Unidentified modification operation" );
}
-
+
master.put( entry, id );
}
-
- public void modify( Name dn, ModificationItem [] mods ) throws NamingException
+
+ public void modify( Name dn, ModificationItem[] mods ) throws NamingException
{
BigInteger id = getEntryId( dn.toString() );
Attributes entry = master.get( id );
-
+
for ( int ii = 0; ii < mods.length; ii++ )
{
Attribute attrMods = mods[ii].getAttribute();
- switch ( mods[ ii ].getModificationOp() )
+ switch ( mods[ii].getModificationOp() )
{
- case( DirContext.ADD_ATTRIBUTE ):
+ case ( DirContext.ADD_ATTRIBUTE ):
add( id, entry, attrMods );
break;
- case( DirContext.REMOVE_ATTRIBUTE ):
+ case ( DirContext.REMOVE_ATTRIBUTE ):
remove( id, entry, attrMods );
break;
- case( DirContext.REPLACE_ATTRIBUTE ):
+ case ( DirContext.REPLACE_ATTRIBUTE ):
replace( id, entry, attrMods );
break;
default:
- throw new NamingException(
- "Unidentified modification operation" );
+ throw new NamingException( "Unidentified modification operation" );
}
}
-
+
master.put( entry, id );
}
@@ -1238,8 +1218,7 @@
* @throws NamingException if there are any errors propagating the name
* changes.
*/
- public void modifyRn( Name dn, String newRdn, boolean deleteOldRdn )
- throws NamingException
+ public void modifyRn( Name dn, String newRdn, boolean deleteOldRdn ) throws NamingException
{
String newRdnAttr = NamespaceTools.getRdnAttribute( newRdn );
String newRdnValue = NamespaceTools.getRdnValue( newRdn );
@@ -1263,20 +1242,20 @@
}
// add the new Rdn value only if it is not already present in the entry
- if ( ! rdnAttr.contains( newRdnValue ) )
+ if ( !rdnAttr.contains( newRdnValue ) )
{
rdnAttr.add( newRdnValue );
}
entry.put( rdnAttr );
-
+
if ( hasUserIndexOn( newRdnAttr ) )
{
Index idx = getUserIndex( newRdnAttr );
idx.add( newRdnValue, id );
-
+
// Make sure the altered entry shows the existance of the new attrib
- if ( ! existanceIdx.hasValue( newRdnAttr.toLowerCase(), id ) )
+ if ( !existanceIdx.hasValue( newRdnAttr.toLowerCase(), id ) )
{
existanceIdx.add( newRdnAttr.toLowerCase(), id );
}
@@ -1301,14 +1280,14 @@
String oldRdn = updn.get( updn.size() - 1 );
String oldRdnAttr = NamespaceTools.getRdnAttribute( oldRdn );
String oldRdnValue = NamespaceTools.getRdnValue( oldRdn );
-
+
entry.get( oldRdnAttr ).remove( oldRdnValue );
if ( hasUserIndexOn( oldRdnAttr ) )
{
Index idx = getUserIndex( oldRdnAttr );
idx.drop( oldRdnValue, id );
-
+
/*
* If there is no value for id in this index due to our
* drop above we remove the oldRdnAttr from the existance idx
@@ -1319,7 +1298,7 @@
}
}
}
-
+
/*
* H A N D L E D N C H A N G E
* ====================================================================
@@ -1331,13 +1310,13 @@
* entry and its descendants
*/
- Name newUpdn = ( Name ) updn.clone(); // copy da old updn
- newUpdn.remove( newUpdn.size() - 1 ); // remove old upRdn
- newUpdn.add( newUpdn.size(), newRdn ); // add da new upRdn
- modifyDn( id, newUpdn, false ); // propagate dn changes
+ Name newUpdn = ( Name ) updn.clone(); // copy da old updn
+ newUpdn.remove( newUpdn.size() - 1 ); // remove old upRdn
+ newUpdn.add( newUpdn.size(), newRdn ); // add da new upRdn
+ modifyDn( id, newUpdn, false ); // propagate dn changes
}
-
-
+
+
/*
* The move operation severs a child from a parent creating a new parent
* child relationship. As a consequence the relationships between the
@@ -1355,18 +1334,17 @@
* which affects alias indices.
* @throws NamingException if something goes wrong
*/
- private void modifyDn( BigInteger id, Name updn, boolean isMove )
- throws NamingException
+ private void modifyDn( BigInteger id, Name updn, boolean isMove ) throws NamingException
{
String aliasTarget = null;
// Now we can handle the appropriate name indices for all cases
ndnIdx.drop( id );
ndnIdx.add( ndnIdx.getNormalized( updn.toString() ), id );
-
+
updnIdx.drop( id );
updnIdx.add( updn.toString(), id );
-
+
/*
* Read Alias Index Tuples
*
@@ -1377,32 +1355,31 @@
* aliasTarget is used as a marker to tell us if we're moving an
* alias. If it is null then the moved entry is not an alias.
*/
- if ( isMove )
+ if ( isMove )
{
aliasTarget = ( String ) aliasIdx.reverseLookup( id );
-
+
if ( null != aliasTarget )
{
- addAliasIndices( id, new LdapName( getEntryDn( id ) ),
- aliasTarget );
+ addAliasIndices( id, new LdapName( getEntryDn( id ) ), aliasTarget );
}
}
-
+
NamingEnumeration children = list( id );
- while ( children.hasMore() )
+ while ( children.hasMore() )
{
// Get the child and its id
IndexRecord rec = ( IndexRecord ) children.next();
BigInteger childId = rec.getEntryId();
-
+
/*
* Calculate the Dn for the child's new name by copying the parents
* new name and adding the child's old upRdn to new name as its Rdn
*/
Name childUpdn = ( Name ) updn.clone();
Name oldUpdn = new LdapName( getEntryUpdn( childId ) );
- String rdn = LdapName.getRdn( oldUpdn );
- childUpdn.add( childUpdn.size(), rdn );
+ String rdn = LdapName.getRdn( oldUpdn );
+ childUpdn.add( childUpdn.size(), rdn );
// Recursively change the names of the children below
modifyDn( childId, childUpdn, isMove );
@@ -1410,8 +1387,7 @@
}
- public void move( Name oldChildDn, Name newParentDn, String newRdn,
- boolean deleteOldRdn ) throws NamingException
+ public void move( Name oldChildDn, Name newParentDn, String newRdn, boolean deleteOldRdn ) throws NamingException
{
BigInteger childId = getEntryId( oldChildDn.toString() );
modifyRn( oldChildDn, newRdn, deleteOldRdn );
@@ -1444,7 +1420,7 @@
// Get the child and the new parent to be entries and Ids
BigInteger newParentId = getEntryId( newParentDn.toString() );
BigInteger oldParentId = getParentId( childId );
-
+
/*
* All aliases including and below oldChildDn, will be affected by
* the move operation with respect to one and subtree indices since
@@ -1454,7 +1430,7 @@
* respective target ids of the aliases.
*/
dropMovedAliasIndices( oldChildDn );
-
+
/*
* Drop the old parent child relationship and add the new one
* Set the new parent id for the child replacing the old parent id
@@ -1468,7 +1444,7 @@
* UpRdn String to the tail of the new parent's Updn Name.
*/
Name childUpdn = new LdapName( getEntryUpdn( childId ) );
- String childRdn = childUpdn.get( childUpdn.size() - 1 );
+ String childRdn = childUpdn.get( childUpdn.size() - 1 );
Name newUpdn = new LdapName( getEntryUpdn( newParentId ) );
newUpdn.add( newUpdn.size(), childRdn );
@@ -1490,27 +1466,25 @@
// Find all the aliases from movedBase down
IndexAssertion isBaseDescendant = new IndexAssertion()
{
- public boolean assertCandidate( IndexRecord rec )
- throws NamingException
+ public boolean assertCandidate( IndexRecord rec ) throws NamingException
{
String dn = getEntryDn( rec.getEntryId() );
if ( dn.endsWith( movedBase.toString() ) )
{
return true;
}
-
+
return false;
}
};
-
+
BigInteger movedBaseId = getEntryId( movedBase.toString() );
- if ( aliasIdx.reverseLookup( movedBaseId ) != null )
+ if ( aliasIdx.reverseLookup( movedBaseId ) != null )
{
dropAliasIndices( movedBaseId, movedBase );
}
-
- NamingEnumeration aliases = new IndexAssertionEnumeration(
- aliasIdx.listIndices( movedBase.toString(), true ),
+
+ NamingEnumeration aliases = new IndexAssertionEnumeration( aliasIdx.listIndices( movedBase.toString(), true ),
isBaseDescendant );
while ( aliases.hasMore() )
{
@@ -1518,8 +1492,8 @@
dropAliasIndices( entry.getEntryId(), movedBase );
}
}
-
-
+
+
/**
* For the alias id all ancestor one and subtree alias tuples are moved
* above the moved base.
@@ -1528,20 +1502,19 @@
* @param movedBase the base where the move occured
* @throws NamingException if indices fail
*/
- private void dropAliasIndices( BigInteger aliasId, Name movedBase )
- throws NamingException
+ private void dropAliasIndices( BigInteger aliasId, Name movedBase ) throws NamingException
{
String targetDn = ( String ) aliasIdx.reverseLookup( aliasId );
BigInteger targetId = getEntryId( targetDn );
String aliasDn = getEntryDn( aliasId );
-
+
/*
* Start droping index tuples with the first ancestor right above the
* moved base. This is the first ancestor effected by the move.
*/
Name ancestorDn = movedBase.getPrefix( 1 );
BigInteger ancestorId = getEntryId( ancestorDn.toString() );
-
+
/*
* We cannot just drop all tuples in the one level and subtree indices
* linking baseIds to the targetId. If more than one alias refers to
@@ -1558,32 +1531,31 @@
{
oneAliasIdx.drop( ancestorId, targetId );
}
-
+
subAliasIdx.drop( ancestorId, targetId );
-
- while ( ! ancestorDn.equals( upSuffix ) )
+
+ while ( !ancestorDn.equals( upSuffix ) )
{
ancestorDn = ancestorDn.getPrefix( 1 );
ancestorId = getEntryId( ancestorDn.toString() );
-
+
subAliasIdx.drop( ancestorId, targetId );
- }
+ }
}
-
+
public void bind( Name bindDn, byte[] credentials, List mechanisms, String saslAuthId ) throws NamingException
{
// does nothing
- throw new LdapAuthenticationNotSupportedException(
- "Bind requests only tunnel down into partitions if there are no authenticators to handle the mechanism.\n" +
- "Check to see if you have correctly configured authenticators for the server.",
+ throw new LdapAuthenticationNotSupportedException(
+ "Bind requests only tunnel down into partitions if there are no authenticators to handle the mechanism.\n"
+ + "Check to see if you have correctly configured authenticators for the server.",
ResultCodeEnum.AUTHMETHODNOTSUPPORTED );
}
-
+
public void unbind( Name bindDn ) throws NamingException
{
// does nothing
}
}
-