org.mycore.backend.videocharger
Class MCRCStoreVideoCharger

java.lang.Object
  extended by org.mycore.datamodel.ifs.MCRContentStore
      extended by org.mycore.backend.videocharger.MCRCStoreVideoCharger

public class MCRCStoreVideoCharger
extends MCRContentStore

This class implements the MCRContentStore interface to store the content of MCRFile objects in IBM VideoCharger Server. This allows the content to be streamed. This implementation uses FTP to manage the files in VideoCharger. The FTP connection parameters are configured in mycore.properties: MCR.IFS.ContentStore..Hostname Hostname of VideoCharger Server MCR.IFS.ContentStore..FTPPort Port of VideoCharger FTP interface, default is 4324 MCR.IFS.ContentStore..UserID User ID for FTP connections, e. g. vsloader MCR.IFS.ContentStore..Password Password for this user MCR.IFS.ContentStore..DebugFTP If true, FTP debug messages are written to stdout, default is false MCR.IFS.ContentStore..AssetGroup Asset group, default is 'AG' This class also provides a method to backup all assets stored in VideoCharger to a directory.

Version:
$Revision: 13085 $ $Date: 2008-02-06 18:27:24 +0100 (Mi, 06 Feb 2008) $
Author:
Frank Lützenkirchen
See Also:
MCRAVExtVideoCharger

Field Summary
protected  String assetGroup
          Asset group
protected  boolean debugFTP
          If true, FTP debug messages are written to stdout
protected  String host
          Hostname of VideoCharger server
protected static String[] ok
          FTP Return code if "quote site avs attr" is successful
protected  String password
          Password for FTP login
protected  int port
          Port of VideoCharger server FTP interface
protected  String user
          User ID for FTP login
 
Fields inherited from class org.mycore.datamodel.ifs.MCRContentStore
formatter, lastTimestamp, prefix, slotDirDepth, storeID
 
Constructor Summary
MCRCStoreVideoCharger()
           
 
Method Summary
static void backupContentTo(String storeID, String directory)
          Reads all assets stored in VideoCharger server and writes the contents to a directory for backup.
protected  com.enterprisedt.net.ftp.FTPClient connect()
          Connects to IBM VideoCharger Server via FTP
protected  void disconnect(com.enterprisedt.net.ftp.FTPClient connection)
          Closes the FTP connection to VideoCharger server
protected  void doDeleteContent(String storageID)
          Deletes the content of an MCRFile object that is stored under the given Storage ID in this store instance.
protected  InputStream doRetrieveContent(MCRFileReader file)
          Retrieves the content of an MCRFile.
protected  void doRetrieveContent(MCRFileReader file, OutputStream target)
          Retrieves the content of an MCRFile to an OutputStream.
protected  String doStoreContent(MCRFileReader file, MCRContentInputStream source)
          Stores the content of an MCRFile by reading from an MCRContentInputStream.
 void init(String storeID)
          Initializes the store and sets its unique store ID.
protected  void retrieveContent(String assetID, OutputStream target)
           
 
Methods inherited from class org.mycore.datamodel.ifs.MCRContentStore
buildNextID, buildNextTimestamp, buildSlotPath, deleteContent, getID, retrieveContent, retrieveContent, storeContent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

host

protected String host
Hostname of VideoCharger server


port

protected int port
Port of VideoCharger server FTP interface


user

protected String user
User ID for FTP login


password

protected String password
Password for FTP login


debugFTP

protected boolean debugFTP
If true, FTP debug messages are written to stdout


assetGroup

protected String assetGroup
Asset group


ok

protected static final String[] ok
FTP Return code if "quote site avs attr" is successful

Constructor Detail

MCRCStoreVideoCharger

public MCRCStoreVideoCharger()
Method Detail

init

public void init(String storeID)
Description copied from class: MCRContentStore
Initializes the store and sets its unique store ID. MCRFiles must remember this ID to indentify the store that holds their file content. The store ID is set by MCRContentStoreFactory when a new store instance is built. Subclasses should override this method.

Overrides:
init in class MCRContentStore
Parameters:
storeID - the non-null unique store ID for this store instance

doStoreContent

protected String doStoreContent(MCRFileReader file,
                                MCRContentInputStream source)
                         throws Exception
Description copied from class: MCRContentStore
Stores the content of an MCRFile by reading from an MCRContentInputStream. Returns a StorageID to indentify the place where the content was stored.

Specified by:
doStoreContent in class MCRContentStore
Parameters:
file - the MCRFile thats content is to be stored
source - the ContentInputStream where the file content is read from
Returns:
an ID that indentifies the place where the content was stored
Throws:
Exception

doDeleteContent

protected void doDeleteContent(String storageID)
                        throws Exception
Description copied from class: MCRContentStore
Deletes the content of an MCRFile object that is stored under the given Storage ID in this store instance.

Specified by:
doDeleteContent in class MCRContentStore
Parameters:
storageID - the storage ID of the MCRFile object
Throws:
Exception

doRetrieveContent

protected void doRetrieveContent(MCRFileReader file,
                                 OutputStream target)
                          throws Exception
Description copied from class: MCRContentStore
Retrieves the content of an MCRFile to an OutputStream. Uses the StorageID to indentify the place where the file content was stored in this store instance.

Specified by:
doRetrieveContent in class MCRContentStore
Parameters:
file - the MCRFile thats content should be retrieved
target - the OutputStream to write the file content to
Throws:
Exception

doRetrieveContent

protected InputStream doRetrieveContent(MCRFileReader file)
                                 throws Exception
Description copied from class: MCRContentStore
Retrieves the content of an MCRFile. Uses the StorageID to indentify the place where the file content was stored in this store instance.

Specified by:
doRetrieveContent in class MCRContentStore
Parameters:
file - the MCRFile thats content should be retrieved
Throws:
Exception

retrieveContent

protected void retrieveContent(String assetID,
                               OutputStream target)
                        throws Exception
Throws:
Exception

backupContentTo

public static void backupContentTo(String storeID,
                                   String directory)
                            throws MCRPersistenceException,
                                   Exception
Reads all assets stored in VideoCharger server and writes the contents to a directory for backup. If the directory already contains an asset with the same name, that assets is skipped and not backed up.

Parameters:
storeID - the store ID fo the VideoCharger store to be backed up
directory - the local directory to write the assets to
Throws:
MCRPersistenceException
Exception

connect

protected com.enterprisedt.net.ftp.FTPClient connect()
                                              throws MCRPersistenceException
Connects to IBM VideoCharger Server via FTP

Throws:
MCRPersistenceException

disconnect

protected void disconnect(com.enterprisedt.net.ftp.FTPClient connection)
Closes the FTP connection to VideoCharger server

Parameters:
connection - the FTP connection to close