m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/pl/edu/mimuw/cloudatlas/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/client')
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java b/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java
index 4019696..56b478c 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java
@@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import pl.edu.mimuw.cloudatlas.api.Api;
import pl.edu.mimuw.cloudatlas.model.*;
+import pl.edu.mimuw.cloudatlas.querysignerapi.QuerySignerApi;
import java.net.InetAddress;
import java.rmi.registry.LocateRegistry;
@@ -32,17 +33,21 @@ import java.util.*;
@Controller
public class ClientController {
- private Api api;
-
+ private Api agentApi;
+ private QuerySignerApi querySignerApi;
private Map<ValueTime, AttributesMap> attributes;
private String currentZoneName;
private static final int MAX_ENTRIES = 10;
ClientController() {
try {
- String hostname = System.getProperty("agent_hostname");
- Registry registry = LocateRegistry.getRegistry(hostname);
- this.api = (Api) registry.lookup("Api");
+ String agentHostname = System.getProperty("agent_hostname");
+ Registry registry = LocateRegistry.getRegistry(agentHostname);
+ this.agentApi = (Api) registry.lookup("Api");
+
+ String querySignerHostname = System.getProperty("querysigner_hostname");
+ Registry querySignerRegistry = LocateRegistry.getRegistry(querySignerHostname);
+ this.querySignerApi = (QuerySignerApi) querySignerRegistry.lookup("QuerySignerApi");
} catch (Exception e) {
System.err.println("Client exception:");
e.printStackTrace();
@@ -74,7 +79,8 @@ public class ClientController {
boolean success = true;
try {
- this.api.installQuery(queryObject.getName(), queryObject.getValue());
+ ValueQuery query = this.querySignerApi.signInstallQuery(queryObject.getName(), queryObject.getValue());
+ this.agentApi.installQuery(queryObject.getName(), query);
} catch (Exception e) {
success = false;
System.err.println("Client exception:");
@@ -99,7 +105,8 @@ public class ClientController {
boolean success = true;
try {
- this.api.uninstallQuery(queryObject.getName());
+ ValueQuery query = querySignerApi.signUninstallQuery(queryObject.getName());
+ this.agentApi.uninstallQuery(queryObject.getName(), query);
} catch (Exception e) {
success = false;
System.err.println("Client exception:");
@@ -153,7 +160,7 @@ public class ClientController {
try {
contactObjects = parseContactsString(contactsObject);
- this.api.setFallbackContacts(contactObjects);
+ this.agentApi.setFallbackContacts(contactObjects);
} catch (Exception e) {
success = false;
System.err.println("Client exception:");
@@ -284,7 +291,7 @@ public class ClientController {
try {
attributeValue = parseAttributeValue(attributeObject);
- api.setAttributeValue(
+ agentApi.setAttributeValue(
attributeObject.getZoneName(),
attributeObject.getAttributeName(),
attributeValue);
@@ -309,7 +316,7 @@ public class ClientController {
String availableZonesString = "";
try {
- availableZones = api.getZoneSet();
+ availableZones = agentApi.getZoneSet();
availableZonesString = availableZones.toString().substring(1, availableZones.toString().length() - 1);
} catch (Exception e) {
success = false;
@@ -336,7 +343,7 @@ public class ClientController {
try {
if (!this.currentZoneName.isEmpty()) {
- attribData = api.getZoneAttributeValues(this.currentZoneName);
+ attribData = agentApi.getZoneAttributeValues(this.currentZoneName);
currentTime = new ValueTime(System.currentTimeMillis());
this.attributes.put(currentTime, attribData);
}