diff options
Diffstat (limited to 'bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal')
4 files changed, 198 insertions, 19 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java index fd30e7288..9d5b81572 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java @@ -32,29 +32,29 @@ import org.eclipse.team.internal.ccvs.core.util.Util; public class CVSProviderPlugin extends Plugin { - private static CVSProviderPlugin instance; - - private static ICVSSynchronizer synchronizer; - - /** - * Int used for the communications timeout on server connections (in seconds) - */ - public static final int DEFAULT_TIMEOUT = 60; - private int communicationsTimeout = DEFAULT_TIMEOUT; - - /** - * Boolean which determines if empty directories received - * from the server should be pruned - */ + // external command to run for ext connection method + public static final String DEFAULT_CVS_RSH = "ssh"; //$NON-NLS-1$ + // remote command to run for ext connection method + public static final String DEFAULT_CVS_SERVER = "cvs"; //$NON-NLS-1$ + // determines if empty directories received from the server should be pruned. public static final boolean DEFAULT_PRUNE = true; - private boolean pruneEmptyDirectories = DEFAULT_PRUNE; + // communication timeout with the server + public static final int DEFAULT_TIMEOUT = 60; - private QuietOption quietness; - + // cvs plugin extension points and ids public static final String ID = "org.eclipse.team.cvs.core"; //$NON-NLS-1$ public static final String PT_AUTHENTICATOR = "authenticator"; //$NON-NLS-1$ public static final String PT_CONNECTIONMETHODS = "connectionmethods"; //$NON-NLS-1$ + private QuietOption quietness; + private int communicationsTimeout = DEFAULT_TIMEOUT; + private boolean pruneEmptyDirectories = DEFAULT_PRUNE; + private String cvsRshCommand = DEFAULT_CVS_RSH; + private String cvsServer = DEFAULT_CVS_SERVER; + + private static CVSProviderPlugin instance; + private static ICVSSynchronizer synchronizer; + /** * The identifier for the CVS nature * (value <code>"org.eclipse.team.cvs.core.nature"</code>). @@ -219,5 +219,37 @@ public class CVSProviderPlugin extends Plugin { }; ResourcesPlugin.getWorkspace().addResourceChangeListener(projectChangeListener, IResourceChangeEvent.POST_AUTO_BUILD); } + + /** + * Gets the cvsRshCommand. + * @return Returns a String + */ + public String getCvsRshCommand() { + return cvsRshCommand; + } + + /** + * Sets the cvsRshCommand. + * @param cvsRshCommand The cvsRshCommand to set + */ + public void setCvsRshCommand(String cvsRshCommand) { + this.cvsRshCommand = cvsRshCommand; + } + + /** + * Gets the cvsServer. + * @return Returns a String + */ + public String getCvsServer() { + return cvsServer; + } + + /** + * Sets the cvsServer. + * @param cvsServer The cvsServer to set + */ + public void setCvsServer(String cvsServer) { + this.cvsServer = cvsServer; + } } diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnection.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnection.java new file mode 100644 index 000000000..36caf9fc7 --- /dev/null +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnection.java @@ -0,0 +1,117 @@ +package org.eclipse.team.internal.ccvs.core.connection; + +/* + * (c) Copyright IBM Corp. 2000, 2001. + * All Rights Reserved. + */ + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.team.ccvs.core.CVSProviderPlugin; +import org.eclipse.team.ccvs.core.ICVSRepositoryLocation; +import org.eclipse.team.ccvs.core.IServerConnection; +import org.eclipse.team.internal.ccvs.core.Policy; + +/** + * Implements a connection method which invokes an external tool to + * establish the connection to the cvs server. Authentication and starting + * of the cvs server are the responsibility of the external connection + * tool. + */ +public class ExtConnection implements IServerConnection { + + // command to start remote cvs in server mode + private static final String INVOKE_SVR_CMD = "server"; //$NON-NLS-1$ + + // The default port for rsh + private static final int DEFAULT_PORT = 9999; + + // cvs format for the repository (e.g. :extssh:user@host:/home/cvs/repo) + private ICVSRepositoryLocation location; + + // incoming from remote host + InputStream inputStream; + + // outgoing to remote host + OutputStream outputStream; + + // Process spawn to run the command + Process process; + + protected ExtConnection(ICVSRepositoryLocation location, String password) { + this.location = location; + // passwork not needed, authentication performed by external tool + } + + /** + * Closes the connection. + */ + public void close() throws IOException { + inputStream.close(); + outputStream.close(); + process.destroy(); + } + + /** + * Returns the <code>InputStream</code> used to read data from the + * server. + */ + public InputStream getInputStream() { + return inputStream; + } + + /** + * Returns the <code>OutputStream</code> used to send data to the + * server. + */ + public OutputStream getOutputStream() { + return outputStream; + } + + /** + * Opens the connection and invokes cvs in server mode. + * + * @see Connection.open() + */ + public void open(IProgressMonitor monitor) throws IOException { + String hostname = location.getHost(); + String username = location.getUsername(); + + String CVS_RSH = CVSProviderPlugin.getPlugin().getCvsRshCommand(); + String CVS_SERVER = CVSProviderPlugin.getPlugin().getCvsServer(); + String[] command = new String[] {CVS_RSH, "-l", username, hostname, CVS_SERVER, INVOKE_SVR_CMD}; //$NON-NLS-1$ + + int port = location.getPort(); + if (port == location.USE_DEFAULT_PORT) + port = DEFAULT_PORT; + try { + // The command line doesn't support the use of a port + if (port != DEFAULT_PORT) + throw new IOException(Policy.bind("EXTServerConnection.invalidPort")); //$NON-NLS-1$ + + if(CVS_RSH == null || CVS_SERVER == null) { + throw new IOException(Policy.bind("EXTServerConnection.varsNotSet")); //$NON-NLS-1$ + } + + process = Runtime.getRuntime().exec(command); + + inputStream = process.getInputStream(); + outputStream = process.getOutputStream(); + } catch (IOException ex) { + try { + close(); + } finally { + throw new IOException(Policy.bind("EXTServerConnection.ioError", CVS_RSH)); //$NON-NLS-1$ + } + } catch (RuntimeException e) { + try { + close(); + } finally { + throw new IOException(Policy.bind("EXTServerConnection.ioError", CVS_RSH)); //$NON-NLS-1$ + } + } + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnectionMethod.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnectionMethod.java new file mode 100644 index 000000000..90b59aca1 --- /dev/null +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnectionMethod.java @@ -0,0 +1,26 @@ +package org.eclipse.team.internal.ccvs.core.connection; + +/* + * (c) Copyright IBM Corp. 2000, 2001. + * All Rights Reserved. + */ + +import org.eclipse.team.ccvs.core.ICVSRepositoryLocation; +import org.eclipse.team.ccvs.core.IConnectionMethod; +import org.eclipse.team.ccvs.core.IServerConnection; + +public class ExtConnectionMethod implements IConnectionMethod { + /** + * @see IConnectionMethod#getName + */ + public String getName() { + return "ext"; //$NON-NLS-1$ + } + + /** + * @see IConnectionMethod#createConnection + */ + public IServerConnection createConnection(ICVSRepositoryLocation repositoryRoot, String password) { + return new ExtConnection(repositoryRoot, password); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties index 811a10e09..aea7aa4a5 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties @@ -108,7 +108,7 @@ Command.status=status Command.tag=tag Command.update=update Command.valid-requests=valid-requests -Command.unsupportedResponse=Unsupported response {0} received from cvs server +Command.unsupportedResponse=Unsupported response received from cvs server: {0} Command.argumentNotManaged=Argument {0} is not managed Command.loadingSyncInfo=Loading CVS synchronization information Command.loadingSyncInfo=Saving CVS synchronization information @@ -162,4 +162,8 @@ SyncFileUtil_Error_reloading_sync_information_58=Error reloading sync informatio SyncFileUtil_Error_writing_to_.cvsignore_61=Error writing to .cvsignore SyncFileUtil_Cannot_close_.cvsignore_62=Cannot close .cvsignore -FileModificationValidator.isReadOnly=File is Read Only.
\ No newline at end of file +FileModificationValidator.isReadOnly=File is Read Only. + +EXTServerConnection.invalidPort=A port cannot be specified for the ext connection method. +EXTServerConnection.varsNotSet=Cannot run external ext program because CVS_RSH and CVS_SERVER variables are not initialized. +EXTServerConnection.ioError=Error starting external connection program: {0}. Ensure that the path is correct and that you can connect manually using this program.
\ No newline at end of file |