|
© 2005 BEA Systems, Inc. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.bea.p13n.content.document.ref.loader.BulkLoader
The reference document repository bulk loader application.
This class is mainly designed to run as a command-line application, via a "java com.bea.p13n.content.document.loader.BulkLoader" command-line. To see a usage, give it a -h flag or read the Usage.txt in this package.
Additionally, BulkLoader objects can be created and used to provide the functionality in other places. The lifecycle of a BulkLoader is as follows:
parseArgs()
if not passed in to constructor.
validateArgs()
to make sure the loader has
valid arguments.
initialize()
to setup internal state.
go()
to execute the load.
shutdown()
to cleanup everything.
If manually constructing and utilizing a BulkLoader object, be certain to synchronize all access to the object. Since the command-line program is single-threaded, BulkLoader objects are not thread-safe by design.
To load the default LoaderFilters
, the BulkLoader
looks for the com/bea/p13n/content/document/loader/loader.properties
file in the CLASSPATH. From that it reads the list of default LoaderFilter
class names from the "loader.defFilters" property. To not use any of the
default filters, specify +filters in the command-line args.
MetaParser
,
FileCache
Nested Class Summary | |
static class |
BulkLoader.ShowUsageException
Deprecated. Quick inner exception thrown on parseArgs() to say we should just print a usage report. |
Field Summary | |
Map |
addlColumnMap
Deprecated. The map of additional DOCUMENT table column name to collection of property names that map onto the column name. |
Collection |
addlColumnNames
Deprecated. The list of additional DOCUMENT table column names. |
int |
commitAfter
Deprecated. The number of documents loaded after which this should commit (0 or less for only at the end). |
protected Connection |
connection
Deprecated. The connection this loader uses. |
String |
conPoolName
Deprecated. The connection pool name. |
static String |
DEF_MD_FILE_EXT
Deprecated. The default file extension for metadata property files. |
static String |
DEF_MIME_TYPE
Deprecated. The default mime type. |
static String |
DEF_SCHEMA_NAME
Deprecated. The default schema name. |
static String |
DEF_SCHEMA_PATH
Deprecated. The default path for the schema file. |
static String |
DEF_WLS_PROPS_PATH
Deprecated. The default weblogic properties file path. |
static String |
deleteDocSql
Deprecated. The preparable sql to remove a document from the database. |
protected PreparedStatement |
deleteDocStmt
Deprecated. The delete document statement. |
static String |
deleteMDSql
Deprecated. The preparable sql to remove a document's implicit metadata from the database. |
protected PreparedStatement |
deleteMDStmt
Deprecated. The delete metadata statement. |
static String |
DOC_MD_TABLE
Deprecated. The document_metadata table name. |
static String |
DOC_TABLE
Deprecated. The document table name. |
String |
docBase
Deprecated. The docBase. |
boolean |
doCleanUp
Deprecated. Are we supposed to do a cleanup. |
boolean |
doDelete
Deprecated. Are we deleting entries. |
boolean |
doMetaParse
Deprecated. Are we supposed to parse '*.htm' and '*.html' files for META tags. |
static Collection |
explicitAttrNames
Deprecated. The set of explicit document metadata attribute names. |
static Collection |
explicitColumnNames
Deprecated. The default set of DOCUMENT table column names. |
String |
fileEncoding
Deprecated. The file enconding (null for VM default). |
List |
fileList
Deprecated. The list of files/directories to scan over. |
List |
htmlMatchList
Deprecated. The list of patterns that represent HTML file names. |
boolean |
ignoreErrors
Deprecated. Do we ignore errors. |
List |
ignoreList
Deprecated. The list of file name patterns to ignore. |
boolean |
includeHidden
Deprecated. Are we supposed to include hidden files and directories. |
boolean |
inheritProps
Deprecated. Are we supposed to inherit metadata properties when recursing directories? |
static String |
insertDocSql
Deprecated. No longer used. |
protected PreparedStatement |
insertDocStmt
Deprecated. The insert document statement. |
static String |
insertMDSql
Deprecated. The preparable sql to insert a document metadata into the database. |
protected PreparedStatement |
insertMDStmt
Deprecated. The insert document metadata statement. |
protected Properties |
jdbcProps
Deprecated. The JDBC connection properties. |
protected String |
jdbcUrl
Deprecated. The JDBC connection url. |
List |
loaderFilters
Deprecated. The list of LoaderFilters to try. |
List |
matchList
Deprecated. The list of file name patterns to include. |
String |
mdFileExt
Deprecated. The file extension of metadata property files. |
protected Collection |
metadataNames
Deprecated. The metadata properties we find along the way. |
protected String |
myInsertDocSql
Deprecated. The SQL statement used to insert into the DOCUMENT table. |
protected String |
myUpdateDocSql
Deprecated. The SQL statement used to update the DOCUMENT table. |
protected long |
numDocsLoaded
Deprecated. The number of documents we've loaded so far. |
boolean |
recurse
Deprecated. Do we recurse over directories? |
String |
schemaName
Deprecated. The name of the schema in the schema file. |
boolean |
schemaOnly
Deprecated. Are we doing only the schema file generation. |
String |
schemaPath
Deprecated. The path to the schema file to output. |
boolean |
testOnly
Deprecated. Are we running in test mode? |
boolean |
truncate
Deprecated. Do we try to truncate. |
static String |
updateDocSql
Deprecated. No longer used. |
protected PreparedStatement |
updateDocStmt
Deprecated. The update document statement. |
boolean |
verbose
Deprecated. Do we spew out messages. |
String |
wlsPropsPath
Deprecated. The weblogic.properties file path. |
Constructor Summary | |
BulkLoader()
Deprecated. Constructor a BulkLoader without command-line arguments. |
|
BulkLoader(String[] args)
Deprecated. Construct a BulkLoader from the given command-line arguments. |
Method Summary | |
boolean |
accept(File dir,
String name)
Deprecated. Implement the FilenameFilter interface method to use our match and ignore lists. |
static void |
close(Object o)
Deprecated. Close an object which has a close() method, ignoring any exceptions. |
void |
commit()
Deprecated. Commit the transaction. |
void |
debug(String mesg)
Deprecated. Out put a debug message. |
int |
deleteDoc(String path)
Deprecated. This will remove the document with id of path from the database, including all of its implicit metadata. |
void |
deleteDocMetadata(String path)
Deprecated. This will remove the implicit metadata for the specified document. |
void |
doLoad()
Deprecated. Do the actual bulk load logic on the file list. |
void |
doLoad(File baseDir,
String path,
Properties dirProps)
Deprecated. Load the given path into the database. |
void |
error(String mesg)
Deprecated. Output an error message. |
void |
error(String mesg,
Throwable ex)
Deprecated. Output an error message. |
protected void |
finalize()
Deprecated. Called when this to be finialized. |
String |
fixPath(String path)
Deprecated. Fix up a path to be forward-slash style and to not have empty path parts. |
static String |
fixString(String in)
Deprecated. Fix empty strings to be nulls. |
String |
fixString(String in,
String tableName,
String colName)
Deprecated. Fix up strings to check potentionally truncate too large values. |
Properties |
getLoaderFilterProperties(File f,
Properties p)
Deprecated. Get the properties from the BulkLoader's LoaderFilters for the given file. |
Properties |
getMetadataProperties(File base,
Properties p)
Deprecated. Get the metadata properties for the given file or directory. |
String |
getPropertyForColumn(String colName,
Properties p)
Deprecated. Get the property value for the specified additional column name. |
void |
go()
Deprecated. Let the bulkloader go. |
void |
initialize()
Deprecated. Initialize the bulkloader from the current state. |
int |
insertDoc(String path,
File f,
Properties p,
String mimeType)
Deprecated. Update or insert a document and metadata into the database. |
static boolean |
isHidden(File f)
Deprecated. Check if the specified file is a hidden file. |
boolean |
isHtmlFile(String name)
Deprecated. Tell if the specified file name is an HTML file to the loader. |
static boolean |
isReadableDirectory(String name)
Deprecated. Check if the specified file name is a directory that we can get into. |
void |
loadPropertyColumnInfo(Properties p)
Deprecated. Load the set of jdbc.column. |
static int |
main(BulkLoader loader,
String[] args)
Deprecated. The main method invoked on a BulkLoader instance. |
static void |
main(String[] args)
Deprecated. Command-line entry point. |
void |
parseArgs(String[] args)
Deprecated. Parse the given input arguments. |
void |
printSchema()
Deprecated. Print the schema xml for all the metadata we've loaded so far. |
void |
printSchema(PrintWriter out,
String enc)
Deprecated. Print the schema xml for all the metadata we've loaded so far to the given output stream. |
void |
rollback()
Deprecated. Rollback the transaction. |
protected void |
setJDBCInfo()
Deprecated. Set the jdbc connection url and properties from the current weblogic.properties file. |
boolean |
shouldIgnore(String name)
Deprecated. Tell if the loader should ignore the specified file name. |
boolean |
shouldInclude(String name)
Deprecated. Tell if the loader should include the specified file name. |
void |
shutdown()
Deprecated. Shutdown this bulk loader. |
static List |
split(String str,
String on)
Deprecated. Split a delimited list into a List. |
static Properties |
splitToProperties(String str,
String on)
Deprecated. Split a WLS connection pool style string in a Properties object of the name=value pairs. |
void |
usage(PrintStream out)
Deprecated. Print the usage of the application. |
void |
usage(PrintWriter out)
Deprecated. Print the usage of the application. |
void |
validateArgs()
Deprecated. Validate that we have been passed correct arguments. |
void |
warning(String mesg)
Deprecated. Output a warning message. |
void |
warning(String mesg,
Throwable ex)
Deprecated. Output a warning message. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public Map addlColumnMap
public Collection addlColumnNames
public int commitAfter
protected Connection connection
public String conPoolName
public static final String DEF_MD_FILE_EXT
public static final String DEF_MIME_TYPE
public static final String DEF_SCHEMA_NAME
public static final String DEF_SCHEMA_PATH
public static final String DEF_WLS_PROPS_PATH
public static final String deleteDocSql
protected PreparedStatement deleteDocStmt
public static final String deleteMDSql
protected PreparedStatement deleteMDStmt
public static String DOC_MD_TABLE
public static String DOC_TABLE
public String docBase
public boolean doCleanUp
public boolean doDelete
public boolean doMetaParse
public static final Collection explicitAttrNames
public static final Collection explicitColumnNames
public String fileEncoding
public List fileList
public List htmlMatchList
public boolean ignoreErrors
public List ignoreList
public boolean includeHidden
public boolean inheritProps
public static final String insertDocSql
protected PreparedStatement insertDocStmt
public static final String insertMDSql
protected PreparedStatement insertMDStmt
protected Properties jdbcProps
protected String jdbcUrl
public List loaderFilters
public List matchList
Empty to include all.
public String mdFileExt
This should start with a ".".
protected Collection metadataNames
protected String myInsertDocSql
This will constructed in initialize() from with any additional column information.
protected String myUpdateDocSql
This will constructed in initialize() from with any additional column information.
protected long numDocsLoaded
public boolean recurse
public String schemaName
public boolean schemaOnly
public String schemaPath
public boolean testOnly
public boolean truncate
public static final String updateDocSql
protected PreparedStatement updateDocStmt
public boolean verbose
public String wlsPropsPath
Constructor Detail |
public BulkLoader()
public BulkLoader(String[] args) throws IllegalArgumentException
IllegalArgumentException
- thrown on invalid argsparseArgs(java.lang.String[])
Method Detail |
public boolean accept(File dir, String name)
accept
in interface FilenameFilter
public static void close(Object o)
public void commit()
public void debug(String mesg)
Subclasses can override this method to change where messages go.
public int deleteDoc(String path) throws SQLException
path
- the document path
SQLException
- thrown on a database error.deleteDocMetadata(java.lang.String)
public void deleteDocMetadata(String path) throws SQLException
path
- the document path
SQLException
- thrown on a database error.deleteDocMetadata(java.lang.String)
public void doLoad() throws SQLException
SQLException
public void doLoad(File baseDir, String path, Properties dirProps) throws SQLException
If path is a directory, all files underneath it that match our patterns will be included. If path is a file, it will be loaded.
baseDir
- the base directory (can be used to get absolute file
paths).path
- the path to the file or directory (this can be multi-part,
not just name).dirProps
- the base md properties for file (this should be a clone
this method can modify as needed).
SQLException
- thrown on a database error.public void error(String mesg)
public void error(String mesg, Throwable ex)
Subclasses can override this method to change where messages go.
protected void finalize() throws Throwable
Throwable
public String fixPath(String path)
public static String fixString(String in)
public String fixString(String in, String tableName, String colName)
public Properties getLoaderFilterProperties(File f, Properties p)
f
- the file.p
- the properties object to add to (null to create new one).
public Properties getMetadataProperties(File base, Properties p) throws IOException
This does not do a META data parse.
base
- the file or directory base path.p
- the properties to load into (null to create new).
IOException
- on an error reading the properties file.public String getPropertyForColumn(String colName, Properties p)
This will loop over the property names mapped to the column name and return the first found value in the properties.
public void go() throws SQLException, IOException
SQLException
- if the load/cleanup fails.
IOException
- if printing the schema fails.public void initialize() throws SQLException, IllegalStateException
This calls setJDBCInfo()
and then creates a
JDBC connection. It additinal configures any known column size
limitations and constructs any SQL statements it needs to.
SQLException
- thrown on an error connecting to the database.
IllegalStateException
- thrown on an initialization error.setJDBCInfo()
public int insertDoc(String path, File f, Properties p, String mimeType) throws SQLException
path
- the document path id.f
- the file of the document (can be null).p
- the implicit properties.mimeType
- the preferred mime type of the document (null for
default).
SQLException
- thrown on a database error.public static boolean isHidden(File f)
Under UNIX, the File.isHidden() reports that "/weblogicCommerce/dmsBase/." is a hidden file, which it is not. So, this fixes that problem by getting canonicals paths for directories before calling isHidden(). That seems to do the trick.
public boolean isHtmlFile(String name)
public static boolean isReadableDirectory(String name)
public void loadPropertyColumnInfo(Properties p)
public static int main(BulkLoader loader, String[] args)
This will take a BulkLoader through the bulk loading steps. Output
will be sent via the BulkLoader's debug()
,
warning()
, and error()
methods.
This will not call System.exit().
args
- the command-line args.
parseArgs(java.lang.String[])
,
validateArgs()
,
initialize()
,
go()
,
commit()
public static void main(String[] args)
This will call System.exit() on invalid args or error. To invoke a bulk load from your own code, create and manipulate a BulkLoader object. You can use the other main method, which does not exit.
args
- the command-line args.main(BulkLoader, String[])
public void parseArgs(String[] args) throws IllegalArgumentException
args
- the input arguments.
BulkLoader.ShowUsageException
- thrown if the caller should show a usage
report.
IllegalArgumentException
- thrown on bad arguments.public void printSchema() throws IOException
IOException
- thrown on an error outputting the schema xml.public void printSchema(PrintWriter out, String enc) throws IOException
out
- the output stream.enc
- the file encoding (will go in xml head if not null).
IOException
- thrown on an I/O error.public void rollback()
protected void setJDBCInfo() throws IllegalStateException
IllegalStateException
- thrown if we cannot get the information.public boolean shouldIgnore(String name)
public boolean shouldInclude(String name)
public void shutdown()
public static List split(String str, String on)
public static Properties splitToProperties(String str, String on)
public void usage(PrintStream out)
public void usage(PrintWriter out)
public void validateArgs() throws IllegalStateException
This does not validate that the arguments are valid. That will be done in initialize().
IllegalStateException
public void warning(String mesg)
public void warning(String mesg, Throwable ex)
Subclasses can override this method to change where messages go.
|
© 2005 BEA Systems, Inc. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |