25N/A/*
25N/A * CDDL HEADER START
25N/A *
25N/A * The contents of this file are subject to the terms of the
25N/A * Common Development and Distribution License (the "License").
25N/A * You may not use this file except in compliance with the License.
25N/A *
25N/A * See LICENSE.txt included in this distribution for the specific
25N/A * language governing permissions and limitations under the License.
25N/A *
25N/A * When distributing Covered Code, include this CDDL HEADER in each
25N/A * file and include the License file at LICENSE.txt.
25N/A * If applicable, add the following below this CDDL HEADER, with the
25N/A * fields enclosed by brackets "[]" replaced with your own identifying
25N/A * information: Portions Copyright [yyyy] [name of copyright owner]
25N/A *
25N/A * CDDL HEADER END
25N/A */
25N/A
25N/A/*
1460N/A * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
25N/A */
25N/Apackage org.opensolaris.opengrok.history;
25N/A
25N/Aimport java.io.File;
1460N/Aimport java.util.Date;
1460N/Aimport java.util.Map;
25N/A
305N/Ainterface HistoryCache {
170N/A
25N/A /**
715N/A * Create and initialize an empty history cache if one doesn't exist
715N/A * already.
715N/A *
1460N/A * @throws HistoryException if initialization fails
715N/A */
715N/A void initialize() throws HistoryException;
715N/A
715N/A /**
887N/A * Check whether this cache implementation can store history for the given
887N/A * repository.
887N/A *
887N/A * @param repository the repository to check
887N/A * @return {@code true} if this cache implementation can store history
887N/A * for the repository, or {@code false} otherwise
887N/A */
887N/A boolean supportsRepository(Repository repository);
887N/A
887N/A /**
1466N/A * Retrieve the history for the given path, either from the cache or by
25N/A * parsing the history information in the repository.
25N/A *
1466N/A * @param path The path to retrieve history for
1466N/A * @param parserClass The class that implements the parser to use
1466N/A * @param repository The external repository to read the history from
1466N/A * (can be <code>null</code>)
1466N/A * @param withFiles If {@code true} the returned history will contain
1466N/A * a list of files touched by each changeset (the file list may be
1466N/A * skipped if {@code false}, but it doesn't have to)
1466N/A * @param isDir If {@code null} the returned history type (file or
1466N/A * directory) gets determined automatically: if path physically exists
1466N/A * and is a directory, directory is assumed, file otherwise.
1466N/A * If {@code true} this method blindly assumes type directory and a
1466N/A * directory history gets returned, otherwise a file history.
1466N/A * @return the history for the given path.
1461N/A * @throws HistoryException if no history could be obtained dueto an error.
25N/A */
1466N/A History get(File path, Repository repository, boolean withFiles, Boolean isDir)
1466N/A throws HistoryException;
61N/A
25N/A /**
743N/A * Store the history for a repository.
1190N/A *
305N/A * @param history The history to store
743N/A * @param repository The repository whose history to store
615N/A * @throws HistoryException if the history cannot be stored
25N/A */
743N/A void store(History history, Repository repository)
715N/A throws HistoryException;
678N/A
678N/A /**
795N/A * Optimize how the history is stored on disk. This method is typically
795N/A * called after the cache has been populated, or after large modifications
795N/A * to the cache. The exact effect of this method is specific to each
795N/A * implementation, but it may for example include compressing, compacting
795N/A * or reordering the disk image of the cache in order to optimize
795N/A * performance or space usage.
795N/A *
795N/A * @throws HistoryException if an error happens during optimization
795N/A */
795N/A void optimize() throws HistoryException;
795N/A
795N/A /**
764N/A * Check if the specified directory is present in the cache.
764N/A * @param directory the directory to check
764N/A * @param repository the repository in which the directory is stored
764N/A * @return {@code true} if the directory is in the cache, {@code false}
764N/A * otherwise
1461N/A * @throws HistoryException if no history could be obtained dueto an error.
678N/A */
764N/A boolean hasCacheForDirectory(File directory, Repository repository)
715N/A throws HistoryException;
761N/A
761N/A /**
761N/A * Get the revision identifier for the latest cached revision in a
761N/A * repository.
761N/A *
761N/A * @param repository the repository whose latest revision to return
761N/A * @return a string representing the latest revision in the cache, or
761N/A * {@code null} if it is unknown
1461N/A * @throws HistoryException if no history could be obtained dueto an error.
761N/A */
761N/A String getLatestCachedRevision(Repository repository)
761N/A throws HistoryException;
864N/A
864N/A /**
1460N/A * Get the last modified times for all files and subdirectories in the
1460N/A * specified directory.
1460N/A *
1460N/A * @param directory which directory to fetch modification times for
1460N/A * @param repository the repository in which the directory lives
1474N/A * @param path2rev where to store the path to revision entries. If
1474N/A * {@code null}, revisions get simply ignored.
1460N/A * @return a map from file names to modification times
1461N/A * @throws HistoryException if no history could be obtained dueto an error.
1460N/A */
1474N/A Map<String, Date> getLastModifiedTimes(File directory, Repository repository,
1474N/A Map<String,String> path2rev) throws HistoryException;
1460N/A
1460N/A /**
1475N/A * Get the last modified times for all subdirectories in the
1475N/A * source root directory.
1475N/A *
1475N/A * @param path2rev where to store the path to revision entries. If
1475N/A * {@code null}, revisions get simply ignored.
1475N/A * @return a map from file names to modification times
1475N/A * @throws HistoryException if no history could be obtained dueto an error.
1475N/A */
1475N/A Map<String, Date> getLastModifiedTimes(Map<String, String> path2rev)
1475N/A throws HistoryException;
1475N/A
1475N/A /**
969N/A * Clear the history cache for a repository.
969N/A *
969N/A * @param repository the repository whose cache to clear
969N/A * @throws HistoryException if the cache couldn't be cleared
969N/A */
969N/A void clear(Repository repository) throws HistoryException;
969N/A
969N/A /**
864N/A * Get a string with information about the history cache.
864N/A *
864N/A * @return a free form text string describing the history cache instance
864N/A * @throws HistoryException if an error occurred while getting the info
864N/A */
864N/A String getInfo() throws HistoryException;
1475N/A
25N/A}