diff options
author | Simon Rettberg | 2017-07-24 13:42:20 +0200 |
---|---|---|
committer | Simon Rettberg | 2017-07-24 13:42:20 +0200 |
commit | 4d319a4f7678ee99888d9842be53f1a10fbca92e (patch) | |
tree | e51fcd0ebe8e0aaa58addea6910e2d0f78c553f8 /dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java | |
parent | [server] Adapt to new thrift version (diff) | |
download | tutor-module-4d319a4f7678ee99888d9842be53f1a10fbca92e.tar.gz tutor-module-4d319a4f7678ee99888d9842be53f1a10fbca92e.tar.xz tutor-module-4d319a4f7678ee99888d9842be53f1a10fbca92e.zip |
[client] Support feature string supplied by server
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java index 6fa5c3bc..47b8fa85 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java @@ -1,11 +1,15 @@ package org.openslx.dozmod.thrift; +import java.util.HashSet; +import java.util.Set; + import org.apache.log4j.Logger; import org.apache.thrift.TException; import org.openslx.bwlp.thrift.iface.ImagePermissions; import org.openslx.bwlp.thrift.iface.LecturePermissions; import org.openslx.bwlp.thrift.iface.SatelliteConfig; import org.openslx.bwlp.thrift.iface.WhoamiInfo; +import org.openslx.sat.thrift.version.Feature; import org.openslx.thrifthelper.ThriftManager; public class Session { @@ -23,6 +27,8 @@ public class Session { private static long satelliteApiVersion = -1; private static SatelliteConfig satConf = null; + + private static Set<Feature> features = null; public static void initialize(WhoamiInfo whoami, String satAddress, String satToken, String masToken, long satApiVersion) { @@ -179,4 +185,26 @@ public class Session { return isSuperUser() && satelliteApiVersion >= 3; } + public static boolean hasFeature(Feature feature) { + synchronized (Feature.class) { + if (features == null) { + String ret; + try { + ret = ThriftManager.getSatClient().getSupportedFeatures(); + } catch (TException e) { + return false; + } + if (ret == null) + return false; + features = new HashSet<>(); + for (String f : ret.split(" ")) { + try { + features.add(Feature.valueOf(f)); + } catch (Throwable t) {} + } + } + return features.contains(feature); + } + } + } |