|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mycore.frontend.cli.MCRCommandLineInterface
public class MCRCommandLineInterface
The main class implementing the MyCoRe command line interface. With the command line interface, you can import, export, update and delete documents and other
data from/to the filesystem. Metadata is imported from and exported to XML files. The command line interface is for administrative purposes and to be used on
the server side. It implements an interactive command prompt and understands a set of commands. Each command is an instance of the class
MCRCommand.
MCRCommand| Field Summary | |
|---|---|
protected static ConcurrentLinkedQueue<Number> |
benchList
|
protected static Vector<String> |
commandQueue
A queue of commands waiting to be executed |
protected static BufferedReader |
console
The standard input console where the user enters commands |
protected static Vector<String> |
failedCommands
|
protected static ArrayList<MCRCommand> |
knownCommands
The array holding all known commands |
(package private) static Logger |
logger
The Logger |
protected static HashMap<String,Integer> |
numInvocations
Stores total number of executions for each command |
protected static HashMap<String,Long> |
timeNeeded
Stores total time needed for all executions of the given command |
| Constructor Summary | |
|---|---|
MCRCommandLineInterface()
|
|
| Method Summary | |
|---|---|
static void |
addMillis(long l)
|
static void |
cancelOnError()
|
static void |
changeToUser(String user,
String password)
This command changes the user of the session context to a new user. |
static void |
clearMillis()
|
static void |
executeShellCommand(String command)
Executes simple shell commands from inside the command line interface and shows their output. |
static void |
exit()
Exits the command line interface. |
protected static void |
handleFailedCommands()
|
protected static void |
initCommands()
Reads command definitions from a configuration file and builds the MCRCommand instances |
static void |
listKnownCommands()
Shows a list of commands understood by the command line interface and shows their input syntax. |
static void |
login(String user)
This command changes the user of the session context to a new user. |
static void |
main(String[] args)
The main method that either shows up an interactive command prompt or reads a file containing a list of commands to be processed |
protected static void |
processCommand(String command)
Processes a command entered by searching a matching command in the list of known commands and executing its method. |
protected static String |
readCommandFromPrompt()
Shows up a command prompt. |
static List<String> |
readCommandsFile(String file)
Reads a file containing a list of commands to be executed and adds them to the commands queue for processing. |
protected static void |
saveFailedCommand(String lastCommand)
|
static void |
saveMillis(String fileBaseName)
|
protected static void |
saveQueue(String lastCommand)
|
static void |
show(String fname)
Show contents of a local text file, including line numbers. |
static void |
showCommandsHelp(String com)
Shows the help text of one or more commands. |
static void |
showCommandStatistics()
Shows statistics on number of invocations and time needed for each command successfully executed. |
protected static void |
showException(Throwable ex)
Shows details about an exception that occured during command processing |
protected static void |
showOutput(InputStream in)
Catches the output read from an input stream and prints it line by line on standard out. |
static void |
skipOnError()
|
static void |
whoami()
The method print the current user. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
static Logger logger
protected static ArrayList<MCRCommand> knownCommands
protected static Vector<String> commandQueue
protected static Vector<String> failedCommands
protected static BufferedReader console
protected static ConcurrentLinkedQueue<Number> benchList
protected static HashMap<String,Long> timeNeeded
protected static HashMap<String,Integer> numInvocations
| Constructor Detail |
|---|
public MCRCommandLineInterface()
| Method Detail |
|---|
protected static void initCommands()
public static void main(String[] args)
protected static String readCommandFromPrompt()
protected static void processCommand(String command)
command - The command string to be processedpublic static void showCommandStatistics()
protected static void saveQueue(String lastCommand)
protected static void saveFailedCommand(String lastCommand)
protected static void handleFailedCommands()
public static void show(String fname)
throws Exception
fname - the filename
Exceptionprotected static void showException(Throwable ex)
ex - The exception that was catched while processing a command
public static List<String> readCommandsFile(String file)
throws IOException,
FileNotFoundException
file - The file holding the commands to be processed
IOException - when the file could not be read
FileNotFoundException - when the file was not foundpublic static void listKnownCommands()
public static void showCommandsHelp(String com)
com - the command
public static void executeShellCommand(String command)
throws IOException,
SecurityException
command - the shell command to be executed
IOException - when an IO error occured while catching the output returned by the command
SecurityException - when the command could not be executed for security reasonspublic static void whoami()
public static void changeToUser(String user,
String password)
user - the new user IDpassword - the password of the new userpublic static void login(String user)
user - the new user ID
protected static void showOutput(InputStream in)
throws IOException
IOExceptionpublic static void cancelOnError()
public static void skipOnError()
public static void addMillis(long l)
public static void clearMillis()
public static void saveMillis(String fileBaseName)
throws IOException
IOExceptionpublic static void exit()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||