Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.flexstor.common.gui.imprt
Class ImportModel  view ImportModel download ImportModel.java

java.lang.Object
  extended byjava.util.Observable
      extended bycom.flexstor.common.gui.imprt.AbstractImportModel
          extended bycom.flexstor.common.gui.imprt.ImportModel
All Implemented Interfaces:
ImportModelI, java.util.Observer

public class ImportModel
extends AbstractImportModel

Data model for Import.


Field Summary
private  java.lang.String appServerHost
          The app server host name.
private  java.lang.String appServerHostTmpDir
          App server host temp directory.
private  java.lang.String appServerRemoteProtocol
          App server remote file protocol
private  boolean bFromRetrieval
          Flag that indicates whether import is done from the main tool bar or from the search retrieval.
private  boolean bImportImmediately
          Flag to indicate whether import is to be done immediately or to be queued.
private  com.flexstor.common.modules.registry.BaseInstanceI currentAsset
          Current base instance object.
private  com.flexstor.common.disguise.DisplayUtils dUtils
          Disguise utility class.
private  java.lang.String IMPORT_GUI_PATH
          The path for the import_gui directory.
private  java.util.Date queueDate
          Flag to indicate whether import is to be done immediately or to be queued.
private  java.lang.String SERVICE_NAME
          Name of the service to be called for the import.
private  java.lang.String sStatus
          Import status.
private  com.flexstor.common.awt.taskframe.TaskFrame tfStatus
          Status frame
private  int transactionNumber
          The unique transaction number for this import session.
 
Fields inherited from class com.flexstor.common.gui.imprt.AbstractImportModel
fileToBeImported, importSettings, manager
 
Fields inherited from class java.util.Observable
 
Constructor Summary
ImportModel(com.flexstor.common.settings.ImportSettingManagerI manager)
          Constructor, which is called when the Import frame is brought up from the main tool bar.
ImportModel(com.flexstor.common.settings.ImportSettingManagerI manager, com.flexstor.common.modules.registry.BaseInstanceI baseInstance)
          Constructor that is called when the Import frame is brought from the search retrieval frame.
ImportModel(com.flexstor.common.settings.ImportSettingManagerI mgr, com.flexstor.common.settings.ImportSettingsI setting)
          Constructor.
ImportModel(com.flexstor.common.settings.ImportSettingManagerI mgr, com.flexstor.common.settings.ImportSettingsI setting, com.flexstor.common.modules.registry.BaseInstanceI baseInstance)
          Constructor.
 
Method Summary
 void attachObserver(java.lang.Object object)
          Attaches an observer.
 boolean canPerform()
          Check if Import can be performed.
private  boolean deleteFile(java.lang.String file)
          Deletes a file specified by the complete path.
 void detachObserver(java.lang.Object object)
          Detaches an observer
private  boolean dirHasSufficientPermission()
          Checks if the import_gui directory have sufficient access permissions.
private  void displayError(java.lang.String message, int transID)
          Displays the error occured.
 void dispose()
          Disposes the task frame shown while import immediately.
private  void doImport()
           
 com.flexstor.common.modules.registry.BaseInstanceI getCurrentAsset()
          Returns the base instance object.
private  java.lang.String getCurrentDisguiseName()
          Returns the name of the current disguise name user is importing into.
private  com.flexstor.common.data.TraversalItem getElementInfoItem(int disguiseId, int structurID, int elementRecordID)
          Function, that depending on the type of the base instance, creates and returns traversalinfoitem data object.
private  java.lang.String getFileName(java.lang.String path)
          Returns the name of the file out of the file path.
private  long getFileSize(java.lang.String f)
          Returns the size of the file.
 java.lang.String getStatus()
          Returns the Import status.
 void importFiles()
          Function that actually imports the assets.
 boolean initialize()
          Initializes the model.
 boolean isChanged()
          Checks is the model has changed.
 boolean isDefaultImportSetting()
          Checks if import process can proceed.
private  boolean isEnoughDiskSpace(long fileSize)
          Checks if there is enough disk space.
 boolean isFromRetrieval()
          Checks if the Import is supposed to be done from the retrieval search frame.
private  boolean isLocalFile(java.lang.String fileName)
          Checks if the path represents an local file.
private  boolean isValidDisguise()
          Checks if the disguise in the control is valid.
 boolean loadSystemDefaultImportSetting()
          Loads the systems own default import setting in case the user does not have his\her own default import setting Or the user's own default Import setting could not be loaded.
 boolean loadUserDefaultImportSetting()
          Loads the user's own default import setting.
