KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dspace > checker > BitstreamDAO


1 /*
2  * Copyright (c) 2004-2005, Hewlett-Packard Company and Massachusetts
3  * Institute of Technology. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * - Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * - Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * - Neither the name of the Hewlett-Packard Company nor the name of the
17  * Massachusetts Institute of Technology nor the names of their
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
30  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
31  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
32  * DAMAGE.
33  */

34 package org.dspace.checker;
35
36 import java.io.IOException JavaDoc;
37 import java.io.InputStream JavaDoc;
38 import java.sql.SQLException JavaDoc;
39
40 import org.dspace.core.Context;
41 import org.dspace.storage.bitstore.BitstreamStorageManager;
42
43 /**
44  * <p>
45  * Data Access Object for Bitstreams.
46  * </p>
47  *
48  * @author Jim Downing
49  * @author Grace Carpenter
50  * @author Nathan Sarr
51  *
52  */

53 public class BitstreamDAO
54 {
55     /**
56      * Default Constructor
57      */

58     public BitstreamDAO()
59     {
60         ;
61     }
62
63     /**
64      * Retrieves the bitstream from the bitstore.
65      *
66      * @param id
67      * the bitstream id.
68      *
69      * @return Bitstream as an InputStream
70      *
71      * @throws IOException
72      * Rethrown from BitstreamStorageManager
73      * @throws SQLException
74      * Rethrown from BitstreamStorageManager
75      *
76      * @see org.dspace.storage.bitstore.BitstreamStorageManager#retrieve(Context,
77      * int)
78      */

79     public InputStream JavaDoc getBitstream(int id) throws IOException JavaDoc, SQLException JavaDoc
80     {
81
82         Context context = null;
83         InputStream JavaDoc is = null;
84         try
85         {
86             context = new Context();
87             is = BitstreamStorageManager.retrieve(context, id);
88         }
89         finally
90         {
91             context.abort();
92         }
93
94         return is;
95     }
96 }
97
Popular Tags