public interface

ContentService

com.atlassian.stash.content.ContentService

Class Overview

Retrieves the diff, the content or the the blame information of a file.

Summary

Public Methods
@Nonnull List<Blame> getBlame(Repository repository, String objectId, String path, PageRequest pageRequest)
Returns Blame for the lines included by the provided PageRequest for the specified objectId+path in the specified repository.
@Nonnull ContentTreeNode.Type getType(Repository repository, String objectId, String path)
@Deprecated void streamDiff(Repository repository, String sinceId, String untilId, Iterable<String> paths, DiffContentCallback callback)
This method is deprecated. in 2.4 for removal in 3.0, replaced by streamDiff(DiffRequest, DiffContentCallback)
void streamDiff(DiffRequest request, DiffContentCallback callback)
Streams diff output for the specified paths at the specified changeset.
@Deprecated void streamDiff(Repository repository, String sinceId, String untilId, String path, DiffContentCallback callback)
This method is deprecated. in 2.4 for removal in 3.0, replaced by streamDiff(DiffRequest, DiffContentCallback)
void streamDirectory(Repository repository, String objectId, String path, boolean recursive, ContentTreeCallback callback, PageRequest pageRequest)
Performs a directory listing for the specified objectId+path from the specified repository, streaming the results to the provided callback.
void streamFile(Repository repository, String objectId, String path, PageRequest pageRequest, boolean withBlame, FileContentCallback fileContentCallback)
void streamFile(Repository repository, String objectId, String path, TypeAwareOutputSupplier outputStreamSupplier)
Streams the raw content of the file into an OutputStream obtained from the given TypeAwareOutputSupplier.

Public Methods

@Nonnull public List<Blame> getBlame (Repository repository, String objectId, String path, PageRequest pageRequest)

Returns Blame for the lines included by the provided PageRequest for the specified objectId+path in the specified repository.

The objectId provided here can be several things:

  • A branch name
  • A tag name
  • A hash (which can identify a branch, a tag, or a specific commit, among other things)

Blame is returned in a List rather than a Page because paging is implicitly handled by the lines in the PageRequest--no more than 1 Blame instance per-line can ever be generated, so there is no need to page the returned blame (and doing so would require the use of two PageRequests, one to page the lines and one to page the blame).

Parameters
repository the repository to use
objectId an identifier (name or hash) for the branch, tag or commit at which blame should be retrieved
path the path for which blame should be retrieved
pageRequest defines the set of lines within the file for which blame should be generated
Returns
  • a list containing 0 or more Blame objects, ordered by the line at which they start in the file

@Nonnull public ContentTreeNode.Type getType (Repository repository, String objectId, String path)

@Deprecated public void streamDiff (Repository repository, String sinceId, String untilId, Iterable<String> paths, DiffContentCallback callback)

This method is deprecated.
in 2.4 for removal in 3.0, replaced by streamDiff(DiffRequest, DiffContentCallback)

Streams diff output for the specified paths at the specified changeset.

Note: This interface is currently not paged. The implementation will apply a hard cap and it is not possible to request subsequent content when that cap is exceeded.

Parameters
repository the repository to use
sinceId the starting changeset for the diff or null for the untilId's parent
untilId the terminating changeset for the diff
paths paths to one or more files to diff
callback the callback for receiving the diff details

public void streamDiff (DiffRequest request, DiffContentCallback callback)

Streams diff output for the specified paths at the specified changeset.

Note: This interface is currently not paged. The implementation will apply a hard cap and it is not possible to request subsequent content when that cap is exceeded.

Parameters
request the repository, starting and terminating changsets, paths to filter

@Deprecated public void streamDiff (Repository repository, String sinceId, String untilId, String path, DiffContentCallback callback)

This method is deprecated.
in 2.4 for removal in 3.0, replaced by streamDiff(DiffRequest, DiffContentCallback)

Streams diff output for the targeted path at the specified changeset.

Note: This interface is currently not paged. The implementation will apply a hard cap and it is not possible to request subsequent content when that cap is exceeded.

Parameters
repository the repository to use
sinceId the starting changeset for the diff or null for the untilId's parent
untilId the terminating changeset for the diff
path the path to the file to diff
callback the callback for receiving the diff details

public void streamDirectory (Repository repository, String objectId, String path, boolean recursive, ContentTreeCallback callback, PageRequest pageRequest)

Performs a directory listing for the specified objectId+path from the specified repository, streaming the results to the provided callback.

The objectId provided here can be several things:

  • A branch name
  • A tag name
  • A hash (which can identify a branch, a tag, or a specific commit, among other things)

The listing is provided to the caller via a callback mechanism - the supplied ContentTreeCallback parameter. This method promises to call onStartPage(int) on the supplied instance once followed by zero or more onTreeNode(String, String, com.atlassian.stash.content.ContentTreeNode.Type) for each path in the directory and finally followed by a onEndPage(com.atlassian.stash.util.Page). The caller may force the directory to be performed recursively by supplying the appropriate flag. When recursive, only files will be listed, not sub directories.

Parameters
repository the repository to use
objectId an identifier (name or hash) for the branch, tag or commit at which blame should be retrieved
path the path for which blame should be retrieved
recursive whether the directory listing should be recursive
callback the callback instance to call as the page starts, the children nodes are encountered and as the page ends
pageRequest defines the range of children in the listing the caller is interested in

public void streamFile (Repository repository, String objectId, String path, PageRequest pageRequest, boolean withBlame, FileContentCallback fileContentCallback)

Parameters
repository the repository
objectId the identifier for a point in the repository. Can be a changeset id, a branch or a tag
path the path to the file
pageRequest the page request for the start and limit of the page
withBlame true to include blame information for content; otherwise, false to omit it
fileContentCallback the callback for receiving lines and page information
Throws
ServiceException if the stream file operation fails

public void streamFile (Repository repository, String objectId, String path, TypeAwareOutputSupplier outputStreamSupplier)

Streams the raw content of the file into an OutputStream obtained from the given TypeAwareOutputSupplier. The implementation might try to detect the mime-type of the file, and pass that information to the TypeAwareOutputSupplier. Note: this method is not paged.

Parameters
repository the repository to use
objectId the identifier for a point in the repository. Can be a changeset id, a branch or a tag
path the path to the file
outputStreamSupplier an object that can return an OutputStream given a mime-type
Throws
ServiceException if the stream operation fails.