private  void logError(java.lang.String message, int transID)
          Log the error.
private  java.lang.String makePathClientProtocolCompatible(java.lang.String path)
          Changes the file path to NFS path.
 void notifyAllObservers()
          Notifies all the observers.
 void notifyAllObservers(java.lang.Object object)
          Notifies all the observers with a notifying object.
private  void performInitialValidations()
          Performs the initial validations before starting the actual Import process.
private  boolean properInstall()
          Checks is the installtion is proper for the import from the GUI.
 boolean reloadCurrentImportSetting()
          Reloads current import setting.
private  void setImportStatus(java.lang.String status)
          Sets the Import process status.
private  void showMessage(java.lang.String msg)
          Shows message on the status frame.
 void update(java.util.Observable obs, java.lang.Object obj)
          Implementation of Observer interface.
 
Methods inherited from class com.flexstor.common.gui.imprt.AbstractImportModel
canPerform, enabledInput, getCurrentImportSetting, getDisguiseId, getFilesToBeImported, getPersistManager, getStructureId, getUniqueAssetIDs, getUniqueBucketID, getUniqueElementBucketIDs, getUniqueRecordIDs, getUniqueTransactionID, setBoxChecked, setCurrentImportSetting, setFilesToBeImported, setPersistManager
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.flexstor.common.gui.imprt.ImportModelI
addObserver, deleteObserver
 

Field Detail

appServerHost

private java.lang.String appServerHost
The app server host name.


appServerHostTmpDir

private java.lang.String appServerHostTmpDir
App server host temp directory.


sStatus

private java.lang.String sStatus
Import status.


transactionNumber

private int transactionNumber
The unique transaction number for this import session. All the loggings are done in respect if this number.


currentAsset

private com.flexstor.common.modules.registry.BaseInstanceI currentAsset
Current base instance object. Represents the tree node where import is to be done. It is null when the Import is done from the main tool bar.


bFromRetrieval

private boolean bFromRetrieval
Flag that indicates whether import is done from the main tool bar or from the search retrieval.


IMPORT_GUI_PATH

private java.lang.String IMPORT_GUI_PATH
The path for the import_gui directory.


SERVICE_NAME

private java.lang.String SERVICE_NAME
Name of the service to be called for the import.


dUtils

private com.flexstor.common.disguise.DisplayUtils dUtils
Disguise utility class.


tfStatus

private com.flexstor.common.awt.taskframe.TaskFrame tfStatus
Status frame


bImportImmediately

private boolean bImportImmediately
Flag to indicate whether import is to be done immediately or to be queued.


queueDate

private java.util.Date queueDate
Flag to indicate whether import is to be done immediately or to be queued.


appServerRemoteProtocol

private java.lang.String appServerRemoteProtocol
App server remote file protocol

Constructor Detail

ImportModel

public ImportModel(com.flexstor.common.settings.ImportSettingManagerI manager)
Constructor, which is called when the Import frame is brought up from the main tool bar.


ImportModel

public ImportModel(com.flexstor.common.settings.ImportSettingManagerI manager,
                   com.flexstor.common.modules.registry.BaseInstanceI baseInstance)
Constructor that is called when the Import frame is brought from the search retrieval frame.


ImportModel

public ImportModel(com.flexstor.common.settings.ImportSettingManagerI mgr,
                   com.flexstor.common.settings.ImportSettingsI setting)
Constructor.


ImportModel

public ImportModel(com.flexstor.common.settings.ImportSettingManagerI mgr,
                   com.flexstor.common.settings.ImportSettingsI setting,
                   com.flexstor.common.modules.registry.BaseInstanceI baseInstance)
Constructor.

Method Detail

getCurrentAsset

public com.flexstor.common.modules.registry.BaseInstanceI getCurrentAsset()
Returns the base instance object. It represents the node of the tree on the search retrieval frame. From the Import stand point it can represent a normal bucket or an element.

Since:
3.0

initialize

public boolean initialize()
Initializes the model. And checks if the installtion and configuration meets the basic requirements to do a Import. It includes : 1. There should be an import/upload subdirectory inside installation\conf. 2. It should have proper read/write/execute permissions.

Since:
3.0

loadUserDefaultImportSetting

public boolean loadUserDefaultImportSetting()
Loads the user's own default import setting.


loadSystemDefaultImportSetting

