public class Client extends Object implements ClientServices, ResponseServices
Connection,
Serialized Form| Modifier and Type | Class and Description |
|---|---|
static interface |
Client.Factory
Factory for creating clients.
|
| Constructor and Description |
|---|
Client(Connection connection,
AdminHandler adminHandler)
Construct a Client using a given connection and file handler.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
Call this method to abort the current command.
|
void |
addWrapper(StringPattern pattern,
KeywordSubstitutionOptions option)
This method is called by WrapperSendResponse for each wrapper setting
sent back by the CVS server
|
String |
convertPathname(String localDirectory,
String repository)
Convert a pathname in the CVS sense (see 5.10 in the protocol
document) into a local absolute pathname for the file.
|
void |
copyLocalFile(String pathname,
String newName)
Copy the local file
|
void |
dontUseGzipFileHandler()
ReSet the filehandler for Gzip compressed data.
|
void |
ensureConnection()
Ensures, that the connection is open.
|
boolean |
executeCommand(Command command,
GlobalOptions globalOptions)
Execute a command.
|
boolean |
exists(File file)
Tests for existence of the given file.
|
AdminHandler |
getAdminHandler()
Get the admin handler uesd to read and write administrative information
about files on the local machine.
|
Set<File> |
getAllFiles(File directory)
Get all the files contained within a given directory that are known to
CVS.
|
Connection |
getConnection()
Get the connection used for communicating with the server.
|
long |
getCounter()
Counts
processRequests(java.util.List). |
Iterator<Entry> |
getEntries(File directory)
Get the entries for a specified directory.
|
Entry |
getEntry(File f)
Get the Entry for the specified file, if one exists.
|
EventManager |
getEventManager()
Get the CVS event manager.
|
GlobalOptions |
getGlobalOptions()
Get the global options that are set to this client.
|
FileHandler |
getGzipFileHandler()
Return the Gzip stream handler.
|
IgnoreFileFilter |
getIgnoreFileFilter()
Returns the IgnoreFileFilter used to ignore non-cvs files.
|
String |
getLocalPath()
Get the local path; that is, the path to the directory in which the
currently executing command is referring.
|
Date |
getNextFileDate()
Get the modified date for the next file.
|
String |
getRepository()
Get the repository path from the connection.
|
String |
getRepositoryForDirectory(File directory)
Semantically equivalent to
ClientServices.getRepositoryForDirectory(String) but
does not try to recover from missing CVS/Repository file. |
String |
getRepositoryForDirectory(String directory)
Get the repository path for a given directory, for example in the
directory /home/project/foo/bar, the repository directory might be
/usr/cvs/foo/bar.
|
String |
getStickyTagForDirectory(File directory)
Checks for presence of CVS/Tag file and returns it's value.
|
FileHandler |
getUncompressedFileHandler()
Return the uncompressed file handler.
|
Map<StringPattern,KeywordSubstitutionOptions> |
getWrappersMap()
Returns the wrappers map associated with the CVS server The map is valid
only after the connection is established
|
boolean |
isAborted()
Tests whether command execution should be aborted.
|
boolean |
isFirstCommand()
Returns true if no previous command was executed using thiz.
|
void |
processRequests(List<Request> requests)
Process all the requests.
|
void |
removeEntry(File file)
Remove the Entry for the specified file.
|
void |
removeLocalFile(String pathname)
Remove the specified file from the local disk.
|
void |
removeLocalFile(String pathName,
String repositoryName)
Removes the specified file determined by pathName and repositoryName.
|
void |
setAdminHandler(AdminHandler adminHandler)
Set the admin handler used to read and write administrative information
about files on the local machine.
|
void |
setConnection(Connection connection)
Set the connection used for communicating with the server.
|
void |
setEntry(File file,
Entry entry)
Set the Entry for the specified file.
|
void |
setGzipFileHandler(FileHandler gzipFileHandler)
Set the handler for Gzip data.
|
void |
setIgnoreFileFilter(IgnoreFileFilter ignoreFileFilter)
Sets the specified IgnoreFileFilter to use to ignore non-cvs files.
|
void |
setIsFirstCommand(boolean isFirstCommand)
Set whether this is the first command.
|
void |
setLocalPath(String localPath)
Set the local path, i.e.
|
void |
setNextFileDate(Date modifiedDate)
Set the modified date of the next file to be written.
|
void |
setUncompressedFileHandler(FileHandler uncompFileHandler)
Set the uncompressed file handler.
|
void |
setValidRequests(String requests)
This method is called when a response for the ValidRequests request is
received.
|
boolean |
shouldBeIgnored(File directory,
String noneCvsFile)
Returnes true to indicate, that the file specified by directory and
nonCvsFile should be ignored.
|
void |
updateAdminData(String localDirectory,
String repositoryPath,
Entry entry)
Create or update the administration files for a particular file.
|
public Client(Connection connection, AdminHandler adminHandler)
// establish connection to the given CVS pserver
PServerConnection connection = new PServerConnection();
connection.setUserName(userName);
connection.setHostName(hostName);
connection.setEncodedPassword(StandardScrambler.getInstance().scramble(password));
connection.setRepository(repository);
// test the connection
try {
connection.open();
} catch (AuthenticationException e) {
// do something
}
// create a CVS client
Client cvsClient = new Client(connection,new StandardAdminHandler());
// set the directory in which we work
cvsClient.setLocalPath(localPath);
connection - the connection to the cvs serveradminHandler - the admin handler to usepublic Connection getConnection()
public void setConnection(Connection connection)
c - the connection to use for all communication with the serverpublic AdminHandler getAdminHandler()
public void setAdminHandler(AdminHandler adminHandler)
public String getLocalPath()
getLocalPath in interface ClientServicespublic void setLocalPath(String localPath)
public boolean isFirstCommand()
isFirstCommand in interface ClientServicespublic void setIsFirstCommand(boolean isFirstCommand)
setIsFirstCommand in interface ClientServicespublic FileHandler getUncompressedFileHandler()
getUncompressedFileHandler in interface ResponseServicespublic void setUncompressedFileHandler(FileHandler uncompFileHandler)
setUncompressedFileHandler in interface ClientServicespublic FileHandler getGzipFileHandler()
getGzipFileHandler in interface ResponseServicespublic void setGzipFileHandler(FileHandler gzipFileHandler)
setGzipFileHandler in interface ClientServicespublic void dontUseGzipFileHandler()
dontUseGzipFileHandler in interface ResponseServicespublic boolean isAborted()
ClientServicesisAborted in interface ClientServicespublic void ensureConnection()
throws AuthenticationException
ensureConnection in interface ClientServicesAuthenticationException - if it wasn't possible to connectpublic void processRequests(List<Request> requests) throws IOException, UnconfiguredRequestException, ResponseException, CommandAbortedException
processRequests in interface ClientServicesrequests - the requets to processIOExceptionUnconfiguredRequestExceptionResponseExceptionCommandAbortedExceptionpublic boolean executeCommand(Command command, GlobalOptions globalOptions) throws CommandException, CommandAbortedException, AuthenticationException
GlobalOptions options = new GlobalOptions();
options.setCVSRoot(":pserver:"+userName+"@"+hostName+":"+cvsRoot);
command - the command to executeoptions - the global options to use for executing the commandCommandException - if an error occurs when executing the commandCommandAbortedException - if the command is abortedAuthenticationExceptionpublic long getCounter()
processRequests(java.util.List). send and received bytes.public String convertPathname(String localDirectory, String repository)
convertPathname in interface ResponseServiceslocalDirectory - the name of the local directory, relative to the directory in
which the command was givenrepository - the full repository name for the filepublic String getRepository()
getRepository in interface ClientServicesConnection.getRepository()public void updateAdminData(String localDirectory, String repositoryPath, Entry entry) throws IOException
updateAdminData in interface ClientServicesupdateAdminData in interface ResponseServiceslocalDirectory - the local directory, relative to the directory in which the
command was given, where the file in question livesrepositoryPath - the path of the file in the repository, in absolute form.entry - the entry object for that fileIOException - if there is an error writing the filespublic void setNextFileDate(Date modifiedDate)
setNextFileDate in interface ResponseServicesmodifiedDate - the date the file should be marked as modifiedpublic Date getNextFileDate()
getNextFileDate in interface ResponseServicespublic Entry getEntry(File f) throws IOException
getEntry in interface ClientServicesf - the fileIOException - if the Entries file cannot be readpublic Iterator<Entry> getEntries(File directory) throws IOException
getEntries in interface ClientServicesdirectory - the directory for which to get the entriesIOExceptionpublic boolean exists(File file)
ClientServicesexists in interface ClientServicesfile - file to test for existencepublic String getRepositoryForDirectory(String directory) throws IOException
Repositoryin the CVS directory on the client (this is the case in the standard CVS command-line tool). If no
CVS / Repositoryfile was found, the specified directory, the localpath are used to "guess" the repository path.
getRepositoryForDirectory in interface ClientServicesdirectory - the directoryIOExceptionpublic String getRepositoryForDirectory(File directory) throws IOException
ClientServicesClientServices.getRepositoryForDirectory(String) but
does not try to recover from missing CVS/Repository file.getRepositoryForDirectory in interface ClientServicesdirectory - the directory to get repository forIOException - if the repository cannot be determined by reading
CVS/Repository filepublic void setEntry(File file, Entry entry) throws IOException
setEntry in interface ResponseServicesfile - the fileentry - the new entryIOException - if an error occurs writing the detailspublic void removeEntry(File file) throws IOException
removeEntry in interface ClientServicesremoveEntry in interface ResponseServicesfile - the file whose entry is to be removedIOException - if an error occurs writing the Entries filepublic void removeLocalFile(String pathname) throws IOException
removeLocalFile in interface ResponseServicespathname - the full path to the file to removeIOException - if an IO error occurs while removing the filepublic void removeLocalFile(String pathName, String repositoryName) throws IOException
removeLocalFile in interface ResponseServicesIOException - if an IO error occurs while removing the filepublic void copyLocalFile(String pathname, String newName) throws IOException
ResponseServicescopyLocalFile in interface ResponseServicespathname - the full path to the file to coypnewName - the new name of the file (not the full path)IOException - if an IO error occurs while copying the filepublic EventManager getEventManager()
getEventManager in interface ResponseServicespublic GlobalOptions getGlobalOptions()
getGlobalOptions in interface ClientServicesgetGlobalOptions in interface ResponseServicespublic void abort()
public Set<File> getAllFiles(File directory) throws IOException
getAllFiles in interface ClientServicesdirectory - the directory to look inIOExceptionpublic void setIgnoreFileFilter(IgnoreFileFilter ignoreFileFilter)
ClientServicessetIgnoreFileFilter in interface ClientServicespublic IgnoreFileFilter getIgnoreFileFilter()
ClientServicesgetIgnoreFileFilter in interface ClientServicespublic boolean shouldBeIgnored(File directory, String noneCvsFile)
ClientServicesshouldBeIgnored in interface ClientServicespublic String getStickyTagForDirectory(File directory)
getStickyTagForDirectory in interface ClientServicespublic void setValidRequests(String requests)
setValidRequests in interface ResponseServicesrequests - A List of requests that is valid for this CVS server separated
by spaces.public void addWrapper(StringPattern pattern, KeywordSubstitutionOptions option)
addWrapper in interface ResponseServicespattern - A StringPattern indicating the pattern for which the wrapper
appliesoption - A KeywordSubstituionOption corresponding to the settingpublic Map<StringPattern,KeywordSubstitutionOptions> getWrappersMap() throws CommandException
getWrappersMap in interface ClientServicesCommandExceptionCopyright © 2013. All rights reserved.