Add ProjectCache.remove()
We need a way to remove data from the project cache so that plugins can do things such as delete projects. Signed-off-by: Brad Larson <bklarson@gmail.com> Change-Id: I37e2ca53614ccb8a06480f7a0a6d9a6884b0c3b5
This commit is contained in:
		| @@ -32,6 +32,12 @@ public interface ProjectCache { | ||||
|   /** Invalidate the cached information about the given project. */ | ||||
|   public void evict(Project p); | ||||
|  | ||||
|   /** | ||||
|    * Remove information about the given project from the cache. It will no | ||||
|    * longer be returned from {@link #all()}. | ||||
|    */ | ||||
|   void remove(Project p); | ||||
|  | ||||
|   /** @return sorted iteration of projects. */ | ||||
|   public abstract Iterable<Project.NameKey> all(); | ||||
|  | ||||
|   | ||||
| @@ -114,6 +114,20 @@ public class ProjectCacheImpl implements ProjectCache { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public void remove(final Project p) { | ||||
|     listLock.lock(); | ||||
|     try { | ||||
|       SortedSet<Project.NameKey> n = list.get(ListKey.ALL); | ||||
|       n = new TreeSet<Project.NameKey>(n); | ||||
|       n.remove(p.getNameKey()); | ||||
|       list.put(ListKey.ALL, Collections.unmodifiableSortedSet(n)); | ||||
|     } finally { | ||||
|       listLock.unlock(); | ||||
|     } | ||||
|     evict(p); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public void onCreateProject(Project.NameKey newProjectName) { | ||||
|     listLock.lock(); | ||||
|   | ||||
| @@ -277,6 +277,10 @@ public class RefControlTest extends TestCase { | ||||
|       public void evict(Project p) { | ||||
|       } | ||||
|  | ||||
|       @Override | ||||
|       public void remove(Project p) { | ||||
|       } | ||||
|  | ||||
|       @Override | ||||
|       public Iterable<Project.NameKey> all() { | ||||
|         return Collections.emptySet(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Brad Larson
					Brad Larson