Configuration.java revision 1123
/*
* 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 String sourceRoot;
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 Project defaultProject;
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 IgnoredNames ignoredNames;
private Filter includedNames;
private String userPageSuffix;
private String bugPattern;
private String reviewPage;
private String reviewPattern;
private boolean remoteScmSupported;
private boolean optimizeDatabase;
private boolean useLuceneLocking;
private boolean compressXref;
private boolean indexVersionedFilesOnly;
private int hitsPerPage;
private int cachePages;
private String databaseDriver;
private String databaseUrl;
private Integer scanningDepth;
private boolean obfuscatingEMailAddresses;
public Integer 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);
setHitsPerPage(25);
setCachePages(5);
}
return ctags;
}
}
public int getCachePages() {
return cachePages;
}
public void setCachePages(int cachePages) {
this.cachePages = cachePages;
}
public int getHitsPerPage() {
return hitsPerPage;
}
public void setHitsPerPage(int 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
*/
public void setHistoryCache(boolean historyCache) {
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
*/
public void setHistoryCacheTime(int historyCacheTime) {
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
*/
public void setHistoryCacheInDB(boolean historyCacheInDB) {
this.historyCacheInDB = historyCacheInDB;
}
return projects;
}
}
public String getSourceRoot() {
return sourceRoot;
}
this.sourceRoot = sourceRoot;
}
public String getDataRoot() {
return dataRoot;
}
}
return repositories;
}
this.repositories = repositories;
}
public String getUrlPrefix() {
return urlPrefix;
}
}
public void setGenerateHtml(boolean generateHtml) {
this.generateHtml = generateHtml;
}
public boolean isGenerateHtml() {
return generateHtml;
}
this.defaultProject = defaultProject;
}
public Project getDefaultProject() {
return defaultProject;
}
public int getIndexWordLimit() {
return indexWordLimit;
}
public void setIndexWordLimit(int indexWordLimit) {
this.indexWordLimit = indexWordLimit;
}
public boolean isVerbose() {
return verbose;
}
public void setVerbose(boolean verbose) {
}
public boolean isPrintProgress() {
return printProgress;
}
public void setPrintProgress(boolean printProgress) {
this.printProgress = printProgress;
}
public void setAllowLeadingWildcard(boolean allowLeadingWildcard) {
}
public boolean isAllowLeadingWildcard() {
return allowLeadingWildcard;
}
private boolean quickContextScan;
public boolean isQuickContextScan() {
return quickContextScan;
}
public void setQuickContextScan(boolean quickContextScan) {
this.quickContextScan = quickContextScan;
}
this.ignoredNames = ignoredNames;
}
public IgnoredNames getIgnoredNames() {
return ignoredNames;
}
this.includedNames = includedNames;
}
public Filter getIncludedNames() {
return includedNames;
}
}
public String getUserPage() {
return userPage;
}
this.userPageSuffix = userPageSuffix;
}
public String getUserPageSuffix() {
return userPageSuffix;
}
}
public String getBugPage() {
return bugPage;
}
this.bugPattern = bugPattern;
}
public String getBugPattern() {
return bugPattern;
}
public String getReviewPage() {
return reviewPage;
}
this.reviewPage = reviewPage;
}
public String getReviewPattern() {
return reviewPattern;
}
this.reviewPattern = reviewPattern;
}
public String getWebappLAF() {
return webappLAF;
}
}
public boolean isRemoteScmSupported() {
return remoteScmSupported;
}
public void setRemoteScmSupported(boolean remoteScmSupported) {
this.remoteScmSupported = remoteScmSupported;
}
public boolean isOptimizeDatabase() {
return optimizeDatabase;
}
public void setOptimizeDatabase(boolean optimizeDatabase) {
this.optimizeDatabase = optimizeDatabase;
}
public boolean isUsingLuceneLocking() {
return useLuceneLocking;
}
public void setUsingLuceneLocking(boolean useLuceneLocking) {
this.useLuceneLocking = useLuceneLocking;
}
public void setCompressXref(boolean compressXref) {
this.compressXref = compressXref;
}
public boolean isCompressXref() {
return compressXref;
}
public boolean isIndexVersionedFilesOnly() {
return indexVersionedFilesOnly;
}
public void setIndexVersionedFilesOnly(boolean indexVersionedFilesOnly) {
}
public Date getDateForLastIndexRun() {
}
public String getDatabaseDriver() {
return databaseDriver;
}
this.databaseDriver = databaseDriver;
}
public String getDatabaseUrl() {
return databaseUrl;
}
this.databaseUrl = databaseUrl;
}
return allowedSymlinks;
}
this.allowedSymlinks = allowedSymlinks;
}
public boolean isObfuscatingEMailAddresses() {
return obfuscatingEMailAddresses;
}
public void setObfuscatingEMailAddresses(boolean obfuscate) {
this.obfuscatingEMailAddresses = obfuscate;
}
/**
* 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 {
}
}
public String getXMLRepresentationAsString() {
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;
}
}