KickJava   Java API By Example, From Geeks To Geeks.

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


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.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 JavaDoc[] 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 JavaDoc[] getLockedObjects()
54     {
55         List JavaDoc l = new ArrayList JavaDoc();
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( " " ); //$NON-NLS-1$
66
monitor.worked( 1 );
67
68         connection.bind( monitor );
69         connection.fetchRootDSE( monitor );
70
71         IEntry[] baseDNEntries = connection.getRootDSE().getChildren();
72         baseDNs = new String JavaDoc[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 JavaDoc getErrorMessage()
85     {
86         return BrowserCoreMessages.jobs__fetch_basedns_error;
87     }
88
89
90     public String JavaDoc[] getBaseDNs()
91     {
92         if ( baseDNs == null )
93         {
94             baseDNs = new String JavaDoc[0];
95         }
96         return baseDNs;
97     }
98
99
100     protected void runNotification()
101     {
102
103     }
104
105 }
106
Popular Tags