public interface ContentService
Modifier and Type | Method and Description |
---|---|
Commit |
editFile(EditFileRequest request)
Adds a new file or updates the content of an existing file.
|
Page<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. |
long |
getMaxUploadSize()
Retrieves the maximum size, in bytes, for uploading content.
|
ContentTreeNode.Type |
getType(Repository repository,
String objectId,
String path) |
void |
streamArchive(ArchiveRequest request,
TypeAwareOutputSupplier outputSupplier)
Streams an archive of the specified repository at the specified commit, optionally filtering by path.
|
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 supplier)
Streams the raw content of the file into an OutputStream obtained from the given TypeAwareOutputSupplier.
|
void |
streamPatch(PatchRequest request,
TypeAwareOutputSupplier outputSupplier)
Streams a patch for a given commit or commit range.
|
Commit editFile(@Nonnull EditFileRequest request) throws ServiceException
request
- details for adding/updating a fileEditFileFailedException
- if the edit operation failsFeatureUnsupportedScmException
- if the SCM for the specified repository does not support editing filesFileAlreadyExistsException
- if a file or path exists at the given path on the tip of the branch and
no source commit was givenFileContentUnmodifiedException
- if the given content is identical to the content of the file at the tip
of the given branchRepositoryHookVetoedException
- if one or more hooks canceled the file edit
FileOutOfDateException
- if the given file has been changed since the source commit occurredFileTranscodingException
- if the input content could not be transcoded to the existing
file's encodingNoSuchBranchException
- if the given branch does not exist in the repositoryNoSuchPathException
- if the file is not present in the source commit or at the tip of
the given branchServiceException
@Nonnull Page<Blame> getBlame(@Nonnull Repository repository, @Nonnull String objectId, @Nonnull String path, @Nonnull PageRequest pageRequest)
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:
repository
- the repository to useobjectId
- an identifier (name or hash) for the branch, tag or commit at which blame should be retrievedpath
- the path for which blame should be retrievedpageRequest
- defines the set of lines within the file for which blame should be generatedBlame
objects, ordered by the line at which they start in the filelong getMaxUploadSize()
@Nonnull ContentTreeNode.Type getType(@Nonnull Repository repository, @Nonnull String objectId, @Nullable String path)
void streamArchive(@Nonnull ArchiveRequest request, @Nonnull TypeAwareOutputSupplier outputSupplier)
request
- describes the commit to archive, the format to archive it in, and the repository to
archive it fromoutputSupplier
- a supplier which, when given the archive content type, will provide an output streamvoid streamDirectory(@Nonnull Repository repository, @Nonnull String objectId, @Nullable String path, boolean recursive, @Nonnull ContentTreeCallback callback, @Nonnull PageRequest pageRequest)
callback
.
The objectId provided here can be several things:
The listing is provided to the caller via a callback mechanism - the supplied ContentTreeCallback
parameter. This method promises to call ContentTreeCallback.onStart(ContentTreeContext)
on the supplied instance
once followed by zero or more ContentTreeCallback.onTreeNode(ContentTreeNode)
for each path in the directory and finally followed by a ContentTreeCallback.onEnd(ContentTreeSummary)
.
When recursive
is false
, file sizes
will be populated and subdirectories
below the specified path
will be returned. For recursive listings, subdirectories and file sizes are
omitted to improve performance.
repository
- the repository to useobjectId
- an identifier (name or hash) for the branch, tag or commit at which blame should be retrievedpath
- the path for which blame should be retrievedrecursive
- whether the directory listing should be recursivecallback
- the callback instance to call as the page starts, the children nodes are encountered and as the page endspageRequest
- defines the range of children in the listing the caller is interested invoid streamFile(@Nonnull Repository repository, @Nonnull String objectId, @Nonnull String path, @Nonnull PageRequest pageRequest, boolean withBlame, @Nonnull FileContentCallback fileContentCallback) throws ServiceException
repository
- the repositoryobjectId
- the identifier for a point in the repository. Can be a commit ID, a branch or a tagpath
- the path to the filepageRequest
- the page request for the start and limit of the pagewithBlame
- true
to include blame information for content; otherwise, false
to omit itfileContentCallback
- the callback for receiving lines and page informationServiceException
- if the stream file operation failsvoid streamFile(@Nonnull Repository repository, @Nonnull String objectId, @Nonnull String path, @Nonnull TypeAwareOutputSupplier supplier) throws ServiceException
repository
- the repository to useobjectId
- the identifier for a point in the repository. Can be a commit ID, branch or tagpath
- the path to the filesupplier
- an object that can return an OutputStream given a mime-typeServiceException
- if the stream operation fails.void streamPatch(@Nonnull PatchRequest request, @Nonnull TypeAwareOutputSupplier outputSupplier)
request
- describes the commit and repository for which to generate the patchoutputSupplier
- a supplier which will provide an output streamCopyright © 2019 Atlassian. All rights reserved.