The CTP FileStorageService Web Server

From MircWiki
Revision as of 20:29, 11 June 2008 by Johnperry (talk | contribs)
Jump to navigation Jump to search

This article describes the web server which is included in the CTP FileStorageService. The primary intended audience for this article is programmers who wish to write applications to access stored objects, but the article may also be useful for CTP administrators. A prerequisite for fully understanding this article is MIRC Clinical Trial Processor.

1 The FileStorageService

The FileStorageService is a CTP pipeline stage which stores objects in a file storage device. Files are stored in a hierarchy of directories, grouping objects by study. An object is associated with a study by its study UID.

As described indescribed in MIRC Clinical Trial Processor, CTP manages four types of objects:

  • DicomObject
  • XmlObject
  • ZipObject
  • FileObject

The first three contain unique identifiers for the study and for the object itself. The FileObject, which contains data of unknown format, cannot provide either a study UID or an object UID, so the FileStorageService assigns a FileObject to a study called "__bullpen" and assigns a unique filename to the object, which is used as its object UID.

The type attribute of the FileStorageService determines the directory structure above the study directories.

  • At the top, there may be one or more directories which are called FileSystems. Objects (and their studies) are assigned to a FileSystem based on the fs-name-tag attribute. If the fs-name-tag attribute is supplied in the configuration, a DicomObject is interrogated for the contents of the corresponding element and the contents are used as the name of the FileSystem. If no fs-name-tag is supplied in the configuration, the FileStorageService assigns all objects to the "__default" FileSystem.
  • If the type attribute is supplied in the configuration, studies are divided among intermediate directories based on the date on which the study was received:
    • type="year" creates one level of directories based on the year.
    • type="month" creates one level of directories based on the year, and within each year, a level based on the month within the year.
    • type="week" creates one level of directories based on the year, and within each year, a level based on the week number within the year.

The purpose of the type attribute is to allow FileStorageServices to handle a large number of objects without any directory growing too large for the operating system to handle efficiently.

2 The FileStorageService Web Server

The port attribute, when present in the configuration element of the FileStorageService, starts a web server. This web server is independent of the one which CTP always provides to allow the operation of the system to be monitored.

The root directory of the web server is the same as the root directory of the FileStorageService. The web server can serve files from any directory in the tree. Since the directory structure, as defined by the type parameter, is transparent to the user, the web server provides two servlets which navigate the indexes of the FileSystems and studies to provide access to objects more conveniently.

  • The Storage Servlet is primarily intended to provide users a way to navigate the stored objects with a browser.
  • The Ajax Servlet is primarily intended to provide programmatic access to the data in the indexes.

The next sections describe the URLs which are recognized by these servlets.

A brief aside: It is important to remember that when a URL path invokes a servlet, the path is not necessarily a file path on the web server. The servlets use the URL path elements as pointers into indexes at each level in the hierarchy, filling in intermediate levels from configuration information when required. This makes URL paths shorter and absolves the user or programmer from having to know about the internals of the storage hierarchy.

3 The Storage Servlet

The Storage Servlet is invoked when the first path element in the URL is "storage". The servlet only provides an HTTP GET method.

The path "/storage" returns an HTML page listing all the FileSystems. If there is only one file system, this URL acts as if the path were "/storage/{FileSystemName}".

The path "/storage/{FileSystemName}" returns an HTML page listing all the studies in the identified FileSystem. The page contains two links for each study, one which lists the objects in the study and one which displays the DicomObjects in the study with a simple viewer.

The path "/storage/{FileSystemName}/{StudyName}" returns an HTML page listing all the objects in the identified study. The servlet recognizes a query string with two values:

  • If the query string "?format=list" is supplied, the returned HTML page is an object listing.
  • If the query string "?format=display" is supplied, the returned HTML page is a simple viewer.
  • If no query string is supplied, the listing is returned.

The object listing contains a line for each object in the study. Depending on the object type, one or more links are provided.

  • The link identifying the file name allows the object's file to be downloaded.
  • For DicomObjects, the "List" link returns an HTML page containing a listing of all the elements in the object except the pixels themselves.
  • For DicomObjects which are images, the "Display" link returns a JPEG version of the image.

The path "/storage/{FileSystemName}/{StudyName}/{FileName}" returns the identified file inany of the formats identified above:

  • With no query string, the object's file is returned.
  • With the query string "?format=list", a DicomObject returns an element listing; other object types return the file.
  • With the query string "format=jpeg", a DicomObject which is an image returns a JPEG version of the image; other object types return the file.

A note on the StudyName path element: While DICOM UIDs are valid URL path elements, the same cannot be said for UIDs obtained from XmlObjects or ZipObjects. Before using a study UID, the FileStorageService filters it to ensure that it can be used as a valid path element. The result is called a study name. For DicomObjects, the study name and the StudyInstanceUID are identical. For other object types, they may not be. When planning a trial or research activity which uses XmlObjects or ZipObjects, it is wise to ensure that UIDs are always constructed along the lines of a DICOM standard UID.

4 The Ajax Servlet

The Ajax Servlet