Rename 'proceedFrom' to 'offset'

This commit is contained in:
René Pfeuffer
2020-02-19 09:23:23 +01:00
parent 6b3f36e7ea
commit fe1591171d
14 changed files with 51 additions and 51 deletions

View File

@@ -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();

View File

@@ -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) {

View File

@@ -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));
}