Commit 1207f049 authored by Matija Obreza's avatar Matija Obreza

Merge branch '465-document-migration-from-api-v0-to-v1' into 'master'

Resolve "Document migration from API v0 to v1"

Closes #465

See merge request genesys-pgr/genesys-server!451
parents df889fee da6a5802
This diff is collapsed.
...@@ -82,7 +82,7 @@ To add images to an accession you must first upload the image to Genesys with a ...@@ -82,7 +82,7 @@ To add images to an accession you must first upload the image to Genesys with a
[source,bash] [source,bash]
---- ----
$ curl 'https://sandbox.genesys-pgr.org/api/v0/img/XXX001/acn/ACC001/?originalFilename=IMG0012.jpg' -i -X PUT -H 'Content-Type: image/jpeg' -d @path/to/IMG0012.jpg $ curl 'https://api.sandbox.genesys-pgr.org/api/v0/img/XXX001/acn/ACC001/?originalFilename=IMG0012.jpg' -i -X PUT -H 'Content-Type: image/jpeg' -d @path/to/IMG0012.jpg
---- ----
The request `Content-Type` header must be set to the image content type (e.g. The request `Content-Type` header must be set to the image content type (e.g.
......
...@@ -53,7 +53,7 @@ initiated by opening the authorization URL in a browser (please substitute `CLIE ...@@ -53,7 +53,7 @@ initiated by opening the authorization URL in a browser (please substitute `CLIE
with valid data): with valid data):
---- ----
https://sandbox.genesys-pgr.org/oauth/authorize?client_id=CLIENTID&client_secret=SECRET&response_type=code&redirect_uri=oob&scope=write https://api.sandbox.genesys-pgr.org/oauth/authorize?client_id=CLIENTID&client_secret=SECRET&response_type=code&redirect_uri=oob&scope=write
---- ----
The server will prompt you to authorize the access to your protected resources on Genesys. The server will prompt you to authorize the access to your protected resources on Genesys.
...@@ -61,7 +61,7 @@ After your confirmation, the server will present an authorization code (which wi ...@@ -61,7 +61,7 @@ After your confirmation, the server will present an authorization code (which wi
From a shell, execute the following `curl` command, with your authorization code in place of `THECODE`: From a shell, execute the following `curl` command, with your authorization code in place of `THECODE`:
---- ----
$ curl 'https://sandbox.genesys-pgr.org/oauth/token?grant_type=authorization_code&client_id=CLIENTID&client_secret=SECRET&redirect_uri=oob&code=THECODE' $ curl 'https://api.sandbox.genesys-pgr.org/oauth/token?grant_type=authorization_code&client_id=CLIENTID&client_secret=SECRET&redirect_uri=oob&code=THECODE'
---- ----
==== Username and password ==== Username and password
...@@ -71,7 +71,7 @@ applications) where the user's password will not be captured or stored -- i.e. ...@@ -71,7 +71,7 @@ applications) where the user's password will not be captured or stored -- i.e.
it will be used once. A password grant can be used as follows: it will be used once. A password grant can be used as follows:
---- ----
$ curl 'https://sandbox.genesys-pgr.org/oauth/token' --data 'scope=write+read&grant_type=password&username=USERNAME&password=PASSWORD&client_id=CLIENT_ID&client_secret=CLIENT_SECRET' $ curl 'https://api.sandbox.genesys-pgr.org/oauth/token' --data 'scope=write+read&grant_type=password&username=USERNAME&password=PASSWORD&client_id=CLIENT_ID&client_secret=CLIENT_SECRET'
---- ----
==== Client credentials ==== Client credentials
...@@ -93,7 +93,7 @@ To obtain a valid (but short-lived) access token, a simple `POST` request to ...@@ -93,7 +93,7 @@ To obtain a valid (but short-lived) access token, a simple `POST` request to
Genesys is required: Genesys is required:
---- ----
$ curl -X POST 'https://sandbox.genesys-pgr.org/oauth/token?grant_type=client_credentials&client_id=CLIENTID&client_secret=SECRET&redirect_uri=oob' $ curl -X POST 'https://api.sandbox.genesys-pgr.org/oauth/token?grant_type=client_credentials&client_id=CLIENTID&client_secret=SECRET&redirect_uri=oob'
---- ----
This type of grant takes out the *user* authentication and authenticates the This type of grant takes out the *user* authentication and authenticates the
...@@ -132,7 +132,7 @@ or by including it in the request URL as a query string parameter: ...@@ -132,7 +132,7 @@ or by including it in the request URL as a query string parameter:
[source,bash] [source,bash]
---- ----
$ curl 'https://sandbox.genesys-pgr.org/api/v0/me?access_token=OAUTH-ACCESS-TOKEN' $ curl 'https://api.sandbox.genesys-pgr.org/api/v0/me?access_token=OAUTH-ACCESS-TOKEN'
---- ----
=== Using the refresh token === Using the refresh token
...@@ -156,7 +156,7 @@ The refresh token must be securely persisted and can be used to request a new ac ...@@ -156,7 +156,7 @@ The refresh token must be securely persisted and can be used to request a new ac
when the previous access token expires: when the previous access token expires:
---- ----
$ curl 'https://sandbox.genesys-pgr.org/oauth/token?grant_type=refresh_token&client_id=CLIENTID&client_secret=SECRET&redirect_uri=oob&refresh_token=OAUTH-REFRESH-TOKEN' $ curl 'https://api.sandbox.genesys-pgr.org/oauth/token?grant_type=refresh_token&client_id=CLIENTID&client_secret=SECRET&redirect_uri=oob&refresh_token=OAUTH-REFRESH-TOKEN'
---- ----
......
...@@ -13,9 +13,9 @@ December 2015: Documentation commit {buildNumber} ...@@ -13,9 +13,9 @@ December 2015: Documentation commit {buildNumber}
All API access is over HTTPS, and accessed from the https://www.genesys-pgr.org domain or All API access is over HTTPS, and accessed from the https://api.genesys-pgr.org domain or
through https://sandbox.genesys-pgr.org for testing purposes. All data is sent and received as JSON. through https://api.sandbox.genesys-pgr.org for testing purposes. All data is sent and received as JSON.
In this manual, all URLs are pointing to the Genesys sandbox environment at https://sandbox.genesys-pgr.org. In this manual, all URLs are pointing to the Genesys sandbox environment at https://api.sandbox.genesys-pgr.org.
include::api/security.adoc[] include::api/security.adoc[]
......
...@@ -14,9 +14,9 @@ March 2017: Documentation commit {buildNumber} ...@@ -14,9 +14,9 @@ March 2017: Documentation commit {buildNumber}
Genesys implements basic <<brapiv1, BrAPI v1 specification>> Genesys implements basic <<brapiv1, BrAPI v1 specification>>
All API access is over HTTPS, and accessed from the https://www.genesys-pgr.org domain or All API access is over HTTPS, and accessed from the https://api.genesys-pgr.org domain or
through https://sandbox.genesys-pgr.org for testing purposes. All data is sent and received as JSON. through https://api.sandbox.genesys-pgr.org for testing purposes. All data is sent and received as JSON.
In this manual, all URLs are pointing to the Genesys sandbox environment at https://sandbox.genesys-pgr.org. In this manual, all URLs are pointing to the Genesys sandbox environment at https://api.sandbox.genesys-pgr.org.
include::brapi/auth.adoc[] include::brapi/auth.adoc[]
......
...@@ -10,7 +10,8 @@ Authorization: Bearer <TOKEN> ...@@ -10,7 +10,8 @@ Authorization: Bearer <TOKEN>
=== Login === Login
Genesys does not support the `/login` endpoint. Genesys does not support the `/login` endpoint. You must obtain the OAuth access token as described
in Genesys API manual.
=== Logout === Logout
......
...@@ -34,7 +34,7 @@ Genesys returns the standard BrAPI Germplasm response: ...@@ -34,7 +34,7 @@ Genesys returns the standard BrAPI Germplasm response:
}, },
"result": <1> [{ "result": <1> [{
"defaultDisplayName": "DJUG 16", "defaultDisplayName": "DJUG 16",
"germplasmPUI": null, "germplasmPUI": "10.0000/ABCD*",
"pedigree": null, "pedigree": null,
"seedSource": null, "seedSource": null,
"synonyms": ["DJUG 16"], "synonyms": ["DJUG 16"],
......
...@@ -46,6 +46,7 @@ public class BrAPIServiceImpl implements BrAPIService { ...@@ -46,6 +46,7 @@ public class BrAPIServiceImpl implements BrAPIService {
Germplasm g = new Germplasm(); Germplasm g = new Germplasm();
g.setUuid(accession.getUuid()); g.setUuid(accession.getUuid());
g.setGermplasmPUI(accession.getDoi());
g.setAcceNumb(accession.getAccessionNumber()); g.setAcceNumb(accession.getAccessionNumber());
g.setDefaultDisplayName(accession.getAccessionNumber()); g.setDefaultDisplayName(accession.getAccessionNumber());
g.setAcceName(accession.getAccessionNumber()); g.setAcceName(accession.getAccessionNumber());
......
...@@ -138,7 +138,7 @@ public class AccessionControllerTest extends AbstractApiTest { ...@@ -138,7 +138,7 @@ public class AccessionControllerTest extends AbstractApiTest {
public void beforeTest() throws Exception { public void beforeTest() throws Exception {
super.beforeTest(); super.beforeTest();
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(documentationConfiguration(this.restDocumentation).uris().withScheme("https").withHost( mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(documentationConfiguration(this.restDocumentation).uris().withScheme("https").withHost(
"sandbox.genesys-pgr.org").withPort(443)).build(); "api.sandbox.genesys-pgr.org").withPort(443)).build();
institute = new FaoInstitute(); institute = new FaoInstitute();
institute.setCode("INS001"); institute.setCode("INS001");
institute.setFullName("An institute"); institute.setFullName("An institute");
......
...@@ -92,7 +92,7 @@ public class CropsControllerTest extends AbstractApiTest { ...@@ -92,7 +92,7 @@ public class CropsControllerTest extends AbstractApiTest {
super.beforeTest(); super.beforeTest();
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(documentationConfiguration(this.restDocumentation).uris() mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(documentationConfiguration(this.restDocumentation).uris()
.withScheme("https") .withScheme("https")
.withHost("sandbox.genesys-pgr.org") .withHost("api.sandbox.genesys-pgr.org")
.withPort(443)).build(); .withPort(443)).build();
crop = cropService.addCrop("maize", "Maize", "Crop description in EN", null); crop = cropService.addCrop("maize", "Maize", "Crop description in EN", null);
......
...@@ -84,7 +84,7 @@ public class ApiCropsTest extends AbstractApiTest { ...@@ -84,7 +84,7 @@ public class ApiCropsTest extends AbstractApiTest {
@Before @Before
public void setUp() { public void setUp() {
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext) mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext)
.apply(documentationConfiguration(this.restDocumentation).uris().withScheme("https").withHost("sandbox.genesys-pgr.org").withPort(443)).build(); .apply(documentationConfiguration(this.restDocumentation).uris().withScheme("https").withHost("api.sandbox.genesys-pgr.org").withPort(443)).build();
crop = cropService.addCrop("maize", "Maize", "Crop description in EN", null); crop = cropService.addCrop("maize", "Maize", "Crop description in EN", null);
assertThat(crop.getId(), greaterThan(0l)); assertThat(crop.getId(), greaterThan(0l));
......
...@@ -117,7 +117,7 @@ public class ApiImagesDocsTest extends AbstractApiTest { ...@@ -117,7 +117,7 @@ public class ApiImagesDocsTest extends AbstractApiTest {
@Before @Before
public void setUp() throws InterruptedException { public void setUp() throws InterruptedException {
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext) mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext)
.apply(documentationConfiguration(this.restDocumentation).uris().withScheme("https").withHost("sandbox.genesys-pgr.org").withPort(443)).build(); .apply(documentationConfiguration(this.restDocumentation).uris().withScheme("https").withHost("api.sandbox.genesys-pgr.org").withPort(443)).build();
List<FaoInstitute> institutes = new ArrayList<>(); List<FaoInstitute> institutes = new ArrayList<>();
institute = new FaoInstitute(); institute = new FaoInstitute();
......
...@@ -72,7 +72,7 @@ public class ApiRequestsDocsTest extends AbstractApiTest { ...@@ -72,7 +72,7 @@ public class ApiRequestsDocsTest extends AbstractApiTest {
@Before @Before
public void setUp() { public void setUp() {
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext) mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext)
.apply(documentationConfiguration(this.restDocumentation).uris().withScheme("https").withHost("sandbox.genesys-pgr.org").withPort(443)).build(); .apply(documentationConfiguration(this.restDocumentation).uris().withScheme("https").withHost("api.sandbox.genesys-pgr.org").withPort(443)).build();
Collection<FaoInstitute> institutes = new ArrayList<>(); Collection<FaoInstitute> institutes = new ArrayList<>();
institute = new FaoInstitute(); institute = new FaoInstitute();
......
...@@ -81,7 +81,7 @@ public class BrAPITest extends AbstractApiTest { ...@@ -81,7 +81,7 @@ public class BrAPITest extends AbstractApiTest {
@Before @Before
public void setUp() { public void setUp() {
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext) mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext)
.apply(documentationConfiguration(this.restDocumentation).uris().withScheme("https").withHost("sandbox.genesys-pgr.org").withPort(443)).build(); .apply(documentationConfiguration(this.restDocumentation).uris().withScheme("https").withHost("api.sandbox.genesys-pgr.org").withPort(443)).build();
crop = cropService.addCrop("maize", "Maize", "Crop description in EN", null); crop = cropService.addCrop("maize", "Maize", "Crop description in EN", null);
assertThat(crop.getId(), greaterThan(0l)); assertThat(crop.getId(), greaterThan(0l));
......
...@@ -135,7 +135,7 @@ public class AccessionControllerTest extends AbstractApiTest { ...@@ -135,7 +135,7 @@ public class AccessionControllerTest extends AbstractApiTest {
public void beforeTest() throws Exception { public void beforeTest() throws Exception {
super.beforeTest(); super.beforeTest();
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(documentationConfiguration(this.restDocumentation).uris().withScheme("https").withHost( mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(documentationConfiguration(this.restDocumentation).uris().withScheme("https").withHost(
"sandbox.genesys-pgr.org").withPort(443)).build(); "api.sandbox.genesys-pgr.org").withPort(443)).build();
institute = new FaoInstitute(); institute = new FaoInstitute();
institute.setCode("INS001"); institute.setCode("INS001");
institute.setFullName("An institute"); institute.setFullName("An institute");
......
...@@ -64,7 +64,7 @@ public class AsciiDocControllerTest extends AbstractApiTest { ...@@ -64,7 +64,7 @@ public class AsciiDocControllerTest extends AbstractApiTest {
/*@formatter:off*/ /*@formatter:off*/
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext) mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext)
.apply(documentationConfiguration(this.restDocumentation) .apply(documentationConfiguration(this.restDocumentation)
.uris().withScheme("https").withHost("sandbox.genesys-pgr.org").withPort(443)) .uris().withScheme("https").withHost("api.sandbox.genesys-pgr.org").withPort(443))
.build(); .build();
/*@formatter:on*/ /*@formatter:on*/
......
...@@ -107,7 +107,7 @@ public class CropsControllerTest extends AbstractApiTest { ...@@ -107,7 +107,7 @@ public class CropsControllerTest extends AbstractApiTest {
super.beforeTest(); super.beforeTest();
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(documentationConfiguration(this.restDocumentation).uris() mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(documentationConfiguration(this.restDocumentation).uris()
.withScheme("https") .withScheme("https")
.withHost("sandbox.genesys-pgr.org") .withHost("api.sandbox.genesys-pgr.org")
.withPort(443)).build(); .withPort(443)).build();
crop = cropService.addCrop("maize", "Maize", "Crop description in EN", null); crop = cropService.addCrop("maize", "Maize", "Crop description in EN", null);
......
...@@ -78,7 +78,7 @@ public class UserRegistrationControllerTest extends AbstractApiTest { ...@@ -78,7 +78,7 @@ public class UserRegistrationControllerTest extends AbstractApiTest {
public void beforeTest() throws Exception { public void beforeTest() throws Exception {
super.beforeTest(); super.beforeTest();
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(documentationConfiguration(this.restDocumentation).uris().withScheme("https").withHost( mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(documentationConfiguration(this.restDocumentation).uris().withScheme("https").withHost(
"sandbox.genesys-pgr.org").withPort(443)).build(); "api.sandbox.genesys-pgr.org").withPort(443)).build();
} }
@Test @Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment