KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > core > client > CommandOutputListener


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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.team.internal.ccvs.core.CVSStatus;
16 import org.eclipse.team.internal.ccvs.core.ICVSFolder;
17 import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
18 import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
19 import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
20
21 public class CommandOutputListener implements ICommandOutputListener {
22     
23     /*
24      * Failure string that is returned from the server when pserver is used and the root directory
25      * is not readable. The problem can be fixed by making the directory readable or by using -f in
26      * the pserver configuration file. We will ignore the error since it does not affect the command.
27      */

28     public static final String JavaDoc ROOT_CVSIGNORE_READ_FAILURE = "cvs server: cannot open /root/.cvsignore: Permission denied"; //$NON-NLS-1$
29

30     public IStatus messageLine(String JavaDoc line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) {
31         return OK;
32     }
33     public IStatus errorLine(String JavaDoc line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) {
34         String JavaDoc protocolError = getProtocolError(line, location);
35         if (protocolError != null) {
36             return new CVSStatus(IStatus.ERROR, CVSStatus.PROTOCOL_ERROR, protocolError, commandRoot);
37         }
38         if (line.equals(ROOT_CVSIGNORE_READ_FAILURE) || getServerMessage(ROOT_CVSIGNORE_READ_FAILURE, location).equals(getServerMessage(line, location))) {
39             // Don't report this as an error since it does not affect the command
40
return new CVSStatus(IStatus.WARNING, CVSStatus.ERROR_LINE, line, commandRoot);
41         }
42         return new CVSStatus(IStatus.ERROR, CVSStatus.ERROR_LINE, line, commandRoot);
43     }
44     
45     /**
46      * Return the portion of the line that describes the error if the error line
47      * is a protocol error or null if the line is not a protocol error.
48      *
49      * @param line the error line received from the server
50      * @param location the repository location
51      * @return String the potocol error or null
52      */

53     protected String JavaDoc getProtocolError(String JavaDoc line, ICVSRepositoryLocation location) {
54         if (line.startsWith("Protocol error:")) { //$NON-NLS-1$
55
return line;
56         }
57         return null;
58     }
59
60     public String JavaDoc getServerMessage(String JavaDoc line, ICVSRepositoryLocation location) {
61         return ((CVSRepositoryLocation)location).getServerMessageWithoutPrefix(line, SERVER_PREFIX);
62     }
63
64     public String JavaDoc getServerAbortedMessage(String JavaDoc line, ICVSRepositoryLocation location) {
65         return ((CVSRepositoryLocation)location).getServerMessageWithoutPrefix(line, SERVER_ABORTED_PREFIX);
66     }
67
68     public String JavaDoc getServerRTagMessage(String JavaDoc line, ICVSRepositoryLocation location) {
69         return ((CVSRepositoryLocation)location).getServerMessageWithoutPrefix(line, RTAG_PREFIX);
70     }
71 }
72
Popular Tags