Jonathan Hart | 6df9017 | 2014-04-03 10:13:11 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.datagrid.web; |
Toshio Koide | 3738ee5 | 2014-02-12 14:57:39 -0800 | [diff] [blame] | 2 | |
| 3 | import java.io.IOException; |
Nick Karanatsios | 8abe717 | 2014-02-19 20:31:48 -0800 | [diff] [blame] | 4 | import java.util.Collection; |
Jonathan Hart | a99ec67 | 2014-04-03 11:30:34 -0700 | [diff] [blame] | 5 | import java.util.HashMap; |
Toshio Koide | 3738ee5 | 2014-02-12 14:57:39 -0800 | [diff] [blame] | 6 | import java.util.Iterator; |
Jonathan Hart | a99ec67 | 2014-04-03 11:30:34 -0700 | [diff] [blame] | 7 | import java.util.LinkedList; |
| 8 | import java.util.Map; |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 9 | |
Jonathan Hart | a99ec67 | 2014-04-03 11:30:34 -0700 | [diff] [blame] | 10 | import net.floodlightcontroller.util.MACAddress; |
Jonathan Hart | aa38097 | 2014-04-03 10:24:46 -0700 | [diff] [blame] | 11 | import net.onrc.onos.core.intent.ConstrainedShortestPathIntent; |
| 12 | import net.onrc.onos.core.intent.Intent; |
| 13 | import net.onrc.onos.core.intent.IntentMap; |
| 14 | import net.onrc.onos.core.intent.IntentOperation; |
| 15 | import net.onrc.onos.core.intent.IntentOperationList; |
| 16 | import net.onrc.onos.core.intent.ShortestPathIntent; |
| 17 | import net.onrc.onos.core.intent.runtime.IPathCalcRuntimeService; |
Pavlin Radoslavov | 2fa80f4 | 2014-04-18 13:10:38 -0700 | [diff] [blame] | 18 | import net.onrc.onos.core.util.Dpid; |
Jonathan Hart | aa38097 | 2014-04-03 10:24:46 -0700 | [diff] [blame] | 19 | |
Toshio Koide | 3738ee5 | 2014-02-12 14:57:39 -0800 | [diff] [blame] | 20 | import org.codehaus.jackson.JsonGenerationException; |
| 21 | import org.codehaus.jackson.JsonNode; |
| 22 | import org.codehaus.jackson.map.JsonMappingException; |
Toshio Koide | 3738ee5 | 2014-02-12 14:57:39 -0800 | [diff] [blame] | 23 | import org.codehaus.jackson.map.ObjectMapper; |
Nick Karanatsios | 5fcf93e | 2014-02-15 14:13:55 -0800 | [diff] [blame] | 24 | import org.codehaus.jackson.node.ArrayNode; |
Nick Karanatsios | 88948d3 | 2014-02-18 15:14:30 -0800 | [diff] [blame] | 25 | import org.codehaus.jackson.node.ObjectNode; |
Nick Karanatsios | 1f4defb | 2014-02-23 19:34:47 -0800 | [diff] [blame] | 26 | import org.restlet.resource.Delete; |
Nick Karanatsios | 88948d3 | 2014-02-18 15:14:30 -0800 | [diff] [blame] | 27 | import org.restlet.resource.Get; |
Jonathan Hart | a99ec67 | 2014-04-03 11:30:34 -0700 | [diff] [blame] | 28 | import org.restlet.resource.Post; |
| 29 | import org.restlet.resource.ServerResource; |
Nick Karanatsios | 5fcf93e | 2014-02-15 14:13:55 -0800 | [diff] [blame] | 30 | import org.slf4j.Logger; |
| 31 | import org.slf4j.LoggerFactory; |
Toshio Koide | 3738ee5 | 2014-02-12 14:57:39 -0800 | [diff] [blame] | 32 | |
| 33 | /** |
Yuta HIGUCHI | d4acc80 | 2014-06-19 22:30:31 -0700 | [diff] [blame^] | 34 | * old REST API implementation for the Intents. |
Toshio Koide | 3738ee5 | 2014-02-12 14:57:39 -0800 | [diff] [blame] | 35 | */ |
| 36 | public class IntentResource extends ServerResource { |
Ray Milkey | ec83894 | 2014-04-09 11:28:43 -0700 | [diff] [blame] | 37 | private static final Logger log = LoggerFactory.getLogger(IntentResource.class); |
Nick Karanatsios | da9f36f | 2014-02-21 01:27:02 -0800 | [diff] [blame] | 38 | // TODO need to assign proper application id. |
Ray Milkey | 2476cac | 2014-04-08 11:03:21 -0700 | [diff] [blame] | 39 | private static final String APPLN_ID = "1"; |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 40 | |
Toshio Koide | 3738ee5 | 2014-02-12 14:57:39 -0800 | [diff] [blame] | 41 | @Post("json") |
Nick Karanatsios | 88948d3 | 2014-02-18 15:14:30 -0800 | [diff] [blame] | 42 | public String store(String jsonIntent) throws IOException { |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 43 | IPathCalcRuntimeService pathRuntime = (IPathCalcRuntimeService) getContext() |
Nick Karanatsios | 8abe717 | 2014-02-19 20:31:48 -0800 | [diff] [blame] | 44 | .getAttributes().get(IPathCalcRuntimeService.class.getCanonicalName()); |
| 45 | if (pathRuntime == null) { |
Nick Karanatsios | da9f36f | 2014-02-21 01:27:02 -0800 | [diff] [blame] | 46 | log.warn("Failed to get path calc runtime"); |
Nick Karanatsios | 8abe717 | 2014-02-19 20:31:48 -0800 | [diff] [blame] | 47 | return ""; |
| 48 | } |
Nick Karanatsios | 5fcf93e | 2014-02-15 14:13:55 -0800 | [diff] [blame] | 49 | String reply = ""; |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 50 | ObjectMapper mapper = new ObjectMapper(); |
| 51 | JsonNode jNode = null; |
| 52 | try { |
| 53 | jNode = mapper.readValue(jsonIntent, JsonNode.class); |
| 54 | } catch (JsonGenerationException ex) { |
| 55 | log.error("JsonGeneration exception ", ex); |
| 56 | } catch (JsonMappingException ex) { |
| 57 | log.error("JsonMappingException occurred", ex); |
| 58 | } catch (IOException ex) { |
| 59 | log.error("IOException occurred", ex); |
| 60 | } |
Nick Karanatsios | 1a4a200 | 2014-02-14 04:35:39 -0800 | [diff] [blame] | 61 | |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 62 | if (jNode != null) { |
| 63 | reply = parseJsonNode(jNode.getElements(), pathRuntime); |
| 64 | } |
Nick Karanatsios | 5fcf93e | 2014-02-15 14:13:55 -0800 | [diff] [blame] | 65 | return reply; |
Toshio Koide | 3738ee5 | 2014-02-12 14:57:39 -0800 | [diff] [blame] | 66 | } |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 67 | |
Nick Karanatsios | 1f4defb | 2014-02-23 19:34:47 -0800 | [diff] [blame] | 68 | @Delete("json") |
| 69 | public String store() { |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 70 | IPathCalcRuntimeService pathRuntime = (IPathCalcRuntimeService) getContext(). |
Nick Karanatsios | 1f4defb | 2014-02-23 19:34:47 -0800 | [diff] [blame] | 71 | getAttributes().get(IPathCalcRuntimeService.class.getCanonicalName()); |
| 72 | pathRuntime.purgeIntents(); |
| 73 | // TODO no reply yet from the purge intents call |
| 74 | return ""; |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 75 | |
Nick Karanatsios | 1f4defb | 2014-02-23 19:34:47 -0800 | [diff] [blame] | 76 | } |
Toshio Koide | 3738ee5 | 2014-02-12 14:57:39 -0800 | [diff] [blame] | 77 | |
Nick Karanatsios | 88948d3 | 2014-02-18 15:14:30 -0800 | [diff] [blame] | 78 | @Get("json") |
Nick Karanatsios | 8abe717 | 2014-02-19 20:31:48 -0800 | [diff] [blame] | 79 | public String retrieve() throws IOException { |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 80 | IPathCalcRuntimeService pathRuntime = (IPathCalcRuntimeService) getContext(). |
Nick Karanatsios | 8abe717 | 2014-02-19 20:31:48 -0800 | [diff] [blame] | 81 | getAttributes().get(IPathCalcRuntimeService.class.getCanonicalName()); |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 82 | |
Nick Karanatsios | 87e8be7 | 2014-02-21 23:45:37 -0800 | [diff] [blame] | 83 | String intentCategory = (String) getRequestAttributes().get("category"); |
| 84 | IntentMap intentMap = null; |
| 85 | if (intentCategory.equals("high")) { |
| 86 | intentMap = pathRuntime.getHighLevelIntents(); |
| 87 | } else { |
| 88 | intentMap = pathRuntime.getPathIntents(); |
| 89 | } |
Nick Karanatsios | 8abe717 | 2014-02-19 20:31:48 -0800 | [diff] [blame] | 90 | ObjectMapper mapper = new ObjectMapper(); |
| 91 | String restStr = ""; |
Nick Karanatsios | ed645df | 2014-02-20 23:22:29 -0800 | [diff] [blame] | 92 | |
| 93 | String intentId = (String) getRequestAttributes().get("intent_id"); |
Nick Karanatsios | 8abe717 | 2014-02-19 20:31:48 -0800 | [diff] [blame] | 94 | ArrayNode arrayNode = mapper.createArrayNode(); |
Nick Karanatsios | 8abe717 | 2014-02-19 20:31:48 -0800 | [diff] [blame] | 95 | Collection<Intent> intents = intentMap.getAllIntents(); |
| 96 | if (!intents.isEmpty()) { |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 97 | if ((intentId != null)) { |
Nick Karanatsios | da9f36f | 2014-02-21 01:27:02 -0800 | [diff] [blame] | 98 | String applnIntentId = APPLN_ID + ":" + intentId; |
| 99 | Intent intent = intentMap.getIntent(applnIntentId); |
Nick Karanatsios | ed645df | 2014-02-20 23:22:29 -0800 | [diff] [blame] | 100 | if (intent != null) { |
| 101 | ObjectNode node = mapper.createObjectNode(); |
Nick Karanatsios | 87e8be7 | 2014-02-21 23:45:37 -0800 | [diff] [blame] | 102 | // TODO refactor/remove duplicate code. |
Nick Karanatsios | da9f36f | 2014-02-21 01:27:02 -0800 | [diff] [blame] | 103 | node.put("intent_id", intentId); |
Nick Karanatsios | ed645df | 2014-02-20 23:22:29 -0800 | [diff] [blame] | 104 | node.put("status", intent.getState().toString()); |
Nick Karanatsios | 87e8be7 | 2014-02-21 23:45:37 -0800 | [diff] [blame] | 105 | LinkedList<String> logs = intent.getLogs(); |
| 106 | ArrayNode logNode = mapper.createArrayNode(); |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 107 | for (String intentLog : logs) { |
Nick Karanatsios | 87e8be7 | 2014-02-21 23:45:37 -0800 | [diff] [blame] | 108 | logNode.add(intentLog); |
| 109 | } |
| 110 | node.put("log", logNode); |
Nick Karanatsios | ed645df | 2014-02-20 23:22:29 -0800 | [diff] [blame] | 111 | arrayNode.add(node); |
| 112 | } |
| 113 | } else { |
| 114 | for (Intent intent : intents) { |
| 115 | ObjectNode node = mapper.createObjectNode(); |
Nick Karanatsios | da9f36f | 2014-02-21 01:27:02 -0800 | [diff] [blame] | 116 | String applnIntentId = intent.getId(); |
| 117 | intentId = applnIntentId.split(":")[1]; |
| 118 | node.put("intent_id", intentId); |
Nick Karanatsios | ed645df | 2014-02-20 23:22:29 -0800 | [diff] [blame] | 119 | node.put("status", intent.getState().toString()); |
Nick Karanatsios | 87e8be7 | 2014-02-21 23:45:37 -0800 | [diff] [blame] | 120 | LinkedList<String> logs = intent.getLogs(); |
| 121 | ArrayNode logNode = mapper.createArrayNode(); |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 122 | for (String intentLog : logs) { |
Nick Karanatsios | 87e8be7 | 2014-02-21 23:45:37 -0800 | [diff] [blame] | 123 | logNode.add(intentLog); |
| 124 | } |
| 125 | node.put("log", logNode); |
Nick Karanatsios | ed645df | 2014-02-20 23:22:29 -0800 | [diff] [blame] | 126 | arrayNode.add(node); |
| 127 | } |
Nick Karanatsios | 8abe717 | 2014-02-19 20:31:48 -0800 | [diff] [blame] | 128 | } |
Nick Karanatsios | ed645df | 2014-02-20 23:22:29 -0800 | [diff] [blame] | 129 | restStr = mapper.writeValueAsString(arrayNode); |
Nick Karanatsios | 8abe717 | 2014-02-19 20:31:48 -0800 | [diff] [blame] | 130 | } |
| 131 | return restStr; |
Nick Karanatsios | 88948d3 | 2014-02-18 15:14:30 -0800 | [diff] [blame] | 132 | } |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 133 | |
Nick Karanatsios | 8abe717 | 2014-02-19 20:31:48 -0800 | [diff] [blame] | 134 | private String parseJsonNode(Iterator<JsonNode> nodes, |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 135 | IPathCalcRuntimeService pathRuntime) throws IOException { |
Nick Karanatsios | 8abe717 | 2014-02-19 20:31:48 -0800 | [diff] [blame] | 136 | IntentOperationList operations = new IntentOperationList(); |
Nick Karanatsios | 5fcf93e | 2014-02-15 14:13:55 -0800 | [diff] [blame] | 137 | ObjectMapper mapper = new ObjectMapper(); |
| 138 | ArrayNode arrayNode = mapper.createArrayNode(); |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 139 | while (nodes.hasNext()) { |
| 140 | JsonNode node = nodes.next(); |
| 141 | if (node.isObject()) { |
| 142 | JsonNode data; |
| 143 | Iterator<String> fieldNames = node.getFieldNames(); |
Nick Karanatsios | 5fcf93e | 2014-02-15 14:13:55 -0800 | [diff] [blame] | 144 | Map<String, Object> fields = new HashMap<>(); |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 145 | while (fieldNames.hasNext()) { |
| 146 | String fieldName = fieldNames.next(); |
| 147 | data = node.get(fieldName); |
Nick Karanatsios | 5fcf93e | 2014-02-15 14:13:55 -0800 | [diff] [blame] | 148 | parseFields(data, fieldName, fields); |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 149 | } |
Nick Karanatsios | 87e8be7 | 2014-02-21 23:45:37 -0800 | [diff] [blame] | 150 | Intent intent = processIntent(fields, operations); |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 151 | appendIntentStatus(intent, (String) fields.get("intent_id"), mapper, arrayNode); |
| 152 | } |
| 153 | } |
Nick Karanatsios | 8abe717 | 2014-02-19 20:31:48 -0800 | [diff] [blame] | 154 | pathRuntime.executeIntentOperations(operations); |
Nick Karanatsios | 5fcf93e | 2014-02-15 14:13:55 -0800 | [diff] [blame] | 155 | return mapper.writeValueAsString(arrayNode); |
Toshio Koide | 3738ee5 | 2014-02-12 14:57:39 -0800 | [diff] [blame] | 156 | } |
Nick Karanatsios | 1a4a200 | 2014-02-14 04:35:39 -0800 | [diff] [blame] | 157 | |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 158 | private void appendIntentStatus(Intent intent, final String intentId, |
| 159 | ObjectMapper mapper, ArrayNode arrayNode) throws IOException { |
Nick Karanatsios | 88948d3 | 2014-02-18 15:14:30 -0800 | [diff] [blame] | 160 | ObjectNode node = mapper.createObjectNode(); |
Nick Karanatsios | da9f36f | 2014-02-21 01:27:02 -0800 | [diff] [blame] | 161 | node.put("intent_id", intentId); |
Nick Karanatsios | 87e8be7 | 2014-02-21 23:45:37 -0800 | [diff] [blame] | 162 | node.put("status", intent.getState().toString()); |
| 163 | LinkedList<String> logs = intent.getLogs(); |
| 164 | ArrayNode logNode = mapper.createArrayNode(); |
| 165 | for (String intentLog : logs) { |
| 166 | logNode.add(intentLog); |
| 167 | } |
| 168 | node.put("log", logNode); |
Nick Karanatsios | 88948d3 | 2014-02-18 15:14:30 -0800 | [diff] [blame] | 169 | arrayNode.add(node); |
Nick Karanatsios | 5fcf93e | 2014-02-15 14:13:55 -0800 | [diff] [blame] | 170 | } |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 171 | |
Nick Karanatsios | 87e8be7 | 2014-02-21 23:45:37 -0800 | [diff] [blame] | 172 | private Intent processIntent(Map<String, Object> fields, IntentOperationList operations) { |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 173 | String intentType = (String) fields.get("intent_type"); |
| 174 | String intentOp = (String) fields.get("intent_op"); |
Nick Karanatsios | 87e8be7 | 2014-02-21 23:45:37 -0800 | [diff] [blame] | 175 | Intent intent; |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 176 | String intentId = (String) fields.get("intent_id"); |
Toshio Koide | 565d6dd | 2014-03-27 11:22:25 -0700 | [diff] [blame] | 177 | boolean pathFrozen = false; |
| 178 | if (intentId.startsWith("F")) { // TODO define REST API for frozen intents |
| 179 | pathFrozen = true; |
| 180 | intentId = intentId.substring(1); |
| 181 | } |
| 182 | String applnIntentId = APPLN_ID + ":" + intentId; |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 183 | |
Nick Karanatsios | 88948d3 | 2014-02-18 15:14:30 -0800 | [diff] [blame] | 184 | IntentOperation.Operator operation = IntentOperation.Operator.ADD; |
| 185 | if ((intentOp.equals("remove"))) { |
| 186 | operation = IntentOperation.Operator.REMOVE; |
| 187 | } |
Pavlin Radoslavov | 2fa80f4 | 2014-04-18 13:10:38 -0700 | [diff] [blame] | 188 | Dpid srcSwitchDpid = new Dpid((String) fields.get("srcSwitch")); |
| 189 | Dpid dstSwitchDpid = new Dpid((String) fields.get("dstSwitch")); |
| 190 | |
Nick Karanatsios | 5fcf93e | 2014-02-15 14:13:55 -0800 | [diff] [blame] | 191 | if (intentType.equals("shortest_intent_type")) { |
Nick Karanatsios | da9f36f | 2014-02-21 01:27:02 -0800 | [diff] [blame] | 192 | ShortestPathIntent spi = new ShortestPathIntent(applnIntentId, |
Pavlin Radoslavov | 2fa80f4 | 2014-04-18 13:10:38 -0700 | [diff] [blame] | 193 | srcSwitchDpid.value(), |
Nick Karanatsios | 5fcf93e | 2014-02-15 14:13:55 -0800 | [diff] [blame] | 194 | (long) fields.get("srcPort"), |
| 195 | MACAddress.valueOf((String) fields.get("srcMac")).toLong(), |
Pavlin Radoslavov | 2fa80f4 | 2014-04-18 13:10:38 -0700 | [diff] [blame] | 196 | dstSwitchDpid.value(), |
Nick Karanatsios | 5fcf93e | 2014-02-15 14:13:55 -0800 | [diff] [blame] | 197 | (long) fields.get("dstPort"), |
| 198 | MACAddress.valueOf((String) fields.get("dstMac")).toLong()); |
Toshio Koide | 565d6dd | 2014-03-27 11:22:25 -0700 | [diff] [blame] | 199 | spi.setPathFrozen(pathFrozen); |
Nick Karanatsios | a1bad35 | 2014-02-22 14:16:34 -0800 | [diff] [blame] | 200 | operations.add(operation, spi); |
Nick Karanatsios | 87e8be7 | 2014-02-21 23:45:37 -0800 | [diff] [blame] | 201 | intent = spi; |
Nick Karanatsios | 5fcf93e | 2014-02-15 14:13:55 -0800 | [diff] [blame] | 202 | } else { |
Nick Karanatsios | da9f36f | 2014-02-21 01:27:02 -0800 | [diff] [blame] | 203 | ConstrainedShortestPathIntent cspi = new ConstrainedShortestPathIntent(applnIntentId, |
Nick Karanatsios | 5fcf93e | 2014-02-15 14:13:55 -0800 | [diff] [blame] | 204 | Long.decode((String) fields.get("srcSwitch")), |
| 205 | (long) fields.get("srcPort"), |
| 206 | MACAddress.valueOf((String) fields.get("srcMac")).toLong(), |
| 207 | Long.decode((String) fields.get("dstSwitch")), |
| 208 | (long) fields.get("dstPort"), |
| 209 | MACAddress.valueOf((String) fields.get("dstMac")).toLong(), |
| 210 | (double) fields.get("bandwidth")); |
Toshio Koide | 565d6dd | 2014-03-27 11:22:25 -0700 | [diff] [blame] | 211 | cspi.setPathFrozen(pathFrozen); |
Nick Karanatsios | a1bad35 | 2014-02-22 14:16:34 -0800 | [diff] [blame] | 212 | operations.add(operation, cspi); |
Nick Karanatsios | 87e8be7 | 2014-02-21 23:45:37 -0800 | [diff] [blame] | 213 | intent = cspi; |
Nick Karanatsios | 5fcf93e | 2014-02-15 14:13:55 -0800 | [diff] [blame] | 214 | } |
Nick Karanatsios | 87e8be7 | 2014-02-21 23:45:37 -0800 | [diff] [blame] | 215 | return intent; |
Nick Karanatsios | 5fcf93e | 2014-02-15 14:13:55 -0800 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | private void parseFields(JsonNode node, String fieldName, Map<String, Object> fields) { |
| 219 | if ((node.isTextual())) { |
Nick Karanatsios | 5fcf93e | 2014-02-15 14:13:55 -0800 | [diff] [blame] | 220 | fields.put(fieldName, node.getTextValue()); |
| 221 | } else if ((node.isInt())) { |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 222 | fields.put(fieldName, (long) node.getIntValue()); |
Nick Karanatsios | 5fcf93e | 2014-02-15 14:13:55 -0800 | [diff] [blame] | 223 | } else if (node.isDouble()) { |
Nick Karanatsios | 5fcf93e | 2014-02-15 14:13:55 -0800 | [diff] [blame] | 224 | fields.put(fieldName, node.getDoubleValue()); |
| 225 | } else if ((node.isLong())) { |
Nick Karanatsios | 5fcf93e | 2014-02-15 14:13:55 -0800 | [diff] [blame] | 226 | fields.put(fieldName, node.getLongValue()); |
| 227 | } |
| 228 | } |
Toshio Koide | 3738ee5 | 2014-02-12 14:57:39 -0800 | [diff] [blame] | 229 | } |