/*
* 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 {
"org.apache.derby.jdbc.EmbeddedDriver";
"org.apache.derby.jdbc.ClientDriver";
/**
* Get the indexer instance.
* @return a singleton
*/
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 listTokens = 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 'q':
cfg.setVerbose(false);
break;
case 'e':
cfg.setGenerateHtml(false);
break;
case 'P':
addProjects = true;
break;
case 'p':
break;
case 'c':
break;
case 'w':
{
}
}
}
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':
{
}
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 {
} 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;
case 'Z':
cfg.setChattyStatusPage(true);
break;
case 'E':
cfg.setCompressXref(false);
break;
default:
}
}
if (s != null) {
}
if (s != null) {
}
try {
}
} catch (Exception e) {
// don't care
}
}
if (optind != -1) {
++optind;
}
}
//logging starts here
.getProperty("java.util.logging.FileHandler.pattern");
}
}
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) {
if (!projectDir.getCanonicalPath()
{
}
}
}
}
//Set updated configuration in RuntimeEnvironment
return;
}
progress);
}
} catch (IndexerException ex) {
} catch (Throwable e) {
}
}
}
// PMD wants us to use length() > 0 && charAt(0) instead of startsWith()
// for performance. We prefer clarity over performance here, so silence it.
/**
* Prepare the environment to execute indexing. Basically it does some
* consistency checks wrt. commadline options sets and executes simple tasks
* like zapping or refreshing the history cache, list available projects
* including their path, create spelling index for related projects,
* writing the config file.
*
* @param searchRepositories If {@code true} scan for new repositories in
* the source root directory.
* @param addProjects If {@code true} add automatically projects found
* @param defaultProject The name of the project to use as default. Might
* be {@code null}.
* @param configFilename The pathname of the configuration file to write.
* If {@code null} writing the config file gets skipped.
* for the given or all projects.
* @param listFiles If {@code true}, print a list of all files of
* the index database for given projects to stdout.
* @param listTokens If {@code true}, print a list of frequent
* tokens for related projects to stdout.
* @param subFiles Determine target projects by the given repo
* files when <var>listFiles</var> or <var>createDict</var> is set to
* {@code true}. {@code null} implies "all projects".
* @param repositories Target repositories.{@code null} implies
* "all projects".
* @param zapCache List of project names, whose history cache should
* be zapped. An Asterisk ('*') implies zap all. Ignored if empty.
* @param listRepoPathes If {@code true}, just list available projects
* incl. their path, zap projects (if set) and return.
* @throws IndexerException
* @throws IOException
* @throws NullPointerException if <var>env</var> or <var>zapCache</var> is
* {@code null}
*/
@SuppressWarnings("PMD.SimplifyStartsWith")
boolean addProjects,
boolean refreshHistory,
boolean listFiles,
boolean listTokens,
{
throw new IndexerException("Please specify a DATA ROOT path");
}
throw new IndexerException("Please specify a SRC_ROOT with option -s");
}
if (!RuntimeEnvironment.validateExuberantCtags()) {
throw new IndexerException("Didn't find Exuberant Ctags");
}
throw new IndexerException("Internal error, zapCache shouldn't be null");
}
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) {
cfg.setDefaultProject(p);
break;
}
}
}
if (configFilename != null) {
}
if (refreshHistory) {
}
if (listFiles) {
}
if (listTokens) {
}
}
/**
* Index and optionally optimize related databases. Obtains an
* {@link RuntimeEnvironment} instance and registers with it, so that
* required infos are obtained from there.
*
* @param update If {@code true} update the index for related projects.
* @param noThreads Number of threads to use for indexing.
* @param subFiles Use the giben repo files to determine the projects,
* which should be indexed or index db optimized.
* @param progress If {@code true} show progress when indexing. Wrt.
* to logging and terminal flooding a really bad idea.
* @throws IOException
* @see IndexDatabase#update(ExecutorService, IndexChangedListener, List)
*/
throws IOException
{
if (update) {
} else if (cfg.isOptimizeDatabase()) {
}
} else {
} else {
db = new IndexDatabase();
} else {
}
if (idx != -1) {
}
if (idx == -1) {
}
} else {
}
}
}
public void run() {
try {
if (update) {
} else if (optimize) {
}
} catch (Throwable e) {
}
}
});
}
}
while (!executor.isTerminated()) {
try {
// Wait forever
} catch (InterruptedException exp) {
+ exp.getMessage());
}
}
}
/**
* Send the configuration of the current thread's runtime environment to
* the given host.
* @param configHost where to send the configuration. Format: host:port .
*/
if (configHost != null) {
try {
+ " (is web application server running with opengrok deployed?): "
+ ex.getMessage());
}
}
}
}
}
private Indexer() {
}
}