KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > cvsclient > ClientServices


1 /*****************************************************************************
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is the CVS Client Library.
16  * The Initial Developer of the Original Software is Robert Greig.
17  * Portions created by Robert Greig are Copyright (C) 2000.
18  * All Rights Reserved.
19  *
20  * Contributor(s): Robert Greig.
21  *****************************************************************************/

22 package org.netbeans.lib.cvsclient;
23
24 import java.io.*;
25 import java.util.*;
26
27 import org.netbeans.lib.cvsclient.admin.*;
28 import org.netbeans.lib.cvsclient.command.*;
29 import org.netbeans.lib.cvsclient.connection.*;
30 import org.netbeans.lib.cvsclient.file.*;
31 import org.netbeans.lib.cvsclient.request.*;
32 import org.netbeans.lib.cvsclient.response.*;
33 import org.netbeans.lib.cvsclient.util.*;
34
35 /**
36  * Clients that provide the ability to execute commands must implement this
37  * interface. All commands use this interface to get details about the
38  * environment in which it is being run, and to perform administrative
39  * functions such as obtaining Entry lines for specified files.
40  * @author Robert Greig
41  */

42 public interface ClientServices {
43     /**
44      * Process all the requests.
45      *
46      * @param requests the requets to process
47      */

48     void processRequests(List requests) throws IOException,
49             UnconfiguredRequestException, ResponseException,
50             CommandAbortedException;
51
52     /**
53      * Get the repository used for this connection.
54      *
55      * @return the repository, for example /home/bob/cvs
56      */

57     String JavaDoc getRepository();
58
59     /**
60      * Get the repository path for a given directory, for example in
61      * the directory /home/project/foo/bar, the repository directory
62      * might be /usr/cvs/foo/bar. The repository directory is commonly
63      * stored in the file <pre>Repository</pre> in the CVS directory on
64      * the client. (This is the case in the standard CVS command-line tool)
65      *
66      * @param directory the directory
67      */

68     String JavaDoc getRepositoryForDirectory(String JavaDoc directory)
69             throws IOException;
70
71     /**
72      * Semantically equivalent to {@link #getRepositoryForDirectory(String)} but does not try to recover from
73      * missing CVS/Repository file.
74      *
75      * @param directory the directory to get repository for
76      * @return repository path that corresponds to the given local working directory or null if local directory
77      * is not versioned or does not exist
78      * @throws IOException if the repository cannot be determined by reading CVS/Repository file
79      */

80     String JavaDoc getRepositoryForDirectory(File directory) throws IOException;
81     
82     /**
83      * Get the local path that the command is executing in.
84      *
85      * @return the local path
86      */

87     String JavaDoc getLocalPath();
88
89     /**
90      * Get the Entry for the specified file, if one exists.
91      *
92      * @param file the file
93      *
94      * @throws IOException if the Entries file cannot be read
95      */

96     Entry getEntry(File file) throws IOException;
97
98     /**
99      * Get the entries for a specified directory.
100      *
101      * @param directory the directory for which to get the entries
102      *
103      * @return an iterator of Entry objects
104      */

105     Iterator getEntries(File directory) throws IOException;
106
107     /**
108      * Create or update the administration files for a particular file
109      * This will create the CVS directory if necessary, and the
110      * Root and Repository files if necessary. It will also update
111      * the Entries file with the new entry
112      *
113      * @param localDirectory the local directory, relative to the directory
114      * in which the command was given, where the file in
115      * question lives
116      * @param entry the entry object for that file
117      *
118      * @throws IOException if there is an error writing the files
119      */

120     void updateAdminData(String JavaDoc localDirectory, String JavaDoc repositoryPath,
121                          Entry entry)
122             throws IOException;
123
124     /**
125      * Get all the files contained within a given
126      * directory that are <b>known to CVS</b>.
127      *
128      * @param directory the directory to look in
129      *
130      * @return a set of all files.
131      */

132     Set getAllFiles(File directory) throws IOException;
133
134     /**
135      * Returns true if no command was sent before.
136      * This is used, because the server rejects some doubled commands.
137      */

138     boolean isFirstCommand();
139
140     /**
141      * Set whether this is the first command. Normally you do not need to set
142      * this yourself - after execution the first command will have set this to
143      * false.
144      */

145     void setIsFirstCommand(boolean first);
146
147     /**
148      * Removes the Entry for the specified file.
149      */

150     void removeEntry(File file) throws IOException;
151
152     /**
153      * Sets the specified IgnoreFileFilter to use to ignore non-cvs files.
154      * TS, 2001-11-23: really needed in the interface (it's never used)?
155      */

156     void setIgnoreFileFilter(IgnoreFileFilter filter);
157
158     /**
159      * Returns the IgnoreFileFilter used to ignore non-cvs files.
160      * TS, 2001-11-23: really needed in the interface (it's never used)?
161      */

162     IgnoreFileFilter getIgnoreFileFilter();
163
164     /**
165      * Returnes true to indicate, that the file specified by directory and nonCvsFile
166      * should be ignored.
167      */

168     boolean shouldBeIgnored(File directory, String JavaDoc nonCvsFile);
169
170     //
171
// allow the user of the Client to define the FileHandlers
172
//
173

174     /**
175      * Set the uncompressed file handler.
176      */

177     void setUncompressedFileHandler(FileHandler handler);
178
179     /**
180      * Set the handler for Gzip data.
181      */

182     void setGzipFileHandler(FileHandler handler);
183
184     /**
185      * Checks for presence of CVS/Tag file and returns it's value.
186      *
187      * @return the value of CVS/Tag file for the specified directory
188      * null if file doesn't exist
189      */

190     String JavaDoc getStickyTagForDirectory(File directory);
191
192     /**
193      * Ensures, that the connection is open.
194      *
195      * @throws AuthenticationException if it wasn't possible to connect
196      */

197     void ensureConnection() throws AuthenticationException;
198     
199     /**
200      * Returns the wrappers map associated with the CVS server
201      * The map is valid only after the connection is established
202      */

203     Map getWrappersMap() throws CommandException;
204     
205     /**
206      * Get the global options that are set to this client.
207      * Individual commands can get the global options via this method.
208      */

209     GlobalOptions getGlobalOptions();
210
211     /**
212      * Tests for existence of the given file. Normally this method
213      * delegates to File.exists() but it may also return true for files
214      * that exists only virtually (in memory). Is such case the file/directory
215      * will not exist on disk but its metadata will be available via getEntries() methods.
216      *
217      * @param file file to test for existence
218      * @return true if the file exists, false otherwise
219      */

220     boolean exists(File file);
221     
222     /**
223      * Tests whether command execution should be aborted. Commands are encouraged to regulary
224      * poll this value if they expect to block for a long time in their code.
225      *
226      * @return true if currently running command should abort, false otherwise
227      */

228     boolean isAborted();
229 }
230
Popular Tags