001: /*****************************************************************************
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is the CVS Client Library.
027: * The Initial Developer of the Original Software is Robert Greig.
028: * Portions created by Robert Greig are Copyright (C) 2000.
029: * All Rights Reserved.
030: *
031: * If you wish your version of this file to be governed by only the CDDL
032: * or only the GPL Version 2, indicate your decision by adding
033: * "[Contributor] elects to include this software in this distribution
034: * under the [CDDL or GPL Version 2] license." If you do not indicate a
035: * single choice of license, a recipient has the option to distribute
036: * your version of this file under either the CDDL, the GPL Version 2 or
037: * to extend the choice of license to its licensees as provided above.
038: * However, if you add GPL Version 2 code and therefore, elected the GPL
039: * Version 2 license, then the option applies only if the new code is
040: * made subject to such option by the copyright holder.
041: *
042: * Contributor(s): Robert Greig.
043: *****************************************************************************/package org.netbeans.lib.cvsclient;
044:
045: import java.io.*;
046: import java.util.*;
047:
048: import org.netbeans.lib.cvsclient.admin.*;
049: import org.netbeans.lib.cvsclient.command.*;
050: import org.netbeans.lib.cvsclient.connection.*;
051: import org.netbeans.lib.cvsclient.file.*;
052: import org.netbeans.lib.cvsclient.request.*;
053: import org.netbeans.lib.cvsclient.response.*;
054: import org.netbeans.lib.cvsclient.util.*;
055:
056: /**
057: * Clients that provide the ability to execute commands must implement this
058: * interface. All commands use this interface to get details about the
059: * environment in which it is being run, and to perform administrative
060: * functions such as obtaining Entry lines for specified files.
061: * @author Robert Greig
062: */
063: public interface ClientServices {
064: /**
065: * Process all the requests.
066: *
067: * @param requests the requets to process
068: */
069: void processRequests(List requests) throws IOException,
070: UnconfiguredRequestException, ResponseException,
071: CommandAbortedException;
072:
073: /**
074: * Get the repository used for this connection.
075: *
076: * @return the repository, for example /home/bob/cvs
077: */
078: String getRepository();
079:
080: /**
081: * Get the repository path for a given directory, for example in
082: * the directory /home/project/foo/bar, the repository directory
083: * might be /usr/cvs/foo/bar. The repository directory is commonly
084: * stored in the file <pre>Repository</pre> in the CVS directory on
085: * the client. (This is the case in the standard CVS command-line tool)
086: *
087: * @param directory the directory
088: */
089: String getRepositoryForDirectory(String directory)
090: throws IOException;
091:
092: /**
093: * Semantically equivalent to {@link #getRepositoryForDirectory(String)} but does not try to recover from
094: * missing CVS/Repository file.
095: *
096: * @param directory the directory to get repository for
097: * @return repository path that corresponds to the given local working directory or null if local directory
098: * is not versioned or does not exist
099: * @throws IOException if the repository cannot be determined by reading CVS/Repository file
100: */
101: String getRepositoryForDirectory(File directory) throws IOException;
102:
103: /**
104: * Get the local path that the command is executing in.
105: *
106: * @return the local path
107: */
108: String getLocalPath();
109:
110: /**
111: * Get the Entry for the specified file, if one exists.
112: *
113: * @param file the file
114: *
115: * @throws IOException if the Entries file cannot be read
116: */
117: Entry getEntry(File file) throws IOException;
118:
119: /**
120: * Get the entries for a specified directory.
121: *
122: * @param directory the directory for which to get the entries
123: *
124: * @return an iterator of Entry objects
125: */
126: Iterator getEntries(File directory) throws IOException;
127:
128: /**
129: * Create or update the administration files for a particular file
130: * This will create the CVS directory if necessary, and the
131: * Root and Repository files if necessary. It will also update
132: * the Entries file with the new entry
133: *
134: * @param localDirectory the local directory, relative to the directory
135: * in which the command was given, where the file in
136: * question lives
137: * @param entry the entry object for that file
138: *
139: * @throws IOException if there is an error writing the files
140: */
141: void updateAdminData(String localDirectory, String repositoryPath,
142: Entry entry) throws IOException;
143:
144: /**
145: * Get all the files contained within a given
146: * directory that are <b>known to CVS</b>.
147: *
148: * @param directory the directory to look in
149: *
150: * @return a set of all files.
151: */
152: Set getAllFiles(File directory) throws IOException;
153:
154: /**
155: * Returns true if no command was sent before.
156: * This is used, because the server rejects some doubled commands.
157: */
158: boolean isFirstCommand();
159:
160: /**
161: * Set whether this is the first command. Normally you do not need to set
162: * this yourself - after execution the first command will have set this to
163: * false.
164: */
165: void setIsFirstCommand(boolean first);
166:
167: /**
168: * Removes the Entry for the specified file.
169: */
170: void removeEntry(File file) throws IOException;
171:
172: /**
173: * Sets the specified IgnoreFileFilter to use to ignore non-cvs files.
174: * TS, 2001-11-23: really needed in the interface (it's never used)?
175: */
176: void setIgnoreFileFilter(IgnoreFileFilter filter);
177:
178: /**
179: * Returns the IgnoreFileFilter used to ignore non-cvs files.
180: * TS, 2001-11-23: really needed in the interface (it's never used)?
181: */
182: IgnoreFileFilter getIgnoreFileFilter();
183:
184: /**
185: * Returnes true to indicate, that the file specified by directory and nonCvsFile
186: * should be ignored.
187: */
188: boolean shouldBeIgnored(File directory, String nonCvsFile);
189:
190: //
191: // allow the user of the Client to define the FileHandlers
192: //
193:
194: /**
195: * Set the uncompressed file handler.
196: */
197: void setUncompressedFileHandler(FileHandler handler);
198:
199: /**
200: * Set the handler for Gzip data.
201: */
202: void setGzipFileHandler(FileHandler handler);
203:
204: /**
205: * Checks for presence of CVS/Tag file and returns it's value.
206: *
207: * @return the value of CVS/Tag file for the specified directory
208: * null if file doesn't exist
209: */
210: String getStickyTagForDirectory(File directory);
211:
212: /**
213: * Ensures, that the connection is open.
214: *
215: * @throws AuthenticationException if it wasn't possible to connect
216: */
217: void ensureConnection() throws AuthenticationException;
218:
219: /**
220: * Returns the wrappers map associated with the CVS server
221: * The map is valid only after the connection is established
222: */
223: Map getWrappersMap() throws CommandException;
224:
225: /**
226: * Get the global options that are set to this client.
227: * Individual commands can get the global options via this method.
228: */
229: GlobalOptions getGlobalOptions();
230:
231: /**
232: * Tests for existence of the given file. Normally this method
233: * delegates to File.exists() but it may also return true for files
234: * that exists only virtually (in memory). Is such case the file/directory
235: * will not exist on disk but its metadata will be available via getEntries() methods.
236: *
237: * @param file file to test for existence
238: * @return true if the file exists, false otherwise
239: */
240: boolean exists(File file);
241:
242: /**
243: * Tests whether command execution should be aborted. Commands are encouraged to regulary
244: * poll this value if they expect to block for a long time in their code.
245: *
246: * @return true if currently running command should abort, false otherwise
247: */
248: boolean isAborted();
249: }
|