Indexer.java revision 1190
/*
* 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
*/
/*
*
* Portions Copyright 2011 Jens Elkner.
*/
/**
* 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 listRepos = 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;
}
}
cfg = new Configuration();
}
// Now we can handle all the other options..
switch (cmd) {
case 'x':
createDict = true;
runIndex = false;
break;
case 'q':
cfg.setVerbose(false);
break;
case 'e':
cfg.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':
cfg.setHistoryCacheInDB(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':
{
cfg.setRemoteScmSupported(true);
cfg.setRemoteScmSupported(false);
} else {
}
}
break;
case 'O':
{
cfg.setOptimizeDatabase(true);
cfg.setOptimizeDatabase(false);
} else {
}
optimizedChanged = true;
}
}
break;
case 'v':
cfg.setVerbose(true);
break;
case 'C':
cfg.setPrintProgress(true);
break;
case 's':
{
if (!sourceRoot.isDirectory()) {
}
break;
}
case 'd':
{
}
if (!dataRoot.isDirectory()) {
}
break;
}
case 'i':
break;
case 'I':
break;
case 'S':
searchRepositories = true;
break;
case 'Q':
cfg.setQuickContextScan(true);
cfg.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':
cfg.setAllowLeadingWildcard(true);
cfg.setAllowLeadingWildcard(false);
} else {
}
break;
case 'A':
{
}
break;
}
try {
arg[0],
} catch (Exception e) {
}
}
break;
case 'L':
break;
case 'T':
try {
} catch (NumberFormatException exp) {
}
break;
case 'z':
try {
} catch (NumberFormatException exp) {
}
break;
case 'l':
cfg.setUsingLuceneLocking(true);
cfg.setUsingLuceneLocking(false);
} else {
}
break;
case 'B':
break;
case 'X':
break;
case 'V':
break;
case 'k':
break;
case 'K':
listRepos = true;
break;
case '?':
break;
case 't':
try {
} catch (NumberFormatException exp) {
}
break;
default:
}
}
try {
}
} catch (Exception e) {
// don't care
}
}
if (optind != -1) {
++optind;
}
}
//logging starts here
}
if (cfg.isHistoryCacheInDB()) {
// 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 (projectDirs != null) {
}
}
}
}
//Set updated configuration in RuntimeEnvironment
return;
}
progress);
}
} catch (IndexerException ex) {
} catch (IOException ioe) {
}
}
}
// PMD wants us to use length() > 0 && charAt(0) instead of startsWith()
// for performance. We prefer clarity over performance here, so silence it.
@SuppressWarnings("PMD.SimplifyStartsWith")
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 (listRepoPathes) {
return;
}
}
}
boolean all = false;
all = true;
break;
}
}
}
if (all) {
}
}
try {
} catch (HistoryException e) {
+ e.getLocalizedMessage());
}
}
return;
}
}
if (addProjects) {
// Keep a copy of the old project list so that we can preserve
// the customization of existing projects.
}
// Add a project for each top-level directory in source root.
// This is an existing object. Reuse the old project,
// possibly with customizations, instead of creating a
// new with default values.
// Found a new directory with no matching project, so
// create a new project with default properties.
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 {
}
}
}
});
}
}
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() {
}
}