miless.commandline
Class DerivateCommands

java.lang.Object
  extended by miless.commandline.Commands
      extended by miless.commandline.DerivateCommands
All Implemented Interfaces:
MCRExternalCommandInterface

public class DerivateCommands
extends Commands
implements MCRExternalCommandInterface

A collection of methods that implement the behavior of command line interface commands for importing, exporting, updating and deleting derivates in the system.

Version:
$Revision: 17179 $ $Date: 2010-03-24 21:57:22 +0100 (Wed, 24 Mar 2010) $
Author:
Frank L´┐Żtzenkirchen
See Also:
Derivate

Constructor Summary
DerivateCommands()
           
 
Method Summary
static void backupAllToDirectory(String dir)
          Backups metadata of all derivates and their files to a directory
static void backupToDirectory(int minID, int maxID, String dir)
          Backups metadata of all derivates with IDs in a certain range to a directory
static void backupToDirectory(int id, String directory)
          Backups derivate metadata to an XML file in a given directory.
static void delete(int id)
          Deletes a derivate and all its files in the system database
 ArrayList getPossibleCommands()
           
static void loadAllFromDirectory(String directory)
          Reads all files ending with "*.xml" from a directory, assuming that they contain derivate metadata, and imports each derivate and its files into the system.
protected static void loadFiles(InternalDerivate d, String file)
          Imports the files of an internal derivate and links them to the derivate.
static void loadFromFile(String file)
          Imports a derivate and its files into the system.
static void moveFileContent(int minID, int maxID, String fromStore, String toStore, String tempDir)
          Moves the content of all derivates with IDs between minID and maxID from the content store with ID fromStore to the content store with ID toStore, using the local directory tempDir as working directory for temporary file storage.
static void repairContentIndex()
          Repairs search index of derivate files
static void saveAllToDirectory(String dir)
          Saves all derivates and their files to a directory
static void saveToDirectory(int minID, int maxID, String dir)
          Saves all derivates with IDs in a certain range to a directory
static void saveToDirectory(int id, String directory)
          Saves derivate metadata to an XML file in a given directory.
static void setImportMode(String mode)
          Sets DerivateManager import mode.
static void updateFromFile(String file)
          Updates a dervate by reading its metadata from an xml file and (in case of an internal derivate) appending or updating the existing files stored in the system.
 
Methods inherited from class miless.commandline.Commands
appendFileSeparator, readXML, writeXML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DerivateCommands

public DerivateCommands()
Method Detail

getPossibleCommands

public ArrayList getPossibleCommands()
Specified by:
getPossibleCommands in interface MCRExternalCommandInterface

delete

public static void delete(int id)
                   throws Exception
Deletes a derivate and all its files in the system database

Parameters:
id - The ID of the derivate to be deleted
Throws:
Exception

loadFromFile

public static void loadFromFile(String file)
                         throws Exception
Imports a derivate and its files into the system. It reads an XML file containing the derivate metadata. If the derivate is an InternalDerivate, the system will import the files and link them to the derivate. The files that should be imported have to be in a directory with the same name as the XML file, except that the extension ".xml" is missing.

Parameters:
file - The path of the xml file holding the derivate metadata
Throws:
Exception

loadFiles

protected static void loadFiles(InternalDerivate d,
                                String file)
                         throws Exception
Imports the files of an internal derivate and links them to the derivate. The files that should be imported have to be in a directory with the same name as the XML file, except that the extension ".xml" is missing.

Parameters:
file - The path of the xml file holding the derivate metadata
Throws:
Exception

saveToDirectory

public static void saveToDirectory(int id,
                                   String directory)
                            throws Exception
Saves derivate metadata to an XML file in a given directory. The name of the XML file created is "derivate-XXX.xml", where XXX is the derivate ID. If the derivate is an internal derivate, the files of the derivate will be exported to a directory with the name "derivate-XXX".

Parameters:
id - The ID of the derivate to be exported
directory - The path of the directory where the XML file and the files belonging to the derivate will be saved
Throws:
Exception

backupToDirectory

public static void backupToDirectory(int id,
                                     String directory)
                              throws Exception
Backups derivate metadata to an XML file in a given directory. The name of the XML file created is "derivate-metadata-XXX.xml", where XXX is the derivate ID.

Parameters:
id - The ID of the derivate to be backuped
directory - The path of the directory where the XML file will be saved
Throws:
Exception

updateFromFile

public static void updateFromFile(String file)
                           throws Exception
Updates a dervate by reading its metadata from an xml file and (in case of an internal derivate) appending or updating the existing files stored in the system. The files that should be imported have to be in a directory with the same name as the XML file, except that the extension ".xml" is missing. All existing files will NOT be deleted if they have not changed.

Parameters:
file - The path of the xml file holding the derivate metadata
Throws:
Exception

loadAllFromDirectory

public static void loadAllFromDirectory(String directory)
                                 throws Exception
Reads all files ending with "*.xml" from a directory, assuming that they contain derivate metadata, and imports each derivate and its files into the system.

Parameters:
directory - The path of the directory where the xml files are located
Throws:
Exception

saveToDirectory

public static void saveToDirectory(int minID,
                                   int maxID,
                                   String dir)
                            throws Exception
Saves all derivates with IDs in a certain range to a directory

Parameters:
dir - The directory where the xml files and the files belonging to the derivates will be saved
minID - The lowest derivate ID that should be saved
maxID - The highest derivate ID that should be saved
Throws:
Exception

backupToDirectory

public static void backupToDirectory(int minID,
                                     int maxID,
                                     String dir)
                              throws Exception
Backups metadata of all derivates with IDs in a certain range to a directory

Parameters:
dir - The directory where the xml files will be saved
minID - The lowest derivate ID that should be saved
maxID - The highest derivate ID that should be saved
Throws:
Exception

saveAllToDirectory

public static void saveAllToDirectory(String dir)
                               throws Exception
Saves all derivates and their files to a directory

Parameters:
dir - The path of the directory where the XML files and the derivate content files should be saved
Throws:
Exception

backupAllToDirectory

public static void backupAllToDirectory(String dir)
                                 throws Exception
Backups metadata of all derivates and their files to a directory

Parameters:
dir - The path of the directory where the XML files should be saved
Throws:
Exception

moveFileContent

public static void moveFileContent(int minID,
                                   int maxID,
                                   String fromStore,
                                   String toStore,
                                   String tempDir)
                            throws Exception
Moves the content of all derivates with IDs between minID and maxID from the content store with ID fromStore to the content store with ID toStore, using the local directory tempDir as working directory for temporary file storage.

Throws:
Exception

setImportMode

public static void setImportMode(String mode)
Sets DerivateManager import mode. When import mode is set to true, date modified of document is not changed when any of its derivates changes. This is useful for re-importing a derivate and its files.


repairContentIndex

public static void repairContentIndex()
                               throws Exception
Repairs search index of derivate files

Throws:
Exception