README.md 2.43 KB
Newer Older
Matija Obreza's avatar
Matija Obreza committed
1 2
# Genesys PGR - Java API Client

Matija Obreza's avatar
Matija Obreza committed
3
**genesys-client-api** library aims to ease integration of your existing accession management software in Java with [Genesys PGR portal](https://www.genesys-pgr.org "Visit Genesys PGR").
Matija Obreza's avatar
Matija Obreza committed
4

Matija Obreza's avatar
README  
Matija Obreza committed
5 6 7 8
## Using the API client

### Initializing the client

Matija Obreza's avatar
Matija Obreza committed
9 10 11 12 13 14 15 16
```java
GenesysClient genesysClient = new GenesysClient();
// Set the Scribe OAuth API implementation
genesysClient.setGenesysApi(new GenesysApi());
// Set server URL
genesysClient.setBaseUrl("https://www.genesys-pgr.org");
// Specify clientKey, secret and the callback URL as registered on the server
genesysClient.connect(clientKey, clientSecret, callbackUrl);
Matija Obreza's avatar
README  
Matija Obreza committed
17

Matija Obreza's avatar
Matija Obreza committed
18 19 20 21 22 23 24 25
// Ask end user to navigate to Genesys server and authorize your access to their resources
String authorizationUrl = genesysClient.getAuthorizationUrl(GenesysClient.EMPTY_TOKEN);
// Open this URL in browser, login and allow us to access your resources and come back with the code
String verifierCode = null; // whatever user provides
genesysClient.authenticate(verifierCode);

// Test it with /me
genesysClient.me();
Matija Obreza's avatar
README  
Matija Obreza committed
26

Matija Obreza's avatar
Matija Obreza committed
27 28 29 30
// Tokens are now accessible. The refreshToken must be **safely** stored for future use.
```

Updating data:
Matija Obreza's avatar
README  
Matija Obreza committed
31

Matija Obreza's avatar
Matija Obreza committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
```java
List<AccessionJson> accns=new ArrayList<AccessionJson>();

// In a loop, create, fill and add entries to the list
{
    AccessionJson accn=new AccessionJson();
    accns.add(accn);
}

// Once the appropriate batch size is reached
// (good size is 10 or 20 entries)
// send to server
try {
    genesysClient.updateAccessions(instCode, accns);
} catch (....) {
    // handle exceptions
}
```
Matija Obreza's avatar
README  
Matija Obreza committed
50 51

## How to reference `genesys-client-api`
Matija Obreza's avatar
Matija Obreza committed
52

Matija Obreza's avatar
Matija Obreza committed
53 54 55 56
```xml
<dependency>
	<groupId>org.genesys-pgr</groupId>
	<artifactId>genesys-client-api</artifactId>
57
	<version>1.1</version>
Matija Obreza's avatar
Matija Obreza committed
58 59
</dependency>
```
Matija Obreza's avatar
Matija Obreza committed
60

Matija Obreza's avatar
Matija Obreza committed
61
Or for the development version:
Matija Obreza's avatar
Matija Obreza committed
62

Matija Obreza's avatar
Matija Obreza committed
63 64 65 66
```xml
<dependency>
	<groupId>org.genesys-pgr</groupId>
	<artifactId>genesys-client-api</artifactId>
67
	<version>1.2-SNAPSHOT</version>
Matija Obreza's avatar
Matija Obreza committed
68 69
</dependency>
```
Matija Obreza's avatar
Matija Obreza committed
70

Matija Obreza's avatar
Matija Obreza committed
71
### Your copy of the library
Matija Obreza's avatar
Matija Obreza committed
72

Matija Obreza's avatar
Matija Obreza committed
73 74 75
- In Eclipse, clone the `genesys-client-api` repository into a new project
- Right-click on the `genesys-client-api` project and select Maven ... Install.
- This will install the current version of the library into your **local** maven repository
Matija Obreza's avatar
Matija Obreza committed
76

Matija Obreza's avatar
Matija Obreza committed
77
### Your new project
Matija Obreza's avatar
Matija Obreza committed
78

Matija Obreza's avatar
Matija Obreza committed
79 80 81 82
- Create a new Maven project in Eclipse, if starting from scratch
- Add dependency on `org.genesys-pgr:genesys-client-api` artefact to your `pom.xml`
- Create your integration project
- Contact helpdesk@genesys-pgr.org for assistance if required