com.pixelmed.dicom
Class StoredFilePathStrategy

java.lang.Object
  extended by com.pixelmed.dicom.StoredFilePathStrategy
Direct Known Subclasses:
ReceivedFilePathStrategy, StoredFilePathStrategyComponentFolders, StoredFilePathStrategyHashSubFolders, StoredFilePathStrategySingleFolder

public abstract class StoredFilePathStrategy
extends Object

This is an abstract class to support creating path names for how to organize the folders and files for stored composite instances based on their SOP Instance UID.

Concrete subclasses implement various different strategies, which may be instantiated themselves, or accessed by the enumerated fields in this class.

The choices may be passed as arguments to constructors of StorageSOPClassSCPDispatcher.

Methods are provided to generate pathnames based on the supplied UID, as well as to create any sub-folders required and generate altrernative path names if the existing path name is alreayd in use for some other purpose.


Field Summary
static StoredFilePathStrategy BYSOPINSTANCEUIDCOMPONENTFOLDERS
          Store all the stored files in a hierarchy of folders using successive numeric components of the SOP Instance UID as the folder name and the SOP Instance UID as the filename within the most deeply nested folder.
static StoredFilePathStrategy BYSOPINSTANCEUIDHASHSUBFOLDERS
          Store all the stored files in a hierarchy of folders using successive decimal digits of the hashcode of the SOP Instance UID as the folder name and the SOP Instance UID as the filename within the most deeply nested folder.
static StoredFilePathStrategy BYSOPINSTANCEUIDINSINGLEFOLDER
          Store all the stored files in a single folder, using the SOP Instance UID as the filename.
protected  int debugLevel
           
protected static String defaultAlternativeSubfolder
           
 
Constructor Summary
protected StoredFilePathStrategy()
           
 
Method Summary
static StoredFilePathStrategy getDefaultStrategy()
          Get the default strategy.
 File makeAlternativeStoredFilePath(File savedInstancesFolder, String alternativeSubfolder, String sopInstanceUID)
          Generate an alternative path to where to store a file based on its SOP Instance UID.
 File makeReliableStoredFilePathWithFoldersCreated(File savedInstancesFolder, String sopInstanceUID)
          Generate a path to where to store a file based on its SOP Instance UID and assure its reliability.
 File makeReliableStoredFilePathWithFoldersCreated(File savedInstancesFolder, String alternativeSubfolder, String sopInstanceUID)
          Generate a path to where to store a file based on its SOP Instance UID and assure its reliability.
 File makeStoredFilePath(File savedInstancesFolder, String sopInstanceUID)
          Generate a path to where to store a file based on its SOP Instance UID.
 String makeStoredFilePath(String sopInstanceUID)
          Generate a path to where to store a file based on its SOP Instance UID.
 void setDebugLevel(int debugLevel)
           
protected  void test(String[] arg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BYSOPINSTANCEUIDINSINGLEFOLDER

public static final StoredFilePathStrategy BYSOPINSTANCEUIDINSINGLEFOLDER

Store all the stored files in a single folder, using the SOP Instance UID as the filename.

See Also:
StoredFilePathStrategySingleFolder

BYSOPINSTANCEUIDCOMPONENTFOLDERS

public static final StoredFilePathStrategy BYSOPINSTANCEUIDCOMPONENTFOLDERS

Store all the stored files in a hierarchy of folders using successive numeric components of the SOP Instance UID as the folder name and the SOP Instance UID as the filename within the most deeply nested folder.

See Also:
StoredFilePathStrategyComponentFolders

BYSOPINSTANCEUIDHASHSUBFOLDERS

public static final StoredFilePathStrategy BYSOPINSTANCEUIDHASHSUBFOLDERS

Store all the stored files in a hierarchy of folders using successive decimal digits of the hashcode of the SOP Instance UID as the folder name and the SOP Instance UID as the filename within the most deeply nested folder.

See Also:
StoredFilePathStrategyHashSubFolders

defaultAlternativeSubfolder

protected static String defaultAlternativeSubfolder

debugLevel

protected int debugLevel
Constructor Detail

StoredFilePathStrategy

protected StoredFilePathStrategy()
Method Detail

getDefaultStrategy

public static final StoredFilePathStrategy getDefaultStrategy()

Get the default strategy.

Returns:
the default strategy (which is BYSOPINSTANCEUIDINSINGLEFOLDER)

makeStoredFilePath

public String makeStoredFilePath(String sopInstanceUID)

Generate a path to where to store a file based on its SOP Instance UID.

Parameters:
sopInstanceUID - the SOP Instance UID of the instance to be saved
Returns:
the path to the file, which may contain nested sub-folders

makeStoredFilePath

public File makeStoredFilePath(File savedInstancesFolder,
                               String sopInstanceUID)

Generate a path to where to store a file based on its SOP Instance UID.

Parameters:
savedInstancesFolder - the folder in which to save the instance
sopInstanceUID - the SOP Instance UID of the instance to be saved
Returns:
the path to the file in the specified folder, which may contain nested sub-folders

makeAlternativeStoredFilePath

public File makeAlternativeStoredFilePath(File savedInstancesFolder,
                                          String alternativeSubfolder,
                                          String sopInstanceUID)

Generate an alternative path to where to store a file based on its SOP Instance UID.

Use when the normal path is already occupied by something other than a file (such as a folder).

Parameters:
savedInstancesFolder - the folder in which to save the instance
alternativeSubfolder - the alternate sub-folder with the saved instance folder in which to save the instance
sopInstanceUID - the SOP Instance UID of the instance to be saved
Returns:
the path to the file in the specified folder and alternate sub-folder

makeReliableStoredFilePathWithFoldersCreated

public File makeReliableStoredFilePathWithFoldersCreated(File savedInstancesFolder,
                                                         String alternativeSubfolder,
                                                         String sopInstanceUID)

Generate a path to where to store a file based on its SOP Instance UID and assure its reliability.

Includes creating any necessary parent folders if they do not already exist, and using an alternate path or name if a desired file name already exists as something else (such as a folder).

Parameters:
savedInstancesFolder - the folder in which to save the instance
alternativeSubfolder - the alternate sub-folder with the saved instance folder in which to save the instance
sopInstanceUID - the SOP Instance UID of the instance to be saved
Returns:
the path to the file in the specified folder, which may contain nested sub-folders

makeReliableStoredFilePathWithFoldersCreated

public File makeReliableStoredFilePathWithFoldersCreated(File savedInstancesFolder,
                                                         String sopInstanceUID)

Generate a path to where to store a file based on its SOP Instance UID and assure its reliability.

Includes creating any necessary parent folders if they do not already exist, and using an alternate path or name (in a default alternative sub-folder) if a desired file name already exists as something else (such as a folder).

Parameters:
savedInstancesFolder - the folder in which to save the instance
sopInstanceUID - the SOP Instance UID of the instance to be saved
Returns:
the path to the file in the specified folder, which may contain nested sub-folders

setDebugLevel

public void setDebugLevel(int debugLevel)

test

protected void test(String[] arg)