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.DN; 29 import org.apache.directory.ldapstudio.browser.core.model.IConnection; 30 import org.apache.directory.ldapstudio.browser.core.model.IEntry; 31 import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException; 32 33 34 public class ReadEntryJob extends AbstractAsyncBulkJob 35 { 36 37 private IConnection connection; 38 39 private DN dn; 40 41 private IEntry readEntry; 42 43 44 public ReadEntryJob( IConnection connection, DN dn ) 45 { 46 this.connection = connection; 47 this.dn = dn; 48 this.readEntry = null; 49 50 setName( BrowserCoreMessages.jobs__read_entry_name ); 51 } 52 53 54 protected IConnection[] getConnections() 55 { 56 return new IConnection[] 57 { connection }; 58 } 59 60 61 protected Object [] getLockedObjects() 62 { 63 List l = new ArrayList (); 64 l.add( connection ); 65 return l.toArray(); 66 } 67 68 69 public IEntry getReadEntry() 70 { 71 return readEntry; 72 } 73 74 75 protected String getErrorMessage() 76 { 77 return BrowserCoreMessages.jobs__read_entry_error; 78 } 79 80 81 protected void executeBulkJob( ExtendedProgressMonitor pm ) throws ModelModificationException 82 { 83 readEntry = connection.getEntryFromCache( dn ); 84 if ( readEntry == null ) 85 { 86 87 pm.beginTask( BrowserCoreMessages.bind( BrowserCoreMessages.jobs__read_entry_task, new String [] 88 { dn.toString() } ), 2 ); 89 pm.reportProgress( " " ); pm.worked( 1 ); 91 92 readEntry = connection.getEntry( dn, pm ); 93 } 94 } 95 96 97 protected void runNotification() 98 { 99 } 100 101 } 102 | Popular Tags |