Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 8aa115bcf8785bf54f64d7dff379f3ab56f8cec9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package org.eclipse.team.internal.ccvs.core.response;

/*
 * (c) Copyright IBM Corp. 2000, 2001.
 * All Rights Reserved.
 */

import java.io.PrintStream;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.connection.Connection;
import org.eclipse.team.internal.ccvs.core.resources.CVSEntryLineTag;
import org.eclipse.team.internal.ccvs.core.resources.FolderSyncInfo;
import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.util.Util;

/**
 * ResponseHandler is an abstract class implementing the IResponseHandler.
 * 
 * At the moment it does just provide some additional helper-classes.
 */
public abstract class ResponseHandler implements IResponseHandler {
	
	public static final String SERVER_DELIM = "/";
	public static final String DUMMY_TIMESTAMP = "dummy timestamp";
	public static final String RESULT_OF_MERGE = "Result of merge+";

	/**
	 * Call the old method without a monitor. Either this method or
	 * the called method have to be overloaded, otherwise an 
	 * UnsupportedOperationException is thrown.<br>
	 * This is done for convinience to be able to keep the old methods
	 * that do not use a progress-monitor.
	 * 
	 * Handle the given response from the server.
	 */
	public void handle(Connection connection, 
							PrintStream messageOutput,
							ICVSFolder mRoot,
							IProgressMonitor monitor) 
							throws CVSException {
		
		handle(connection,messageOutput,mRoot);
	}
	
	/**
	 * This method throws an UnsupportedOperationException.
	 * To be overloaded
	 */
	public void handle(Connection connection, 
							PrintStream messageOutput,
							ICVSFolder mRoot) 
							throws CVSException {
		throw new UnsupportedOperationException();
	}
	
	/**
	 * Set the properties of the local folder, creating the folder if it does
	 * not exist. If the folder does exist, the remote parameter is not used.
	 * Also, the tag parameter is only set if setTag is true. Similarly,
	 * the parameter staticFolder is only set if setStatic is true.
	 * Otherwise these parameters are ignored.
	 */
	protected static void createFolder(Connection connection,
										ICVSFolder mRoot,
										String local,
										String remote,
										String tag,
										boolean staticFolder,
										boolean setTag,
										boolean setStatic) 
										throws CVSException {
		
		FolderSyncInfo info;
		ICVSFolder mFolder;
		
		mFolder = mRoot.getFolder(local);
		
		if (mFolder.exists() && mFolder.isCVSFolder()) {
			info = mFolder.getFolderSyncInfo();	
		} else {
			mFolder.mkdir();
			info = new FolderSyncInfo();
			info.setRoot(connection.getCVSRoot().getLocation());
			info.setRepository(Util.getRelativePath(connection.getRootDirectory(),
									  							remote));
		}
		
		if ((setTag) && (tag != null)) {
			info.setTag(new CVSEntryLineTag(tag));
		}
		
		if (setStatic) {
			info.setIsStatic(staticFolder);
		}
		
		mFolder.setFolderSyncInfo(info);
	}
}

Back to the top