org.dspace.app.xmlui.cocoon
Class ItemExportDownloadReader

java.lang.Object
  extended by org.apache.cocoon.util.AbstractLogEnabled
      extended by org.apache.cocoon.reading.AbstractReader
          extended by org.dspace.app.xmlui.cocoon.ItemExportDownloadReader
All Implemented Interfaces:
org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable, org.apache.cocoon.reading.Reader, org.apache.cocoon.sitemap.SitemapModelComponent, org.apache.cocoon.sitemap.SitemapOutputComponent

public class ItemExportDownloadReader
extends org.apache.cocoon.reading.AbstractReader
implements org.apache.avalon.excalibur.pool.Recyclable

Author:
Jay Paz

Field Summary
protected static int BUFFER_SIZE
          How big of a buffer should we use when reading from the bitstream before writting to the HTTP response?
protected  InputStream compressedExportInputStream
          The bitstream file
protected  String compressedExportName
           
protected  long compressedExportSize
          The compressed export's reported size
protected static int expires
          When should a download expire in milliseconds.
protected  org.apache.cocoon.environment.Request request
          The Cocoon request
protected  org.apache.cocoon.environment.Response response
          The Cocoon response
 
Fields inherited from class org.apache.cocoon.reading.AbstractReader
objectModel, out, parameters, resolver, source
 
Fields inherited from interface org.apache.cocoon.reading.Reader
ROLE
 
Constructor Summary
ItemExportDownloadReader()
           
 
Method Summary
 void generate()
          Write the actual data out to the response.
 String getMimeType()
          Returns the mime-type of the bitstream.
 void recycle()
          Recycle
 void setup(org.apache.cocoon.environment.SourceResolver resolver, Map objectModel, String src, org.apache.avalon.framework.parameters.Parameters par)
          Set up the export reader.
 
Methods inherited from class org.apache.cocoon.reading.AbstractReader
getLastModified, setOutputStream, shouldSetContentLength
 
Methods inherited from class org.apache.cocoon.util.AbstractLogEnabled
getLogger, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER_SIZE

protected static final int BUFFER_SIZE
How big of a buffer should we use when reading from the bitstream before writting to the HTTP response?

See Also:
Constant Field Values

expires

protected static final int expires
When should a download expire in milliseconds. This should be set to some low value just to prevent someone hiting DSpace repeatily from killing the server. Note: 60000 milliseconds are in a second. Format: minutes * seconds * milliseconds

See Also:
Constant Field Values

response

protected org.apache.cocoon.environment.Response response
The Cocoon response


request

protected org.apache.cocoon.environment.Request request
The Cocoon request


compressedExportInputStream

protected InputStream compressedExportInputStream
The bitstream file


compressedExportSize

protected long compressedExportSize
The compressed export's reported size


compressedExportName

protected String compressedExportName
Constructor Detail

ItemExportDownloadReader

public ItemExportDownloadReader()
Method Detail

setup

public void setup(org.apache.cocoon.environment.SourceResolver resolver,
                  Map objectModel,
                  String src,
                  org.apache.avalon.framework.parameters.Parameters par)
           throws org.apache.cocoon.ProcessingException,
                  SAXException,
                  IOException
Set up the export reader. See the class description for information on configuration options.

Specified by:
setup in interface org.apache.cocoon.sitemap.SitemapModelComponent
Overrides:
setup in class org.apache.cocoon.reading.AbstractReader
Throws:
org.apache.cocoon.ProcessingException
SAXException
IOException

generate

public void generate()
              throws IOException,
                     SAXException,
                     org.apache.cocoon.ProcessingException
Write the actual data out to the response. Some implementation notes, 1) We set a short expires time just in the hopes of preventing someone from overloading the server by clicking reload a bunch of times. I realize that this is nowhere near 100% effective but it may help in some cases and shouldn't hurt anything.

Specified by:
generate in interface org.apache.cocoon.reading.Reader
Throws:
IOException
SAXException
org.apache.cocoon.ProcessingException

getMimeType

public String getMimeType()
Returns the mime-type of the bitstream.

Specified by:
getMimeType in interface org.apache.cocoon.sitemap.SitemapOutputComponent
Overrides:
getMimeType in class org.apache.cocoon.reading.AbstractReader

recycle

public void recycle()
Recycle

Specified by:
recycle in interface org.apache.avalon.excalibur.pool.Recyclable
Overrides:
recycle in class org.apache.cocoon.reading.AbstractReader


Copyright © 2013 DuraSpace. All Rights Reserved.