View Javadoc

1   /***
2    * Copyright (C) 2008 Jeremy Thomerson (jthomerson@users.sourceforge.net)
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package net.sf.vcaperture.model;
18  
19  import java.util.Collection;
20  
21  import net.sf.vcaperture.services.ILocalStorageService;
22  import net.sf.vcaperture.util.spring.ApplicationContextFactory;
23  
24  /***
25   * This represents a repository that has been processed by the tool. It provides
26   * completely local access to all of the information needed regarding the
27   * repository so that you can avoid the possibly large overhead of constantly
28   * contacting a repository that may be remote.
29   * 
30   * @author Jeremy Thomerson (jthomerson@users.sourceforge.net)
31   */
32  public class ProcessedRepository extends AbstractRepository {
33  
34  	private final AbstractRepository mBackingRepository;
35  	public ProcessedRepository(AbstractRepository repo) {
36  		copy(repo, this);
37  		mBackingRepository = repo;
38  	}
39  	
40  	@Override
41  	public boolean isRevisionNewer(String name, String startingRevision) {
42  	    return mBackingRepository.isRevisionNewer(name, startingRevision);
43  	}
44  
45  	@Override
46  	public String getLatestRevision() {
47  	    return getStorageService().getLatestStoredRevision(this);
48  	}
49  	
50  	@Override
51      public Collection<Revision> getRevisions(String startingRevision, int maxRevisions) {
52  		return getStorageService().getRevisions(this, startingRevision, maxRevisions);
53      }
54  	
55  	@Override
56  	public RepoFile getFile(String relativePath) {
57  	    return getStorageService().getFile(this, relativePath);
58  	}
59  
60  	public ILocalStorageService getStorageService() {
61      	return ApplicationContextFactory.getFactory().getContext().getBean(ILocalStorageService.class);
62      }
63  	
64  }