Chapter 9. DSpace System Documentation: Application Layer

Table of Contents

9.1. Web User Interface
9.1.1. Web UI Files
9.1.2. The Build Process
9.1.3. Servlets and JSPs
9.1.4. Custom JSP Tags
9.1.5. Internationalisation
9.1.6. HTML Content in Items
9.1.7. Thesis Blocking
9.2. OAI-PMH Data Provider
9.2.1. Sets
9.2.2. Unique Identifier
9.2.3. Access control
9.2.4. Modification Date (OAI Date Stamp)
9.2.5. 'About' Information
9.2.6. Deletions
9.2.7. Flow Control (Resumption Tokens)
9.3. Community and Collection Structure Importer
9.3.1. Limitation
9.4. Package Importer and Exporter
9.4.1. Ingesting
9.4.2. Disseminating
9.4.3. METS packages
9.5. Item Importer and Exporter
9.5.1. DSpace simple archive format
9.5.2. Importing Items
9.5.3. Exporting Items
9.6. Transferring Items Between DSpace Instances
9.7. Registering (Not Importing) Bitstreams
9.7.1. Accessible Storage
9.7.2. Registering Items Using the Item Importer
9.7.3. Internal Identification and Retrieval of Registered Items
9.7.4. Exporting Registered Items
9.7.5. METS Export of Registered Items
9.7.6. Deleting Registered Items
9.8. METS Tools
9.8.1. The Export Tool
9.8.2. The AIP Format
9.8.3. Limitations
9.9. MediaFilters: Transforming DSpace Content
9.10. Sub-Community Management

Back to architecture overview

9.1. Web User Interface

The DSpace Web UI is the largest and most-used component in the application layer. Built on Java Servlet and JavaServer Page technology, it allows end-users to access DSpace over the Web via their Web browsers. As of Dspace 1.3.2 the UI meets both XHTML 1.0 standards and Web Accessibility Initiative (WAI) level-2 standard.

It also features an administration section, consisting of pages intended for use by central administrators. Presently, this part of the Web UI is not particularly sophisticated; users of the administration section need to know what they are doing! Selected parts of this may also be used by collection administrators.

9.1.1. Web UI Files

The Web UI-related files are located in a variety of directories in the DSpace source tree. Note that as of DSpace version 1.2, the deployment mechanism has changed; the build process creates easy-to-deploy Web application archives (.war files).

Table 9.1. Locations of Web UI Source Files



Web UI source files

Servlet Filters (Servlet 2.3 spec)

Custom JSP tag class files

Servlets for main Web UI (controllers)

Servlets that comprise the administration part of the Web UI

Miscellaneous classes used by the servlets and filters


The JSP files


This is where you can place customized versions of JSPs -- see the configuration section


Custom DSpace JSP tag descriptor


The Web application deployment descriptor. Before including in the .war file, the text @@dspace.dir@@ will be replaced with the DSpace installation directory (referred to as [dspace] elsewhere in this system documentation). This allows the Web application to pick up the DSpace configuration and environment.

9.1.2. The Build Process