public boolean loadSystemDefaultImportSetting()
Loads the systems own default import setting in case the user does not have his\her own default import setting Or the user's own default Import setting could not be loaded.


reloadCurrentImportSetting

public boolean reloadCurrentImportSetting()
Reloads current import setting.


canPerform

public boolean canPerform()
Check if Import can be performed.


importFiles

public void importFiles()
Function that actually imports the assets. Note that we DO NOT allow import using the system default import setting (known by the name 'default'), therefore it first checks if the user has selected some other import setting Or created one of his\her own. Then starts the process of creation of the ActionData object. Depending whether it is called from the search retrieval frame or from the main tool bar, traversal path is created for each asset record (representing files to be imported), these asset record data objects are then added to the ActionData, and appropriate service is called. Status frame is shown to let the user know about import process step by step.

Since:
3.0

attachObserver

public void attachObserver(java.lang.Object object)
Attaches an observer.

Since:
3.0

detachObserver

public void detachObserver(java.lang.Object object)
Detaches an observer

Since:
3.0

notifyAllObservers

public void notifyAllObservers()
Notifies all the observers.

Overrides:
notifyAllObservers in class AbstractImportModel
Since:
3.0

notifyAllObservers

public void notifyAllObservers(java.lang.Object object)
Notifies all the observers with a notifying object.

Since:
3.0

update

public void update(java.util.Observable obs,
                   java.lang.Object obj)
Implementation of Observer interface.


isChanged

public boolean isChanged()
Checks is the model has changed.

Since:
3.0

isFromRetrieval

public boolean isFromRetrieval()
Checks if the Import is supposed to be done from the retrieval search frame.

Since:
3.0

isDefaultImportSetting

public boolean isDefaultImportSetting()
Checks if import process can proceed. It fails if an attempt is done to import assets using the default import setting.

Since:
3.0

isValidDisguise

private boolean isValidDisguise()
Checks if the disguise in the control is valid. If its from retrieval it can be a SYSTEM or STANDARD but if its from main tool bar it should be SYSTEM only. And as the same control file can be used for both, its possible that the user does not go to settings dialog to change the disguise.

Since:
3.0

properInstall

private boolean properInstall()
Checks is the installtion is proper for the import from the GUI. It fails if the .. 1. Either there is no //installtion/conf/import/upload/ subdirectory. 2. Ot the directory exists but does not have proper access permissions.


dirHasSufficientPermission

private boolean dirHasSufficientPermission()
Checks if the import_gui directory have sufficient access permissions.


makePathClientProtocolCompatible

private java.lang.String makePathClientProtocolCompatible(java.lang.String path)
Changes the file path to NFS path.


isLocalFile

private boolean isLocalFile(java.lang.String fileName)
Checks if the path represents an local file.


getFileSize

private long getFileSize(java.lang.String f)
Returns the size of the file.


isEnoughDiskSpace

private boolean isEnoughDiskSpace(long fileSize)
Checks if there is enough disk space. This function is called when local files are imported. These files are supposed to be copied from the local disk to a temperary direcroty on app server host. This function checks the space on the App server host. It called disk space service to accomplish the task.


getFileName

private java.lang.String getFileName(java.lang.String path)
Returns the name of the file out of the file path.


deleteFile

private boolean deleteFile(java.lang.String file)
Deletes a file specified by the complete path.


getStatus

public java.lang.String getStatus()
Returns the Import status.


dispose

public void dispose()
Disposes the task frame shown while import immediately.


setImportStatus

private void setImportStatus(java.lang.String status)
Sets the Import process status.


showMessage

private void showMessage(java.lang.String msg)
Shows message on the status frame.


displayError

private void displayError(java.lang.String message,
                          int transID)
Displays the error occured.


logError

private void logError(java.lang.String message,
                      int transID)
Log the error.


getCurrentDisguiseName

private java.lang.String getCurrentDisguiseName()
Returns the name of the current disguise name user is importing into.


getElementInfoItem

private com.flexstor.common.data.TraversalItem getElementInfoItem(int disguiseId,
                                                                  int structurID,
                                                                  int elementRecordID)
Function, that depending on the type of the base instance, creates and returns traversalinfoitem data object.


doImport

private void doImport()

performInitialValidations

private void performInitialValidations()
                                throws com.flexstor.common.exceptions.ImportFailedException
Performs the initial validations before starting the actual Import process. Like if the import settin is default, if the current asset (if from retrieval) is null or the disguise in the CTL file is not a valid one.