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/*
1403N/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;
1403N/Aimport java.util.Date;
1403N/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 *
1403N/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 /**
25N/A * Retrieve the history for the given file, either from the cache or by
25N/A * parsing the history information in the repository.
25N/A *
25N/A * @param file The file to retrieve history for
25N/A * @param parserClass The class that implements the parser to use
25N/A * @param repository The external repository to read the history from (can
25N/A * be <code>null</code>)
839N/A * @param withFiles A flag saying whether or not the returned history
839N/A * should include a list of files touched by each changeset. If false,
839N/A * the implementation is allowed to skip the file list, but it doesn't
839N/A * have to.
615N/A * @throws HistoryException if the history cannot be fetched
25N/A */
839N/A History get(File file, Repository repository, boolean withFiles)
839N/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
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
761N/A */
761N/A String getLatestCachedRevision(Repository repository)
761N/A throws HistoryException;
864N/A
864N/A /**
1403N/A * Get the last modified times for all files and subdirectories in the
1403N/A * specified directory.
1403N/A *
1403N/A * @param directory which directory to fetch modification times for
1403N/A * @param repository the repository in which the directory lives
1403N/A * @return a map from file names to modification times
1403N/A */
1403N/A Map<String, Date> getLastModifiedTimes(
1403N/A File directory, Repository repository)
1403N/A throws HistoryException;
1403N/A
1403N/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;
25N/A}