mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
[DS-321] DSpace command launcher
git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@4311 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* ScriptLauncher.java
|
||||
*
|
||||
* Version: $Revision$
|
||||
*
|
||||
* Date: $Date$
|
||||
*
|
||||
* Copyright (c) 2002-2009, Duraspace. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of Duraspace nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/package org.dspace.app.launcher;
|
||||
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
|
||||
import java.util.List;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* A DSpace script launcher.
|
||||
*
|
||||
* @author Stuart Lewis
|
||||
*/
|
||||
public class ScriptLauncher
|
||||
{
|
||||
/**
|
||||
* Execute the DSpace script launcher
|
||||
*
|
||||
* @param args Any parameters required to be passed to the scripts it executes
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Check that there is at least one argument
|
||||
if (args.length < 1)
|
||||
{
|
||||
System.err.println("You must provide at least one command argument");
|
||||
display();
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
// Parse the configuration file looking for the command entered
|
||||
Document doc = getConfig();
|
||||
String request = args[0];
|
||||
Element root = doc.getRootElement();
|
||||
List<Element> commands = root.getChildren("command");
|
||||
for (Element command : commands)
|
||||
{
|
||||
if (request.equalsIgnoreCase(command.getChild("name").getValue()))
|
||||
{
|
||||
// Run each step
|
||||
List<Element> steps = command.getChildren("step");
|
||||
for (Element step : steps)
|
||||
{
|
||||
// Instantiate the class
|
||||
Class target = null;
|
||||
String className = step.getChild("class").getValue();
|
||||
try
|
||||
{
|
||||
target = Class.forName(className,
|
||||
true,
|
||||
Thread.currentThread().getContextClassLoader());
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
System.err.println("Error in launcher.xml: Invalid class name: " + className);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
// Strip the leading argument from the args, and add the arguments
|
||||
// Set <passargs>false</passargs> if the arguments should not be passed on
|
||||
String[] useargs = args.clone();
|
||||
Class[] argTypes = {useargs.getClass()};
|
||||
boolean passargs = true;
|
||||
if ((step.getAttribute("passuserargs") != null) &&
|
||||
("false".equalsIgnoreCase(step.getAttribute("passuserargs").getValue())))
|
||||
{
|
||||
passargs = false;
|
||||
}
|
||||
if ((args.length == 1) || (!passargs))
|
||||
{
|
||||
useargs = new String[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
String[] argsnew = new String[useargs.length - 1];
|
||||
for (int i = 1; i < useargs.length; i++)
|
||||
{
|
||||
argsnew[i - 1] = useargs[i];
|
||||
}
|
||||
useargs = argsnew;
|
||||
}
|
||||
|
||||
// Add any extra properties
|
||||
List<Element> bits = step.getChildren("argument");
|
||||
if (step.getChild("argument") != null)
|
||||
{
|
||||
String[] argsnew = new String[useargs.length + bits.size()];
|
||||
int i = 0;
|
||||
for (Element arg : bits)
|
||||
{
|
||||
argsnew[i++] = arg.getValue();
|
||||
}
|
||||
for (; i < bits.size() + useargs.length; i++)
|
||||
{
|
||||
argsnew[i] = useargs[i - bits.size()];
|
||||
}
|
||||
useargs = argsnew;
|
||||
}
|
||||
|
||||
// Run the main() method
|
||||
try
|
||||
{
|
||||
Object[] arguments = {useargs};
|
||||
|
||||
// Useful for debugging, so left in the code...
|
||||
/**System.out.print("About to execute: " + className);
|
||||
for (String param : useargs)
|
||||
{
|
||||
System.out.print(" " + param);
|
||||
}
|
||||
System.out.println("");**/
|
||||
|
||||
Method main = target.getMethod("main", argTypes);
|
||||
Object output = main.invoke(null, arguments);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("Exception: " + e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
// The command wasn't found
|
||||
System.err.println("Command not found: " + args[0]);
|
||||
display();
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
public static Document getConfig()
|
||||
{
|
||||
// Load the launcher configuration file
|
||||
String config = ConfigurationManager.getProperty("dspace.dir") +
|
||||
System.getProperty("file.separator") + "config" +
|
||||
System.getProperty("file.separator") + "launcher.xml";
|
||||
SAXBuilder saxBuilder = new SAXBuilder();
|
||||
Document doc = null;
|
||||
try
|
||||
{
|
||||
doc = saxBuilder.build(config);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("Unable to load the launcher configuration file: [dspace]/config/launcher.xml");
|
||||
System.err.println(e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
||||
public static void display()
|
||||
{
|
||||
Document doc = getConfig();
|
||||
List<Element> commands = doc.getRootElement().getChildren("command");
|
||||
System.out.println("Usage: dspace [command-name] {parameters}");
|
||||
for (Element command : commands)
|
||||
{
|
||||
System.out.println(" - " + command.getChild("name").getValue() +
|
||||
": " + command.getChild("description").getValue());
|
||||
}
|
||||
}
|
||||
}
|
@@ -49,6 +49,7 @@
|
||||
- [DS-316] Make SWORD app:accepts configurable
|
||||
- [DS-318] JSPUI: Left over text in edit item about format
|
||||
- [DS-319] Replace '/dspace/bin/dsrun org.dspace.browse.ItemCounter' with /dspace/bin/itemcounter
|
||||
- [DS-321] DSpace command launcher
|
||||
- [DS-327] SWORD temp upload directory missing trailling slash
|
||||
- [DS-328] SWORD service documents do not include atom:generator element
|
||||
|
||||
|
48
dspace/bin/dspace
Normal file
48
dspace/bin/dspace
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
|
||||
###########################################################################
|
||||
#
|
||||
# dspace
|
||||
#
|
||||
# Version: $Revision$
|
||||
#
|
||||
# Date: $Date$
|
||||
#
|
||||
# Copyright (c) 2002-2009, Duraspace. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# - Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# - Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# - Neither the name of the Duraspace nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
# DAMAGE.
|
||||
#
|
||||
###########################################################################
|
||||
|
||||
# Script for running the DSpace launcher.
|
||||
|
||||
# Get the DSPACE/bin directory
|
||||
BINDIR=`dirname $0`
|
||||
|
||||
$BINDIR/dsrun org.dspace.app.launcher.ScriptLauncher $@
|
41
dspace/bin/dspace.bat
Normal file
41
dspace/bin/dspace.bat
Normal file
@@ -0,0 +1,41 @@
|
||||
@REM ###########################################################################
|
||||
@REM #
|
||||
@REM # dspace.bat
|
||||
@REM #
|
||||
@REM # Version: $Revision$
|
||||
@REM #
|
||||
@REM # Date: $Date$
|
||||
@REM #
|
||||
@REM # Copyright (c) 2002-2009, Duraspace. All rights reserved.
|
||||
@REM #
|
||||
@REM # Redistribution and use in source and binary forms, with or without
|
||||
@REM # modification, are permitted provided that the following conditions are
|
||||
@REM # met:
|
||||
@REM #
|
||||
@REM # - Redistributions of source code must retain the above copyright
|
||||
@REM # notice, this list of conditions and the following disclaimer.
|
||||
@REM #
|
||||
@REM # - Redistributions in binary form must reproduce the above copyright
|
||||
@REM # notice, this list of conditions and the following disclaimer in the
|
||||
@REM # documentation and/or other materials provided with the distribution.
|
||||
@REM #
|
||||
@REM # - Neither the name of the Duraspace nor the names of its
|
||||
@REM # contributors may be used to endorse or promote products derived from
|
||||
@REM # this software without specific prior written permission.
|
||||
@REM #
|
||||
@REM # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
@REM # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
@REM # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
@REM # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
@REM # HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
@REM # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
@REM # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
@REM # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
@REM # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
@REM # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
@REM # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
@REM # DAMAGE.
|
||||
@REM #
|
||||
@REM ###########################################################################
|
||||
|
||||
@call dsrun.bat org.dspace.app.launcher.ScriptLauncher %1 %2 %3 %4 %5 %6 %7 %8 %9
|
218
dspace/config/launcher.xml
Normal file
218
dspace/config/launcher.xml
Normal file
@@ -0,0 +1,218 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<commands>
|
||||
|
||||
<command>
|
||||
<name>checker</name>
|
||||
<description>Run the checksum checker</description>
|
||||
<step>
|
||||
<class>org.dspace.app.checker.ChecksumChecker</class>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>cleanup</name>
|
||||
<description>Remove deleted bitstreams from the assetstore</description>
|
||||
<step>
|
||||
<class>org.dspace.storage.bitstore.Cleanup</class>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>create-administrator</name>
|
||||
<description>Create a DSpace administrator account</description>
|
||||
<step>
|
||||
<class>org.dspace.administer.CreateAdministrator</class>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>dsprop</name>
|
||||
<description>View a DSpace property from dspace.cfg</description>
|
||||
<step>
|
||||
<class>org.dspace.core.ConfigurationManager</class>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>export</name>
|
||||
<description>Export items or collections</description>
|
||||
<step>
|
||||
<class>org.dspace.app.itemexport.ItemExport</class>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>filter-media</name>
|
||||
<description>Perform the media filtering to extract full text from docuemnts and to create thumbnails</description>
|
||||
<step>
|
||||
<class>org.dspace.app.mediafilter.MediaFilterManager</class>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>generate-sitemaps</name>
|
||||
<description>Generate search engine and html sitemaps</description>
|
||||
<step>
|
||||
<class>org.dspace.app.sitemap.GenerateSitemaps</class>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>import</name>
|
||||
<description>Import items into DSpace</description>
|
||||
<step>
|
||||
<class>org.dspace.app.itemimport.ItemImport</class>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>index-init</name>
|
||||
<description>Initialise the search and browse indexes</description>
|
||||
<step passuserargs="false">
|
||||
<class>org.dspace.browse.IndexBrowse</class>
|
||||
<argument>-f</argument>
|
||||
<argument>-r</argument>
|
||||
</step>
|
||||
<step passuserargs="false">
|
||||
<class>org.dspace.browse.ItemCounter</class>
|
||||
</step>
|
||||
<step passuserargs="false">
|
||||
<class>org.dspace.search.DSIndexer</class>
|
||||
<argument>-b</argument>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>index-update</name>
|
||||
<description>Update the search and browse indexes</description>
|
||||
<step passuserargs="false">
|
||||
<class>org.dspace.browse.IndexBrowse</class>
|
||||
<argument>-i</argument>
|
||||
</step>
|
||||
<step passuserargs="false">
|
||||
<class>org.dspace.browse.ItemCounter</class>
|
||||
</step>
|
||||
<step passuserargs="false">
|
||||
<class>org.dspace.search.DSIndexer</class>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>itemcounter</name>
|
||||
<description>Update the item strength counts in the user interface</description>
|
||||
<step passuserargs="false">
|
||||
<class>org.dspace.browse.ItemCounter</class>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>itemupdate</name>
|
||||
<description>Item update tool for altering metadata and bitstream content in items</description>
|
||||
<step>
|
||||
<class>org.dspace.app.itemimport.ItemUpdate</class>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>metadata-export</name>
|
||||
<description>Export metadata for batch editing</description>
|
||||
<step>
|
||||
<class>org.dspace.app.bulkedit.MetadataExport</class>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>metadata-import</name>
|
||||
<description>Import metadata after batch editing</description>
|
||||
<step>
|
||||
<class>org.dspace.app.bulkedit.MetadataImport</class>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>packager</name>
|
||||
<description>Execute a packager</description>
|
||||
<step>
|
||||
<class>org.dspace.app.packager.Packager</class>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>stat-general</name>
|
||||
<description>Compile the general statistics</description>
|
||||
<step passuserargs="false">
|
||||
<class>org.dspace.app.statistics.CreateStatReport</class>
|
||||
<argument>-r stat-general</argument>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>stat-initial</name>
|
||||
<description>Compile the initial statistics</description>
|
||||
<step passuserargs="false">
|
||||
<class>org.dspace.app.statistics.CreateStatReport</class>
|
||||
<argument>-r stat-initial</argument>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>stat-monthly</name>
|
||||
<description>Compile the monthly statistics</description>
|
||||
<step passuserargs="false">
|
||||
<class>org.dspace.app.statistics.CreateStatReport</class>
|
||||
<argument>-r stat-monthly</argument>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>stat-report-general</name>
|
||||
<description>Create the general statistics report</description>
|
||||
<step passuserargs="false">
|
||||
<class>org.dspace.app.statistics.CreateStatReport</class>
|
||||
<argument>-r stat-report-general</argument>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>stat-report-initial</name>
|
||||
<description>Create the general statistics report</description>
|
||||
<step passuserargs="false">
|
||||
<class>org.dspace.app.statistics.CreateStatReport</class>
|
||||
<argument>-r stat-report-initial</argument>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>stat-report-monthly</name>
|
||||
<description>Create the monthly statistics report</description>
|
||||
<step passuserargs="false">
|
||||
<class>org.dspace.app.statistics.CreateStatReport</class>
|
||||
<argument>-r stat-report-monthly</argument>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>structure-builder</name>
|
||||
<description>Build DSpace commnity and collection structure</description>
|
||||
<step>
|
||||
<class>org.dspace.administer.StructBuilder</class>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>sub-daily</name>
|
||||
<description>Send daily subscription notices</description>
|
||||
<step>
|
||||
<class>org.dspace.eperson.Subscribe</class>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>update-handle-prefix</name>
|
||||
<description>Update handle records and metadata when moving from one handle to another</description>
|
||||
<step>
|
||||
<class>org.dspace.handle.UpdateHandlePrefix</class>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
</commands>
|
Reference in New Issue
Block a user