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.services;
18  
19  import java.util.Collection;
20  
21  import net.sf.vcaperture.model.AbstractRepository;
22  import net.sf.vcaperture.model.RepoFile;
23  import net.sf.vcaperture.model.RepoFileRevision;
24  import net.sf.vcaperture.model.Revision;
25  
26  /***
27   * Service that provides the functionality for local storage of repositories.
28   * 
29   * @author Jeremy Thomerson (jthomerson@users.sourceforge.net)
30   */
31  public interface ILocalStorageService {
32  
33  	/***
34       * @param repo
35       *            The repo you need the revision for
36       * @return the latest revision that has been locally stored, or
37       *         <tt>AbstractRepository.getNullRevisionDefault()</tt> if none has been stored.
38       * @throws StorageException
39       *             if there is an error retrieving it
40       * @see AbstractRepository#getNullRevisionDefault()
41       */
42  	String getLatestStoredRevision(AbstractRepository repo) throws StorageException;
43  
44  	/***
45  	 * @param repo
46       *            The repo you need the revision for
47  	 * @param relativePath
48       *            The relative path of the file you need
49  	 * @return the RepoFile at that path
50  	 * @throws StorageException
51       *             if there is an error retrieving it
52  	 */
53  	RepoFile getFile(AbstractRepository repo, String relativePath) throws StorageException;
54  
55  	/***
56       * Saves the revision information for this repo / revision combo.
57       * <p>
58       * <b>IMPORTANT:</b> This does NOT save the individual files that were part of this revision.
59       * You must do that separately.
60       * </p>
61       * 
62       * @param repo
63       *            The repo that the revision applies to
64       * @param rev
65       *            The revision to save
66       * @throws StorageException
67       *             if there is an error saving it
68       */
69  	void saveRevision(AbstractRepository repo, Revision rev) throws StorageException;
70  
71  	/***
72       * Saves an actual file that was part of the revision. The <tt>RepoFileRevision</tt> passed in
73       * should already have it's revisions field updated to reflect that it was part of this
74       * revision. This method saves both the <tt>RepoFile</tt> and the contents of the
75       * <tt>RepoFileRevision</tt>.
76       * 
77       * @param repo
78       *            The repo that the revision applies to
79       * @param rfr
80       *            The revision to save
81       * @throws StorageException
82       *             if there is an error saving it
83       */
84  	void saveFileRevision(AbstractRepository repo, RepoFileRevision rfr) throws StorageException;
85  
86  	Collection<Revision> getRevisions(AbstractRepository repo, String startingRevision, int maxRevisions);
87  
88  }