Skip to content

file content/genre API #3050

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 22 commits into from
Feb 26, 2020
Merged

file content/genre API #3050

merged 22 commits into from
Feb 26, 2020

Conversation

vladak
Copy link
Member

@vladak vladak commented Feb 24, 2020

This change implements API endpoints for retrieving file content and genre. There is no paging support.

I refactored the authorization introduced for the history API endpoint so that it can be used via annotations.

Demo:

$ curl -D headers -s -X GET 'http://localhost:8080/source/api/v1/file/content?path=opengrok/dev/checkstyle/fileheader.txt' | jq
[
  {
    "line": "/*",
    "number": 1
  },
  {
    "line": " * CDDL HEADER START",
    "number": 2
  },
  {
    "line": " *",
    "number": 3
  },
  {
    "line": " * The contents of this file are subject to the terms of the",
    "number": 4
  },
  {
    "line": " * Common Development and Distribution License (the \"License\").",
    "number": 5
  },
  {
    "line": " * You may not use this file except in compliance with the License.",
    "number": 6
  },
  {
    "line": " *",
    "number": 7
  },
  {
    "line": " * See LICENSE.txt included in this distribution for the specific",
    "number": 8
  },
  {
    "line": " * language governing permissions and limitations under the License.",
    "number": 9
  },
  {
    "line": " *",
    "number": 10
  },
  {
    "line": " * When distributing Covered Code, include this CDDL HEADER in each",
    "number": 11
  },
  {
    "line": " * file and include the License file at LICENSE.txt.",
    "number": 12
  },
  {
    "line": " * If applicable, add the following below this CDDL HEADER, with the",
    "number": 13
  },
  {
    "line": " * fields enclosed by brackets \"[]\" replaced with your own identifying",
    "number": 14
  },
  {
    "line": " * information: Portions Copyright [yyyy] [name of copyright owner]",
    "number": 15
  },
  {
    "line": " *",
    "number": 16
  },
  {
    "line": " * CDDL HEADER END",
    "number": 17
  },
  {
    "line": " */",
    "number": 18
  },
  {
    "line": "",
    "number": 19
  }
]
$ curl -D headers -s -X GET 'http://localhost:8080/source/api/v1/file/genre?path=opengrok/dev/checkstyle/fileheader.txt'
PLAIN
$ curl --head -s -X GET 'http://localhost:8080/source/api/v1/file/content?path=opengrok/testdata/sources/java/main.jar' 
HTTP/1.1 406 
Set-Cookie: JSESSIONID=A9E0888D024C309CBAD44C507A7BBAB0; Path=/source; HttpOnly
Content-Type: text/html;charset=utf-8
Content-Language: en
Content-Length: 1212
Date: Mon, 24 Feb 2020 11:17:16 GMT

$ curl -s -X GET 'http://localhost:8080/source/api/v1/file/genre?path=opengrok/testdata/sources/java/main.jar' 
XREFABLE

Copy link
Contributor

@tulinkry tulinkry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you test with curl also on escaped path parameter? file/content?path=opengrok%2Fsrc%2Fmain%2Ffile

@vladak
Copy link
Member Author

vladak commented Feb 25, 2020

Could you test with curl also on escaped path parameter? file/content?path=opengrok%2Fsrc%2Fmain%2Ffile

works fine.

Copy link
Contributor

@idodeclare idodeclare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vladak vladak merged commit d7648fc into oracle:master Feb 26, 2020
@vladak vladak deleted the filecontent_API branch February 26, 2020 13:49
@tulinkry tulinkry mentioned this pull request Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants