|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.greenstone.fedora.installer.GSearchInstaller
public class GSearchInstaller
This class essentially follows the instructions at http://drama.ramp.org.au/cgi-bin/trac.cgi/wiki/InstallingFedoraGSearch in order to install Fedora Generic Search from their optimised fedoragsearch.war file. (I've also tested it on the original war file fedoragsearch.war available from http://defxws2006.cvt.dk/fedoragsearch/ and it works.) It then does a few minor extra things in order to make Fedora Generic Search work specifically with a Fedora repository of Greenstone documents.
Nested Class Summary | |
---|---|
(package private) static class |
GSearchInstaller.IgnoreDTDEntityResolver
This EntityResolver allows the XML parser to ignore validating against the DTD specified in the XML since it is pointing to the wrong location. |
Field Summary | |
---|---|
java.lang.String |
CATALINA_HOME
|
protected static java.util.Properties |
defaults
Default initialisation/customisation values. |
java.lang.String |
FEDORA_HOME
|
static java.lang.String |
FEDORAGSEARCH
|
java.lang.String |
fedoraPassword
|
java.lang.String |
fedoraUsername
|
protected java.util.Properties |
gSearchProperties
Reads from gsearch.properties file which contains default directory paths (using variables like FEDORA_HOME and CATALINA_HOME) and HOST and PORT, and sets these to custom values. |
java.lang.String |
gsearchWarFileName
|
java.lang.String |
host
|
java.lang.String |
indexName
|
java.lang.String |
port
|
protected static java.lang.String |
PROP_FILE
|
protected static java.lang.String |
PROP_HOST
|
protected static java.lang.String |
PROP_INDEX
|
protected static java.lang.String |
PROP_PASSW
|
protected static java.lang.String |
PROP_PORT
|
protected static java.lang.String |
PROP_REPOS
|
protected static java.lang.String |
PROP_UNAME
|
java.lang.String |
repositoryName
|
java.lang.String |
scriptExtension
|
static java.lang.String |
TOMCAT
|
Constructor Summary | |
---|---|
GSearchInstaller()
GSearchInstaller constructor sets all custom values to defaults |
|
GSearchInstaller(java.util.Properties options)
GSearchInstaller constructor sets the custom values |
Method Summary | |
---|---|
protected void |
copyPropFile(java.util.Properties properties,
java.lang.String propFileName,
java.io.File outputPath)
Stores the given properties in the file outputPath/propFileName. |
protected void |
copyTemplateFile(java.lang.String src,
java.io.File dest,
boolean replace)
Copies internal template src file (in executable jar) to dest file. |
protected void |
createLuceneIndexDir()
Creates the Lucene index directory in the right location inside FEDORA_HOME into which FedoraGSearch will store the indexes for the Greenstone contents in the Fedora repository. |
protected void |
customiseFedoraConfigFile()
Makes changes to the fedora.fcfg file located inside FEDORA_HOME. |
protected java.util.Properties |
customiseProperties(java.lang.String propFileName,
boolean display)
Loads properties from the property file denoted by propFileName and replaces all place-holders (such as FEDORA_HOME, CATALINA_HOME, HOST, PORT) with the custom values specified for this installation. |
static java.lang.String |
elementToFormattedString(org.w3c.dom.Element e,
java.lang.String dtd_SystemId)
Given an Element, this will return its String representation properly indented for display. |
protected static java.lang.String |
getSafeValue(javax.swing.JTextField field,
java.lang.String property)
This method returns the value of the textfield for the given GSearchInstaller initialiser property, if this is not the empty string. |
static java.lang.String |
getValue(org.w3c.dom.Element e)
Extract the text from an element, if any. |
void |
indexGreenstoneContents(boolean emptyFirst)
Indexes the contents of the repository(name) specified during Fedora Generic Search installation. |
static java.lang.String |
info()
|
void |
install()
|
static void |
main(java.lang.String[] args)
The main method creates a GSearchInstaller to install Fedora Generic Search from a (Muradora) fedoragsearch.war file. |
protected void |
moveUnpackWarFile(java.io.File gsearchWarFile)
Moves the (fedoragsearch.war) war file from the given location into FEDORA_HOME's tomcat folder (i.e. |
static java.util.Properties |
parseInstallationArgs(java.lang.String[] args)
Called to process multiple command line arguments where these arguments are GSearchInstaller constructor options followed by their values. |
protected org.w3c.dom.Document |
readXML(java.lang.Object xmlSource,
java.lang.String dtd_SystemId,
java.lang.String sourceFileName)
Reads from an xmlFile. |
protected boolean |
replaceDir(java.lang.String outputPath,
java.lang.String src,
java.lang.String dest)
Method that renames folder src in outputPath to dest. |
protected boolean |
replaceElementWithAttrValue(org.w3c.dom.Document doc,
java.lang.String tagName,
java.lang.String attrName,
java.lang.String attrValueContent,
java.lang.String replacementContent,
boolean onceOnly,
boolean wholeItem)
Given a DOM document, finds the first element where nodeName=tagName where one of the attributes has the name attrName and whose value contains attrValueContent. |
protected boolean |
replaceElementWithValue(org.w3c.dom.Document doc,
java.lang.String tagName,
java.lang.String contentValue,
java.lang.String replacement,
boolean onceOnly,
boolean wholeItem)
Given a DOM document, finds the first element where nodeName=tagName and where the element's inner text contains the string contentValue. |
protected int |
runProcess(java.lang.String[] args,
boolean ignoreWindows)
Method that will run the process associated with the gSearchProperties key. |
static java.util.Properties |
showInputDialog()
Displays a dialog to get user input for - fedora server host, port, username and password, - the names for the fedora generic search index and repository that are to be created, and - for the location of fedoragenericsearch.war (the installer is meant to work specifically with Muradora's fedoragenericsearch.war since they have edited various property and xml files to make it all easier). |
static java.lang.String |
usage()
If the program is run from the command line and the user executed it with -help or help, then this usage String is displayed. |
void |
waitForFedoraServer()
Waits for the fedora server to be ready after a server start. |
void |
waitForServerToStop()
Waits for the fedora server to stop |
protected void |
writeXML(org.w3c.dom.Document doc,
java.io.File xmlFile,
java.lang.String dtdToAddBackIn)
Writes out a DOM structure to a file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String FEDORAGSEARCH
public static final java.lang.String TOMCAT
public final java.lang.String FEDORA_HOME
public final java.lang.String CATALINA_HOME
public final java.lang.String scriptExtension
protected java.util.Properties gSearchProperties
public final java.lang.String indexName
public final java.lang.String repositoryName
public final java.lang.String host
public final java.lang.String port
public final java.lang.String fedoraUsername
public final java.lang.String fedoraPassword
public final java.lang.String gsearchWarFileName
protected static java.lang.String PROP_REPOS
protected static java.lang.String PROP_INDEX
protected static java.lang.String PROP_UNAME
protected static java.lang.String PROP_PASSW
protected static java.lang.String PROP_HOST
protected static java.lang.String PROP_PORT
protected static java.lang.String PROP_FILE
protected static final java.util.Properties defaults
Constructor Detail |
---|
public GSearchInstaller() throws java.lang.Exception
java.lang.Exception
public GSearchInstaller(java.util.Properties options) throws java.lang.Exception
java.lang.Exception
Method Detail |
---|
public void install() throws java.lang.Exception
java.lang.Exception
public void indexGreenstoneContents(boolean emptyFirst) throws java.lang.Exception
emptyFirst
- means the index will be created from scratch by first
executing runSOAPClient.sh with the arguments
"host:port updateIndex createEmpty" before updating from FOXML files.
java.lang.Exception
protected int runProcess(java.lang.String[] args, boolean ignoreWindows) throws java.lang.Exception
args
- signify the executable process and its arguments. The first element
must be the key into gSearchProperties whose value denotes the executable process
that is to be run. Subsequent elements are the actual arguments to that process.ignoreWindows
- if true will not plug the cmd /c start "" at the start of
the arguments. If false, and only of the OS is windows, then these additional
arguments get prepended to those already in the args array.
java.lang.Exception
protected java.util.Properties customiseProperties(java.lang.String propFileName, boolean display) throws java.lang.Exception
propFileName
- is the name of the template properties file
to be opened and read from. (Keep it read-only!)display
- - if true, then prints the contents of the properties
if false, does not.
java.lang.Exception
public void waitForServerToStop() throws java.lang.Exception
java.lang.Exception
public void waitForFedoraServer() throws java.lang.Exception
java.lang.Exception
protected boolean replaceDir(java.lang.String outputPath, java.lang.String src, java.lang.String dest)
outputPath
- is the directory in which src resides.src
- is the name of the folder in outputPath that is
to be renamed.dest
- is what src is to be renamed to.protected void copyPropFile(java.util.Properties properties, java.lang.String propFileName, java.io.File outputPath) throws java.lang.Exception
properties
- is the Properties map to be written out to a file.propFileName
- is the name of the output properties file.outputPath
- is the directory into which the properties file
is to be written.
java.lang.Exception
protected void copyTemplateFile(java.lang.String src, java.io.File dest, boolean replace) throws java.io.IOException
src
- is the internal file (internal to the jar) to be copied
its inputStream is obtained and copied.dest
- is the file into which the contents of src are to be copiedreplace
- indicates whether dest is to be replaced if it already
exists. If replace is true, then any existing dest is replaced with the
copied output file of the same name. If false, the copy operation does
not take place
java.io.IOException
- if the copying failed.protected org.w3c.dom.Document readXML(java.lang.Object xmlSource, java.lang.String dtd_SystemId, java.lang.String sourceFileName) throws java.lang.Exception
xmlSource
- is either an xmlFile or xml InputStream (of a jarred
file, for example) to be read into a DOM structure.dtd_SystemId
- - if specified, validation against the given DTD
is ignored. The DOM structure returned will not contain the DOCTYPE
entity with the given dtd file reference. If writing the DOM out to
a file later on, then it is advised that this DOC_TYPE is added back
in. If there is no dtd to be validated or whose validation is to be
ignored, pass the empty string for dtd_SystemId.sourceFileName
- is the name of the (possibly internal) file
that is to be read.
java.lang.Exception
- if an error occurred during parsing.protected void writeXML(org.w3c.dom.Document doc, java.io.File xmlFile, java.lang.String dtdToAddBackIn) throws java.lang.Exception
doc
- is the DOM to be written out to a filexmlFile
- is the file to write the XML out todtdToAddBackIn
- is "" if there's no special DTD to add
back into the DOCTYPE. If not "", it specifies the dtd file to
be added in the DOCTYPE of the XML output file.
java.lang.Exception
protected boolean replaceElementWithAttrValue(org.w3c.dom.Document doc, java.lang.String tagName, java.lang.String attrName, java.lang.String attrValueContent, java.lang.String replacementContent, boolean onceOnly, boolean wholeItem)
doc
- is the DOM Document object in which to search for
the element to be replacedtagName
- is the name of the element to search forattrName
- is the name of the attribute of the element to search forattrValueContent
- is the portion of the attribute value that will
be replaced by replacementContent.replacementContent
- is the replacement string that will overwrite
the part of the attrName attribute's value that matched attrValueContentonceOnly
- - if true will look for the first match and perform the
replacement once. If false, it will replace all matches found.wholeItem
- - if true, the entire string containing attrValueContent
will be replaced by the string replacementContent. If false, only the
attrValueContent portion of the original string will be replaced.
protected boolean replaceElementWithValue(org.w3c.dom.Document doc, java.lang.String tagName, java.lang.String contentValue, java.lang.String replacement, boolean onceOnly, boolean wholeItem)
doc
- is the DOM Document object in which to search for
the element to be replacedtagName
- is the name of the element to search forcontentValue
- is the portion of the textual content of the
element that should match for the replacement to happenreplacement
- is value that will overwrite the matching portion
of the element's textual content (it will overwrite contentValue).onceOnly
- - if true will look for the first match and perform the
replacement once. If false, it will replace all matches found.wholeItem
- - if true, the entire string containing attrValueContent
will be replaced by the string replacementContent. If false, only the
attrValueContent portion of the original string will be replaced.
public static java.lang.String getValue(org.w3c.dom.Element e)
e
- is the element whose value is to be extracted.
public static java.lang.String elementToFormattedString(org.w3c.dom.Element e, java.lang.String dtd_SystemId) throws java.lang.Exception
e
- is the element to be converted to its string representation.dtd_SystemId
- (if not "") is any DOCTYPE with systemId that needs
to be added back into the file. If "", then no new DOCTYPE entity is
added into the DOM structure represented by Element e.
java.lang.Exception
protected void moveUnpackWarFile(java.io.File gsearchWarFile) throws java.lang.Exception
gsearchWarFile
- the fedoragsearch.war file to be moved and
unpacked.
java.lang.Exception
- if an unpacked fedoragsearch does not exist
in the CATALINA_HOME/webapps folder at the end.protected void customiseFedoraConfigFile() throws java.lang.Exception
java.lang.Exception
protected void createLuceneIndexDir() throws java.lang.Exception
java.lang.Exception
- if the Lucene index directory cannot be created
in the appropriate location inside FEDORA_HOMEpublic static java.util.Properties showInputDialog()
protected static java.lang.String getSafeValue(javax.swing.JTextField field, java.lang.String property)
field
- is the TextField whose value is being extractedproperty
- is the GSearchInstaller property that the TextField
value maps to.
public static java.lang.String info()
public static java.lang.String usage()
public static java.util.Properties parseInstallationArgs(java.lang.String[] args)
args
- are the command-line arguments received by main
which consist of one or more multiple "-option value" pairs.
public static void main(java.lang.String[] args)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |