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