Giter Site home page Giter Site logo

coralapi's Introduction

Coral API

The CoralAPI should wrap up all the boilerplate CORBA stuff for talking to coral.

Usage

Create a CoralAPI client

import edu.utah.nanofab.coralapi.CoralAPI;
import edu.utah.nanofab.coralapi.resource.Account;
import edu.utah.nanofab.coralapi.resource.Member;
import edu.utah.nanofab.coralapi.resource.Project;
...

String coralUser = "coral";
String configUrl = "http://mycoralhostname/coral/lib/config.jar";

CoralAPI coral = new CoralAPI(coralUser, configUrl);

Create a new coral account

Account a = new Account();
a.setName("New Account");
coral.createNewAccount(a);

Update a Member in the system

To update a members info:

Member member = coral.getMemberByName("johndoe");
member.getFirstName();
member.setEmail("[email protected]");
coral.updateMember(member);

Getting Projects for a Member

To get all of the projects for a member:

Project[] projects = coral.getMemberProjects(member);

Validate Account Credentials

To validate the credentials of a coral account:

boolean validCredentials = coral.authenticate("username", "password");

Closing the CoralAPI

When you're done performing operations, don't forget to close the CoralAPI client:

coral.close()

Installation

This project uses maven for packaging and dependency resolution. Since OpenCoral does not use maven, you will have to package your coral jars and put them into a maven repository. You can do this with the following command (assuming coral installation is in the default location of /usr/local/coral and you are using opencoral version 3.4.9):

for i in $(find /usr/local/coral/lib -name '*jar') ; do
      FILEBASE=$(basename $i .jar);
      mvn install:install-file -Dfile=$i -DgroupId=org.opencoral -DartifactId=opencoral-$FILEBASE  -Dversion=3.4.9 -Dpackaging=jar
done

If you have a docker container running opencoral, you can run the following to copy the jars into host:

for i in idl common client server admin runtime; do
	docker cp opencoral-utah-container:/usr/local/coral/lib/$i.jar /tmp/$i.jar
	mvn install:install-file -Dfile=/tmp/$i.jar -DgroupId=org.opencoral -DartifactId=opencoral-$i  -Dversion=3.4.9 -Dpackaging=jar
done

Also some for the client side:

for i in castor-core castor-xml-schema castor-xml xerces; do
	docker cp opencoral-utah-container:/usr/local/coral/ext/$i.jar /tmp/$i.jar
	mvn install:install-file -Dfile=/tmp/$i.jar -DgroupId=org.opencoral -DartifactId=opencoral-$i  -Dversion=3.4.9 -Dpackaging=jar
done

Once those jars are in your local maven repo (~/.m2/...), you can package this project into a jar with:

mvn package -Dmaven.test.skip=true

Tests are skipped because running the tests requires a specific coral test instance and it could potentially destroy data if run against a live coral instance.

Example Command Line Use

You can see examples of building a command line tool in src/main/java/edu/utah/nanofab/coralapi/examples

For example, to build a command line tool that changes a coral user's password:

mvn exec:java -Dexec.mainClass=edu.utah.nanofab.coralapi.examples.PasswordChange -Dexec.args="coral coral"

or

java -cp target/CoralAPI-0.3.1-SHADED.jar edu.utah.nanofab.coralapi.examples.PasswordChange coral coral

Run a Code Generator to Create Some Decorators:

mvn exec:java -Dexec.mainClass=edu.utah.nanofab.coralapi.codegeneration.CreateRetryDecorator -Dexec.args="src/main/java/edu/utah/nanofab/coralapi/CoralAPI.java" | grep -v '^\[INFO\]' > src/main/java/edu/utah/nanofab/coralapi/CoralAPIRetryDecorator.java

mvn exec:java -Dexec.mainClass=edu.utah.nanofab.coralapi.codegeneration.CreateSynchronizedDecorator -Dexec.args="src/main/java/edu/utah/nanofab/coralapi/CoralAPI.java" | grep -v '^\[INFO\]' > src/main/java/edu/utah/nanofab/coralapi/CoralAPISynchronizedDecorator.java

Reference Material

We have some old code that does similar stuff here

coralapi's People

Contributors

utahdesignprocess avatar saltlakeryan avatar smackers-user avatar jon-whit avatar ufabdyop avatar

Stargazers

Yugang Guo avatar

Watchers

James Cloos avatar  avatar Yugang Guo avatar

Forkers

gcoffee

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.