From c515a2e3d673c565a7b5c406cd3ab4a7b33e8f4e Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Tue, 31 Dec 2019 14:16:03 +0100 Subject: Implement getting attributes in new API --- .../cloudatlas/agent/NewApiImplementation.java | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/main') 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 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 { -- cgit v1.2.3