KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > repo > RepositoryRoot


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.ui.repo;
12
13 import java.io.IOException JavaDoc;
14 import java.lang.reflect.InvocationTargetException JavaDoc;
15 import java.util.ArrayList JavaDoc;
16 import java.util.Arrays JavaDoc;
17 import java.util.HashMap JavaDoc;
18 import java.util.HashSet JavaDoc;
19 import java.util.Iterator JavaDoc;
20 import java.util.List JavaDoc;
21 import java.util.Map JavaDoc;
22 import java.util.Set JavaDoc;
23
24 import org.eclipse.core.runtime.*;
25 import org.eclipse.osgi.util.NLS;
26 import org.eclipse.team.core.TeamException;
27 import org.eclipse.team.internal.ccvs.core.*;
28 import org.eclipse.team.internal.ccvs.core.client.Command;
29 import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
30 import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
31 import org.eclipse.team.internal.ccvs.ui.*;
32 import org.eclipse.team.internal.ccvs.ui.Policy;
33 import org.eclipse.team.internal.ccvs.ui.operations.RemoteLogOperation;
34 import org.eclipse.team.internal.ccvs.ui.operations.RemoteLogOperation.LogEntryCache;
35
36 public class RepositoryRoot extends PlatformObject {
37
38     public static final String JavaDoc[] DEFAULT_AUTO_REFRESH_FILES = { ".project" }; //$NON-NLS-1$
39
private static final String JavaDoc DEFINED_MODULE_PREFIX = "module:"; //$NON-NLS-1$
40

41     ICVSRepositoryLocation root;
42     String JavaDoc name;
43     // Map of String (remote folder path) -> TagCacheEntry
44
Map JavaDoc versionAndBranchTags = new HashMap JavaDoc();
45     // Map of String (remote folder path) -> Set (file paths that are project relative)
46
Map JavaDoc autoRefreshFiles = new HashMap JavaDoc();
47     // Map of String (module name) -> ICVSRemoteFolder (that is a defined module)
48
Map JavaDoc modulesCache;
49     Object JavaDoc modulesCacheLock = new Object JavaDoc();
50     // Lis of date tags
51
List JavaDoc dateTags = new ArrayList JavaDoc();
52     
53     public static class TagCacheEntry {
54         Set JavaDoc tags = new HashSet JavaDoc();
55         long lastAccessTime;
56         private static final int CACHE_LIFESPAN_IN_DAYS = 7;
57         public TagCacheEntry() {
58             accessed();
59         }
60         public boolean isExpired() {
61             long currentTime = System.currentTimeMillis();
62             long ms = currentTime - lastAccessTime;
63             int seconds = (int)ms / 1000;
64             int hours = seconds / 60 / 60;
65             int days = hours / 24;
66             return days > CACHE_LIFESPAN_IN_DAYS;
67         }
68         public void accessed() {
69             lastAccessTime = System.currentTimeMillis();
70         }
71     }
72     
73     public RepositoryRoot(ICVSRepositoryLocation root) {
74         this.root = root;
75     }
76     
77     /**
78      * Returns the name.
79      * @return String
80      */

81     public String JavaDoc getName() {
82         return name;
83     }
84
85     /**
86      * Method getRemoteFolder.
87      * @param path
88      * @param tag
89      * @return ICVSRemoteFolder
90      */

91     public ICVSRemoteFolder getRemoteFolder(String JavaDoc path, CVSTag tag, IProgressMonitor monitor) {
92         if (isDefinedModuleName(path)) {
93             return getDefinedModule(getDefinedModuleName(path), tag, monitor);
94         } else {
95             return root.getRemoteFolder(path, tag);
96         }
97     }
98
99     static boolean isDefinedModuleName(String JavaDoc path) {
100         return path.startsWith(DEFINED_MODULE_PREFIX);
101     }
102
103     static String JavaDoc getDefinedModuleName(String JavaDoc path) {
104         return path.substring(DEFINED_MODULE_PREFIX.length());
105     }
106     
107     static String JavaDoc asDefinedModulePath(String JavaDoc path) {
108         return DEFINED_MODULE_PREFIX + path;
109     }
110     
111     /**
112      * Method getDefinedModule.
113      * @param path
114      * @param tag
115      * @param monitor
116      * @return ICVSRemoteFolder
117      */

118     private ICVSRemoteFolder getDefinedModule(String JavaDoc path, CVSTag tag, IProgressMonitor monitor) {
119         Map JavaDoc cache = getDefinedModulesCache(tag, monitor);
120         ICVSRemoteFolder folder = (ICVSRemoteFolder)cache.get(path);
121         if (folder != null) {
122             folder = (ICVSRemoteFolder)folder.forTag(tag);
123         }
124         return folder;
125     }
126     
127     private Map JavaDoc getDefinedModulesCache(CVSTag tag, IProgressMonitor monitor) {
128         if (modulesCache == null) {
129             try {
130                 // Fetch the modules before locking the cache (to avoid deadlock)
131
ICVSRemoteResource[] folders = root.members(CVSTag.DEFAULT, true, monitor);
132                 synchronized(modulesCacheLock) {
133                     modulesCache = new HashMap JavaDoc();
134                     for (int i = 0; i < folders.length; i++) {
135                         ICVSRemoteResource resource = folders[i];
136                         modulesCache.put(resource.getName(), resource);
137                     }
138                 }
139             } catch (CVSException e) {
140                 // we could't fetch the modules. Log the problem and continue
141
CVSUIPlugin.log(e);
142                 // Return an empty map but don't save it so the fetching of
143
// the modules will occur again
144
return new HashMap JavaDoc();
145             }
146         }
147         return modulesCache;
148     }
149     
150     public ICVSRemoteResource[] getDefinedModules(CVSTag tag, IProgressMonitor monitor) {
151         Map JavaDoc cache = getDefinedModulesCache(tag, monitor);
152         return (ICVSRemoteResource[]) cache.values().toArray(new ICVSRemoteResource[cache.size()]);
153     }
154     
155     public static String JavaDoc getRemotePathFor(ICVSResource resource) throws CVSException {
156         if (resource.isFolder()) {
157             if (resource instanceof ICVSRemoteFolder) {
158                 ICVSRemoteFolder remoteFolder = (ICVSRemoteFolder) resource;
159                 if (remoteFolder.isDefinedModule()) {
160                     return asDefinedModulePath(remoteFolder.getName());
161                 }
162             }
163             FolderSyncInfo info = ((ICVSFolder)resource).getFolderSyncInfo();
164             if (info == null)
165                 throw new CVSException(NLS.bind(CVSUIMessages.RepositoryRoot_folderInfoMissing, new String JavaDoc[] { resource.getName() }));
166             return info.getRepository();
167         } else {
168             FolderSyncInfo info = resource.getParent().getFolderSyncInfo();
169             if (info == null)
170                 throw new CVSException(NLS.bind(CVSUIMessages.RepositoryRoot_folderInfoMissing, new String JavaDoc[] { resource.getParent().getName() }));
171             String JavaDoc path = new Path(null, info.getRepository()).append(resource.getName()).toString();
172             return path;
173         }
174     }
175     
176     /**
177      * Returns the root.
178      * @return ICVSRepositoryLocation
179      */

180     public ICVSRepositoryLocation getRoot() {
181         return root;
182     }
183
184     /**
185      * Sets the name.
186      * @param name The name to set
187      */

188     public void setName(String JavaDoc name) {
189         this.name = name;
190     }
191
192     /**
193      * Accept the tags for any remote path that represents a folder. However, for the time being,
194      * the given version tags are added to the list of known tags for the
195      * remote ancestor of the resource that is a direct child of the remote root.
196      *
197      * It is the reponsibility of the caller to ensure that the given remote path is valid.
198      */

199     public void addTags(String JavaDoc remotePath, CVSTag[] tags) {
200         addDateTags(tags);
201         addVersionAndBranchTags(remotePath, tags);
202     }
203
204     private void addDateTags(CVSTag[] tags){
205         for(int i = 0; i < tags.length; i++){
206             if(tags[i].getType() == CVSTag.DATE){
207                 dateTags.add(tags[i]);
208             }
209         }
210     }
211     private void addVersionAndBranchTags(String JavaDoc remotePath, CVSTag[] tags) {
212         // Get the name to cache the version tags with
213
String JavaDoc name = getCachePathFor(remotePath);
214         
215         // Make sure there is a table for the ancestor that holds the tags
216
TagCacheEntry entry = (TagCacheEntry)versionAndBranchTags.get(name);
217         if (entry == null) {
218             entry = new TagCacheEntry();
219             versionAndBranchTags.put(name, entry);
220         } else {
221             entry.accessed();
222         }
223         
224         // Store the tag with the appropriate ancestor
225
for (int i = 0; i < tags.length; i++) {
226             if(tags[i].getType() != CVSTag.DATE){
227                 entry.tags.add(tags[i]);
228             }
229         }
230     }
231
232     /**
233      * Add the given date tag to the list of date tags associated with the repository.
234      * @param tag a date tag
235      */

236     public void addDateTag(CVSTag tag) {
237         if (!dateTags.contains(tag)) {
238             dateTags.add(tag);
239         }
240     }
241     public void removeDateTag(CVSTag tag) {
242         if (dateTags.contains(tag)) {
243             dateTags.remove(tag);
244         }
245     }
246     /**
247      * Return the list of date tags assocaiated with the repository.
248      * @return the list of date tags
249      */

250     public CVSTag[] getDateTags() {
251         return (CVSTag[]) dateTags.toArray(new CVSTag[dateTags.size()]);
252     }
253     
254     /**
255      * Remove the given tags from the receiver
256      * @param remotePath
257      * @param tags
258      */

259     public void removeTags(String JavaDoc remotePath, CVSTag[] tags) {
260         removeDateTags(tags);
261         removeVersionAndBranchTags(remotePath, tags);
262     }
263     
264     private void removeDateTags(CVSTag[] tags) {
265         if(dateTags.isEmpty())return;
266         // Store the tag with the appropriate ancestor
267
for (int i = 0; i < tags.length; i++) {
268             dateTags.remove(tags[i]);
269         }
270     }
271
272     private void removeVersionAndBranchTags(String JavaDoc remotePath, CVSTag[] tags) {
273         // Get the name to cache the version tags with
274
String JavaDoc name = getCachePathFor(remotePath);
275         
276         // Make sure there is a table for the ancestor that holds the tags
277
TagCacheEntry entry = (TagCacheEntry)versionAndBranchTags.get(name);
278         if (entry == null) {
279             return;
280         }
281         
282         // Store the tag with the appropriate ancestor
283
for (int i = 0; i < tags.length; i++) {
284             entry.tags.remove(tags[i]);
285         }
286         entry.accessed();
287     }
288
289     /**
290      * Returns the absolute paths of the auto refresh files relative to the
291      * repository.
292      *
293      * @return String[]
294      */

295     public String JavaDoc[] getAutoRefreshFiles(String JavaDoc remotePath) {
296         String JavaDoc name = getCachePathFor(remotePath);
297         Set JavaDoc files = (Set JavaDoc)autoRefreshFiles.get(name);
298         if (files == null || files.isEmpty()) {
299             // convert the default relative file paths to full paths
300
if (isDefinedModuleName(remotePath)) {
301                 return new String JavaDoc[0];
302             }
303             List JavaDoc result = new ArrayList JavaDoc();
304             for (int i = 0; i < DEFAULT_AUTO_REFRESH_FILES.length; i++) {
305                 String JavaDoc relativePath = DEFAULT_AUTO_REFRESH_FILES[i];
306                 result.add(new Path(null, remotePath).append(relativePath).toString());
307             }
308             return (String JavaDoc[]) result.toArray(new String JavaDoc[result.size()]);
309         } else {
310             return (String JavaDoc[]) files.toArray(new String JavaDoc[files.size()]);
311         }
312     }
313     
314     /**
315      * Sets the auto refresh files for the given remote path to the given
316      * string values which are absolute file paths (relative to the receiver).
317      *
318      * @param autoRefreshFiles The autoRefreshFiles to set
319      */

320     public void setAutoRefreshFiles(String JavaDoc remotePath, String JavaDoc[] autoRefreshFiles) {
321         Set JavaDoc newFiles = new HashSet JavaDoc(Arrays.asList(autoRefreshFiles));
322         // Check to see if the auto-refresh files are the default files
323
if (autoRefreshFiles.length == DEFAULT_AUTO_REFRESH_FILES.length) {
324             boolean isDefault = true;
325             for (int i = 0; i < DEFAULT_AUTO_REFRESH_FILES.length; i++) {
326                 String JavaDoc filePath = DEFAULT_AUTO_REFRESH_FILES[i];
327                 if (!newFiles.contains(new Path(null, remotePath).append(filePath).toString())) {
328                     isDefault = false;
329                     break;
330                 }
331             }
332             if (isDefault) {
333                 this.autoRefreshFiles.remove(getCachePathFor(remotePath));
334                 return;
335             }
336         }
337         this.autoRefreshFiles.put(getCachePathFor(remotePath), newFiles);
338     }
339
340     /**
341      * Fetches tags from auto-refresh files.
342      */

343     public CVSTag[] refreshDefinedTags(ICVSFolder folder, boolean recurse, IProgressMonitor monitor) throws TeamException {
344         monitor.beginTask(null, 100);
345         CVSTag[] tags = null;
346         if (!recurse && !folder.getFolderSyncInfo().isVirtualDirectory()) {
347             // Only try the auto-refresh file(s) if we are not recursing into sub-folders
348
tags = fetchTagsUsingAutoRefreshFiles(folder, Policy.subMonitorFor(monitor, 50));
349         }
350         if (tags == null || tags.length == 0) {
351             // There we're no tags found on the auto-refresh files or we we're aksed to go deep
352
// Try using the log command
353
tags = fetchTagsUsingLog(folder, recurse, Policy.subMonitorFor(monitor, 50));
354         }
355         if (tags != null && tags.length > 0) {
356             String JavaDoc remotePath = getRemotePathFor(folder);
357             addTags(remotePath, tags);
358         }
359         monitor.done();
360         return tags;
361     }
362     
363     private CVSTag[] fetchTagsUsingLog(ICVSFolder folder, final boolean recurse, IProgressMonitor monitor) throws CVSException {
364         LogEntryCache logEntries = new LogEntryCache();
365         RemoteLogOperation operation = new RemoteLogOperation(null, new ICVSRemoteResource[] { asRemoteResource(folder) }, null, null, logEntries) {
366             protected Command.LocalOption[] getLocalOptions(CVSTag tag1,CVSTag tag2) {
367                 Command.LocalOption[] options = new Command.LocalOption[] {};
368                 if (recurse)
369                     return options;
370                 Command.LocalOption[] newOptions = new Command.LocalOption[options.length + 1];
371                 System.arraycopy(options, 0, newOptions, 0, options.length);
372                 newOptions[options.length] = Command.DO_NOT_RECURSE;
373                 return newOptions;
374             }
375         };
376         try {
377             operation.run(monitor);
378         } catch (InvocationTargetException JavaDoc e) {
379             throw CVSException.wrapException(e);
380         } catch (InterruptedException JavaDoc e) {
381             // Ignore;
382
}
383         String JavaDoc[] keys = logEntries.getCachedFilePaths();
384         Set JavaDoc tags = new HashSet JavaDoc();
385         for (int i = 0; i < keys.length; i++) {
386             String JavaDoc key = keys[i];
387             ILogEntry[] entries = logEntries.getLogEntries(key);
388             for (int j = 0; j < entries.length; j++) {
389                 ILogEntry entry = entries[j];
390                 tags.addAll(Arrays.asList(entry.getTags()));
391             }
392         }
393         return (CVSTag[]) tags.toArray(new CVSTag[tags.size()]);
394     }
395
396     private ICVSRemoteResource asRemoteResource(ICVSFolder folder) throws CVSException {
397         if (folder instanceof ICVSRemoteResource) {
398             return (ICVSRemoteResource)folder;
399         }
400         return CVSWorkspaceRoot.getRemoteResourceFor(folder);
401     }
402
403     /**
404      * Fetches tags from auto-refresh files.
405      */

406     private CVSTag[] fetchTagsUsingAutoRefreshFiles(ICVSFolder folder, IProgressMonitor monitor) throws TeamException {
407         String JavaDoc remotePath = getRemotePathFor(folder);
408         String JavaDoc[] filesToRefresh = getAutoRefreshFiles(remotePath);
409         try {
410             monitor.beginTask(null, filesToRefresh.length * 10);
411             List JavaDoc tags = new ArrayList JavaDoc();
412             for (int i = 0; i < filesToRefresh.length; i++) {
413                 ICVSRemoteFile file = root.getRemoteFile(filesToRefresh[i], CVSTag.DEFAULT);
414                 try {
415                     tags.addAll(Arrays.asList(fetchTags(file, Policy.subMonitorFor(monitor, 5))));
416                 } catch (TeamException e) {
417                     IStatus status = e.getStatus();
418                     boolean doesNotExist = false;
419                     if (status.getCode() == CVSStatus.SERVER_ERROR && status.isMultiStatus()) {
420                         IStatus[] children = status.getChildren();
421                         if (children.length == 1 && children[0].getCode() == CVSStatus.DOES_NOT_EXIST) {
422                             // Don't throw an exception if the file does no exist
423
doesNotExist = true;
424                         }
425                     }
426                     if (!doesNotExist) {
427                         throw e;
428                     }
429                 }
430             }
431             return (CVSTag[]) tags.toArray(new CVSTag[tags.size()]);
432         } finally {
433             monitor.done();
434         }
435     }
436     
437     /**
438      * Returns Branch and Version tags for the given files
439      */

440     private CVSTag[] fetchTags(ICVSRemoteFile file, IProgressMonitor monitor) throws TeamException {
441         Set JavaDoc tagSet = new HashSet JavaDoc();
442         ILogEntry[] entries = file.getLogEntries(monitor);
443         for (int j = 0; j < entries.length; j++) {
444             CVSTag[] tags = entries[j].getTags();
445             for (int k = 0; k < tags.length; k++) {
446                 tagSet.add(tags[k]);
447             }
448         }
449         return (CVSTag[])tagSet.toArray(new CVSTag[0]);
450     }
451     
452     /*
453      * Return the cache key (path) for the given folder path.
454      * This has been changed to cache the tags directly
455      * with the folder to better support non-root projects.
456      * However, resources in the local workspace use the folder
457      * the project is mapped to as the tag source (see TagSource)
458      */

459     private String JavaDoc getCachePathFor(String JavaDoc remotePath) {
460         return remotePath;
461     }
462     
463     /**
464      * Write out the state of the receiver as XML on the given XMLWriter.
465      *
466      * @param writer
467      * @throws IOException
468      */

469     public void writeState(XMLWriter writer) {
470
471         HashMap JavaDoc attributes = new HashMap JavaDoc();
472
473         attributes.clear();
474         attributes.put(RepositoriesViewContentHandler.ID_ATTRIBUTE, root.getLocation(false));
475         if (name != null) {
476             attributes.put(RepositoriesViewContentHandler.NAME_ATTRIBUTE, name);
477         }
478         
479         writer.startTag(RepositoriesViewContentHandler.REPOSITORY_TAG, attributes, true);
480
481         //put date tag under repository
482
if(!dateTags.isEmpty()){
483             writer.startTag(RepositoriesViewContentHandler.DATE_TAGS_TAG, attributes, true);
484             Iterator JavaDoc iter = dateTags.iterator();
485             while(iter.hasNext()){
486                 CVSTag tag = (CVSTag)iter.next();
487                 writeATag(writer, attributes, tag, RepositoriesViewContentHandler.DATE_TAG_TAG);
488             }
489             writer.endTag(RepositoriesViewContentHandler.DATE_TAGS_TAG);
490         }
491         
492         // Gather all the modules that have tags and/or auto-refresh files
493
// for each module, write the moduel, tags and auto-refresh files.
494
String JavaDoc[] paths = getKnownRemotePaths();
495         for (int i = 0; i < paths.length; i++) {
496             String JavaDoc path = paths[i];
497             attributes.clear();
498             String JavaDoc name = path;
499             if (isDefinedModuleName(path)) {
500                 name = getDefinedModuleName(path);
501                 
502                 attributes.put(RepositoriesViewContentHandler.TYPE_ATTRIBUTE, RepositoriesViewContentHandler.DEFINED_MODULE_TYPE);
503             }
504             attributes.put(RepositoriesViewContentHandler.PATH_ATTRIBUTE, name);
505             TagCacheEntry entry = (TagCacheEntry)versionAndBranchTags.get(path);
506             boolean writeOutTags = entry != null && !entry.isExpired();
507             if (writeOutTags)
508                 attributes.put(RepositoriesViewContentHandler.LAST_ACCESS_TIME_ATTRIBUTE, Long.toString(entry.lastAccessTime));
509             writer.startTag(RepositoriesViewContentHandler.MODULE_TAG, attributes, true);
510             if (writeOutTags) {
511                 Iterator JavaDoc tagIt = entry.tags.iterator();
512                 while (tagIt.hasNext()) {
513                     CVSTag tag = (CVSTag)tagIt.next();
514                     writeATag(writer, attributes, tag, RepositoriesViewContentHandler.TAG_TAG);
515                 }
516             }
517             Set JavaDoc refreshSet = (Set JavaDoc)autoRefreshFiles.get(path);
518             if (refreshSet != null) {
519                 Iterator JavaDoc filenameIt = refreshSet.iterator();
520                 while (filenameIt.hasNext()) {
521                     String JavaDoc filename = (String JavaDoc)filenameIt.next();
522                     attributes.clear();
523                     attributes.put(RepositoriesViewContentHandler.FULL_PATH_ATTRIBUTE, filename);
524                     writer.startAndEndTag(RepositoriesViewContentHandler.AUTO_REFRESH_FILE_TAG, attributes, true);
525                 }
526             }
527             writer.endTag(RepositoriesViewContentHandler.MODULE_TAG);
528         }
529         writer.endTag(RepositoriesViewContentHandler.REPOSITORY_TAG);
530     }
531
532     private void writeATag(XMLWriter writer, HashMap JavaDoc attributes, CVSTag tag, String JavaDoc s) {
533         attributes.clear();
534         attributes.put(RepositoriesViewContentHandler.NAME_ATTRIBUTE, tag.getName());
535         attributes.put(RepositoriesViewContentHandler.TYPE_ATTRIBUTE, RepositoriesViewContentHandler.TAG_TYPES[tag.getType()]);
536         writer.startAndEndTag(s, attributes, true);
537     }
538
539     /**
540      * Method getKnownTags.
541      * @param remotePath
542      * @return CVSTag[]
543      */

544     public CVSTag[] getAllKnownTags(String JavaDoc remotePath) {
545         TagCacheEntry entry = (TagCacheEntry)versionAndBranchTags.get(getCachePathFor(remotePath));
546         if(entry != null){
547             entry.accessed();
548             CVSTag [] tags1 = (CVSTag[]) entry.tags.toArray(new CVSTag[entry.tags.size()]);
549             CVSTag[] tags2 = getDateTags();
550             int len = tags1.length + tags2.length;
551             CVSTag[] tags = new CVSTag[len];
552             for(int i = 0; i < len; i++){
553                 if(i < tags1.length){
554                     tags[i] = tags1[i];
555                 }else{
556                     tags[i] = tags2[i-tags1.length];
557                 }
558             }
559             return tags;
560         }
561         return getDateTags();
562     }
563
564     public String JavaDoc[] getKnownRemotePaths() {
565         Set JavaDoc paths = new HashSet JavaDoc();
566         paths.addAll(versionAndBranchTags.keySet());
567         paths.addAll(autoRefreshFiles.keySet());
568         return (String JavaDoc[]) paths.toArray(new String JavaDoc[paths.size()]);
569     }
570     /**
571      * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
572      */

573     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
574         if (ICVSRepositoryLocation.class.equals(adapter)) return getRoot();
575         return super.getAdapter(adapter);
576     }
577     
578     /**
579      * Method tagIsKnown.
580      * @param remoteResource
581      * @return boolean
582      */

