public class ContentLoader
extends java.lang.Object
This program accepts a server URI (in the format expected by
ContentSourceFactory.newContentSource(java.net.URI)
) and one or more file pathnames of
documents to load.
Click here for the source code for this class
The main() method in this example leaves the ContentCreateOptions
value set to null which
will apply defaults when documents are loaded. This means that document type (XML, text() or
binary()) may be determined by URI extention. If you instantiate this class from another class,
you can set explicit options via setOptions(com.marklogic.xcc.ContentCreateOptions)
before calling load(java.io.File[])
.
The main() method uses the absolute pathname of each file as its URI for loading. There is also a method provided which takes parallel arrays of URI strings and File objects.
Constructor and Description |
---|
ContentLoader(java.net.URI serverUri)
Construct an instance that may be used to insert content.
|
Modifier and Type | Method and Description |
---|---|
void |
load(java.io.File[] files)
Load the provided
File s into the contentbase, using the absolute pathname of each
File as the document URI. |
void |
load(java.lang.String[] uris,
java.io.File[] files)
Load the provided
File s, using the provided URIs, into the content server. |
static void |
main(java.lang.String[] args)
Command-line main() module to run this content loader.
|
void |
setOptions(ContentCreateOptions options)
Set (or clear) an instance of
ContentCreateOptions which defines creation options to
apply to each document loaded. |
public ContentLoader(java.net.URI serverUri) throws XccConfigException
serverUri
- A URI identifying a ContentSource
, in the format expected by
ContentSourceFactory.newContentSource(java.net.URI)
.XccConfigException
- Thrown if a Session
cannot be created. This usually indicates that the
host/port or user credentials are incorrect.public void load(java.lang.String[] uris, java.io.File[] files) throws RequestException
File
s, using the provided URIs, into the content server.uris
- An array of URIs (identifiers) that correspond to the File
instances given
in the "files" parameter.files
- An array of File
objects representing disk files to be loaded. The
ContentCreateOptions
object set with
setOptions(com.marklogic.xcc.ContentCreateOptions)
, if any, will be
applied to all documents when they are loaded.RequestException
- If there is an unrecoverable problem with sending the data to the server. If this
exception is thrown, none of the documents will have been committed to the
contentbase.public void load(java.io.File[] files) throws RequestException
File
s into the contentbase, using the absolute pathname of each
File
as the document URI.files
- An array of File
objects representing disk files to be loaded. The
ContentCreateOptions
object set with
setOptions(com.marklogic.xcc.ContentCreateOptions)
, if any, will be
applied to all documents when they are loaded.RequestException
- If there is an unrecoverable problem with sending the data to the server. If this
exception is thrown, none of the documents will have been committed to the
contentbase.public void setOptions(ContentCreateOptions options)
ContentCreateOptions
which defines creation options to
apply to each document loaded. This is null (defaults) unless explictly set.options
- public static void main(java.lang.String[] args) throws java.net.URISyntaxException, XccConfigException, RequestException
args
- A URI [arg 0] identifying the server/port/user/db where the content should be
inserted and one or more [args 1-n] giving file pathnames of documents to load.java.net.URISyntaxException
- If there is a problems interpreting the URI.XccConfigException
- If a Session
cannot be created.RequestException
- If the content cannot be inserted in the contentbase.Copyright © 2019 MarkLogic Corporation. All Rights Reserved.
Complete online documentation for MarkLogic Server, XQuery and related components may be found at developer.marklogic.com