1 20 21 package org.apache.directory.ldapstudio.browser.core.jobs; 22 23 24 import java.util.ArrayList ; 25 import java.util.List ; 26 27 import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages; 28 import org.apache.directory.ldapstudio.browser.core.model.IConnection; 29 import org.apache.directory.ldapstudio.browser.core.model.IEntry; 30 31 32 public class FetchBaseDNsJob extends AbstractAsyncBulkJob 33 { 34 35 private IConnection connection; 36 37 private String [] baseDNs; 38 39 40 public FetchBaseDNsJob( IConnection connection ) 41 { 42 this.connection = connection; 43 setName( BrowserCoreMessages.jobs__fetch_basedns_name ); 44 } 45 46 47 protected IConnection[] getConnections() 48 { 49 return new IConnection[0]; 50 } 51 52 53 protected Object [] getLockedObjects() 54 { 55 List l = new ArrayList (); 56 l.add( connection ); 57 return l.toArray(); 58 } 59 60 61 protected void executeBulkJob( ExtendedProgressMonitor monitor ) 62 { 63 64 monitor.beginTask( BrowserCoreMessages.jobs__fetch_basedns_task, 5 ); 65 monitor.reportProgress( " " ); monitor.worked( 1 ); 67 68 connection.bind( monitor ); 69 connection.fetchRootDSE( monitor ); 70 71 IEntry[] baseDNEntries = connection.getRootDSE().getChildren(); 72 baseDNs = new String [baseDNEntries.length]; 73 for ( int i = 0; i < baseDNs.length; i++ ) 74 { 75 baseDNs[i] = baseDNEntries[i].getDn().toString(); 76 } 77 monitor.worked( 1 ); 78 79 connection.close(); 80 81 } 82 83 84 protected String getErrorMessage() 85 { 86 return BrowserCoreMessages.jobs__fetch_basedns_error; 87 } 88 89 90 public String [] getBaseDNs() 91 { 92 if ( baseDNs == null ) 93 { 94 baseDNs = new String [0]; 95 } 96 return baseDNs; 97 } 98 99 100 protected void runNotification() 101 { 102 103 } 104 105 } 106 | Popular Tags |