diff options
author | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2019-12-31 14:16:03 +0100 |
---|---|---|
committer | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2019-12-31 14:18:52 +0100 |
commit | c515a2e3d673c565a7b5c406cd3ab4a7b33e8f4e (patch) | |
tree | 8192ee643300cd33e8d554a98e907edfd6fad938 /src/main/java | |
parent | c823d047ee822e48cbdf12bed796389c2a3e25cd (diff) |
Implement getting attributes in new API
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/pl/edu/mimuw/cloudatlas/agent/NewApiImplementation.java | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/NewApiImplementation.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/NewApiImplementation.java index 4aa5148..c0b313d 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/NewApiImplementation.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/NewApiImplementation.java @@ -70,17 +70,23 @@ public class NewApiImplementation implements Api { } public AttributesMap getZoneAttributeValues(String zoneName) throws RemoteException { - /* + CompletableFuture<ResponseMessage> responseFuture = new CompletableFuture(); + RequestStateMessage message = new RequestStateMessage("", 0, responseFuture); try { - ZMI zmi = root.findDescendant(new PathName(zoneName)); - return zmi.getAttributes(); - } catch (ZMI.NoSuchZoneException e) { - throw new RemoteException("Zone not found", e); - } - */ + eventBus.addMessage(message); + ResponseMessage response = responseFuture.get(); - // placeholder - return new AttributesMap(); + if (response.getType() == ResponseMessage.Type.STATE) { + StateMessage stateMessage = (StateMessage) response; + return stateMessage.getZMI().findDescendant(zoneName).getAttributes(); + } else { + System.out.println("ERROR: getZoneSet didn't receive a StateMessage"); + throw new Exception("Failed to retrieve zone set"); + } + } catch (Exception e) { + System.out.println("ERROR: exception caught in getZoneSet"); + throw new RemoteException(e.getMessage()); + } } public void installQuery(String name, String queryCode) throws RemoteException { |