KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > core > jobs > ReadEntryJob


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20
21 package org.apache.directory.ldapstudio.browser.core.jobs;
22
23
24 import java.util.ArrayList JavaDoc;
25 import java.util.List JavaDoc;
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 JavaDoc[] getLockedObjects()
62     {
63         List JavaDoc l = new ArrayList JavaDoc();
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 JavaDoc 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 JavaDoc[]
88                 { dn.toString() } ), 2 );
89             pm.reportProgress( " " ); //$NON-NLS-1$
90
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