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