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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
/*******************************************************************************
* Copyright (c) 2002 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM - Initial API and implementation
******************************************************************************/
package org.eclipse.team.core.target;
import java.net.URL;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.sync.IRemoteResource;
public abstract class TargetProvider {
/**
* Answers the site which this target is associated with
* @return a printable string
*/
public abstract Site getSite();
/**
* Answers the full path where the provider stores/retrieves to/from.
* @return a printable string
*/
public abstract URL getURL();
/**
* Updates the local resource to have the same content as the corresponding remote
* resource. Where the local resource does not exist, this method will create it.
* Where, the remote resource does not exist and the local does, this method will delete
* the local resource.
* <p>
* If the remote resource is a container (e.g. folder or project) this operation is equivalent
* to getting each member of the remote resource, thereby updating the
* content of existing local members, creating local members to receive new remote resources,
* and deleting local members that no longer have a corresponding remote resource.</p>
* <p>
* Interrupting the method (via the progress monitor) may lead to partial, but consistent, results.</p>
*
* @param resources an array of local resources to update from the corresponding remote
* resources.
* @param progress a progress monitor to indicate the duration of the operation, or
* <code>null</code> if progress reporting is not required.
* @throws TeamException if there is a problem getting one or more of the resources. The
* exception will contain multiple statuses, one for each resource in the <code>resources</code>
* array.
*/
public abstract void get(IResource[] resources, IProgressMonitor progress) throws TeamException;
/**
* Updates the local resource to have the same content as the given remote
* resource. Where the local resource does not exist, this method will create it.
* <p>
* If the remote resource is a container (e.g. folder or project) this operation is equivalent
* to getting each non-container member of the remote resource, thereby updating the
* content of existing local members, creating local members to receive new remote resources,
* and deleting local members that no longer have a corresponding remote resource.</p>
* <p>
* Interrupting the method (via the progress monitor) may lead to partial, but consistent, results.</p>
*
* @param resources an array of local resources to update from the corresponding remote
* resources.
* @param progress a progress monitor to indicate the duration of the operation, or
* <code>null</code> if progress reporting is not required.
* @throws TeamException if there is a problem getting one or more of the resources. The
* exception will contain multiple statuses, one for each resource in the <code>resources</code>
* array.
*/
public abstract void get(IResource resource, IRemoteTargetResource remote, IProgressMonitor progress) throws TeamException;
/**
* Transfers the content of the local resource to the corresponding remote resource.
* <p>
* If a remote resource does not exist this method creates a new remote resource with the same content
* as the given local resource. The local resource is said to <i>correspond</i> to the new remote resource.
* If the local resource doesn't exist and a remote does, the remote resource will be deleted.
* </p>
* <p>
* If the local resource is a container (e.g. folder or project) this operation is equivalent
* to putting each member of the local resource, thereby updating the
* content of existing remote members, creating remote members to receive new local resources,
* and deleting remote members that no longer have a corresponding local resource.</p>
* <p>
* @param resources an array of local resources to be put.
* @param progress a progress monitor to indicate the duration of the operation, or
* <code>null</code> if progress reporting is not required.
* @throws TeamException if there is a problem put'ing one or more of the resources.
* The exception will contain multiple status', one for each resource in the <code>resources</code>
* array.
*/
public abstract void put(IResource[] resources, IProgressMonitor progress) throws TeamException;
/**
* Returns a remote resource handle at the path of the given local resource.
*
* @param resource local resource path to be used to construct the remote handle's path
* @return a handle to a remote resource that may or may not exist
*/
public abstract IRemoteTargetResource getRemoteResourceFor(IResource resource);
/**
* Returns a remote resource handle at the path of this target provider's URL.
* @return a handle to a remote resource that may or may not exist
*/
public abstract IRemoteTargetResource getRemoteResource();
/**
* Replies true if its believed possible to get the given resource.
* This intended to be a relatively quick operation, presumably based on local state of the provider
* or it may be used to indicate that the provider only supports data transfer in one direction.
* It is not intended to indicate the existance of a remote resource. Hence, this method may return true
* even if there is no remote resource.
*/
public boolean canGet(IResource resource) {
return true;
}
/**
* Replies true if its believed possible to put the given resource.
* This intended to be a relatively quick operation, presumably based on local state of the provider
* or it may be used to indicate that the provider only supports data transfer in one direction.
*/
public boolean canPut(IResource resource) {
return true;
}
/**
* Answers true if the base identifier of the given resource is different to the
* current released state of the resource. Also answer true if there was not
* previously a correspondance between the local and remote resource.
*
* @param resource the resource to test
* @param monitor a progress monitor
*
* @throws TeamException if there is a problem getting this information from the server.
*/
public abstract boolean isOutOfDate(IResource resource, IProgressMonitor monitor) throws TeamException;
/**
* Answer true if the local resource currently has a different timestamp to the
* base timestamp for this resource. Answer true for local resources that no longer exist
* (i.e. the local resource did exist and corresponded to a remote resource) and false if the
* local resource does not exist and was never mapped to a remote resource.
*
* @param resource the resource to test
*/
public abstract boolean isDirty(IResource resource);
public abstract void deregister(IProject project);
/**
* This method provides a mechanism for allowing a target provider to optimize connections
* over a set of operations. The default behavior of the method is to run the provided runnable
* and to supply it with the provided progress monitor. Specific target providers may override this
* method in order to ensure that the number of connections made to a remote server is minimized.
* Calls to this method are nestable and it is up to the target provider to ensure that this is
* supported.
*/
public void run(final ITargetRunnable runnable, IProgressMonitor monitor) throws TeamException {
try {
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
try {
runnable.run(monitor);
} catch (TeamException e) {
throw new CoreException(e.getStatus());
}
}
}, monitor);
} catch (CoreException e) {
throw new TeamException(e.getStatus());
}
}
}
|