Configuration.java revision 1469
30N/A * CDDL HEADER START 30N/A * The contents of this file are subject to the terms of the 30N/A * Common Development and Distribution License (the "License"). 30N/A * You may not use this file except in compliance with the License. 30N/A * language governing permissions and limitations under the License. 30N/A * When distributing Covered Code, include this CDDL HEADER in each 30N/A * If applicable, add the following below this CDDL HEADER, with the 30N/A * fields enclosed by brackets "[]" replaced with your own identifying 30N/A * information: Portions Copyright [yyyy] [name of copyright owner] 1054N/A * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. 30N/A * Portions Copyright 2011, 2012 Jens Elkner. 1190N/A * Placeholder class for all configuration variables. Due to the multithreaded 320N/A * nature of the web application, each thread will use the same instance of the 1190N/A * configuration object for each page request. Class and methods should have 77N/A /** The common property key prefix used to access opengrok system properties */ 77N/A /** The property name used to obtain the ctags command to use. */ 30N/A /** The command to use if no ctags command was given explicitly */ 77N/A /** Relative path wrt. servlet context to the default CSS to use */ 30N/A /** The string property name used to get the date format pattern to use for 58N/A * directory listings in the web app. It needs to be a pattern acceptable 145N/A * by {@link java.text.SimpleDateFormat}. 145N/A * @see #DIRLIST_DATE_DEFAULT */ 490N/A /** The boolean property name used to determine, whether the web app should 490N/A * show {@code Today} instead of the last modified date, if the file has 490N/A * been changed in the last 24 hours. */ 490N/A * Should the history log be cached? 1185N/A * The maximum time in milliseconds {@code HistoryCache.get()} can take 993N/A * before its result is cached. 993N/A * Should the history cache be stored in a database? 77N/A * Default project will be used, when no project is selected and no project 77N/A * is in cookie, so basically only the first time you open the first page, 77N/A * or when you clear your web cookies 58N/A //if below is set, then we count how many files per project we need to process and print percentage of completion per project 58N/A * Get the default tab size (number of space characters per tab character) 58N/A * to use for each project. If {@code <= 0} tabs are read/write as is. 77N/A * @return current tab size set. 77N/A * @see Project#getTabSize() 77N/A * @see org.opensolaris.opengrok.analysis.ExpandTabsReader 1016N/A * Set the default tab size (number of space characters per tab character) 1016N/A * @param tabSize tabsize to set. 1016N/A * @see Project#setTabSize(int) 1016N/A * @see org.opensolaris.opengrok.analysis.ExpandTabsReader 1066N/A * Get the depth of scanning for repositories in the directory tree relative 1327N/A * Set the depth of scanning for repositories in the directory tree relative 1016N/A * @param scanningDepth the scan depth to set. 58N/A * Creates a new instance of Configuration 1190N/A //defaults for an opengrok instance configuration 58N/A // TODO generate relative search paths, get rid of -w <webapp> option to indexer ! 1190N/A // setUrlPrefix(".." + Prefix.SEARCH_R + '?'); 77N/A //below can cause an outofmemory error, since it is defaulting to NO LIMIT 58N/A * Get the {@link SimpleDateFormat} pattern to use to show the last modified 145N/A * time in web app directory listings. 58N/A * @return an always usuable pattern for date formatting. 145N/A * Set the {@link SimpleDateFormat} pattern to use to show the last modified 58N/A * time in web app directory listings. 1190N/A * @param pattern the pattern to use. Ignored if {@code null} or invalid. 816N/A * Check, whether the web app should show {@code Today} instead of the last 816N/A * modified time if the target was changed within the last 24 hours. 816N/A * @return {@code true} if {@code Today} should be shown. 99N/A * Set, whether the web app should show {@code Today} instead of the last 99N/A * modified time if the target was changed within the last 24 hours. 99N/A * @param enable use {@code true} if {@code Today} should be shown. 99N/A * @see #DIRLIST_TODAY_PROPERTY_KEY 1327N/A * Get the client command to use to access the repository for the given 1327N/A * fully quallified classname. 1327N/A * @param clazzName name of the targeting class 1327N/A * @return {@code null} if not yet set, the client command otherwise. 1190N/A * Set the client command to use to access the repository for the given 77N/A * fully quallified classname. 77N/A * @param clazzName name of the targeting class. If {@code null} this method 77N/A * @param cmd the client command to use. If {@code null} the corresponding 58N/A * entry for the given clazzName get removed. 145N/A * @return the client command previously set, which might be {@code null}. 77N/A * Get a map of repository class names with the corresponding CLI command to 77N/A * access the repository it is able to handle. 77N/A * Basically exists to satisfy bean/de|encoder stuff, only. 58N/A * @return a unmodifyable map. 77N/A * Set the map of repository class names with the corresponding CLI command 58N/A * to access the repository it is able to handle. 145N/A * Basically exists to satisfy bean/de|encoder stuff, only. 58N/A * @param cmds the map to copy. 773N/A * Get the name of the ctags program in use 773N/A * @return the name of the ctags program in use 773N/A * Specify the CTags program to use 773N/A * @param ctags the ctags program to use 65N/A * Get the number of search result pages, which should be cached in 65N/A * @return the number of result pages to cache. 65N/A * Set the number of search result pages, which should be cached in 335N/A * @param cachePages the number of result pages to cache. 335N/A * @see #getHitsPerPage() 335N/A * Get the number of hits to display on one search result page. 335N/A * @return number of hits per page. 335N/A * Set the number of hits to display on one search result page. 106N/A * @param hitsPerPage number of hits per page to set. 665N/A * Should the history log be cached? 665N/A * @return {@code true} if a {@code HistoryCache} implementation should be 665N/A * used, {@code false} otherwise 145N/A * Set whether history should be cached. 1190N/A * @param historyCache if {@code true} enable history cache 77N/A * How long can a history request take before it's cached? If the time is 145N/A * exceeded, the result is cached. This setting only affects 58N/A * {@code FileHistoryCache}. 77N/A * @return the maximum time in milliseconds a history request can take 77N/A * before it's cached 77N/A * Set the maximum time a history request can take before it's cached. This 1190N/A * setting is only respected if {@code FileHistoryCache} is used. 99N/A * @param historyCacheTime maximum time in milliseconds 99N/A * Should the history cache be stored in a database? If yes, 99N/A * {@code JDBCHistoryCache} will be used to cache the history; otherwise, 99N/A * {@code FileHistoryCache} is used. 145N/A * @return whether the history cache should be stored in a database 124N/A * Set whether the history cache should be stored in a database, and 99N/A * {@code JDBCHistoryCache} should be used instead of {@code 1190N/A * @param historyCacheInDB whether the history cached should be stored in a 124N/A * @return a list containing all of the projects (may be null) 124N/A * Set the list of the projects 1115N/A * @param projects the list of projects to use 1115N/A * Get the path to where the sources are located 1115N/A * @return path to where the sources are located 125N/A * @param sourceRoot the location of the sources 145N/A * Get the path to the where the index database is stored 125N/A * @return the path to the index database 145N/A * Set the path to where the index database is stored 125N/A * @param dataRoot the index database 145N/A * Get the map of known repositories. 112N/A * @return a possible empty list including {@code null}. 1026N/A * Set the map of known repositories. 1026N/A * @param repositories the repositories to set. 145N/A * Get the the URL prefix to be used by the {@link 129N/A * as lexers (see {@link org.opensolaris.opengrok.analysis.JFlexXref}) when 129N/A * they create output with html links. 1185N/A * @return the URI encoded prefix to use. 1190N/A * Set the URL prefix to be used by the {@link 1185N/A * as lexers (see {@link org.opensolaris.opengrok.analysis.JFlexXref}) when 1185N/A * they create output with html links. 1185N/A * @param urlPrefix URI encoded prefix to set. 1185N/A * Set whether to generate hyper text cross reference (xref) files 1190N/A * offline (i.e. when indexing). If set to {@code false}, xref files are 1185N/A * created on the fly on demand and gets disposed when served to the client 129N/A * - so saves disk space, but could be sightly slow and more resource 129N/A * demanding for the servlet container. 129N/A * @param generateHtml {@code true} to generate and cache xref files immediately. 1100N/A * Check, whether to generate and cache xref files immediately. 1100N/A * Set the project that is specified to be the default project to use. The 1100N/A * default project is the project you will search (from the web application) 1100N/A * if the page request didn't contain the cookie. 1100N/A * @param defaultProject The default project to use 129N/A * Get the project that is specified to be the default project to use. The 145N/A * default project is the project you will search (from the web application) 129N/A * if the page request didn't contain the cookie. 129N/A * @return the default project (may be null if not specified) 129N/A * Chandan wrote the following answer on the opengrok-discuss list: 129N/A * "Traditionally search engines (specially spiders) think that large files 129N/A * are junk. Large files tend to be multimedia files etc., which text 129N/A * search spiders do not want to chew. So they ignore the contents of 129N/A * the file after a cutoff length. Lucene does this by number of words, 129N/A * which is by default is 10,000." 129N/A * By default OpenGrok will increase this limit to 60000, but it may be 145N/A * overridden in the configuration file 129N/A * @return The maximum words to index 145N/A * Set the number of words in a file Lucene will index. 129N/A * See getIndexWordLimit for a better description. 1190N/A * @param indexWordLimit the number of words to index in a single file 318N/A * Is the verbosity flag turned on? 318N/A * @return true if we can print extra information 318N/A * Set the verbosity flag (to add extra debug information in output) 318N/A * @param verbose new value 318N/A * Is the progress print flag turned on? 318N/A * @return {@code true} if we can print per project progress % 318N/A * Set the printing of progress % flag (user convenience). 318N/A * @param enable {@code true} to enable progress printing. 145N/A * Specify if a search may start with a wildcard. Note that queries 144N/A * that start with a wildcard will give a significant impact on the 173N/A * search performace (disabled by default). 173N/A * @param allowLeadingWildcard set to {@code true} to activate 1190N/A * Is leading wildcards allowed? 253N/A * @return {@code true} if a search may start with a wildcard 296N/A * Check whether a quick context scan should be done. 296N/A * @return {@code true} if quick scan should be made. 296N/A * @see #setQuickContextScan(boolean) 480N/A * If set to {@code true}, at most 1 MiB of a file gets read into a buffer 480N/A * at once and than tokenized. Otherwise the whole file gets processed as 480N/A * usual, i.e. the file content gets read on demand when tokenizing and the 480N/A * whole file gets processed (no matter of its size). 480N/A * @param quickContextScan if {@code true} enable quick scanning 833N/A * Takes precedence over {@link #getIncludedNames()}. 833N/A * @param ignoredNames stuff to ignore. If {@code null} defaults will be 833N/A * Takes precedence over {@link #getIncludedNames()}. 833N/A * @return stuff to ignore. 1123N/A * @param includedNames stuff to index. {@code null} means everything. 1123N/A * @see #setIgnoredNames(IgnoredNames) 1123N/A * @return stuff to index. {@code null} means everything. 1125N/A * Set the user page for the history listing 1125N/A * @param userPage the URI encoded URL fragment preceeding the username from 1125N/A * Get the user page for the history listing 1125N/A * @return the URI encoded URL string fragment preceeding the username 1125N/A * Set the user page suffix for the history listing 77N/A * @param userPageSuffix the URI encoded URL fragment following the username 77N/A * Get the user page suffix for the history listing 77N/A * @return the URI encoded URL string fragment following the username 1190N/A * Set the bug page for the history listing 77N/A * @param bugPage the URI encoded URL fragment preceeding the bug ID 58N/A * Get the bug page for the history listing 58N/A * @return the URI encoded URL string fragment preceeding the bug ID 471N/A * Set the bug regex for the history listing 471N/A * @param bugPattern the regex to search history comments 639N/A * Get the bug regex for the history listing 639N/A * @return the regex that is looked for in history comments 77N/A * Get the review (ARC) page for the history listing 77N/A * @return the URI encoded URL string fragment preceeding the review page ID 77N/A * Set the review (ARC) page for the history listing 77N/A * @param reviewPage the URI encoded URL fragment preceeding the review page ID 58N/A * Get the review (ARC) regex for the history listing 58N/A * @return the regex that is looked for in history comments 58N/A * Set the review (ARC) regex for the history listing 471N/A * @param reviewPattern the regex to search history comments 1185N/A * Get the name of the web app Look And Feel (LAF) theme to use. It gets 1185N/A * used to construct the stylesheet and image include links in web pages 1185N/A * and names a directory, which contains all this stuff. 1185N/A * @return the name of the web app LAF 58N/A * Set the name of the web app Look And Feel (LAF) theme to use. It gets 58N/A * used to construct the stylesheet and image include links in web pages 1190N/A * and names a directory, which contains all this stuff. 58N/A * @param webappLAF the name of the web app LAF. If {@code null} the default 1327N/A * Check whether file histories should be retrieved from the related remote 58N/A * repositories when needed. 1195N/A * @return {@code true} if fetch on demand is enabled. 58N/A * Set whether file histories should be retrieved from the related remote 1327N/A * repositories when needed. 1327N/A * @param remoteScmSupported {@code true} if fetch on demand is enabled. 1190N/A * Check, whether the lucene index database should be optimized (compact 58N/A * segments etc.) after indexing has been run. 30N/A * @return {@code true} if optimization is enabled. * Set, whether the lucene index database should be optimized (compact * segments etc.) after indexing has been run. * @param optimizeDatabase {@code true} if optimization should be done. * Check, wheter lucene should lock index files when indexing to avoid * concurrent access, reading invalid data. * @return {@code true} if locking should be used. * Set wheter lucene should lock index files when indexing to avoid * concurrent access, reading invalid data. * @param useLuceneLocking {@code true} if locking should be used. * Set if we should compress the xref files or not. Applies to newly * application automatically detects, whether an xref file is compressed * and processes it properly. * @param compressXref set to {@code true} if generated xref html files * Set if we should compress generated xref html files? * @return {@code true} if the xref html files should be compressed. * Check, whether unversioned files should not be indexed. * If {@code true}, it takes precedence over {@link #getIncludedNames()}, * i.e. files are not indexed when unversioned, even if they match an * @return {@code true} if indexing of unversioned files is disabled. * Set, whether unversioned files should not be indexed. * If set to {@code true}, it takes precedence over {@link #getIncludedNames()}, * i.e. files are not indexed when unversioned, even if they match an * @param indexVersionedFilesOnly {@code true} to disable indexing of * Get the time, when this instance has been modified. If not explicitly set * or set to {@code 0}, it gets initialized with the time of the first call * @return time in milliseconds since 1 Jan 1970 00:00:00 GMT // since we use it for If-Last-Modified-Since evals, which has no // millis, we need to clear the milliseconds part * Set the time, when this configuration has been modified for the last time. * @param lastModified the time in milliseconds since 1 Jan 1970 00:00:00 GMT * Get the date of the last index update. * @return the time of the last index update. * Get the contents of a file or empty string if the file cannot be read. * should usually not happen * 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. * @see #FOOTER_INCLUDE_FILE * 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. * @see #HEADER_INCLUDE_FILE * The name of the file relative to the <var>DATA_ROOT</var>, which should * be included into the body of web app's "Home" page. * Get the contents of the body include file. * @return an empty string if it could not be read successfully, the * contents of the file otherwise. * @see Configuration#BODY_INCLUDE_FILE * 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. * Get the fully quallified class name of the history database driver to use. * @return the database driver class name. * Set the fully quallified class name of the history database driver to use. * @param databaseDriver the database driver class name to set. * Get the JDBC connection URL to use to connect to the history database. * @return the JDBC connection URL to use. * Set the JDBC connection URL to use to connect to the history database. * @param databaseUrl the JDBC connection URL to set. * Get the optional file to be used to handover additional options to the * @return {@code null} if not set, the options filename otherwise. * Set the file to be used to handover additional options to the ctags * @param filename the options filename to use. Might be {@code null}. * Get the pathnames of symlinks, which are allowed to be processed (e.g. * indexed, tokenized, etc.). * @return a possible empty set. * Set the pathnames of symlinks, which are allowed to be processed (e.g. * indexed, tokenized, etc.). * @param allowedSymlinks symlinks to allow. {@code null} means none. * Check whether e-mail addresses should be obfuscated in the xref. * @return {@code true} if obfuscation is needed. * Set whether e-mail addresses should be obfuscated in the xref. * @param obfuscate {@code true} if obfuscation is needed. * Should status.jsp print internal settings, like paths and database * @return {@code true} if status.jsp should show the configuration. * Set whether status.jsp should print internal settings. * @param chattyStatusPage {@code true} if internal settings should be printed. * Write the current configuration to a file * @param file the file to write the configuration into * @throws IOException if an error occurs * Serialize this instance into an XML formatted string. * @return this instance as xml string * Read the file containing a serialized {@link Configuration} instance and * return the marshalled instance. * @param file the file to read * @return the un-serialized Configuration instance represented by the file. * @throws IOException if the file cannot be read/decoded. * Read the given string representing a in XML serialized {@link Configuration} * and return the marshalled instance. * @param xmlconfig serialized config to read. * @return the un-serialized Configuration instance represented by the string. * @throws IOException if the string cannot be decoded.