README.md 2.44 KB
Newer Older
Matija Obreza's avatar
Matija Obreza committed
1 2 3 4 5 6

# Genesys PGR - Java API Client

**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
README  
Matija Obreza committed
7 8 9 10 11 12
## Using the API client

### Initializing the client


	GenesysClient genesysClient = new GenesysClient();
Matija Obreza's avatar
Matija Obreza committed
13 14
	// Set the Scribe OAuth API implementation
	genesysClient.setGenesysApi(new GenesysApi());
Matija Obreza's avatar
README  
Matija Obreza committed
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
	// 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);

	// 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();
	
	// Tokens are now accessible. The refreshToken must be **safely** stored for future use.
	
Updating data:

	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 25 or 50 entries)
	// send to server
	try {
		genesysClient.updateAccessions(instCode, accns);
	} catch (....) {
		// handle exceptions
	}


## 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 57
The genesys-client-api snapshots are published on [OSSRH](https://oss.sonatype.org/content/groups/public).

	<dependency>
		<groupId>org.genesys-pgr</groupId>
		<artifactId>genesys-client-api</artifactId>
Matija Obreza's avatar
README  
Matija Obreza committed
58
		<version>0.0.4-SNAPSHOT</version>
Matija Obreza's avatar
Matija Obreza committed
59
	</dependency>
Matija Obreza's avatar
Matija Obreza committed
60 61 62 63 64 65 66 67 68 69

### Your copy of the library

* 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

### Your new project

* Create a new Maven project in Eclipse, if starting from scratch
Matija Obreza's avatar
Matija Obreza committed
70 71 72 73 74 75 76 77
* Add dependency on org.genesys-pgr:genesys-client-api artefact to your `pom.xml`

	<dependency>
		<groupId>org.genesys-pgr</groupId>
		<artifactId>genesys-client-api</artifactId>
		<version>0.0.3-SNAPSHOT</version>
	</dependency>

Matija Obreza's avatar
Matija Obreza committed
78
* Create your integration project