Pavlin Radoslavov | 1366905 | 2014-05-13 10:33:39 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.intent.runtime.web; |
| 2 | |
Pavlin Radoslavov | 1366905 | 2014-05-13 10:33:39 -0700 | [diff] [blame] | 3 | import net.onrc.onos.core.intent.Intent; |
| 4 | import net.onrc.onos.core.intent.IntentMap; |
| 5 | import net.onrc.onos.core.intent.runtime.IPathCalcRuntimeService; |
Ray Milkey | 3aeda4f | 2014-05-21 14:38:58 -0700 | [diff] [blame^] | 6 | import org.restlet.representation.Representation; |
Pavlin Radoslavov | 1366905 | 2014-05-13 10:33:39 -0700 | [diff] [blame] | 7 | import org.restlet.resource.Get; |
| 8 | import org.restlet.resource.ServerResource; |
| 9 | import org.slf4j.Logger; |
| 10 | import org.slf4j.LoggerFactory; |
| 11 | |
Ray Milkey | 3aeda4f | 2014-05-21 14:38:58 -0700 | [diff] [blame^] | 12 | import java.util.Collection; |
| 13 | |
Pavlin Radoslavov | 1366905 | 2014-05-13 10:33:39 -0700 | [diff] [blame] | 14 | /** |
| 15 | * A class to access the low-level intents. |
| 16 | */ |
| 17 | public class IntentLowResource extends ServerResource { |
| 18 | private static final Logger log = LoggerFactory.getLogger(IntentLowResource.class); |
| 19 | |
| 20 | /** |
| 21 | * Gets all low-level intents. |
| 22 | * |
Ray Milkey | 3aeda4f | 2014-05-21 14:38:58 -0700 | [diff] [blame^] | 23 | * @return a Representation of a collection of all of the low-level intents. |
Pavlin Radoslavov | 1366905 | 2014-05-13 10:33:39 -0700 | [diff] [blame] | 24 | */ |
| 25 | @Get("json") |
Ray Milkey | 3aeda4f | 2014-05-21 14:38:58 -0700 | [diff] [blame^] | 26 | public Representation retrieve() { |
Pavlin Radoslavov | 1366905 | 2014-05-13 10:33:39 -0700 | [diff] [blame] | 27 | IPathCalcRuntimeService pathRuntime = (IPathCalcRuntimeService) getContext(). |
| 28 | getAttributes().get(IPathCalcRuntimeService.class.getCanonicalName()); |
| 29 | |
| 30 | // |
| 31 | // Get all low-level intents |
| 32 | // |
| 33 | IntentMap intentMap = pathRuntime.getPathIntents(); |
| 34 | Collection<Intent> intents = intentMap.getAllIntents(); |
| 35 | |
Ray Milkey | 3aeda4f | 2014-05-21 14:38:58 -0700 | [diff] [blame^] | 36 | return toRepresentation(intents, null); |
Pavlin Radoslavov | 1366905 | 2014-05-13 10:33:39 -0700 | [diff] [blame] | 37 | } |
| 38 | } |