Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 75077dfe5e5bdc825ed9c0725bf3929496afc76c (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
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
/*******************************************************************************
 * Copyright (c) 2000, 2006 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.team.internal.ccvs.core.resources;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.Status;
import org.eclipse.team.internal.ccvs.core.*;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;

/**
 * The low level cache provides the sync info as bytes
 */
/*package*/ abstract class SyncInfoCache {

	// the resources plugin synchronizer is used to cache and possibly persist. These
	// are keys for storing the sync info.
	/*package*/ static final QualifiedName FOLDER_SYNC_KEY = new QualifiedName(CVSProviderPlugin.ID, "folder-sync"); //$NON-NLS-1$
	/*package*/ static final QualifiedName RESOURCE_SYNC_KEY = new QualifiedName(CVSProviderPlugin.ID, "resource-sync"); //$NON-NLS-1$
	/*package*/ static final QualifiedName IGNORE_SYNC_KEY = new QualifiedName(CVSProviderPlugin.ID, "folder-ignore"); //$NON-NLS-1$

	/*package*/ static final byte[][] EMPTY_RESOURCE_SYNC_INFOS = new byte[0][0];
	
	/*package*/ static final QualifiedName IS_DIRTY = new QualifiedName(CVSProviderPlugin.ID, "is-dirty"); //$NON-NLS-1$
	/*package*/ static final String IS_DIRTY_INDICATOR = "d"; //$NON-NLS-1$
	/*package*/ static final String NOT_DIRTY_INDICATOR = "c"; //$NON-NLS-1$
	/*package*/ static final String RECOMPUTE_INDICATOR = "r"; //$NON-NLS-1$
	
	/*package*/ static final IStatus STATUS_OK = new Status(IStatus.OK, CVSProviderPlugin.ID, 0, CVSMessages.ok, null); 
	
	/**
	 * Returns the folder sync info for the container; null if none.
	 * Folder must exist and must not be the workspace root.
	 * The folder sync info for the container MUST ALREADY BE CACHED.
	 * <p>
	 * The <code>canModifyWorkspace</code>
	 * flag is used to indicate whether it is OK to modify ISycnrhonizer entries for
	 * the given resource. A value of <code>true</code> indicates that the client
	 * holds a scheduling rule that encompasses the resource and the workspace is
	 * open for modification.
	 * @param container the container
     * @param threadSafeAccess if false, the return value can only be used if not null
	 * @param canModifyWorkspace indicates if it is OK to modify the ISycnrhonizer
	 *
	 * @return the folder sync info for the folder, or null if none.
	 * @see #cacheFolderSync
	 */
	/*package*/ abstract FolderSyncInfo getCachedFolderSync(IContainer container, boolean threadSafeAccess) throws CVSException;

	/**
	 * Sets the folder sync info for the container; if null, deletes it.
	 * Folder must exist and must not be the workspace root.
	 * The folder sync info for the container need not have previously been
	 * cached. The <code>canModifyWorkspace</code>
	 * flag is used to indicate whether it is OK to modify ISycnrhonizer entries for
	 * the given resource. A value of <code>true</code> indicates that the client
	 * holds a scheduling rule that encompasses the resource and the workspace is
	 * open for modification.
	 *
	 * @param container the container
	 * @param info the new folder sync info
	 * @param canModifyWorkspace indicates if it is OK to modify the ISycnrhonizer
	 */
	/*package*/ abstract void setCachedFolderSync(IContainer container, FolderSyncInfo info, boolean canModifyWorkspace) throws CVSException;

	/**
	 * Returns the resource sync info for the given resource. The resource sync
	 * info for the resource MUST ALREADY BE CACHED.
	 * @param resource the resource
	 * @param threadSafeAccess if false, the return value can only be used if not null
	 *
	 * @return the bytes containing the resource's sync info
	 * @see #cacheResourceSyncForChildren
	 */
	/*package*/ abstract byte[] getCachedSyncBytes(IResource resource, boolean threadSafeAccess) throws CVSException;

	/**
	 * Sets the resource sync info for the resource; if null, deletes it. Parent
	 * must exist and must not be the workspace root. The resource sync info for
	 * the resource MUST ALREADY BE CACHED. The <code>canModifyWorkspace</code>
	 * flag is used to indicate whether it is OK to modify ISycnrhonizer entries for
	 * the given resource. A value of <code>true</code> indicates that the client
	 * holds a scheduling rule that encompasses the resource and the workspace is
	 * open for modification.
	 *
	 * @param resource the resource
	 * @param syncBytes the bytes containing the new resource sync info
	 * @param canModifyWorkspace indicates if it is OK to modify the ISycnrhonizer
	 * @see #cacheResourceSyncForChildren
	 */
	/*package*/ abstract void setCachedSyncBytes(IResource resource, byte[] syncBytes, boolean canModifyWorkspace) throws CVSException;
	
	/*package*/ abstract String getDirtyIndicator(IResource resource, boolean threadSafeAccess) throws CVSException;
	
	/*package*/ abstract void setDirtyIndicator(IResource resource, String indicator) throws CVSException;
	
	/*package*/ abstract void flushDirtyCache(IResource resource) throws CVSException;
	
	/*package*/ abstract boolean isSyncInfoLoaded(IContainer parent) throws CVSException;
	
	/**
	 * Query the low level cache to see if the sync info for the provided
	 * container is loaded.
	 * 
	 * @param container
	 * @return boolean
	 * @throws CVSException
	 */
	/*package*/ abstract boolean isFolderSyncInfoCached(IContainer container) throws CVSException;
	
	/**
	 * Query the low level cache to see if the sync info for the direct children
	 * of the provided container is loaded.
	 * 
	 * @param container
	 * @return boolean
	 */
	/*package*/ abstract boolean isResourceSyncInfoCached(IContainer container) throws CVSException;
	
	/**
	 * Indicate to the low level cache that the sync info for all it's direct
	 * children have been set so they match what is on disk.
	 * 
	 * @param container
	 */
	/*package*/ abstract void setResourceSyncInfoCached(IContainer container) throws CVSException;

	/**
	 * Return whether the cache also caches dirty state or recomputes it
	 * each time it is requested.
	 */
	public abstract boolean cachesDirtyState();
}

Back to the top