-
Notifications
You must be signed in to change notification settings - Fork 779
Annotation API #3056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Annotation API #3056
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,31 @@ OpenGrok RESTful API documentation. The following endpoints are accessible under | |
|
||
Besides `/suggester` and `/search` endpoints, everything is accessible from `localhost` only. | ||
|
||
## Annotation [/annotation{?path}] | ||
|
||
### Get annotation for a file [GET] | ||
|
||
+ Parameters | ||
+ path (string) - path of file, relative to source root | ||
|
||
+ Response 200 (application/json) | ||
+ Body | ||
|
||
[ | ||
{ | ||
"revision": "c55d5891", | ||
"author": "Adam Hornáček", | ||
"description": "changeset: c55d5891\nsummary: Rewrite README.txt to use markdown syntax\nuser: Adam Hornáček <[email protected]>\ndate: Wed Aug 30 17:42:12 CEST 2017", | ||
"version": "1/15" | ||
}, | ||
{ | ||
"revision": "5e0c6b22", | ||
"author": "Vladimir Kotal", | ||
"description": "changeset: 5e0c6b22\nsummary: bump year\nuser: Vladimir Kotal <[email protected]>\ndate: Thu Jul 18 14:43:01 CEST 2019", | ||
"version": "14/15" | ||
} | ||
] | ||
|
||
## Authorization framework reload [/configuration/authorization/reload] | ||
|
||
### reloads authorization framework [POST] | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
opengrok-indexer/src/main/java/org/opengrok/indexer/util/HeadHandler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* CDDL HEADER START | ||
* | ||
* The contents of this file are subject to the terms of the | ||
* Common Development and Distribution License (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* | ||
* See LICENSE.txt included in this distribution for the specific | ||
* language governing permissions and limitations under the License. | ||
* | ||
* When distributing Covered Code, include this CDDL HEADER in each | ||
* file and include the License file at LICENSE.txt. | ||
* If applicable, add the following below this CDDL HEADER, with the | ||
* fields enclosed by brackets "[]" replaced with your own identifying | ||
* information: Portions Copyright [yyyy] [name of copyright owner] | ||
* | ||
* CDDL HEADER END | ||
*/ | ||
|
||
/* | ||
* Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. | ||
*/ | ||
|
||
package org.opengrok.indexer.util; | ||
|
||
import java.io.BufferedInputStream; | ||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.nio.charset.Charset; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* The purpose of this class is to provide {@code StreamHandler} that limits the output | ||
* to specified number of lines. Compared to {@code SpoolHandler} it consumes | ||
* limited amount of heap. | ||
*/ | ||
public class HeadHandler implements Executor.StreamHandler { | ||
private final int maxLines; | ||
|
||
private final List<String> lines = new ArrayList<>(); | ||
private final Charset charset; | ||
|
||
private static final int bufferedReaderSize = 200; | ||
|
||
/** | ||
* Charset of the underlying reader is set to UTF-8. | ||
* @param maxLines maximum number of lines to store | ||
*/ | ||
public HeadHandler(int maxLines) { | ||
this.maxLines = maxLines; | ||
this.charset = StandardCharsets.UTF_8; | ||
} | ||
|
||
/** | ||
* @param maxLines maximum number of lines to store | ||
* @param charset character set | ||
*/ | ||
public HeadHandler(int maxLines, Charset charset) { | ||
this.maxLines = maxLines; | ||
this.charset = charset; | ||
} | ||
|
||
/** | ||
* @return number of lines read | ||
*/ | ||
public int count() { | ||
return lines.size(); | ||
} | ||
|
||
/** | ||
* @param index index | ||
* @return line at given index. Will be non {@code null} for valid index. | ||
*/ | ||
public String get(int index) { | ||
return lines.get(index); | ||
} | ||
|
||
// for testing | ||
static int getBufferedReaderSize() { | ||
return bufferedReaderSize; | ||
} | ||
|
||
@Override | ||
public void processStream(InputStream input) throws IOException { | ||
try (BufferedInputStream bufStream = new BufferedInputStream(input); | ||
BufferedReader reader = new BufferedReader(new InputStreamReader(bufStream, this.charset), | ||
bufferedReaderSize)) { | ||
int lineNum = 0; | ||
while (lineNum < maxLines) { | ||
String line = reader.readLine(); | ||
if (line == null) { // EOF | ||
return; | ||
} | ||
lines.add(line); | ||
lineNum++; | ||
} | ||
|
||
// Read and forget the rest. | ||
byte[] buf = new byte[1024]; | ||
while ((bufStream.read(buf)) != -1) { | ||
; | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.