Package org.dspace.checker

Source Code of org.dspace.checker.BitstreamDAO

/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.checker;

import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;

import org.dspace.core.Context;
import org.dspace.storage.bitstore.BitstreamStorageManager;

/**
* <p>
* Data Access Object for Bitstreams.
* </p>
*
* @author Jim Downing
* @author Grace Carpenter
* @author Nathan Sarr
*
*/
public class BitstreamDAO
{
    /**
     * Default Constructor
     */
    public BitstreamDAO()
    {
    }

    /**
     * Retrieves the bitstream from the bitstore.
     *
     * @param id
     *            the bitstream id.
     *
     * @return Bitstream as an InputStream
     *
     * @throws IOException
     *             Rethrown from BitstreamStorageManager
     * @throws SQLException
     *             Rethrown from BitstreamStorageManager
     *
     * @see org.dspace.storage.bitstore.BitstreamStorageManager#retrieve(Context,
     *      int)
     */
    public InputStream getBitstream(int id) throws IOException, SQLException
    {

        Context context = null;
        InputStream is = null;
        try
        {
            context = new Context();
            is = BitstreamStorageManager.retrieve(context, id);
        }
        finally
        {
            context.abort();
        }

        return is;
    }
}
TOP

Related Classes of org.dspace.checker.BitstreamDAO

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.