m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/pl/edu/mimuw/cloudatlas/agent/ApiImplementation.java
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/agent/ApiImplementation.java
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/agent/ApiImplementation.java')
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/ApiImplementation.java16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/ApiImplementation.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/ApiImplementation.java
index d2e808a..90e7789 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/ApiImplementation.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/ApiImplementation.java
@@ -28,6 +28,8 @@ import pl.edu.mimuw.cloudatlas.model.Type;
import pl.edu.mimuw.cloudatlas.model.TypePrimitive;
import pl.edu.mimuw.cloudatlas.model.ZMI;
import pl.edu.mimuw.cloudatlas.api.Api;
+import pl.edu.mimuw.cloudatlas.querysigner.QueryData;
+import pl.edu.mimuw.cloudatlas.querysigner.QueryUtils;
public class ApiImplementation implements Api {
ZMI root;
@@ -60,16 +62,11 @@ public class ApiImplementation implements Api {
}
}
- public void installQuery(String name, String queryCode) throws RemoteException {
- Pattern queryNamePattern = Pattern.compile("&[a-zA-Z][\\w_]*");
- Matcher matcher = queryNamePattern.matcher(name);
- if (!matcher.matches()) {
- throw new RemoteException("Invalid query identifier");
- }
+ public void installQuery(String name, QueryData query) throws RemoteException {
+ QueryUtils.validateQueryName(name);
try {
- ValueQuery query = new ValueQuery(queryCode);
Attribute attributeName = new Attribute(name);
- installQueryInHierarchy(root, attributeName, query);
+ installQueryInHierarchy(root, attributeName, new ValueQuery(query));
executeAllQueries(root);
} catch (Exception e) {
throw new RemoteException("Failed to install query", e);
@@ -85,7 +82,8 @@ public class ApiImplementation implements Api {
}
}
- public void uninstallQuery(String queryName) throws RemoteException {
+ public void uninstallQuery(String queryName, QueryData query) throws RemoteException {
+ QueryUtils.validateQueryName(queryName);
uninstallQueryInHierarchy(root, new Attribute(queryName));
}