mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-01 19:15:52 +01:00
Rename 'proceedFrom' to 'offset'
This commit is contained in:
@@ -318,12 +318,12 @@ public final class BrowseCommandBuilder
|
||||
/**
|
||||
* Proceed the list from the given number on (zero based).
|
||||
*
|
||||
* @param proceedFrom The number of the entry, the result should start with (zero based).
|
||||
* @param offset The number of the entry, the result should start with (zero based).
|
||||
* All preceding entries will be omitted.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public BrowseCommandBuilder setProceedFrom(int proceedFrom) {
|
||||
request.setProceedFrom(proceedFrom);
|
||||
public BrowseCommandBuilder setOffset(int offset) {
|
||||
request.setOffset(offset);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public final class BrowseCommandRequest extends FileBaseCommandRequest
|
||||
public static final int DEFAULT_REQUEST_LIMIT = 100;
|
||||
|
||||
private static final long serialVersionUID = 7956624623516803183L;
|
||||
private int proceedFrom;
|
||||
private int offset;
|
||||
|
||||
public BrowseCommandRequest() {
|
||||
this(null);
|
||||
@@ -207,12 +207,12 @@ public final class BrowseCommandRequest extends FileBaseCommandRequest
|
||||
/**
|
||||
* Proceed the list from the given number on (zero based).
|
||||
*
|
||||
* @param proceedFrom The number of the entry, the result should start with (zero based).
|
||||
* @param offset The number of the entry, the result should start with (zero based).
|
||||
* All preceding entries will be omitted.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public void setProceedFrom(int proceedFrom) {
|
||||
this.proceedFrom = proceedFrom;
|
||||
public void setOffset(int offset) {
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
@@ -270,8 +270,8 @@ public final class BrowseCommandRequest extends FileBaseCommandRequest
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public int getProceedFrom() {
|
||||
return proceedFrom;
|
||||
public int getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public void updateCache(BrowserResult update) {
|
||||
|
||||
@@ -254,7 +254,7 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
|
||||
private FileObject findChildren(FileObject parent, org.eclipse.jgit.lib.Repository repo, BrowseCommandRequest request, ObjectId revId, TreeWalk treeWalk) throws IOException {
|
||||
List<FileObject> files = Lists.newArrayList();
|
||||
while (treeWalk.next() && ++resultCount <= request.getLimit() + request.getProceedFrom())
|
||||
while (treeWalk.next() && ++resultCount <= request.getLimit() + request.getOffset())
|
||||
{
|
||||
|
||||
FileObject fileObject = createFileObject(repo, request, revId, treeWalk);
|
||||
@@ -263,7 +263,7 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
return fileObject;
|
||||
}
|
||||
|
||||
if (resultCount > request.getProceedFrom()) {
|
||||
if (resultCount > request.getOffset()) {
|
||||
files.add(fileObject);
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
|
||||
parent.setChildren(files);
|
||||
|
||||
if (resultCount > request.getLimit() + request.getProceedFrom()) {
|
||||
if (resultCount > request.getLimit() + request.getOffset()) {
|
||||
parent.setTruncated(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -252,10 +252,10 @@ public class GitBrowseCommandTest extends AbstractGitCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBrowseProceedFrom() throws IOException {
|
||||
public void testBrowseOffset() throws IOException {
|
||||
BrowseCommandRequest request = new BrowseCommandRequest();
|
||||
request.setLimit(2);
|
||||
request.setProceedFrom(2);
|
||||
request.setOffset(2);
|
||||
FileObject root = createCommand()
|
||||
.getBrowserResult(request).getFile();
|
||||
assertNotNull(root);
|
||||
|
||||
@@ -102,7 +102,7 @@ public class HgBrowseCommand extends AbstractCommand implements BrowseCommand
|
||||
}
|
||||
|
||||
cmd.setLimit(request.getLimit());
|
||||
cmd.setProceedFrom(request.getProceedFrom());
|
||||
cmd.setOffset(request.getOffset());
|
||||
|
||||
FileObject file = cmd.execute();
|
||||
return new BrowserResult(c == null? "tip": c.getNode(), revision, file);
|
||||
|
||||
@@ -159,14 +159,14 @@ public class HgFileviewCommand extends AbstractCommand
|
||||
/**
|
||||
* Proceed the list from the given number on (zero based).
|
||||
*
|
||||
* @param proceedFrom The number of the entry, the result should start with (zero based).
|
||||
* @param offset The number of the entry, the result should start with (zero based).
|
||||
* All preceding entries will be omitted.
|
||||
*
|
||||
* @return {@code this}
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public HgFileviewCommand setProceedFrom(int proceedFrom) {
|
||||
cmdAppend("-f", proceedFrom);
|
||||
public HgFileviewCommand setOffset(int offset) {
|
||||
cmdAppend("-o", offset);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ def collect_sub_repositories(revCtx):
|
||||
|
||||
class File_Printer:
|
||||
|
||||
def __init__(self, ui, repo, revCtx, disableLastCommit, transport, limit, proceedFrom):
|
||||
def __init__(self, ui, repo, revCtx, disableLastCommit, transport, limit, offset):
|
||||
self.ui = ui
|
||||
self.repo = repo
|
||||
self.revCtx = revCtx
|
||||
@@ -205,7 +205,7 @@ class File_Printer:
|
||||
self.transport = transport
|
||||
self.result_count = -1
|
||||
self.limit = limit
|
||||
self.proceedFrom = proceedFrom
|
||||
self.offset = offset
|
||||
|
||||
def print_directory(self, path):
|
||||
if self.shouldPrintResult():
|
||||
@@ -247,10 +247,10 @@ class File_Printer:
|
||||
# The first result is the selected path (or root if not specified). This
|
||||
# always has to be printed. Therefore we start counting with -1.
|
||||
self.result_count += 1
|
||||
return self.result_count == 0 or self.proceedFrom < self.result_count <= self.limit + self.proceedFrom
|
||||
return self.result_count == 0 or self.offset < self.result_count <= self.limit + self.offset
|
||||
|
||||
def isTruncated(self):
|
||||
return self.result_count > self.limit + self.proceedFrom
|
||||
return self.result_count > self.limit + self.offset
|
||||
|
||||
def finish(self):
|
||||
if self.isTruncated():
|
||||
@@ -294,14 +294,14 @@ class File_Viewer:
|
||||
('s', 'disableSubRepositoryDetection', False, 'disables detection of sub repositories'),
|
||||
('t', 'transport', False, 'format the output for command server'),
|
||||
('l', 'limit', 1000, 'limit the number of results'),
|
||||
('f', 'proceedFrom', 0, 'proceed from the given result number (zero based)'),
|
||||
('o', 'offset', 0, 'proceed from the given result number (zero based)'),
|
||||
])
|
||||
def fileview(ui, repo, **opts):
|
||||
revCtx = scmutil.revsingle(repo, opts["revision"])
|
||||
subrepos = {}
|
||||
if not opts["disableSubRepositoryDetection"]:
|
||||
subrepos = collect_sub_repositories(revCtx)
|
||||
printer = File_Printer(ui, repo, revCtx, opts["disableLastCommit"], opts["transport"], opts["limit"], opts["proceedFrom"])
|
||||
printer = File_Printer(ui, repo, revCtx, opts["disableLastCommit"], opts["transport"], opts["limit"], opts["offset"])
|
||||
viewer = File_Viewer(revCtx, printer)
|
||||
viewer.recursive = opts["recursive"]
|
||||
viewer.sub_repositories = subrepos
|
||||
|
||||
@@ -195,10 +195,10 @@ public class HgBrowseCommandTest extends AbstractHgCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProceedFrom() throws IOException {
|
||||
public void testOffset() throws IOException {
|
||||
BrowseCommandRequest request = new BrowseCommandRequest();
|
||||
request.setLimit(2);
|
||||
request.setProceedFrom(2);
|
||||
request.setOffset(2);
|
||||
|
||||
BrowserResult result = new HgBrowseCommand(cmdContext, repository).getBrowserResult(request);
|
||||
FileObject root = result.getFile();
|
||||
|
||||
@@ -131,11 +131,11 @@ public class SvnBrowseCommand extends AbstractSvnCommand
|
||||
throws SVNException
|
||||
{
|
||||
Collection<SVNDirEntry> entries = svnRepository.getDir(parent.getPath(), revisionNumber, null, (Collection) null);
|
||||
for (Iterator<SVNDirEntry> iterator = entries.iterator(); resultCount < request.getLimit() + request.getProceedFrom() && iterator.hasNext(); ++resultCount) {
|
||||
for (Iterator<SVNDirEntry> iterator = entries.iterator(); resultCount < request.getLimit() + request.getOffset() && iterator.hasNext(); ++resultCount) {
|
||||
SVNDirEntry entry = iterator.next();
|
||||
FileObject child = createFileObject(request, svnRepository, revisionNumber, entry, basePath);
|
||||
|
||||
if (resultCount >= request.getProceedFrom()) {
|
||||
if (resultCount >= request.getOffset()) {
|
||||
parent.addChild(child);
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public class SvnBrowseCommand extends AbstractSvnCommand
|
||||
traverse(svnRepository, revisionNumber, request, child, createBasePath(child.getPath()));
|
||||
}
|
||||
}
|
||||
if (resultCount >= request.getLimit() + request.getProceedFrom()) {
|
||||
if (resultCount >= request.getLimit() + request.getOffset()) {
|
||||
parent.setTruncated(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,9 +203,9 @@ public class SvnBrowseCommandTest extends AbstractSvnCommandTestBase
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProceedFrom() {
|
||||
public void testOffset() {
|
||||
BrowseCommandRequest request = new BrowseCommandRequest();
|
||||
request.setProceedFrom(1);
|
||||
request.setOffset(1);
|
||||
BrowserResult result = createCommand().getBrowserResult(request);
|
||||
|
||||
assertNotNull(result);
|
||||
|
||||
@@ -129,9 +129,9 @@ class FileTree extends React.Component<Props, State> {
|
||||
baseUrlWithRevision += "/" + encodeURIComponent(tree.revision);
|
||||
}
|
||||
|
||||
const proceedFrom = queryString.parse(location.search).proceedFrom;
|
||||
if (proceedFrom) {
|
||||
baseUrlWithRevision += "?proceedFrom=" + proceedFrom;
|
||||
const offset = queryString.parse(location.search).offset;
|
||||
if (offset) {
|
||||
baseUrlWithRevision += "?offset=" + offset;
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -31,7 +31,7 @@ abstract class BaseFileObjectDtoMapper extends HalAppenderMapper implements Inst
|
||||
abstract SubRepositoryDto mapSubrepository(SubRepository subRepository);
|
||||
|
||||
@ObjectFactory
|
||||
FileObjectDto createDto(@Context NamespaceAndName namespaceAndName, @Context BrowserResult browserResult, @Context Integer proceedFrom, FileObject fileObject) {
|
||||
FileObjectDto createDto(@Context NamespaceAndName namespaceAndName, @Context BrowserResult browserResult, @Context Integer offset, FileObject fileObject) {
|
||||
String path = removeFirstSlash(fileObject.getPath());
|
||||
Links.Builder links = Links.linkingTo();
|
||||
if (fileObject.isDirectory()) {
|
||||
@@ -41,7 +41,7 @@ abstract class BaseFileObjectDtoMapper extends HalAppenderMapper implements Inst
|
||||
links.single(link("history", resourceLinks.fileHistory().self(namespaceAndName.getNamespace(), namespaceAndName.getName(), browserResult.getRevision(), path)));
|
||||
}
|
||||
if (fileObject.isTruncated()) {
|
||||
links.single(link("proceed", resourceLinks.source().content(namespaceAndName.getNamespace(), namespaceAndName.getName(), browserResult.getRevision(), path) + "?proceedFrom=" + (proceedFrom + BrowseCommandRequest.DEFAULT_REQUEST_LIMIT)));
|
||||
links.single(link("proceed", resourceLinks.source().content(namespaceAndName.getNamespace(), namespaceAndName.getName(), browserResult.getRevision(), path) + "?offset=" + (offset + BrowseCommandRequest.DEFAULT_REQUEST_LIMIT)));
|
||||
}
|
||||
|
||||
Embedded.Builder embeddedBuilder = embeddedBuilder();
|
||||
|
||||
@@ -30,8 +30,8 @@ import static de.otto.edison.hal.Link.link;
|
||||
@Mapper
|
||||
public abstract class BrowserResultToFileObjectDtoMapper extends BaseFileObjectDtoMapper {
|
||||
|
||||
FileObjectDto map(BrowserResult browserResult, NamespaceAndName namespaceAndName, int proceedFrom) {
|
||||
FileObjectDto fileObjectDto = fileObjectToDto(browserResult.getFile(), namespaceAndName, browserResult, proceedFrom);
|
||||
FileObjectDto map(BrowserResult browserResult, NamespaceAndName namespaceAndName, int offset) {
|
||||
FileObjectDto fileObjectDto = fileObjectToDto(browserResult.getFile(), namespaceAndName, browserResult, offset);
|
||||
fileObjectDto.setRevision(browserResult.getRevision());
|
||||
|
||||
return fileObjectDto;
|
||||
@@ -40,7 +40,7 @@ public abstract class BrowserResultToFileObjectDtoMapper extends BaseFileObjectD
|
||||
@Mapping(target = "attributes", ignore = true) // We do not map HAL attributes
|
||||
@Mapping(target = "children", qualifiedBy = Children.class)
|
||||
@Children
|
||||
protected abstract FileObjectDto fileObjectToDto(FileObject fileObject, @Context NamespaceAndName namespaceAndName, @Context BrowserResult browserResult, @Context Integer proceedFrom);
|
||||
protected abstract FileObjectDto fileObjectToDto(FileObject fileObject, @Context NamespaceAndName namespaceAndName, @Context BrowserResult browserResult, @Context Integer offset);
|
||||
|
||||
@Override
|
||||
void applyEnrichers(Links.Builder links, Embedded.Builder embeddedBuilder, NamespaceAndName namespaceAndName, BrowserResult browserResult, FileObject fileObject) {
|
||||
|
||||
@@ -35,37 +35,37 @@ public class SourceRootResource {
|
||||
@GET
|
||||
@Produces(VndMediaType.SOURCE)
|
||||
@Path("")
|
||||
public FileObjectDto getAllWithoutRevision(@PathParam("namespace") String namespace, @PathParam("name") String name, @DefaultValue("0") @QueryParam("proceedFrom") int proceedFrom) throws IOException {
|
||||
return getSource(namespace, name, "/", null, proceedFrom);
|
||||
public FileObjectDto getAllWithoutRevision(@PathParam("namespace") String namespace, @PathParam("name") String name, @DefaultValue("0") @QueryParam("offset") int offset) throws IOException {
|
||||
return getSource(namespace, name, "/", null, offset);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Produces(VndMediaType.SOURCE)
|
||||
@Path("{revision}")
|
||||
public FileObjectDto getAll(@PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("revision") String revision, @DefaultValue("0") @QueryParam("proceedFrom") int proceedFrom) throws IOException {
|
||||
return getSource(namespace, name, "/", revision, proceedFrom);
|
||||
public FileObjectDto getAll(@PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("revision") String revision, @DefaultValue("0") @QueryParam("offset") int offset) throws IOException {
|
||||
return getSource(namespace, name, "/", revision, offset);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Produces(VndMediaType.SOURCE)
|
||||
@Path("{revision}/{path: .*}")
|
||||
public FileObjectDto get(@PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("revision") String revision, @PathParam("path") String path, @DefaultValue("0") @QueryParam("proceedFrom") int proceedFrom) throws IOException {
|
||||
return getSource(namespace, name, path, revision, proceedFrom);
|
||||
public FileObjectDto get(@PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("revision") String revision, @PathParam("path") String path, @DefaultValue("0") @QueryParam("offset") int offset) throws IOException {
|
||||
return getSource(namespace, name, path, revision, offset);
|
||||
}
|
||||
|
||||
private FileObjectDto getSource(String namespace, String repoName, String path, String revision, int proceedFrom) throws IOException {
|
||||
private FileObjectDto getSource(String namespace, String repoName, String path, String revision, int offset) throws IOException {
|
||||
NamespaceAndName namespaceAndName = new NamespaceAndName(namespace, repoName);
|
||||
try (RepositoryService repositoryService = serviceFactory.create(namespaceAndName)) {
|
||||
BrowseCommandBuilder browseCommand = repositoryService.getBrowseCommand();
|
||||
browseCommand.setPath(path);
|
||||
browseCommand.setProceedFrom(proceedFrom);
|
||||
browseCommand.setOffset(offset);
|
||||
if (revision != null && !revision.isEmpty()) {
|
||||
browseCommand.setRevision(URLDecoder.decode(revision, "UTF-8"));
|
||||
}
|
||||
BrowserResult browserResult = browseCommand.getBrowserResult();
|
||||
|
||||
if (browserResult != null) {
|
||||
return browserResultToFileObjectDtoMapper.map(browserResult, namespaceAndName, proceedFrom);
|
||||
return browserResultToFileObjectDtoMapper.map(browserResult, namespaceAndName, offset);
|
||||
} else {
|
||||
throw notFound(entity("Source", path).in("Revision", revision).in(namespaceAndName));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user