Nesstar Public API

Using the Nesstar public API to build applications to harness/use data stored in a Nesstar server

It is possible to build custom applications to harness or to do tailor made operations on the rich metadata stored in a Nesstar server. The Nesstar team has built a public API for this purpose. The first stable version of Nesstar API has been release. However, it is extended with new functionality on a regular basis. The API also provides basic data support.

To get this API and its dependencies, just list it as a dependency in your projects pom file. We currently have only published the jars to our own maven repository, so you'll need to tell maven about that as well.

Getting started

Let's say you want to build a metadata harvester using the Nesstar public API. Your pom file could look something like this:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <repositories>
    <repository>
       <id>Nesstar</id>
       <name>Nesstar Maven Repository</name>
       <url>http://nesstar-dev.nsd.uib.no/nexus/content/groups/public/</url>
    </repository>
  </repositories>
  <modelVersion>4.0.0</modelVersion>
  <packaging>jar</packaging>
  <groupId>org.foo.bar</groupId>
  <artifactId>nesstar_harvester</artifactId>
  <version>1.0-SNAPSHOT</version>
  <dependencies>
    <dependency>
       <groupId>com.nesstar</groupId>
       <artifactId>nesstar_public_api</artifactId>
       <version>0.1</version>
    </dependency>
  </dependencies>
</project>
   

Documentation

The javadocs for the Nesstar public API is served up by the maven repository. This means that your IDE should be able to automatically download and display updated documentation. If you would rather download the javadocs yourself, you can find them at the maven repository.

Example

The following code connects to a Nesstar server running on http://nesstar-demo.nsd.uib.no, fetches a list of all studies on this server and dumps them to the console. Put in your own values for serverURL and serverPort and this should be a nice starting point for a proper application.

import com.nesstar.api.*;
import java.io.IOException;

public final class NesstarStudyLister {
  private NesstarDB nesstarDB;
  private Server server;

  public NesstarStudyLister(String serverURL, int serverPort) throws IOException {
    nesstarDB = NesstarDBFactory.getInstance();
    server = nesstarDB.getServer(serverURL, serverPort);
  } 
  
  public void listStudies() throws NotAuthorizedException {
    NesstarList <Study> allStudies = server.getStudies();
    for (Study study : allStudies) { 
      System.out.println(study.getLabel());
    } 
  } 
  
  public static void main (String [] args) throws NotAuthorizedException {
    NesstarStudyLister instance;                
    String serverURL = "nesstar-demo.nsd.uib.no";
    int serverPort = 80;
    
    try {
      instance = new NesstarStudyLister(serverURL, serverPort);  
      instance.listStudies();
    } catch (IOException ioe) {
      System.err.println("Error: " + ioe);
    } 
  } 
} 
   

All the files related to the example above including customized maven pom file & project files for Eclipse are available in a zip file for download.