/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* See LICENSE.txt included in this distribution for the specific
* language governing permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at LICENSE.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/**
* Placeholder class for all configuration variables. Due to the multithreaded
* nature of the web application, each thread will use the same instance of the
* configuration object for each page request. Class and methods should have
* package scope, but that didn't work with the XMLDecoder/XMLEncoder.
*/
public final class Configuration {
/**
* Should the history log be cached?
*/
private boolean historyCache;
/**
* The maximum time in milliseconds {@code HistoryCache.get()} can take
* before its result is cached.
*/
private int historyCacheTime;
/**
* Should the history cache be stored in a database?
*/
private boolean historyCacheInDB;
private boolean generateHtml;
/**
* Default project will be used, when no project is selected and no project
* is in cookie, so basically only the first time you open the first page,
* or when you clear your web cookies
*/
private int indexWordLimit;
private boolean verbose;
/**
* If below is set, then we count how many files per project we need
* to process and print percentage of completion per project.
*/
private boolean printProgress;
private boolean allowLeadingWildcard;
private boolean remoteScmSupported;
private boolean optimizeDatabase;
private boolean useLuceneLocking;
private boolean compressXref;
private boolean indexVersionedFilesOnly;
private boolean tagsEnabled;
private int hitsPerPage;
private int cachePages;
private int scanningDepth;
private boolean obfuscatingEMailAddresses;
private boolean chattyStatusPage;
private int tabSize;
/**
* Get the default tab size (number of space characters per tab character)
*
*
*
*
* @return current tab size set.
* @see Project#getTabSize()
* @see org.opensolaris.opengrok.analysis.ExpandTabsReader
*/
public int getTabSize() {
return tabSize;
}
/**
* Set the default tab size (number of space characters per tab character)
*
*
*
*
* @param tabSize tabsize to set.
* @see Project#setTabSize(int)
* @see org.opensolaris.opengrok.analysis.ExpandTabsReader
*/
}
public int getScanningDepth() {
return scanningDepth;
}
this.scanningDepth = scanningDepth;
}
/**
* Creates a new instance of Configuration
*/
public Configuration() {
//defaults for an opengrok instance configuration
setHistoryCache(true);
setHistoryCacheTime(30);
setHistoryCacheInDB(false);
setUrlPrefix("/source/s?");
//setUrlPrefix("../s?"); // TODO generate relative search paths, get rid of -w <webapp> option to indexer !
//below can cause an outofmemory error, since it is defaulting to NO LIMIT
setVerbose(false);
setPrintProgress(false);
setGenerateHtml(true);
setQuickContextScan(true);
setIgnoredNames(new IgnoredNames());
setIncludedNames(new Filter());
setBugPattern("\\b([12456789][0-9]{6})\\b");
setWebappLAF("default");
setRemoteScmSupported(false);
setOptimizeDatabase(true);
setUsingLuceneLocking(false);
setCompressXref(true);
setIndexVersionedFilesOnly(false);
setTagsEnabled(false);
setHitsPerPage(25);
setCachePages(5);
//setTabSize(4);
}
}
return null;
}
}
}
}
}
return ctags;
}
}
public int getCachePages() {
return cachePages;
}
this.cachePages = cachePages;
}
public int getHitsPerPage() {
return hitsPerPage;
}
this.hitsPerPage = hitsPerPage;
}
/**
* Should the history log be cached?
*
* @return {@code true} if a {@code HistoryCache} implementation should be
* used, {@code false} otherwise
*/
public boolean isHistoryCache() {
return historyCache;
}
/**
* Set whether history should be cached.
*
* @param historyCache if {@code true} enable history cache
*/
this.historyCache = historyCache;
}
/**
* How long can a history request take before it's cached? If the time is
* exceeded, the result is cached. This setting only affects
* {@code FileHistoryCache}.
*
* @return the maximum time in milliseconds a history request can take
* before it's cached
*/
public int getHistoryCacheTime() {
return historyCacheTime;
}
/**
* Set the maximum time a history request can take before it's cached. This
* setting is only respected if {@code FileHistoryCache} is used.
*
* @param historyCacheTime maximum time in milliseconds
*/
this.historyCacheTime = historyCacheTime;
}
/**
* Should the history cache be stored in a database? If yes,
* {@code JDBCHistoryCache} will be used to cache the history; otherwise,
* {@code FileHistoryCache} is used.
*
* @return whether the history cache should be stored in a database
*/
public boolean isHistoryCacheInDB() {
return historyCacheInDB;
}
/**
* Set whether the history cache should be stored in a database, and
* {@code JDBCHistoryCache} should be used instead of {@code
* FileHistoryCache}.
*
* @param historyCacheInDB whether the history cached should be stored in a
* database
*/
this.historyCacheInDB = historyCacheInDB;
}
return projects;
}
}
return sourceRoot;
}
this.sourceRoot = sourceRoot;
}
return dataRoot;
}
}
return repositories;
}
this.repositories = repositories;
}
return urlPrefix;
}
/**
* Set the URL prefix to be used by the {@link
* org.opensolaris.opengrok.analysis.executables.JavaClassAnalyzer} as well
* as lexers (see {@link org.opensolaris.opengrok.analysis.JFlexXref}) when
* they create output with html links.
*
* @param urlPrefix prefix to use.
*/
}
this.generateHtml = generateHtml;
}
public boolean isGenerateHtml() {
return generateHtml;
}
this.defaultProject = defaultProject;
}
return defaultProject;
}
public int getIndexWordLimit() {
return indexWordLimit;
}
this.indexWordLimit = indexWordLimit;
}
public boolean isVerbose() {
return verbose;
}
}
public boolean isPrintProgress() {
return printProgress;
}
this.printProgress = printProgress;
}
}
public boolean isAllowLeadingWildcard() {
return allowLeadingWildcard;
}
private boolean quickContextScan;
public boolean isQuickContextScan() {
return quickContextScan;
}
this.quickContextScan = quickContextScan;
}
this.ignoredNames = ignoredNames;
}
return ignoredNames;
}
this.includedNames = includedNames;
}
return includedNames;
}
}
return userPage;
}
this.userPageSuffix = userPageSuffix;
}
return userPageSuffix;
}
}
return bugPage;
}
this.bugPattern = bugPattern;
}
return bugPattern;
}
return reviewPage;
}
this.reviewPage = reviewPage;
}
return reviewPattern;
}
this.reviewPattern = reviewPattern;
}
return webappLAF;
}
}
public boolean isRemoteScmSupported() {
return remoteScmSupported;
}
this.remoteScmSupported = remoteScmSupported;
}
public boolean isOptimizeDatabase() {
return optimizeDatabase;
}
this.optimizeDatabase = optimizeDatabase;
}
public boolean isUsingLuceneLocking() {
return useLuceneLocking;
}
this.useLuceneLocking = useLuceneLocking;
}
this.compressXref = compressXref;
}
public boolean isCompressXref() {
return compressXref;
}
public boolean isIndexVersionedFilesOnly() {
return indexVersionedFilesOnly;
}
}
public boolean isTagsEnabled() {
return this.tagsEnabled;
}
this.tagsEnabled = tagsEnabled;
}
/**
* Get the date of the last index update.
*
* @return the time of the last index update.
*/
if (lastModified == null) {
}
return lastModified;
}
/**
* Get the contents of a file or empty string if the file cannot be read.
*/
return "";
}
try {
}
/*
* should usually not happen
*/
} finally {
try {
} catch (Exception e) { /*
* nothing we can do about it
*/ }
try {
} catch (Exception e) { /*
* nothing we can do about it
*/ }
}
}
return "";
}
/**
* The name of the file relative to the <var>DATA_ROOT</var>, which should
* be included into the footer of generated web pages.
*/
/**
* Get the contents of the footer include file.
*
* @return an empty string if it could not be read successfully, the
* contents of the file otherwise.
*/
}
return footer;
}
/**
* The name of the file relative to the <var>DATA_ROOT</var>, which should
* be included into the footer of generated web pages.
*/
/**
* Get the contents of the footer include file.
*
* @return an empty string if it could not be read successfully, the
* contents of the file otherwise.
*/
}
return header;
}
/**
* The name of the eftar file relative to the <var>DATA_ROOT</var>, which
* contains definition tags.
*/
/**
* Get the eftar file, which contains definition tags.
*
* @return {@code null} if there is no such file, the file otherwise.
*/
if (dtagsEftar == null) {
} else {
dtagsEftar = "";
}
}
}
return databaseDriver;
}
this.databaseDriver = databaseDriver;
}
return databaseUrl;
}
this.databaseUrl = databaseUrl;
}
return CTagsExtraOptionsFile;
}
this.CTagsExtraOptionsFile = filename;
}
return allowedSymlinks;
}
this.allowedSymlinks = allowedSymlinks;
}
public boolean isObfuscatingEMailAddresses() {
return obfuscatingEMailAddresses;
}
this.obfuscatingEMailAddresses = obfuscate;
}
public boolean isChattyStatusPage() {
return chattyStatusPage;
}
this.chattyStatusPage = chattyStatusPage;
}
/**
* Write the current configuration to a file
*
* @param file the file to write the configuration into
* @throws IOException if an error occurs
*/
try {
this.encodeObject(out);
} finally {
}
}
this.encodeObject(bos);
}
e.writeObject(this);
e.close();
}
try {
return decodeObject(in);
} finally {
}
}
final Configuration ret;
return ret;
}
d.close();
if (!(ret instanceof Configuration)) {
throw new IOException("Not a valid config file");
}
return (Configuration) ret;
}
}