2 * Copyright (C) 2008, Google Inc.
6 * Redistribution and use in source and binary forms, with or
7 * without modification, are permitted provided that the following
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * - Neither the name of the Git Development Community nor the
19 * names of its contributors may be used to endorse or promote
20 * products derived from this software without specific prior
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
24 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
35 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 package org
.spearce
.jgit
.transport
;
40 import java
.io
.IOException
;
41 import java
.io
.InputStream
;
43 import org
.spearce
.jgit
.errors
.TransportException
;
44 import org
.spearce
.jgit
.lib
.Repository
;
47 * Single shot fetch from a streamed Git bundle.
49 * The bundle is read from an unbuffered input stream, which limits the
50 * transport to opening at most one FetchConnection before needing to recreate
51 * the transport instance.
53 public class TransportBundleStream
extends TransportBundle
{
54 private InputStream src
;
57 * Create a new transport to fetch objects from a streamed bundle.
59 * The stream can be unbuffered (buffering is automatically provided
60 * internally to smooth out short reads) and unpositionable (the stream is
61 * read from only once, sequentially).
63 * When the FetchConnection or the this instance is closed the supplied
64 * input stream is also automatically closed. This frees callers from
65 * needing to keep track of the supplied stream.
68 * repository the fetched objects will be loaded into.
70 * symbolic name of the source of the stream. The URI can
71 * reference a non-existent resource. It is used only for
72 * exception reporting.
74 * the stream to read the bundle from.
76 public TransportBundleStream(final Repository db
, final URIish uri
,
77 final InputStream in
) {
83 public FetchConnection
openFetch() throws TransportException
{
85 throw new TransportException(uri
, "Only one fetch supported");
87 return new BundleFetchConnection(src
);
98 } catch (IOException err
) {
99 // Ignore a close error.