1 11 package org.eclipse.team.internal.ccvs.core.client; 12 13 import org.eclipse.core.runtime.IProgressMonitor; 14 import org.eclipse.core.runtime.IStatus; 15 import org.eclipse.osgi.util.NLS; 16 import org.eclipse.team.internal.ccvs.core.*; 17 import org.eclipse.team.internal.ccvs.core.CVSException; 18 import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; 19 import org.eclipse.team.internal.ccvs.core.CVSStatus; 20 import org.eclipse.team.internal.ccvs.core.ICVSFolder; 21 import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; 22 import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener; 23 import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; 24 25 32 public class Version extends RemoteCommand { 33 34 private static final String CVS_NT_PREFIX_1 = "Concurrent Versions System (CVS) NT "; private static final String CVS_NT_PREFIX_2 = "Concurrent Versions System (CVSNT) "; private static final String CVS_PREFIX = "Concurrent Versions System (CVS) "; 40 protected String getRequestId() { 41 return "version"; } 43 44 public IStatus execute(Session session, final ICVSRepositoryLocation location, IProgressMonitor monitor) throws CVSException { 45 46 if ( ! session.isValidRequest(getRequestId())) { 48 IStatus status = new CVSStatus(IStatus.WARNING, CVSStatus.SERVER_IS_UNKNOWN, NLS.bind(CVSMessages.Version_versionNotValidRequest, new String [] { location.getHost() }), session.getLocalRoot()); 49 ((CVSRepositoryLocation)location).setServerPlaform(CVSRepositoryLocation.UNKNOWN_SERVER); 50 CVSProviderPlugin.log(status); 51 return status; 52 } 53 54 ICommandOutputListener listener = new ICommandOutputListener() { 55 public IStatus messageLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) { 56 String knownPrefix = null; 57 boolean isCVSNT = false; 58 if (line.startsWith(CVS_NT_PREFIX_1)) { 59 isCVSNT = true; 60 knownPrefix = CVS_NT_PREFIX_1; 61 } else if (line.startsWith(CVS_NT_PREFIX_2)) { 62 isCVSNT = true; 63 knownPrefix = CVS_NT_PREFIX_2; 64 } else if (line.startsWith(CVS_PREFIX)) { 65 knownPrefix = CVS_PREFIX; 66 } 67 IStatus status = OK; 68 int serverType = CVSRepositoryLocation.CVS_SERVER; 69 if (knownPrefix != null) { 70 String versionNumber = line.substring(knownPrefix.length(), line.indexOf(' ', knownPrefix.length() + 1)); 71 if (versionNumber.startsWith("1.10") || versionNumber.equals("1.11") || versionNumber.equals("1.11.1")) { serverType = CVSRepositoryLocation.UNSUPPORTED_SERVER; 73 status = new CVSStatus(IStatus.WARNING, CVSStatus.UNSUPPORTED_SERVER_VERSION, NLS.bind(CVSMessages.Version_unsupportedVersion, new String [] { location.getHost(), versionNumber }),location); 74 } else if (isCVSNT) { 75 serverType = CVSRepositoryLocation.CVSNT_SERVER; 76 } 77 } else { 78 serverType = CVSRepositoryLocation.UNKNOWN_SERVER; 79 status = new CVSStatus(IStatus.INFO, CVSStatus.SERVER_IS_UNKNOWN, NLS.bind(CVSMessages.Version_unknownVersionFormat, new String [] { location.getHost(), line }), location); 80 } 81 ((CVSRepositoryLocation)location).setServerPlaform(serverType); 82 return status; 83 } 84 public IStatus errorLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) { 85 return new CVSStatus(IStatus.ERROR, CVSStatus.ERROR_LINE, line, commandRoot); 86 } 87 }; 88 89 return execute(session, NO_GLOBAL_OPTIONS, NO_LOCAL_OPTIONS, new String [] {}, listener, monitor); 90 } 91 92 95 protected boolean isWorkspaceModification() { 96 return false; 97 } 98 99 } 100 | Popular Tags |