blob: bf0b5274f57544c4e7e2780b1605cf8194392a8e [file] [log] [blame]
Pavlin Radoslavov13669052014-05-13 10:33:39 -07001package net.onrc.onos.core.intent.runtime.web;
2
3import java.io.IOException;
4import java.util.Collection;
5
6import net.onrc.onos.core.intent.Intent;
7import net.onrc.onos.core.intent.IntentMap;
8import net.onrc.onos.core.intent.runtime.IPathCalcRuntimeService;
9
10import org.restlet.resource.Get;
11import org.restlet.resource.ServerResource;
12import org.slf4j.Logger;
13import org.slf4j.LoggerFactory;
14
15/**
16 * A class to access the low-level intents.
17 */
18public 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}