Skip to content

Commit

Permalink
Work on REST API
Browse files Browse the repository at this point in the history
  • Loading branch information
gwilmer committed Nov 1, 2012
1 parent 2539f37 commit efb072f
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 25 deletions.
Expand Up @@ -9,6 +9,10 @@
import org.jumpmind.symmetric.ISymmetricEngine;
import org.jumpmind.symmetric.web.SymmetricEngineHolder;
import org.jumpmind.symmetric.web.WebConstants;
import org.jumpmind.symmetric.web.rest.model.ChannelStatus;
import org.jumpmind.symmetric.web.rest.model.Engine;
import org.jumpmind.symmetric.web.rest.model.Identity;
import org.jumpmind.symmetric.web.rest.model.NodeStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
Expand All @@ -26,36 +30,50 @@ public class RestService {
@Autowired
ServletContext context;

//TODO: determine error strategy
//TODO: add throws

/**
* Returns the list of engine names that are configured on the node.
* @return Set<{@link Engine> of engine names configured on the node
*/
@RequestMapping(value = "/engine", method = RequestMethod.GET)
@ResponseBody
public final Set<Engine> engine() {
//TODO:implement
//return getSymmetricEngineHolder().getEngines().keySet();
return null;
}

/**
* Returns the identity for the specified engine on the node.
* @param String engine
* @return String the identity of the engine
* @return {@link Identity} of the engine
*/
@RequestMapping(value = "/identity/engines/{engine}", method = RequestMethod.GET)
@RequestMapping(value = "/engine/{engine}/identity", method = RequestMethod.GET)
@ResponseBody
public final String identity(@PathVariable("engine") String engineName) {
ISymmetricEngine engine = getSymmetricEngine(engineName);
return engine.getNodeService().findIdentityNodeId();
public final Identity identity(@PathVariable("engine") String engineName) {
//TODO:implement
//ISymmetricEngine engine = getSymmetricEngine(engineName);
//return engine.getNodeService().findIdentityNodeId();
return null;
}

/**
* Returns the list of engine names that are configured on the node.
* @return Set<String> of engine names configured on the node
* Returns the identity for the single engine on the node.
* If more than one engine exists on the node, service will
* return an HTTP Status Code 405 (Method Not Allowed)
* @return Identity the identity of the engine
*/
@RequestMapping(value = "/engines", method = RequestMethod.GET)
@RequestMapping(value = "/engine/identity", method = RequestMethod.GET)
@ResponseBody
public final Set<String> engines() {
return getSymmetricEngineHolder().getEngines().keySet();
public final Identity identity() {
//TODO: implement
return null;
}


/**
* Loads a profile for the specified engine on the node.
* @param engineName
*/
@RequestMapping(value = "/loadprofile/engines/{engine}", method = RequestMethod.POST)
@RequestMapping(value = "/engines/{engine}/profile", method = RequestMethod.POST)
@ResponseBody
//TODO: figure out how we will pass the file info...
public final void loadProfile(@PathVariable("engine") String engineName, @RequestParam MultipartFile file) {
Expand All @@ -67,7 +85,7 @@ public final void loadProfile(@PathVariable("engine") String engineName, @Reques
* @param engineName
* @param tableName
*/
@RequestMapping(value = "/droptrigger/engines/{engine}/tables/{table}", method = RequestMethod.POST)
@RequestMapping(value = "/engines/{engine}/tables/{table}/trigger", method = RequestMethod.DELETE)
@ResponseBody
public final void dropTrigger(@PathVariable("engine") String engineName,
@PathVariable("table") String tableName) {
Expand All @@ -78,7 +96,7 @@ public final void dropTrigger(@PathVariable("engine") String engineName,
* Drops all SymmetricDS triggers for the specified engine on the node.
* @param engineName
*/
@RequestMapping(value = "/droptrigger/engines/{engine}", method = RequestMethod.POST)
@RequestMapping(value = "/engines/{engine}/trigger", method = RequestMethod.DELETE)
@ResponseBody
public final void dropTrigger(@PathVariable("engine") String engineName) {
//TODO: Implementation
Expand All @@ -89,7 +107,7 @@ public final void dropTrigger(@PathVariable("engine") String engineName) {
* @param engineName
* @param tableName
*/
@RequestMapping(value = "/synctrigger/engines/{engine}/tables/{table}", method = RequestMethod.POST)
@RequestMapping(value = "engines/{engine}/tables/{table}/trigger", method = RequestMethod.POST)
@ResponseBody
public final void syncTrigger(@PathVariable("engine") String engineName,
@PathVariable("table") String tableName) {
Expand All @@ -100,7 +118,7 @@ public final void syncTrigger(@PathVariable("engine") String engineName,
* Creates SymmetricDS triggers for all configured tables on the specified engine on the node.
* @param engineName
*/
@RequestMapping(value = "/synctrigger/engines/{engine}", method = RequestMethod.POST)
@RequestMapping(value = "/engines/{engine}/trigger", method = RequestMethod.POST)
@ResponseBody
public final void syncTrigger(@PathVariable("engine") String engineName) {
//TODO: Implementation
Expand All @@ -127,7 +145,7 @@ public final void initialize(@PathVariable("engine") String engineName) {
* @param engineName
* @return {@link NodeStatus}
*/
@RequestMapping(value = "/nodestatus/engines/{engine}", method = RequestMethod.GET)
@RequestMapping(value = "/engines/{engine}/node/status", method = RequestMethod.GET)
@ResponseBody
public final NodeStatus nodeStatus(@PathVariable("engine") String engineName) {
//TODO: Implementation
Expand All @@ -139,7 +157,7 @@ public final NodeStatus nodeStatus(@PathVariable("engine") String engineName) {
* @param engineName
* @return Set<{@link ChannelStatus}>
*/
@RequestMapping(value = "/channelstatus/engines/{engine}", method = RequestMethod.GET)
@RequestMapping(value = "/engines/{engine}/channel/status", method = RequestMethod.GET)
@ResponseBody
public final Set<ChannelStatus> channelStatus(@PathVariable("engine") String engineName) {
throw new RuntimeException("Test");
Expand All @@ -149,7 +167,7 @@ public final Set<ChannelStatus> channelStatus(@PathVariable("engine") String eng
* Uninstalls all SymmetricDS objects from the database for the specified engine of the node.
* @param engineName
*/
@RequestMapping(value = "/uninstall/engines/{engine}", method = RequestMethod.POST)
@RequestMapping(value = "/engines/{engine}", method = RequestMethod.DELETE)
@ResponseBody
public final void unintstall(@PathVariable("engine") String engineName) {
//TODO: Implementation
Expand All @@ -176,7 +194,7 @@ public final void stop() {
/**
* Refreshes the cache for the node.
*/
@RequestMapping(value = "/refreshcache", method = RequestMethod.POST)
@RequestMapping(value = "/cache", method = RequestMethod.PUT)
@ResponseBody
public final void refreshCache() {
//TODO: Implementation
Expand Down
@@ -1,4 +1,4 @@
package org.jumpmind.symmetric.web.rest;
package org.jumpmind.symmetric.web.rest.model;

public class ChannelStatus {

Expand Down
@@ -0,0 +1,19 @@
package org.jumpmind.symmetric.web.rest.model;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Engine {

private String Name;

public String getName() {
return Name;
}

public void setName(String name) {
Name = name;
}


}
@@ -0,0 +1,19 @@
package org.jumpmind.symmetric.web.rest.model;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Identity {

private String id;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}


}
@@ -1,4 +1,4 @@
package org.jumpmind.symmetric.web.rest;
package org.jumpmind.symmetric.web.rest.model;

import org.jumpmind.symmetric.Version;
import javax.xml.bind.annotation.XmlRootElement;
Expand Down

0 comments on commit efb072f

Please sign in to comment.