m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/pl/edu/mimuw/cloudatlas/client
diff options
context:
space:
mode:
authorMagdalena GrodziƄska <mag.grodzinska@gmail.com>2020-01-14 22:53:45 +0100
committerGitHub <noreply@github.com>2020-01-14 22:53:45 +0100
commit47ff68f0535f90eb4b09cb8c9c88555abd900cc8 (patch)
tree4ed4b28dc3d97a74646c977c4efbf6471e7f6f67 /src/main/java/pl/edu/mimuw/cloudatlas/client
parent50924560e8829914a4b8d315752c693890210c88 (diff)
parent42abac9eda30ba47ef6e710d0af22969f657a0cd (diff)
Merge pull request #118 from m-chrzan/query_signer
Query signer
Diffstat (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/client')
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java30
1 files changed, 19 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..5f34fe9 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,8 @@ 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.querysigner.QueryData;
+import pl.edu.mimuw.cloudatlas.querysignerapi.QuerySignerApi;
import java.net.InetAddress;
import java.rmi.registry.LocateRegistry;
@@ -32,17 +34,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 +80,8 @@ public class ClientController {
boolean success = true;
try {
- this.api.installQuery(queryObject.getName(), queryObject.getValue());
+ QueryData 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 +106,8 @@ public class ClientController {
boolean success = true;
try {
- this.api.uninstallQuery(queryObject.getName());
+ QueryData query = querySignerApi.signUninstallQuery(queryObject.getName());
+ this.agentApi.uninstallQuery(queryObject.getName(), query);
} catch (Exception e) {
success = false;
System.err.println("Client exception:");
@@ -153,7 +161,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 +292,7 @@ public class ClientController {
try {
attributeValue = parseAttributeValue(attributeObject);
- api.setAttributeValue(
+ agentApi.setAttributeValue(
attributeObject.getZoneName(),
attributeObject.getAttributeName(),
attributeValue);
@@ -309,7 +317,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 +344,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);
}