org.eclipse.jgit.transport
Class UploadPack

java.lang.Object
  extended by org.eclipse.jgit.transport.UploadPack

public class UploadPack
extends Object

Implements the server side of a fetch connection, transmitting objects.


Constructor Summary
UploadPack(Repository copyFrom)
          Create a new pack upload for an open repository.
 
Method Summary
 Map<String,Ref> getAdvertisedRefs()
           
 PackWriter.Statistics getPackStatistics()
          Get the PackWriter's statistics if a pack was sent to the client.
 PreUploadHook getPreUploadHook()
           
 RefFilter getRefFilter()
           
 Repository getRepository()
           
 RevWalk getRevWalk()
           
 int getTimeout()
           
 boolean isBiDirectionalPipe()
           
 void sendAdvertisedRefs(RefAdvertiser adv)
          Generate an advertisement of available refs and capabilities.
 void setBiDirectionalPipe(boolean twoWay)
           
 void setLogger(UploadPackLogger logger)
          Set the logger.
 void setPackConfig(PackConfig pc)
          Set the configuration used by the pack generator.
 void setPreUploadHook(PreUploadHook hook)
          Set the hook that controls how this instance will behave.
 void setRefFilter(RefFilter refFilter)
          Set the filter used while advertising the refs to the client.
 void setTimeout(int seconds)
          Set the timeout before willing to abort an IO call.
 void upload(InputStream input, OutputStream output, OutputStream messages)
          Execute the upload task on the socket.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UploadPack

public UploadPack(Repository copyFrom)
Create a new pack upload for an open repository.

Parameters:
copyFrom - the source repository.
Method Detail

getRepository

public final Repository getRepository()
Returns:
the repository this upload is reading from.

getRevWalk

public final RevWalk getRevWalk()
Returns:
the RevWalk instance used by this connection.

getAdvertisedRefs

public final Map<String,Ref> getAdvertisedRefs()
Returns:
all refs which were advertised to the client.

getTimeout

public int getTimeout()
Returns:
timeout (in seconds) before aborting an IO operation.

setTimeout

public void setTimeout(int seconds)
Set the timeout before willing to abort an IO call.

Parameters:
seconds - number of seconds to wait (with no data transfer occurring) before aborting an IO read or write operation with the connected client.

isBiDirectionalPipe

public boolean isBiDirectionalPipe()
Returns:
true if this class expects a bi-directional pipe opened between the client and itself. The default is true.

setBiDirectionalPipe

public void setBiDirectionalPipe(boolean twoWay)
Parameters:
twoWay - if true, this class will assume the socket is a fully bidirectional pipe between the two peers and takes advantage of that by first transmitting the known refs, then waiting to read commands. If false, this class assumes it must read the commands before writing output and does not perform the initial advertising.

getRefFilter

public RefFilter getRefFilter()
Returns:
the filter used while advertising the refs to the client

setRefFilter

public void setRefFilter(RefFilter refFilter)
Set the filter used while advertising the refs to the client.

Only refs allowed by this filter will be sent to the client. This can be used by a server to restrict the list of references the client can obtain through clone or fetch, effectively limiting the access to only certain refs.

Parameters:
refFilter - the filter; may be null to show all refs.

getPreUploadHook

public PreUploadHook getPreUploadHook()
Returns:
the configured upload hook.

setPreUploadHook

public void setPreUploadHook(PreUploadHook hook)
Set the hook that controls how this instance will behave.

Parameters:
hook - the hook; if null no special actions are taken.

setPackConfig

public void setPackConfig(PackConfig pc)
Set the configuration used by the pack generator.

Parameters:
pc - configuration controlling packing parameters. If null the source repository's settings will be used.

setLogger

public void setLogger(UploadPackLogger logger)
Set the logger.

Parameters:
logger - the logger instance. If null, no logging occurs.

upload

public void upload(InputStream input,
                   OutputStream output,
                   OutputStream messages)
            throws IOException
Execute the upload task on the socket.

Parameters:
input - raw input to read client commands from. Caller must ensure the input is buffered, otherwise read performance may suffer.
output - response back to the Git network client, to write the pack data onto. Caller must ensure the output is buffered, otherwise write performance may suffer.
messages - secondary "notice" channel to send additional messages out through. When run over SSH this should be tied back to the standard error channel of the command execution. For most other network connections this should be null.
Throws:
IOException

getPackStatistics

public PackWriter.Statistics getPackStatistics()
Get the PackWriter's statistics if a pack was sent to the client.

Returns:
statistics about pack output, if a pack was sent. Null if no pack was sent, such as during the negotation phase of a smart HTTP connection, or if the client was already up-to-date.

sendAdvertisedRefs

public void sendAdvertisedRefs(RefAdvertiser adv)
                        throws IOException,
                               UploadPackMayNotContinueException
Generate an advertisement of available refs and capabilities.

Parameters:
adv - the advertisement formatter.
Throws:
IOException - the formatter failed to write an advertisement.
UploadPackMayNotContinueException - the hook denied advertisement.


Copyright © 2011. All Rights Reserved.