org.bibalex.daf.managers.archive
Class CommandLineArchiver

java.lang.Object
  extended by org.bibalex.daf.managers.archive.CommandLineArchiver

public class CommandLineArchiver
extends java.lang.Object

This class archive jobs using command line not GUI

Author:
Mohammed.Abuouda

Field Summary
private  FileHandlerFTPImpl backupFileHandler
          backupFileHandler is ftp file handler to download folders from backup server to the local machine
private  java.lang.String backupServerIP
          backupServerIP represents the backup server IP that holds the backed up folders
private  java.lang.String backupServerPassword
          backupServerPassword represents the backup server Password
private  java.lang.String backupServerPath
          backupServerPath represents the path that contains the backed up folders
private  java.lang.String backupServerUser
          backupServerUser represents the backup server User Name
(package private)  DBConnection conn
           
(package private)  java.lang.String destFolder
          destFolder to move jobs in, it's located under working directory of WS to working user
private  FileHandlerLocalImpl localFileHandler
          localFileHandler is a local file handler to create and delete media folder
(package private)  float mediaSize
           
(package private)  int MTID
           
(package private)  java.lang.String newMediaBarCode
           
(package private)  int newMediaID
           
private  ResourceManager resourceManager
          resourceManager handles working with resource fiel
 
Constructor Summary
CommandLineArchiver()
          class constrictor
 
Method Summary
private  boolean checkSelectedJobs(java.util.ArrayList TL_IDList, int mediaType)
          This method checks the validity of recording all the checked jobs in the archive list to DB
private  boolean confirmDeletion(int MTID, int mediaID)
          This method confrim media deletion on DB
private  boolean createLocalFolder()
          This method creates local folder on working user on working WS
private  java.util.ArrayList createMedia()
          this method creates new instance of media type
private  boolean deleteMediaFolder(java.lang.String mediaPath, int MTID, int mediaID)
          This method checks if media folder has folder orr empty.
private  void getBackupServerInformation()
          getBackupServerInformation reads backup server credentials
 boolean getJobs(int mediaType, java.lang.String jobCount)
          This method carries out downloading jobs in user working directory
private  java.lang.String getPath(java.lang.String mediaBarcode, int jobID, int version)
          This method forms job's full path
private  boolean mediaRollBack(int MTID, int mediaID)
          rolls back media instance
private  java.lang.String paddingString(java.lang.String s, int n, char c, boolean paddingLeft)
          pad a string S with a size of N with char C on the left (True) or on the right(flase)
private  boolean publishMedia(int mediaID, java.lang.String mediaBarcodePath, int jobID, java.lang.String version)
          This method confirm media and publish the archiving data to DAK
 boolean recordJobs(java.lang.String mediaBarcode, int jobID, int version)
          This method gets all jobs in specified fodler and record them in DB as archived
private  boolean recordJobsToDB(java.util.ArrayList TL_IDList, int mediaType, int mediaID)
           
private  boolean validateWS()
          This methos checks if current WS can archive or not
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

conn

DBConnection conn

MTID

int MTID

newMediaID

int newMediaID

mediaSize

float mediaSize

newMediaBarCode

java.lang.String newMediaBarCode

localFileHandler

private FileHandlerLocalImpl localFileHandler
localFileHandler is a local file handler to create and delete media folder


backupFileHandler

private FileHandlerFTPImpl backupFileHandler
backupFileHandler is ftp file handler to download folders from backup server to the local machine


resourceManager

private ResourceManager resourceManager
resourceManager handles working with resource fiel


backupServerIP

private java.lang.String backupServerIP
backupServerIP represents the backup server IP that holds the backed up folders


backupServerUser

private java.lang.String backupServerUser
backupServerUser represents the backup server User Name


backupServerPassword

private java.lang.String backupServerPassword
backupServerPassword represents the backup server Password


backupServerPath

private java.lang.String backupServerPath
backupServerPath represents the path that contains the backed up folders


destFolder

java.lang.String destFolder
destFolder to move jobs in, it's located under working directory of WS to working user

Constructor Detail

CommandLineArchiver

public CommandLineArchiver()
class constrictor

Method Detail

getJobs

public boolean getJobs(int mediaType,
                       java.lang.String jobCount)
This method carries out downloading jobs in user working directory

Parameters:
mediaType - the media type to collect jobs based on
jobCount - the jobs number to be retrieved
Returns:
1 on success,0 on failure

recordJobs

public boolean recordJobs(java.lang.String mediaBarcode,
                          int jobID,
                          int version)
This method gets all jobs in specified fodler and record them in DB as archived

Parameters:
mediaBarcode - media barcode
jobID - the job to be recorded
version - the job version
Returns:
true on success, false otherwise

getPath

private java.lang.String getPath(java.lang.String mediaBarcode,
                                 int jobID,
                                 int version)
This method forms job's full path

Parameters:
jobID - the job to get its folder
version - job's version
Returns:
full path

validateWS

private boolean validateWS()
This methos checks if current WS can archive or not

Parameters:
MTID - the media type to validate WS on
Returns:
true if valid, false otherwise

createMedia

private java.util.ArrayList createMedia()
this method creates new instance of media type

Parameters:
MTID - the media type to create new instance of
Returns:
ArrayList of new media ID, new Media Barcode and media size

mediaRollBack

private boolean mediaRollBack(int MTID,
                              int mediaID)
rolls back media instance

Parameters:
MTID - the media type
mediaID - the media to be rolled back
Returns:
true ion success, false otherwise

createLocalFolder

private boolean createLocalFolder()
This method creates local folder on working user on working WS

Returns:
ture on success, false otherwise

getBackupServerInformation

private void getBackupServerInformation()
                                 throws java.lang.Exception
getBackupServerInformation reads backup server credentials

Throws:
java.lang.Exception

publishMedia

private boolean publishMedia(int mediaID,
                             java.lang.String mediaBarcodePath,
                             int jobID,
                             java.lang.String version)
This method confirm media and publish the archiving data to DAK

Parameters:
mediaID - media to be published
mediaType - media type
mediaBarcodePath - physical folder of media
jobID - job to be published
version - job's version
Returns:
true on success, false otherwise

paddingString

private java.lang.String paddingString(java.lang.String s,
                                       int n,
                                       char c,
                                       boolean paddingLeft)
pad a string S with a size of N with char C on the left (True) or on the right(flase)


deleteMediaFolder

private boolean deleteMediaFolder(java.lang.String mediaPath,
                                  int MTID,
                                  int mediaID)
This method checks if media folder has folder orr empty. when folder is empty then it must deleted

Parameters:
mediaPath - the media folder path
Returns:
true on success, false otherwise

confirmDeletion

private boolean confirmDeletion(int MTID,
                                int mediaID)
This method confrim media deletion on DB

Parameters:
MTID -
mediaID - media to be confirmed
Returns:
true on success, false otherwise

checkSelectedJobs

private boolean checkSelectedJobs(java.util.ArrayList TL_IDList,
                                  int mediaType)
This method checks the validity of recording all the checked jobs in the archive list to DB

Parameters:
readyToArchiveCheckList - The list of the checked jobs to be archived
mediaType - The type of media to archive jobs to
mediaID - The newly generated mediaID to use for archiving
Returns:
true if all the checked versions can be recorded to database with the given media, false if any of these versions has been recorded befor with this media type

recordJobsToDB

private boolean recordJobsToDB(java.util.ArrayList TL_IDList,
                               int mediaType,
                               int mediaID)