Differences
This shows you the differences between two versions of the page.
registry [2013/11/04 05:59] icmu20132 |
registry [2017/07/21 03:08] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Registry Service ====== | ||
- | Mobile nodes Registry service, offering a RegistryCoreServer to talk with mobile clients, a Web Console interface to manage nodes with a web browser, and a REST API to exchange JSON data with other servers or clients. | ||
- | The main objective of this service is to provide UUID to label mapping and vice-versa. This way you can map long and near-to-impossible to remember UUID strings to friendly names like an e-mail, a car plate, a proper noun, nickname, username or any other type of label you need. | ||
- | |||
- | ===== Architecture ===== | ||
- | ---- | ||
- | |||
- | * Here is the simple architecture of the Registry service. | ||
- | {{ :: | ||
- | |||
- | ===== Screenshots ===== | ||
- | Web Console Interface screenshots for basic Admin operations. This is a CRUD interface. | ||
- | |||
- | CRUD stands for Create, Retrieve, Update, Delete (as in managing objects/ | ||
- | |||
- | ---- | ||
- | |||
- | * Adding a node. | ||
- | {{ :: | ||
- | |||
- | ---- | ||
- | |||
- | * Editing a node. | ||
- | {{ :: | ||
- | |||
- | ---- | ||
- | |||
- | * Listing nodes. | ||
- | {{ :: | ||
- | |||
- | ===== REST API ===== | ||
- | REST API services HTTP clients and helps them to manage nodes in the database from outside the Java server or client code, by making HTTP calls to predefined service routes. | ||
- | |||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | |||
- | <file bash api-client.sh> | ||
- | #!/bin/bash | ||
- | |||
- | export registry_host=" | ||
- | |||
- | # Create node | ||
- | # POST /api/nodes | ||
- | |||
- | curl \ | ||
- | --header ' | ||
- | --request POST \ | ||
- | --data ' | ||
- | http:// | ||
- | |||
- | # Retrieve node | ||
- | # GET / | ||
- | |||
- | curl \ | ||
- | --request GET \ | ||
- | http:// | ||
- | |||
- | # Nodes list | ||
- | # GET /api/nodes | ||
- | |||
- | curl \ | ||
- | --request GET \ | ||
- | http:// | ||
- | |||
- | # Search nodes | ||
- | # GET / | ||
- | |||
- | curl \ | ||
- | --request GET \ | ||
- | http:// | ||
- | |||
- | # Update node | ||
- | # PUT / | ||
- | |||
- | curl \ | ||
- | --header ' | ||
- | --request PUT \ | ||
- | --data ' | ||
- | http:// | ||
- | |||
- | # Delete node | ||
- | # DELETE / | ||
- | |||
- | curl \ | ||
- | --request DELETE \ | ||
- | http:// | ||
- | </ | ||
- | |||
- | More REST API usage samples can be found in the [[https:// | ||
- | |||
- | ===== CrudLib API ===== | ||
- | CrudLib helps you to manage nodes in the database from inside the core server. | ||
- | |||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | |||
- | <file java SnippetServer.java> | ||
- | // This sample is only a snippet, the complete code for a server can be found in the Registry service repository. | ||
- | |||
- | import crublib.CrudLib; | ||
- | |||
- | CrudLib.addNode(Json.parse(requestMessage.getPayload())); | ||
- | |||
- | CrudLib.getNode(requestMessage.getPayload()); | ||
- | |||
- | CrudLib.lstNodes(); | ||
- | |||
- | CrudLib.srchNodes(requestMessage.getPayload()); | ||
- | |||
- | CrudLib.updNode(requestMessage.getPayload(), | ||
- | |||
- | CrudLib.delNode(requestMessage.getPayload()); | ||
- | </ | ||
- | |||
- | Complete CrudLib usage can be found in the [[https:// | ||
- | |||
- | ===== RequestInfo and ResponseInfo API ===== | ||
- | Handling RequestInfo and ResponseInfo objects any mobile client can interact with the Registry service and call all the methods available in the core server, just like we can do in the REST API or CrudLib. | ||
- | |||
- | RequestInfo and ResponseInfo basically have two attributes: type and payload, both set in the constructor. | ||
- | |||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | |||
- | RequestInfo and ResponseInfo types. | ||
- | |||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | |||
- | <file java SnippetClient.java> | ||
- | // This sample is only a snippet, the complete code for a client can be found in the Registry service repository. | ||
- | |||
- | import modellibrary.RequestInfo; | ||
- | import modellibrary.ResponseInfo; | ||
- | |||
- | public class RegistryCoreClient implements NodeConnectionListener { | ||
- | @Override | ||
- | public void connected(NodeConnection remoteCon) { | ||
- | // REQUEST send | ||
- | JSONObject xresult = new JSONObject(); | ||
- | JSONObject xinfo = new JSONObject(); | ||
- | |||
- | try { | ||
- | xresult.put(" | ||
- | xresult.put(" | ||
- | xinfo.put(" | ||
- | xinfo.put(" | ||
- | xinfo.put(" | ||
- | xinfo.put(" | ||
- | xinfo.put(" | ||
- | xresult.put(" | ||
- | } catch (JSONException e1) { | ||
- | e1.printStackTrace(); | ||
- | } | ||
- | |||
- | ApplicationMessage appMessage4 = new ApplicationMessage(); | ||
- | RequestInfo requestMessage4 = new RequestInfo( | ||
- | appMessage4.getSenderID(), | ||
- | appMessage4.setContentObject(requestMessage4); | ||
- | try { | ||
- | remoteCon.sendMessage(appMessage4); | ||
- | } catch (IOException e) { | ||
- | e.printStackTrace(); | ||
- | } | ||
- | |||
- | ApplicationMessage appMessage1 = new ApplicationMessage(); | ||
- | RequestInfo requestMessage1 = new RequestInfo( | ||
- | appMessage1.getSenderID(), | ||
- | appMessage1.setContentObject(requestMessage1); | ||
- | try { | ||
- | remoteCon.sendMessage(appMessage1); | ||
- | } catch (IOException e) { | ||
- | e.printStackTrace(); | ||
- | } | ||
- | |||
- | ApplicationMessage appMessage2 = new ApplicationMessage(); | ||
- | RequestInfo requestMessage2 = new RequestInfo( | ||
- | appMessage2.getSenderID(), | ||
- | appMessage2.setContentObject(requestMessage2); | ||
- | try { | ||
- | remoteCon.sendMessage(appMessage2); | ||
- | } catch (IOException e) { | ||
- | e.printStackTrace(); | ||
- | } | ||
- | |||
- | ApplicationMessage appMessage3 = new ApplicationMessage(); | ||
- | RequestInfo requestMessage3 = new RequestInfo( | ||
- | appMessage3.getSenderID(), | ||
- | appMessage3.setContentObject(requestMessage3); | ||
- | try { | ||
- | remoteCon.sendMessage(appMessage3); | ||
- | } catch (IOException e) { | ||
- | e.printStackTrace(); | ||
- | } | ||
- | |||
- | ApplicationMessage appMessage5 = new ApplicationMessage(); | ||
- | RequestInfo requestMessage5 = new RequestInfo( | ||
- | appMessage5.getSenderID(), | ||
- | appMessage5.setContentObject(requestMessage5); | ||
- | try { | ||
- | remoteCon.sendMessage(appMessage5); | ||
- | } catch (IOException e) { | ||
- | e.printStackTrace(); | ||
- | } | ||
- | } | ||
- | |||
- | @Override | ||
- | public void newMessageReceived(NodeConnection remoteCon, Message message) { | ||
- | String className = message.getContentObject().getClass() | ||
- | .getCanonicalName(); | ||
- | |||
- | if (className != null) { | ||
- | // RESPONSE recv | ||
- | if (className.equals(ResponseInfo.class.getCanonicalName())) { | ||
- | ResponseInfo responseMessage = (ResponseInfo) Serialization | ||
- | .fromJavaByteStream(message.getContent()); | ||
- | System.out.println(" | ||
- | + responseMessage.getType() + " | payload: " | ||
- | + responseMessage.getPayload()); | ||
- | } else { | ||
- | System.out | ||
- | .println(" | ||
- | + className); | ||
- | } | ||
- | } | ||
- | } | ||
- | } | ||
- | </ | ||
- | |||
- | Complete RequestInfo and ResponseInfo usage sample can be found in the [[https:// | ||
- | |||
- | ===== Trying it out ===== | ||
- | We have made available a VM that is prepared to run Registry services (Core, Web and REST). With just a few commands you will be ready to test the service. You will need: | ||
- | |||
- | * [[https:// | ||
- | * A copy of the [[https:// | ||
- | * Run this: vagrant up; | ||
- | * Wait a few minutes, and you should be set. | ||
- | |||
- | With the automated Vagrant setup all the process of setting up the project, installing the server OS (Linux Ubuntu), installing and configuring dependencies like Java, Play Framework, MySQL, DB migrations/ | ||
- | |||
- | In the [[https:// | ||
- | |||
- | ===== Repository ===== | ||
- | Source code and VM setup are available at [[https:// | ||
- | |||
- | ===== Contact ===== | ||
- | * Rogério Schneider: rschneider@inf.puc-rio.br (Registry server) | ||
- | * André Mac Dowell: andremacdowell@gmail.com (Android Registry client) | ||
- | * Ivan Xavier Araújo de Lima: ivan.xavier@gmail.com (Auth server) |