583     public boolean tagIsKnown(ICVSRemoteResource remoteResource) {
584         if (remoteResource instanceof ICVSRemoteFolder) {
585             ICVSRemoteFolder folder = (ICVSRemoteFolder) remoteResource;
586             String JavaDoc path = getCachePathFor(folder.getRepositoryRelativePath());
587             CVSTag[] tags = getAllKnownTags(path);
588             CVSTag tag = folder.getTag();
589             for (int i = 0; i < tags.length; i++) {
590                 CVSTag knownTag = tags[i];
591                 if (knownTag.equals(tag)) return true;
592             }
593         }
594         return false;
595     }
596     
597     /**
598      * This method is invoked whenever the refresh button in the
599      * RepositoriesView is pressed.
600      */

601     void clearCache() {
602         synchronized(modulesCacheLock) {
603             if (modulesCache != null)
604                 modulesCache = null;
605         }
606     }
607
608     /**
609      * Sets the root.
610      * @param root The root to set
611      */

612     void setRepositoryLocation(ICVSRepositoryLocation root) {
613         this.root = root;
614     }
615
616     /*
617      * Set the last access time of the cache entry for the given path
618      * as it was read from the persitent store.
619      */

620     /* package */ void setLastAccessedTime(String JavaDoc remotePath, long lastAccessTime) {
621         TagCacheEntry entry = (TagCacheEntry)versionAndBranchTags.get(getCachePathFor(remotePath));
622         if(entry != null){
623             entry.lastAccessTime = lastAccessTime;
624         }
625     }
626
627 }
628
Popular Tags