Search in sources :

Example 16 with ForbiddenSymlinkException

use of org.opensolaris.opengrok.util.ForbiddenSymlinkException in project OpenGrok by OpenGrok.

the class HistoryGuru method getHistory.

/**
 * Get the history for the specified file.
 *
 * @param file the file to get the history for
 * @param withFiles whether or not the returned history should contain a
 * list of files touched by each changeset (the file list may be skipped if
 * false, but it doesn't have to)
 * @param ui called from the webapp
 * @return history for the file
 * @throws HistoryException on error when accessing the history
 */
public History getHistory(File file, boolean withFiles, boolean ui) throws HistoryException {
    final File dir = file.isDirectory() ? file : file.getParentFile();
    final Repository repo = getRepository(dir);
    RemoteSCM rscm = RuntimeEnvironment.getInstance().getRemoteScmSupported();
    boolean doRemote = (ui && (rscm == RemoteSCM.UIONLY)) || (rscm == RemoteSCM.ON) || (ui || ((rscm == RemoteSCM.DIRBASED) && (repo != null) && repo.hasHistoryForDirectories()));
    if (repo != null && repo.isWorking() && repo.fileHasHistory(file) && (!repo.isRemote() || doRemote)) {
        if (useCache() && historyCache.supportsRepository(repo)) {
            try {
                return historyCache.get(file, repo, withFiles);
            } catch (ForbiddenSymlinkException ex) {
                LOGGER.log(Level.FINER, ex.getMessage());
                return null;
            }
        }
        return repo.getHistory(file);
    }
    return null;
}
Also used : RemoteSCM(org.opensolaris.opengrok.configuration.Configuration.RemoteSCM) ForbiddenSymlinkException(org.opensolaris.opengrok.util.ForbiddenSymlinkException) File(java.io.File)

Aggregations

ForbiddenSymlinkException (org.opensolaris.opengrok.util.ForbiddenSymlinkException)16 File (java.io.File)14 RuntimeEnvironment (org.opensolaris.opengrok.configuration.RuntimeEnvironment)11 IOException (java.io.IOException)10 FileNotFoundException (java.io.FileNotFoundException)4 DateFormat (java.text.DateFormat)4 ParseException (java.text.ParseException)4 BufferedReader (java.io.BufferedReader)3 InputStreamReader (java.io.InputStreamReader)3 Date (java.util.Date)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 Document (org.apache.lucene.document.Document)2 RepositoryInfo (org.opensolaris.opengrok.history.RepositoryInfo)2 BufferedInputStream (java.io.BufferedInputStream)1 BufferedWriter (java.io.BufferedWriter)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1