The DSpace build process constructs a Web application archive, which is placed in [dspace-source]/build/dspace.war. The build_wars Ant target does the work. The process works as follows:

  • All the DSpace source code is compiled.

  • [dspace-source]/etc/dspace-web.xml is copied to [dspace-source]/build and the @@dspace.dir@@ token inside it replaced with the DSpace installation directory (dspace.dir property from dspace.cfg

  • The JSPs are all copied to [dspace-source]/build/jsp

  • Customized JSPs from [dspace-source]/jsp/local are copied on top of these, thus 'overriding' the default versions

  • [dspace-source]/build/dspace.war is built

The contents of dspace.war are:

  • (Top level) -- the JSPs (customized versions from [dspace-source]/jsp/local will have overwritten the defaults from the DSpace source distribution)

  • WEB-INF/classes -- the compiled DSpace classes

  • WEB-INF/lib -- the third party library JAR files from [dspace-source]/lib, minus servlet.jar which will be available as part of Tomcat (or other servlet engine)

  • WEB-INF/web.xml -- web deployment descriptor, copied from [dspace-source]/build/dspace-web.xml

  • WEB-INF/dspace-tags.tld -- tag descriptor

Note that this does mean there are multiple copies of the compiled DSpace code and third-party libraries in the system, so care must be taken to ensure that they are all in sync. (The storage overhead is a few megabytes, totally insignificant these days.) In general, when you change any DSpace code or JSP, it's best to do a complete update of both the installation ([dspace]), and to rebuild and redeploy the Web UI and OAI .war files, by running this in [dspace-source]:

ant -D [dspace]/config/dspace.cfg update

and then following the instructions that command writes to the console.

9.1.3. Servlets and JSPs

The Web UI is loosely based around the MVC (model, view, controller) model. The content management API corresponds to the model, the Java Servlets are the controllers, and the JSPs are the views. Interactions take the following basic form:

  1. An HTTP request is received from a browser

  2. The appropriate servlet is invoked, and processes the request by invoking the DSpace business logic layer public API

  3. Depending on the outcome of the processing, the servlet invokes the appropriate JSP

  4. The JSP is processed and sent to the browser

The reasons for this approach are:

  • All of the processing is done before the JSP is invoked, so any error or problem that occurs does not occur halfway through HTML rendering

  • The JSPs contain as little code as possible, so they can be customized without having to delve into Java code too much

The servlet is always loaded first. This is a very simple servlet that checks the dspace-config context parameter from the DSpace deployment descriptor, and uses it to locate dspace.cfg. It also loads up the Log4j configuration. It's important that this servlet is loaded first, since if another servlet is loaded up, it will cause the system to try and load DSpace and Log4j configurations, neither of which would be found.

All DSpace servlets are subclasses of the DSpaceServlet class. The DSpaceServlet class handles some basic operations such as creating a DSpace Context object (opening a database connection etc.), authentication and error handling. Instead of overriding the doGet and doPost methods as one normally would for a servlet, DSpace servlets implement doDSGet or doDSPost which have an extra context parameter, and allow the servlet to throw various exceptions that can be handled in a standard way.

The DSpace servlet processes the contents of the HTTP request. This might involve retrieving the results of a search with a query term, accessing the current user's eperson record, or updating a submission in progress. According to the results of this processing, the servlet must decide which JSP should be displayed. The servlet then fills out the appropriate attributes in the HttpRequest object that represents the HTTP request being processed. This is done by invoking the setAttribute method of the javax.servlet.http.HttpServletRequest object that is passed into the servlet from Tomcat. The servlet then forwards control of the request to the appropriate JSP using the JSPManager.showJSP method.

The JSPManager.showJSP method uses the standard Java servlet forwarding mechanism is then used to forward the HTTP request to the JSP. The JSP is processed by Tomcat and the results sent back to the user's browser.

There is an exception to this servlet/JSP style: index.jsp, the 'home page', receives the HTTP request directly from Tomcat without a servlet being invoked first. This is because in the servlet 2.3 specification, there is no way to map a servlet to handle only requests made to '/'; such a mapping results in every request being directed to that servlet. By default, Tomcat forwards requests to '/' to index.jsp. To try and make things as clean as possible, index.jsp contains some simple code that would normally go in a servlet, and then forwards to home.jsp using the JSPManager.showJSP method. This means localized versions of the 'home page' can be created by placing a customized home.jsp in [dspace-source]/jsp/local, in the same manner as other JSPs.

[dspace-source]/jsp/dspace-admin/index.jsp, the administration UI index page, is invoked directly by Tomcat and not through a servlet for similar reasons.

At the top of each JSP file, right after the license and copyright header, is documented the appropriate attributes that a servlet must fill out prior to forwarding to that JSP. No validation is performed; if the servlet does not fill out the necessary attributes, it is likely that an internal server error will occur.

Many JSPs containing forms will include hidden parameters that tell the servlets which form has been filled out. The submission UI servlet (SubmissionController is a prime example of a servlet that deals with the input from many different JSPs. The step and page hidden parameters (written out by the SubmissionController.getSubmissionParameters() method) are used to inform the servlet which page of which step has just been filled out (i.e. which page of the submission the user has just completed).

Below is a detailed, scary diagram depicting the flow of control during the whole process of processing and responding to an HTTP request. More information about the authentication mechanism is mostly described in the configuration section.

Flow of Control During HTTP Request Processing

9.1.4. Custom JSP Tags

The DSpace JSPs all use some custom tags defined in /dspace/jsp/WEB-INF/dspace-tags.tld, and the corresponding Java classes reside in The tags are listed below. The dspace-tags.tld file contains detailed comments about how to use the tags, so that information is not repeated here.


Just about every JSP uses this tag. It produces the standard HTML header and <BODY>tag. Thus the content of each JSP is nested inside a <dspace:layout> tag. The (XML-style)attributes of this tag are slightly complicated--see dspace-tags.tld. The JSPs in the source code bundle also provide plenty of examples.


Can only be used inside a layout tag, and can only be used once per JSP. The content between the start and end sidebar tags is rendered in a column on the right-hand side of the HTML page. The contents can contain further JSP tags and Java 'scriptlets'.


Displays the date represented by an org.dspace.content.DCDate object. Just the one representation of date is rendered currently, but this could use the user's browser preferences to display a localized date in the future.


Obsolete, simple tag, similar to jsp:include. In versions prior to DSpace 1.2, this tag would use the locally modified version of a JSP if one was installed in jsp/local. As of 1.2, the build process now performs this function, however this tag is left in for backwards compatibility.


Displays an item record, including Dublin Core metadata and links to the bitstreams within it. Note that the displaying of the bitstream links is simplistic, and does not take into account any of the bundling structure. This is because DSpace does not have a fully-fledged dissemination architectural piece yet.

Displaying an item record is done by a tag rather than a JSP for two reasons: Firstly, it happens in several places (when verifying an item record during submission or workflow review, as well as during standard item accesses), and secondly, displaying the item turns out to be mostly code-work rather than HTML anyway. Of course, the disadvantage of doing it this way is that it is slightly harder to customize exactly what is displayed from an item record; it is necessary to edit the tag code ( Hopefully a better solution can be found in the future.

itemlist, collectionlist, communitylist

These tags display ordered sequences of items, collections and communities, showing minimal information but including a link to the page containing full details. These need to be used in HTML tables.


This tag is used to render a link to a pop-up page (typically a help page.) If Javascript is available, the link will either open or pop to the front any existing DSpace pop-up window. If Javascript is not available, a standard HTML link is displayed that renders the link destination in a window named 'dspace.popup'. In graphical browsers, this usually opens a new window or re-uses an existing window of that name, but if a window is re-used it is not 'raised' which might confuse the user. In text browsers, following this link will simply replace the current page with the destination of the link. This obviously means that Javascript offers the best functionality, but other browsers are still supported.


A tag which produces a widget analogous to HTML <SELECT>, that allows a user to select one or multiple e-people from a pop-up list.


Using an item's Dublin Core metadata DSpace can display an SFX link, if an SFX server is available. This tag does so for a particular item if the sfx.server.url property is defined in dspace.cfg.

9.1.5. Internationalisation

The Java Standard Tag Library v1.0 is used to specify messages in the JSPs like this:


<H1>Search Results</H1>


<H1><fmt:message key=""

This message can now be changed using the config/language-packs/ file. (This must be done at build-time: is placed in the dspace.war Web application file.) = Search Results

Phrases may have parameters to be passed in, to make the job of translating easier, reduce the number of 'keys' and to allow translators to make the translated text flow more appropriately for the target language.


<P>Results <%= r.getFirst() %> to <%= r.getLast() %> of <%=
	r.getTotal() %></P>


<fmt:message key="">
  <fmt:param><%= r.getFirst() %></fmt:param>
  <fmt:param><%= r.getLast() %></fmt:param>
  <fmt:param><%= r.getTotal() %></fmt:param>

(Note: JSTL 1.0 does not seem to allow JSP <%= %> expressions to be passed in as values of attribute in <fmt:param value=""/>)

The above would appear in the file as: = Results {0}-{1} of {2}

Introducing number parameters that should be formatted according to the locale used makes no difference in the message key compared to atring parameters: = {0} bytes

In the JSP using this key can be used in the way belov:

  <fmt:param><fmt:formatNumber><%= bitstream.getSize()

(Note: JSTL offers a way to include numbers in the message keys as = {0,number} bytes. Setting the parameter as <fmt:param value="${variable}" /> workes when variable is a single variable name and doesn't work when trying to use a method's return value instead: bitstream.getSize(). Passing the number as string (or using the <%= %> expression) also does not work.)

Multiple can be created for different languages. See ResourceBundle.getBundle. e.g. you can add German and Canadian French translations:

The end user's browser settings determine which language is used. The English language file (or the default server locale) will be used as a default if there's no language bundle for the end user's preferred language. (Note that the English file is not called -- this is so it is always available as a default, regardless of server configuration.)

The dspace:layout tag has been updated to allow dictionary keys to be passed in for the titles. It now has two new parameters: titlekey and parenttitlekey. So where before you'd do:

<dspace:layout title="Here"
               parenttitle="My DSpace">

You now do:

<dspace:layout titlekey=""

And so the layout tag itself gets the relevant stuff out of the dictionary. title and parenttitle still work as before for backwards compatibility, and the odd spot where that's preferable.

Message Key Convention

When translating further pages, please follow the convention for naming message keys to avoid clashes.

For text in JSPs use the complete path + filename of the JSP, then a one-word name for the message. e.g. for the title of jsp/mydspace/main.jsp use:


Some common words (e.g. "Help") can be brought out into keys starting jsp. for ease of translation, e.g.:

jsp.admin = Administer

Other common words/phrases are brought out into 'general' parameters if they relate to a set (directory) of JSPs, e.g. = Delete

Phrases that relate strongly to a topic (eg. MyDSpace) but used in many JSPs outside the particular directory are more convenient to be cross-referenced. For example one could use the key below in jsp/submit/saved.jsp to provide a link back to the user's MyDSpace:

(Cross-referencing of keys in general is not a good idea as it may make maintenance more difficult. But in some cases it has more advantages as the meaning is obvious.)

jsp.mydspace.general.goto-mydspace = Go to My DSpace

For text in servlet code, in custom JSP tags or wherever applicable use the fully qualified classname + a one-word name for the message. e.g. = Title

Which Languages are currently supported?

To view translations currently being developed, please refer to the i18n page of the DSpace Wiki.

9.1.6. HTML Content in Items

For the most part, the DSpace item display just gives a link that allows an end-user to download a bitstream. However, if a bundle has a primary bitstream whose format is of MIME type text/html, instead a link to the HTML servlet is given.

So if we had an HTML document like this:


The Bundle's primary bitstream field would point to the contents.html Bitstream, which we know is HTML (check the format MIME type) and so we know which to serve up first.

The HTML servlet employs a trick to serve up HTML documents without actually modifying the HTML or other files themselves. Say someone is looking at contents.html from the above example, the URL in their browser will look like this:

If there's an image called figure1.gif in that HTML page, the browser will do HTTP GET on this URL:

The HTML document servlet can work out which item the user is looking at, and then which Bitstream in it is called figure1.gif, and serve up that bitstream. Similar for following links to other HTML pages. Of course all the links and image references have to be relative and not absolute.

HTML documents must be "self-contained", as explained here. Provided that full path information is known by DSpace, any depth or complexity of HTML document can be served subject to those contraints. This is usually possible with some kind of batch import. If, however, the document has been uploaded one file at a time using the Web UI, the path information has been stripped. The system can cope with relative links that refer to a deeper path, e.g.

<IMG SRC="images/figure1.gif">

If the item has been uploaded via the Web submit UI, in the Bitstream table in the database we have the 'name' field, which will contain the filename with no path (figure1.gif). We can still work out what images/figure1.gif is by making the HTML document servlet strip any path that comes in from the URL, e.g.
                                        Strip this

BUT all the filenames (regardless of directory names) must be unique. For example, this wouldn't work:


since the HTML document servlet wouldn't know which bitstream to serve up for:

since it would just have figure.gif

To prevent "infinite URL spaces" appearing (e.g. if a file foo.html linked to bar/foo.html, which would link to bar/bar/foo.html...) this behavior can be configured by setting the configuration property webui.html.max-depth-guess.

For example, if we receive a request for foo/bar/index.html, and we have a bitstream called just index.html, we will serve up that bitstream for the request if webui.html.max-depth-guess is 2 or greater. If webui.html.max-depth-guess is 1 or less, we would not serve that bitstream, as the depth of the file is greater. If webui.html.max-depth-guess is zero, the request filename and path must always exactly match the bitstream name. The default value (if that property is not present in dspace.cfg) is 3.

9.1.7. Thesis Blocking

The submission UI has an optional feature that came about as a result of MIT Libraries policy. If the block.theses parameter in dspace.cfg is true, an extra checkbox is included in the first page of the submission UI. This asks the user if the submission is a thesis. If the user checks this box, the submission is halted (deleted) and an error message displayed, explaining that DSpace should not be used to submit theses. This feature can be turned off and on, and the message displayed (/dspace/jsp/submit/no-theses.jsp can be localized as necessary.

9.2. OAI-PMH Data Provider

The DSpace platform supports the Open Archives Initiative Protocol for Metadata Harvesting (OAI-PMH) version 2.0 as a data provider. This is accomplished using the OAICat framework from OCLC.

The DSpace build process builds a Web application archive, [dspace-source]/build/oai.war), in much the same way as the Web UI build process described above. The only differences are that the JSPs are not included, and [dspace-source]/etc/oai-web.xml is used as the deployment descriptor. This 'webapp' is deployed to receive and respond to OAI-PMH requests via HTTP. Note that typically it should not be deployed on SSL (https: protocol). In a typical configuration, this is deployed at oai, for example:

The 'base URL' of this DSpace deployment would be:

It is this URL that should be registered with Note that you can easily change the 'request' portion of the URL by editing [dspace-source]/etc/oai-web.xml and rebuilding and deploying oai.war.

DSpace provides implementations of the OAICat interfaces AbstractCatalog, RecordFactory and Crosswalk that interface with the DSpace content management API and harvesting API (in the search subsystem).

Only the basic oai_dc unqualified Dublin Core metadata set export is enabled by default; this is particularly easy since all items have qualified Dublin Core metadata. When this metadata is harvested, the qualifiers are simply stripped; for example, description.abstract is exposed as unqualified description. The description.provenance field is hidden, as this contains private information about the submitter and workflow reviewers of the item, including their e-mail addresses. Additionally, to keep in line with OAI community practices, values of are exposed as creator values.

Other metadata formats are supported as well, using other Crosswalk implementations; consult the file described below. To enable a format, simply uncomment the lines beginning with Crosswalks.*. Multiple formats are allowed, and the current list includes, in addition to unqualified DC: MPEG DIDL, METS, MODS. There is also an incomplete, experimental qualified DC.

Note that the current simple DC implementation ( does not currently strip out any invalid XML characters that may be lying around in the data. If your database contains a DC value with, for example, some ASCII control codes (form feed etc.) this may cause OAI harvesters problems. This should rarely occur, however. XML entities (such as >) are encoded (e.g. to &gt;)

In addition to the implementations of the OAICat interfaces, there are two configuration files relevant to OAI support:

This resides as a template in [dspace]/config/templates, and the live version is written to [dspace]/config. You probably won't need to edit this; the install-configs script fills out the relevant deployment-specific parameters. You might want to change the earliestDatestamp field to accurately reflect the oldest datestamp in the system. (Note that this is the value of the last_modified column in the Item database table.)


This standard Java Servlet 'deployment descriptor' is stored in the source as [dspace-source]/etc/oai-web.xml, and is written to /dspace/oai/WEB-INF/web.xml.

9.2.1. Sets

OAI-PMH allows repositories to expose an hierarchy of sets in which records may be placed. A record can be in zero or more sets.

DSpace exposes collections as sets. The organization of communities is likely to change over time, and is therefore a less stable basis for selective harvesting.

Each collection has a corresponding OAI set, discoverable by harvesters via the ListSets verb. The setSpec is the Handle of the collection, with the ':' and '/' converted to underscores so that the Handle is a legal setSpec, for example:


Naturally enough, the collection name is also the name of the corresponding set.

9.2.2. Unique Identifier

Every item in OAI-PMH data repository must have an unique identifier, which must conform to the URI syntax. As of DSpace 1.2, Handles are not used; this is because in OAI-PMH, the OAI identifier identifies the metadata record associated with the resource. The resource is the DSpace item, whose resource identifier is the Handle. In practical terms, using the Handle for the OAI identifier may cause problems in the future if DSpace instances share items with the same Handles; the OAI metadata record identifiers should be different as the different DSpace instances would need to be harvested separately and may have different metadata for the item.

The OAI identifiers that DSpace uses are of the form:

oai:host name:handle

For example:

If you wish to use a different scheme, this can easily be changed by editing the value of OAI_ID_PREFIX at the top of the class. (You do not need to change the code if the above scheme works for you; the code picks up the host name and Handles automatically from the DSpace configuration.)

9.2.3. Access control

OAI provides no authentication/authorisation details, although these could be implemented using standard HTTP methods. It is assumed that all access will be anonymous for the time being.

A question is, "is all metadata public?" Presently the answer to this is yes; all metadata is exposed via OAI-PMH, even if the item has restricted access policies. The reasoning behind this is that people who do actually have permission to read a restricted item should still be able to use OAI-based services to discover the content.

If in the future, this 'expose all metadata' approach proves unsatisfactory for any reason, it should be possible to expose only publicly readable metadata. The authorisation system has separate permissions for READing and item and READing the content (bitstreams) within it. This means the system can differentiate between an item with public metadata and hidden content, and an item with hidden metadata as well as hidden content. In this case the OAI data repository should only expose items those with anonymous READ access, so it can hide the existence of records to the outside world completely. In this scenario, one should be wary of protected items that are made public after a time. When this happens, the items are "new" from the OAI-PMH perspective.

9.2.4. Modification Date (OAI Date Stamp)

OAI-PMH harvesters need to know when a record has been created, changed or deleted. DSpace keeps track of a 'last modified' date for each item in the system, and this date is used for the OAI-PMH date stamp. This means that any changes to the metadata (e.g. admins correcting a field, or a withdrawal) will be exposed to harvesters.

9.2.5. 'About' Information

As part of each record given out to a harvester, there is an optional, repeatable "about" section which can be filled out in any (XML-schema conformant) way. Common uses are for provenance and rights information, and there are schemas in use by OAI communities for this. Presently DSpace does not provide any of this information.

9.2.6. Deletions

DSpace keeps track of deletions (withdrawals). These are exposed via OAI, which has a specific mechansim for dealing with this. Since DSpace keeps a permanent record of withdrawn items, in the OAI-PMH sense DSpace supports deletions 'persistently'. This is as opposed to 'transient' deletion support, which would mean that deleted records are forgotten after a time.

Once an item has been withdrawn, OAI-PMH harvests of the date range in which the withdrawal occurred will find the 'deleted' record header. Harvests of a date range prior to the withdrawal will not find the record, despite the fact that the record did exist at that time.

As an example of this, consider an item that was created on 2002-05-02 and withdrawn on 2002-10-06. A request to harvest the month 2002-10 will yield the 'record deleted' header. However, a harvest of the month 2002-05 will not yield the original record.

Note that presently, the deletion of 'expunged' items is not exposed through OAI.

9.2.7. Flow Control (Resumption Tokens)

An OAI data provider can prevent any performance impact caused by harvesting by forcing a harvester to receive data in time-separated chunks. If the data provider receives a request for a lot of data, it can send part of the data with a resumption token. The harvester can then return later with the resumption token and continue.

DSpace supports resumption tokens for 'ListRecords' OAI-PMH requests. ListIdentifiers and ListSets requests do not produce a particularly high load on the system, so resumption tokens are not used for those requests.

Each OAI-PMH ListRecords request will return at most 100 records. This limit is set at the top of (MAX_RECORDS). A potential issue here is that if a harvest yields an exact multiple of MAX_RECORDS, the last operation will result in a harvest with no records in it. It is unclear from the OAI-PMH specification if this is acceptable.

When a resumption token is issued, the optional completeListSize and cursor attributes are not included. OAICat sets the expirationDate of the resumption token to one hour after it was issued, though in fact since DSpace resumption tokens contain all the information required to continue a request they do not actually expire.

Resumption tokens contain all the state information required to continue a request. The format is:


from and until are the ISO 8601 dates passed in as part of the original request, and setSpec is also taken from the original request. offset is the number of records that have already been sent to the harvester. For example:


This means the harvest is 'from' 2003-01-01, has no 'until' date, is for collection hdl:1721.1/1234, and 300 records have already been sent to the harvester. (Actually, if the original OAI-PMH request doesn't specify a 'from' or 'until, OAICat fills them out automatically to '0000-00-00T00:00:00Z' and '9999-12-31T23:59:59Z' respectively. This means DSpace resumption tokens will always have from and until dates in them.)

9.3. Community and Collection Structure Importer

This command-line tool gives you the ability to import a community and collection structure directly from a source XML file. It is executed as follows:

[dspace]/bin/structure-builder -f [source xml] -o [output xml file] -e [administrator email]

This will examine the contents of [source xml], import the structure into DSpace while logged in as the supplied administrator, and then output the same structure to the output file, but including the handle for each imported community and collection as an attribute.

The source xml document needs to be in the following format:

                <name>Community Name</name>
                <intro>Introductory text</intro>
                <copyright>Special copyright
                <sidebar>Sidebar text</sidebar>
                        <name>Sub Community Name</name>
                        <community> ...[ad infinitum]...
                        <name>Collection Name</name>
                        <intro>Introductory text</intro>
                        <copyright>Special copyright
                        <sidebar>Sidebar text</sidebar>

The resulting output document will be as follows:

        <community identifier="123456789/1">
                <name>Community Name</name>
                <intro>Introductory text</intro>
                <copyright>Special copyright
                <sidebar>Sidebar text</sidebar>
                <community identifier="123456789/2">
                        <name>Sub Community Name</name>
                        <community identifier="123456789/3"> ...[ad
	infinitum]... </community>
                <collection identifier="123456789/4">
                        <name>Collection Name</name>
                        <intro>Introductory text</intro>
                        <copyright>Special copyright
                        <sidebar>Sidebar text</sidebar>

9.3.1. Limitation

  • Currently this does not export community and collection structures, although it should only be a small modification to make it do so

9.4. Package Importer and Exporter

This command-line tool gives you access to the Packager plugins. It can ingest a package to create a new DSpace Item, or disseminate an Item as a package.

To see all the options, invoke it as:

 [dspace]/bin/packager --help

This mode also displays a list of the names of package ingesters and disseminators that are available.

9.4.1. Ingesting

To ingest a package from a file, give the command:

 [dspace]/bin/packager -e  user -c  handle -t  packager 

Where user is the e-mail address of the E-Person under whose authority this runs; handle is the Handle of the collection into which the Item is added, packager is the plugin name of the package ingester to use, and path is the path to the file to ingest (or "-" to read from the standard input).

Here is an example that loads a PDF file with internal metadata as a package:

/dspace/bin/packager -e -c 1721.2/13  -t pdf

This example takes the result of retrieving a URL and ingests it:

wget -O - | \
/dspace/bin/packager -e -c 1721.2/13  -t pdf -

9.4.2. Disseminating

To disseminate an Item as a package, give the command:

 [dspace]/bin/packager -e  user -d -i  handle -t    packager 

Where user is the e-mail address of the E-Person under whose authority this runs; handle is the Handle of the Item to disseminate; packager is the plugin name of the package disseminator to use; and path is the path to the file to create (or "-" to write to the standard output). This example writes an Item out as a METS package in the file "":

/dspace/bin/packager -e -d -i 1721.2/454 -t METS

9.4.3. METS packages

DSpace 1.4 includes a package disseminator and matching ingester for the DSpace METS SIP (Submission Information Package) format. They were created to help end users prepare sets of digital resources and metadata for submission to the archive using well-defined standards such as METS, MODS, and PREMIS. The plugin name is METS by default, and it uses MODS for descriptive metadata.

The DSpace METS SIP profile is available at: .

9.5. Item Importer and Exporter

DSpace has a set of command line tools for importing and exporting items in batches, using the DSpace simple archive format. The tools are not terribly robust, but are useful and are easily modified. They also give a good demonstration of how to implement your own item importer if desired.

9.5.1. DSpace simple archive format

The basic concept behind the DSpace's simple archive format is to create an archive, which is directory full of items, with a subdirectory per item. Each item directory contains a file for the item's descriptive metadata, and the files that make up the item.

        dublin_core.xml -- qualified Dublin Core metadata
        contents        -- text file containing one line per filename
        file_1.doc      -- files to be added as bitstreams to the

The dublin_core.xml file has the following format, where each Dublin Core element has it's own entry within a <dcvalue> tagset. There are currently three tag attributes available in the <dcvalue> tagset:

  • <element> - the Dublin Core element

  • <qualifier> - the element's qualifier

  • <language> - (optional)ISO language code for element

    <dcvalue element="title" qualifier="none">A Tale of Two
    <dcvalue element="date"

    <dcvalue element="title" qualifier="alternate" language="fr"
	">J'aime les Printemps</dcvalue>

(Note the optional language tag attribute which notifies the system that the optional title is in French.)

The contents file simply enumerates, one file per line, the bitstream file names. The bitstream name may optionally be followed by the sequence:


where '\t' is the tab character and 'bundlename' is replaced by the name of the bundle to which the bitstream should be added. If no bundle is specified, the bitstream will be added to the 'ORIGINAL' bundle.

9.5.2. Importing Items

Note: Before running the item importer over items previously exported from a DSpace instance, please first refer to Transferring Items Between DSpace Instances.

The item importer is in, and is run with the import utility in the dspace/bin directory. Running it with -h gets the current command-line arguments. Another very important flag is the --test flag, which you can use with any command to simulate all of the actions it will perform without actually making any changes to your DSpace instance - very useful for validating your item directories before doing an import. In the importer's arguments you can use either the user's database ID or email address and the eperson ID, and the collection's database ID or handle as arguments. Currently with the importer you can add, remove, and replace items in a collection. If you specify more than one collection argument then the items will be imported to multiple collections, and the first collection specified becomes the "owning" collection. If there is an error and the import is aborted, there is a --resume flag that you can try to resume the import where you left off after you fix the error.

To add items to a collection with an EPerson as the submitter, type:

[dspace]/bin/import --add 
	--collection=collectionID --source=items_dir --mapfile=mapfile

(or by using the short form)

[dspace]/bin/import -a -e  -c collectionID -s items_dir
	-m mapfile

which would then cycle through the archive directory's items, import them, and then generate a map file which stores the mapping of item directories to item handles. Save this map file! Using the map file you can then 'unimport' with the command:

[dspace]/bin/import --delete --mapfile=mapfile

The imported items listed in the map file would then be deleted. If you wish to replace previously imported items, you can give the command:

[dspace]/bin/import --replace
	--collection=collectID --source=items_dir --mapfile=mapfile

Replacing items uses the map file to replace the old items and still retain their handles.

The importer usually bypasses any workflow assigned to a collection, but adding the --workflow option will route the imported items through the workflow system.

The importer also has a --test flag that will simulate the entire import process without actually doing the import. This is extremely useful for verifying your import files before doing the import step.

9.5.3. Exporting Items

The item exporter can export a single item or a collection of items, and creates a DSpace simple archive for each item to be exported. To export a collection's items you type:

[dspace]/bin/export --type=COLLECTION --id=collID --dest=dest_dir

The keyword COLLECTION means that you intend to export an entire collection. The ID can either be the database ID or the handle. The exporter will begin numbering the simple archives with the sequence number that you supply. To export a single item use the keyword ITEM and give the item ID as an argument:

[dspace]/bin/export --type=ITEM --id=itemID --dest=dest_dir

Each exported item will have an additional file in its directory, named 'handle'. This will contain the handle that was assigned to the item, and this file will be read by the importer so that items exported and then imported to another machine will retain the item's original handle.

9.6. Transferring Items Between DSpace Instances

Where items are to be moved between DSpace instances (for example from a test DSpace into a production DSpace) the item exporter and item importer can be used in conjunction with a script to assist in this process.

After running the item exporter each dublin_core.xml file will contain metadata that was automatically added by DSpace. These fields are as follows:

  • date.accessioned

  • date.available

  • date.issued

  • description.provenance

  • format.extent

  • format.mimetype

  • identifier.uri

In order to avoid duplication of this metadata, run

dspace_migrate <exported item directory>

prior to running the item importer. This will remove the above metadata items, except for date.issued - if the item has been published or publicly distributed before and identifier.uri - if it is not the handle, from the dublin_core.xml file and remove all handle files. It will then be safe to run the item exporter. Use

dspace_migrate --help

for instructions on use of the script.

9.7. Registering (Not Importing) Bitstreams

Registration is an alternate means of incorporating items, their metadata, and their bitstreams into DSpace by taking advantage of the bitstreams already being in storage accessible to DSpace. An example might be that there is a repository for existing digital assets. Rather than using the normal interactive ingest process or the batch import to furnish DSpace the metadata and to upload bitstreams, registration provides DSpace the metadata and the location of the bitstreams. DSpace uses a variation of the import tool to accomplish registration.

9.7.1. Accessible Storage

To register an item its bitstreams must reside on storage accessible to DSpace and therefore referenced by an asset store number in dspace.cfg. The configuration file dspace.cfg establishes one or more asset stores through the use of an integer asset store number. This number relates to a directory in the DSpace host's file system or a set of SRB account parameters. This asset store number is described in The dspace.cfg Configuration Properties File section and in the dspace.cfg file itself. The asset store number(s) used for registered items should generally not be the value of the assetstore.incoming property since it is unlikely that that you will want to mix the bitstreams of normally ingested and imported items and registered items.

9.7.2. Registering Items Using the Item Importer

DSpace uses the same import tool that is used for batch import except that several variations are employed to support registration. The discussion that follows assumes familiarity with the import tool.

The archive format for registration does not include the actual content files (bitstreams) being registered. The format is however a directory full of items to be registered, with a subdirectory per item. Each item directory contains a file for the item's descriptive metadata (dublin_core.xml) and a file listing the item's content files (contents), but not the actual content files themselves.

The dublin_core.xml file for item registration is exactly the same as for regular item import.

The contents file, like that for regular item import, lists the item's content files, one content file per line, but each line has the one of the following formats:

-r -s n -f filepath
-r -s n -f filepath\tbundle:bundlename
-r -s n -f filepath\tbundle:bundlename\tpermissions: -[r|w] 'group
-r -s n -f filepath\tbundle:bundlename\tpermissions: -[r|w] 'group
	name'\tdescription: some text


  • -r indicates this is a file to be registered

  • -s n indicates the asset store number (n)

  • -f filepath indicates the path and name of the content file to be registered (filepath)

  • \t is a tab character

  • bundle:bundlename is an optional bundle name

  • permissions: -[r|w] 'group name' is an optional read or write permission that can be attached to the bitstream

  • description: some text is an optional description field to add to the file

The bundle, that is everything after the filepath, is optional and is normally not used.

The command line for registration is just like the one for regular import:

dsrun --add  --collection=collectionID --source=items_dir

(or by using the short form)

dsrun -a -e  -c
	collectionID -s items_dir -m mapfile

The --workflow and --test flags will function as described in Importing Items.

The --delete flag will function as described in Importing Items but the registered content files will not be removed from storage. See Deleting Registered Items.

The --replace flag will function as described in Importing Items but care should be taken to consider different cases and implications. With old items and new items being registered or ingested normally, there are four combinations or cases to consider. Foremost, an old registered item deleted from DSpace using --replace will not be removed from the storage. See Deleting Registered Items. where is resides. A new item added to DSpace using --replace will be ingested normally or will be registered depending on whether or not it is marked in the contents files with the -r.

9.7.3. Internal Identification and Retrieval of Registered Items

Once an item has been registered, superficially it is indistinguishable from items ingested interactively or by batch import. But internally there are some differences:

First, the randomly generated internal ID is not used because DSpace does not control the file path and name of the bitstream. Instead, the file path and name are that specified in the contents file.

Second, the store_number column of the bitstream database row contains the asset store number specified in the contents file.

Third, the internal_id column of the bitstream database row contains a leading flag (-R) followed by the registered file path and name. For example, -Rfilepath where filepath is the file path and name relative to the asset store corresponding to the asset store number. The asset store could be traditional storage in the DSpace server's file system or an SRB account.

Fourth, an MD5 checksum is calculated by reading the registered file if it is in local storage. If the registerd file is in remote storage (say, SRB) a checksum is calulated on just the file name! This is an efficiency choice since registering a large number of large files that are in SRB would consume substantial network resources and time. A future option could be to have an SRB proxy process calculate MD5s and store them in SRB's metadata catalog (MCAT) for rapid retrieval. SRB offers such an option but it's not yet in production release.

Registered items and their bitstreams can be retrieved transparently just like normally ingested items.

9.7.4. Exporting Registered Items

Registered items may be exported as described in Exporting Items. If so, the export directory will contain actual copies of the files being exported but the lines in the contents file will flag the files as registered. This means that if DSpace items are "round tripped" (see Transferring Items Between DSpace Instances) using the exporter and importer, the registered files in the export directory will again registered in DSpace instead of being uploaded and ingested normally.

9.7.5. METS Export of Registered Items

The METS Export Tool can also be used but note the cautions described in that section and note that MD5 values for items in remote storage are actually MD5 values on just the file name.

9.7.6. Deleting Registered Items

If a registered item is deleted from DSpace, either interactively or by using the --delete or --replace flags described in Importing Items, the item will disappear from DSpace but it's registered content files will remain in place just as they were prior to registration. Bitstreams not registered but added by DSpace as part of registration, such as license.txt files, will be deleted.

9.8. METS Tools

The experimental (incomplete) METS export tool writes DSpace items to a filesystem with the metadata held in a more standard format based on METS.

9.8.1. The Export Tool

The METS export tool is invoked via the command line like this:


The tool can export an individual item, the items within a given collection, or everything in the DSpace instance. To export an individual item, use:

 [dspace]/bin/dsrun --item 

To export the items in collection hdl:123.456/789, use:

 [dspace]/bin/dsrun --collection

To export all the items DSpace, use:


With any of the above forms, you can specify the base directory into which the items will be exported, using --destination [directory]. If this parameter is omitted, the current directory is used.

9.8.2. The AIP Format

Each exported item is written to a separate directory, created under the base directory specified in the command-line arguments, or in the current directory if --destination is omitted. The name of each directory is the Handle, URL-encoded so that the directory name is 'legal'.

Within each item directory is a mets.xml file which contains the METS-encoded metadata for the item. Bitstreams in the item are also stored in the directory. Their filenames are their MD5 checksums, firstly for easy integrity checking, and also to avoid any problems with 'special characters' in the filenames that were legal on the original filing system they came from but are illegal in the server filing system. The mets.xml file includes XLink pointers to these bitstream files.

An example AIP might look like this:

  • hdl%3A123456789%2F8/

    • mets.xml -- METS metadata

    • 184BE84F293342 -- bitstream

    • 3F9AD0389CB821

    • 135FB82113C32D

The contents of the METS in the mets.xml file are as follows:

  • A dmdSec (descriptive metadata section) containing the item's metadata in Metadata Object Description Schema (MODS) XML. The Dublin Core descriptive metadata is mapped to MODS since there is no official qualified Dublin Core XML schema in existence as of yet, and the Library Application Profile of DC that DSpace uses includes some qualifiers that are not part of the DCMI Metadata Terms.

  • An amdSec (administrative metadata section), which contains the a rights metadata element, which in turn contains the base64-encoded deposit license (the license the submitter granted as part of the submission process).

  • A fileSec containing a list of the bitstreams in the item. Each bundle constitutes a fileGrp. Each bitstream is represented by a file element, which contains an FLocat element with a simple XLink to the bitstream in the same directory as the mets.xml file. The file attributes consist of most of the basic technical metadata for the bitstream. Additionally, for those bitstreams that are thumbnails or text extracted from another bitstream in the item, those 'derived' bitstreams have the same GROUPID as the bitstream they were derived from, in order that clients understand that there is a relationship.

    The OWNERID of each file is the 'persistent' bitstream identifier assigned by the DSpace instance. The ID and GROUPID attributes consist of the item's Handle, together with the bitstream's sequence ID, which underscores used in place of dots and slashes. For example, a bitstream with sequence ID 24, in the item hdl:123.456/789 will have the ID123_456_789_24. This is because ID and GROUPID attributes must be of type xsd:id.

9.8.3. Limitations

  • No corresponding import tool yet

  • No structmap section

  • Some technical metadata not written, e.g. the primary bitstream in a bundle, original filenames or descriptions.

  • Only the MIME type is stored, not the (finer grained) bitstream format.

  • Dublin Core to MODS mapping is very simple, probably needs verification

9.9. MediaFilters: Transforming DSpace Content

DSpace can apply filters to content/bitstreams, creating new content. Filters are included that extract text for full-text searching, and create thumbnails for items that contain images. The media filters are controlled by the MediaFilterManager which traverses the asset store, invoking the MediaFilter or FormatFilter classes on bitstreams. The media filter plugin configuration filter.plugins in dspace.cfg contains a list of all enabled media/format filter plugins (see Configuring Media Filters for more information). The media filter system is intended to be run from the command line (or regularly as a cron task):


With no options, this traverses the asset store, applying media filters to bitstreams, and skipping bitstreams that have already been filtered.

Available Command-Line Options:

  • Help : [dspace]/bin/filter-media -h

    • Display help message describing all command-line options.

  • Force mode : [dspace]/bin/filter-media -f

    • Apply filters to ALL bitstreams, even if they've already been filtered. If they've already been filtered, the previously filtered content is overwritten.

  • Identifier mode : [dspace]/bin/filter-media -i 123456789/2

    • Restrict processing to the community, collection, or item named by the identifier - by default, all bitstreams of all items in the repository are processed. The identifier must be a Handle, not a DB key. This option may be combined with any other option.

  • Maximum mode : [dspace]/bin/filter-media -m 1000

    • Suspend operation after the specified maximum number of items have been processed - by default, no limit exists. This option may be combined with any other option.

  • No-Index mode : [dspace]/bin/filter-media -n

    • Suppress index creation - by default, a new search index is created for full-text searching. This option suppresses index creation if you intend to run index-all elsewhere.

  • Plugin mode : [dspace]/bin/filter-media -p "PDF Text Extractor","Word Text Extractor"

    • Apply ONLY the filter plugin(s) listed (separated by commas). By default all named filters listed in the filter.plugins field of dspace.cfg are applied. This option may be combined with any other option. WARNING: multiple plugin names must be separated by a comma (i.e. ',') and NOT a comma followed by a space (i.e. ', ').

  • Skip mode : [dspace]/bin/filter-media -s 123456789/9,123456789/100

    • SKIP the listed identifiers (separated by commas) during processing. The identifiers must be Handles (not DB Keys). They may refer to items, collections or communities which should be skipped. This option may be combined with any other option. WARNING: multiple identifiers must be separated by a comma (i.e. ',') and NOT a comma followed by a space (i.e. ', ').

    • NOTE: If you have a large number of identifiers to skip, you may maintain this comma-separated list within a separate file (e.g. filter-skiplist.txt), and call it similar to the following:

      • [dspace]/bin/filter-media -s `less filter-skiplist.txt`

  • Verbose mode : [dspace]/bin/filter-media -v

    • Verbose mode - print all extracted text and other filter details to STDOUT.

Adding your own filters is done by creating a class which implements the interface. See the Creating a new Media Filter topic and comments in the source file for more information. In theory filters could be implemented in any programming language (C, Perl, etc.) However, they need to be invoked by the Java code in the Media Filter class that you create.

9.10. Sub-Community Management

DSpace provides an administrative tool - 'CommunityFiliator' - for managing community sub-structure. Normally this structure seldom changes, but prior to the 1.2 release sub-communities were not supported, so this tool could be used to place existing pre-1.2 communities into a hierarchy. It has two operations, either establishing a community to sub-community relationship, or dis-establishing an existing relationship.

The familiar parent/child metaphor can be used to explain how it works. Every community in DSpace can be either a 'parent' community - meaning it has at least one sub-community, or a 'child' community - meaning it is a sub-community of another community, or both or neither. In these terms, an 'orphan' is a community that lacks a parent (although it can be a parent); 'orphans' are referred to as 'top-level' communities in the DSpace user-interface, since there is no parent community 'above' them. The first operation - establishing a parent/child relationship - can take place between any community and an orphan. The second operation - removing a parent/child relationship - will make the child an orphan.

Using the dsrun utility in the dspace/bin directory, the establish operation looks like this:

dsrun org.dspace.administer.CommunityFiliator --set --parent=parentID

(or using the short form)

dsrun org.dspace.administer.CommunityFiliator -s -p parentID -c

where '-s' or '--set' means establish a relationship whereby the community identified by the '-p' parameter becomes the parent of the community identified by the '-c' parameter. Both the 'parentID' and 'childID' values may be handles or database IDs.

The reverse operation looks like this:

dsrun org.dspace.administer.CommunityFiliator --remove
	--parent=parentID --child=childID

(or using the short form)

dsrun org.dspace.administer.CommunityFiliator -r -p parentID -c

where '-r' or '--remove' means dis-establish the current relationship in which the community identified by 'parentID' is the parent of the community identified by 'childID'. The outcome will be that the 'childID' community will become an orphan, i.e. a top-level community.

If the required constraints of operation are violated, an error message will appear explaining the problem, and no change will be made. An example in a removal operation, where the stated child community does not have the stated parent community as its parent: "Error, child community not a child of parent community".

It is possible to effect arbitrary changes to the community hierarchy by chaining the basic operations together. For example, to move a child community from one parent to another, simply perform a 'remove' from its current parent (which will leave it an orphan), followed by a 'set' to its new parent.

It is important to understand that when any operation is performed, all the sub-structure of the child community follows it. Thus, if a child has itself children (sub-communities), or collections, they will all move with it to its new 'location' in the community tree.

Licensed under a Creative Commons Attribution 3.0 United States License