Indexer.java revision 1026
/*
* 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
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/**
* Creates and updates an inverted source index
* as well as generates Xref, file stats etc., if specified
* in the options
*/
public final class Indexer {
private static final String DERBY_EMBEDDED_DRIVER =
"org.apache.derby.jdbc.EmbeddedDriver";
private static final String DERBY_CLIENT_DRIVER =
"org.apache.derby.jdbc.ClientDriver";
public static Indexer getInstance() {
return index;
}
/**
* Program entry point
* @param argv argument vector
*/
@SuppressWarnings("PMD.UseStringBufferForStringAppends")
boolean runIndex = true;
boolean update = true;
boolean optimizedChanged = false;
} else {
boolean searchRepositories = false;
boolean addProjects = false;
boolean refreshHistory = false;
boolean listFiles = false;
boolean createDict = false;
// Parse command line options:
try {
} catch (ParseException ex) {
}
try {
int cmd;
// We need to read the configuration file first, since we
// will try to overwrite options..
if (cmd == 'R') {
break;
}
}
// Now we can handle all the other options..
switch (cmd) {
case 't':
createDict = true;
runIndex = false;
break;
case 'q':
env.setVerbose(false);
break;
case 'e':
env.setGenerateHtml(false);
break;
case 'P':
addProjects = true;
break;
case 'p':
break;
case 'c':
break;
case 'w':
{
}
} else {
}
}
break;
case 'W':
break;
case 'U':
break;
case 'R':
// already handled
break;
case 'N':
break;
case 'n':
runIndex = false;
break;
case 'H':
refreshHistory = true;
break;
case 'h':
break;
case 'D':
env.setStoreHistoryCacheInDB(true);
break;
case 'j':
// Should be a full class name, but we also accept
// the shorthands "client" and "embedded". Expand
// the shorthands here.
}
break;
case 'u':
break;
case 'r':
{
env.setRemoteScmSupported(true);
env.setRemoteScmSupported(false);
} else {
}
}
break;
case 'O':
{
env.setOptimizeDatabase(true);
env.setOptimizeDatabase(false);
} else {
}
optimizedChanged = true;
}
}
break;
case 'v':
env.setVerbose(true);
break;
case 's':
{
if (!file.isDirectory()) {
}
}
break;
case 'd':
{
if (!file.isDirectory()) {
}
}
break;
case 'i':
break;
case 'I':
break;
case 'S':
searchRepositories = true;
break;
case 'Q':
env.setQuickContextScan(true);
env.setQuickContextScan(false);
} else {
System.err.println(" Ex: \"-Q on\" will just scan a \"chunk\" of the file and insert \"[..all..]\"");
System.err.println(" \"-Q off\" will try to build a more accurate list by reading the complete file.");
}
break;
case 'm': {
try {
} catch (NumberFormatException exp) {
}
break;
}
case 'a':
env.setAllowLeadingWildcard(true);
env.setAllowLeadingWildcard(false);
} else {
}
break;
case 'A':
{
}
break;
}
try {
arg[0],
} catch (Exception e) {
" as a FileAnalyzerFactory");
e.printStackTrace();
}
}
break;
case 'L':
break;
case 'T':
try {
} catch (NumberFormatException exp) {
}
break;
case 'z':
try {
} catch (NumberFormatException exp) {
}
break;
case 'l':
env.setUsingLuceneLocking(true);
env.setUsingLuceneLocking(false);
} else {
}
break;
case 'V':
break;
case '?':
break;
default:
}
}
if (optind != -1) {
++optind;
}
}
if (env.storeHistoryCacheInDB()) {
// The default database driver is Derby's client driver.
if (databaseDriver == null) {
}
// The default URL depends on the database driver.
if (databaseURL == null) {
} else {
}
}
}
// automatically allow symlinks that are directly in source root
if (sourceRootFile != null) {
if (projectDirs != null) {
}
}
}
}
progress);
}
} catch (IndexerException ex) {
} catch (IOException ioe) {
}
}
}
boolean searchRepositories,
boolean addProjects,
boolean refreshHistory,
boolean listFiles,
boolean createDict,
throw new IndexerException("ERROR: Please specify a DATA ROOT path");
}
throw new IndexerException("ERROR: please specify a SRC_ROOT with option -s !");
}
if (!env.validateExuberantCtags()) {
throw new IndexerException("Didn't find Exuberant Ctags");
}
if (searchRepositories) {
}
}
}
if (addProjects) {
p.setDescription(name);
}
}
// The projects should be sorted...
int ret;
} else {
}
return ret;
}
});
}
if (defaultProject != null) {
env.setDefaultProject(p);
break;
}
}
}
if (configFilename != null) {
}
}
}
if (refreshHistory) {
}
if (listFiles) {
}
if (createDict) {
}
}
throws IOException {
if (update) {
} else if (env.isOptimizeDatabase()) {
}
} else {
} else {
db = new IndexDatabase();
} else {
}
if (idx != -1) {
}
if (idx == -1) {
}
} else {
}
}
}
public void run() {
try {
if (update) {
} else if (optimize) {
}
} catch (Exception e) {
if (update) {
} else {
}
e.printStackTrace();
}
}
});
}
}
while (!executor.isTerminated()) {
try {
// Wait forever
} catch (InterruptedException exp) {
OpenGrokLogger.getLogger().log(Level.WARNING, "Received interrupt while waiting for executor to finish", exp);
}
}
}
if (configHost != null) {
}
try {
log.log(Level.SEVERE, "Failed to send configuration to " + configHost+" (is web application server running with opengrok deployed?)", ex);
}
} else {
}
}
}
}
}
private Indexer() {
}
}