Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Work on REST API
  • Loading branch information
gwilmer committed Nov 5, 2012
1 parent 523fdf5 commit 1156c7f
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 32 deletions.
Expand Up @@ -36,6 +36,8 @@
import org.jumpmind.symmetric.web.rest.model.Engine;
import org.jumpmind.symmetric.web.rest.model.EngineList;
import org.jumpmind.symmetric.web.rest.model.Identity;
import org.jumpmind.symmetric.web.rest.model.Node;
import org.jumpmind.symmetric.web.rest.model.NodeList;
import org.jumpmind.symmetric.web.rest.model.NodeStatus;
import org.jumpmind.symmetric.web.rest.model.RestError;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -111,35 +113,29 @@ public final EngineList engine() {
}

/**
* Returns the {@link Identity} for a given engine on the node.
*
* @param engine - The engine name for which the action is intended.
*
* @return {@link Identity} - The identity of the engine<br>
* Provides a list of children {@link Node} that are registered with this engine.
*/
@RequestMapping(value = "/engine/{engine}/identity", method = RequestMethod.GET)
@RequestMapping(value = "engine/{engine}/children", method = RequestMethod.GET)
@ResponseBody
public final Identity identity(
@PathVariable("engine") String engineName) {
return identityImpl(getSymmetricEngine(engineName));
public final NodeList children(
@PathVariable("engine") String actionName, String engineName) {
return null;
}

/**
* Returns the {@link Identity} for the single engine on this node.
*
* @return {@link Identity} - The identity of the engine
* Provides a list of children {@link Node} that are registered with this engine.
*/
@RequestMapping(value = "/engine/identity", method = RequestMethod.GET)
@RequestMapping(value = "engine/children", method = RequestMethod.GET)
@ResponseBody
public final Identity identity() {
return identityImpl(getSymmetricEngine());
public final NodeList children() {
return null;
}

/**
* Loads a profile for the specified engine on the node.
*
* @param engine - The engine name for which the action is intended.
* @param file - A file stream that contains the profile itself.
* @param engine The engine name for which the action is intended.
* @param file A file stream that contains the profile itself.
* TODO: put more details here on the specifics of how the file needs to be passed
*/
@RequestMapping(value = "engine/{engine}/profile", method = RequestMethod.POST)
Expand All @@ -154,7 +150,7 @@ public final void loadProfile(
/**
* Loads a profile for the single engine on the node.
*
* @param file - A file stream that contains the profile itself.
* @param file A file stream that contains the profile itself.
* TODO: put more details here on the specifics of how the file needs to be passed
*/
@RequestMapping(value = "engine/profile", method = RequestMethod.POST)
Expand All @@ -171,49 +167,54 @@ public final void loadProfile(@RequestParam MultipartFile file) {
* <ul>
* <li><b>synctriggers</b> - Creates or updates trigger instances that are defined in your
* synchronization scenario (i.e. defined in sym_trigger)</li>
* <li><b>droptriggers</b> - Removes trigger instances that are defined in your synchronizationh scenario
* <li><b>droptriggers</b> - Removes trigger instances that are defined in your synchronization scenario
* <li><b>uninstall</b> - Uninstalls all SymmetricDS objects from the given node (database)</li>
* <li><b>generateuninstallscript</b> - Generates an uninstall script for database objects for
* the given engine. The script is contained in the response body.
* <li><b>createinstallscript</b> - Creates an install script for database objects for the given engine.
* The script is contained in the response body.
* <li><b>reinitialize</b> - Reinitializes an engine including unregistering the engine and
* removing all symmetric configuration, operational objects and data from the
* node (database). Does not remove the engine. Thus, if the engine is a Server instance,
* when the engine starts back up, it will need configuration reloaded. If the engine is
* a client, it will request registration again from its configured registration server.</li>
* <li><b> - refreshcache</b> - Refreshes the cached parameters
* <li><b>refreshcache</b> - Refreshes the cached parameters
* <li><b>start</b> - Starts the given engine</li>
* <li><b>stop</b> - Stops the given engine</li>
* </ul>
* </p>
* @param actionName - One of the actions listed above
* @param force - Whether to force the action to occur regardless of activity occuring on the node
* @return TODO: determine whether we really want this to return an ActionResponse object (is it really needed?)
* @param actionName One of the actions listed above
* @param force Whether to force the action to occur regardless of activity occurring on the node
*/
@RequestMapping(value = "/engine", method = RequestMethod.GET)
@ResponseBody
public final void action(
public final String action(
@RequestParam(value = "action") String actionName,
@RequestParam(required = false, value = "force") boolean force) {

actionImpl(getSymmetricEngine(), actionName, force);

return null;
}


/**
* Performs a specific action on the specified engine on the node.
* @param engine - The engine name for which the action is intended.
* @param action - The action desired
* @param force - Whether to force the action to occur regardless of activity occuring on the node
* @return TODO: determine whether we reall want the return type.
* @param engine The engine name for which the action is intended.
* @param action The action desired
* @param force Whether to force the action to occur regardless of activity occurring on the node
* @see #action(String, boolean)
*/
@RequestMapping(value = "/engine/{engine}", method = RequestMethod.GET)
@ResponseBody
public final void action(
public final String action(
@PathVariable("engine") String engineName,
@RequestParam(value = "action") String actionName,
@RequestParam(required = false, value = "force") boolean force) {

actionImpl(getSymmetricEngine(engineName), actionName, force);

return null;
}

/**
Expand All @@ -240,7 +241,7 @@ public final NodeStatus nodeStatus(@PathVariable("engine") String engineName) {
public final Set<ChannelStatus> channelStatus(@PathVariable("engine") String engineName) {
throw new RuntimeException("Test");
}

//***********************************************************************************************
//TODO: stuff that should probably get moved out to some type of delegate or implementation class
//***********************************************************************************************
Expand Down
@@ -0,0 +1,46 @@
/*
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU Lesser General Public License (the
* "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see
* <http://www.gnu.org/licenses/>.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jumpmind.symmetric.web.rest.model;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Node {

private String name;

public Node(String name) {
setName(name);
}

public Node() {

}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

}
@@ -0,0 +1,55 @@
/*
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU Lesser General Public License (the
* "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see
* <http://www.gnu.org/licenses/>.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jumpmind.symmetric.web.rest.model;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "nodelist")
public class NodeList {

List<Node> nodes;

public NodeList(Node... nodes) {
this.setNodes(nodes);
}

public NodeList() {
this.nodes = new ArrayList<Node>();
}

public void setNodes(Node[] nodes) {
this.nodes = new ArrayList<Node>();
for (Node node : nodes) {
this.nodes.add(node);
}
}

public Node[] getNodes() {
return nodes.toArray(new Node[nodes.size()]);
}

public void addNode(Node node) {
this.nodes.add(node);
}
}
Expand Up @@ -103,6 +103,45 @@ public class NodeStatus {
*/
private String symmetricVersion = Version.version();

/**
* The last heartbeat for the given node.
*/
private String lastHeartbeat;

/**
* The hearbeat interval for the given node.
*/
private String hearbeatInterval;


public boolean isStarted() {
return started;
}

public void setStarted(boolean started) {
this.started = started;
}

public String getLastHeartbeat() {
return lastHeartbeat;
}

public void setLastHeartbeat(String lastHeartbeat) {
this.lastHeartbeat = lastHeartbeat;
}

public String getHearbeatInterval() {
return hearbeatInterval;
}

public void setHearbeatInterval(String hearbeatInterval) {
this.hearbeatInterval = hearbeatInterval;
}

public void setInitialLoaded(boolean initialLoaded) {
this.initialLoaded = initialLoaded;
}

/**
* @return boolean indicating if the node is registered with another node.
*/
Expand Down

0 comments on commit 1156c7f

Please sign in to comment.