From cc4a98586df0ac5836b235e4dc3cfbb7f3d94209 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 26 Nov 2018 15:48:51 +0100 Subject: [client] MetaDataCache: Add getters for ldap/netshare predefined list --- .../openslx/dozmod/thrift/cache/MetaDataCache.java | 48 ++++++++++++++++++++-- 1 file changed, 44 insertions(+), 4 deletions(-) (limited to 'dozentenmodul') diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/cache/MetaDataCache.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/cache/MetaDataCache.java index f44523dc..6d75f792 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/cache/MetaDataCache.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/cache/MetaDataCache.java @@ -1,13 +1,18 @@ package org.openslx.dozmod.thrift.cache; +import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; import org.apache.thrift.TApplicationException; import org.apache.thrift.TException; +import org.openslx.bwlp.thrift.iface.LdapFilter; import org.openslx.bwlp.thrift.iface.Location; +import org.openslx.bwlp.thrift.iface.NetShare; import org.openslx.bwlp.thrift.iface.OperatingSystem; +import org.openslx.bwlp.thrift.iface.PredefinedData; import org.openslx.bwlp.thrift.iface.Virtualizer; +import org.openslx.dozmod.thrift.Session; import org.openslx.thrifthelper.ThriftManager; import org.openslx.util.GenericDataCache; import org.openslx.util.GenericDataCache.CacheMode; @@ -19,10 +24,12 @@ public class MetaDataCache { /** * How long to cache data. */ - private static final int CACHE_TIME_MS = 60 * 60 * 1000; + private static final int CACHE_TIME_LONG_MS = 60 * 60 * 1000; + + private static final int CACHE_TIME_SHORT_MS = 10 * 60 * 1000; private static final GenericDataCache> osCache = new GenericDataCache>( - CACHE_TIME_MS) { + CACHE_TIME_LONG_MS) { @Override protected List update() throws TException { try { @@ -35,7 +42,7 @@ public class MetaDataCache { }; private static final GenericDataCache> virtualizerCache = new GenericDataCache>( - CACHE_TIME_MS) { + CACHE_TIME_LONG_MS) { @Override protected List update() throws TException { try { @@ -50,7 +57,7 @@ public class MetaDataCache { private static int locationFails = 0; private static final GenericDataCache> locationCache = new GenericDataCache>( - CACHE_TIME_MS) { + CACHE_TIME_SHORT_MS) { @Override protected List update() throws TException { if (locationFails > 2) @@ -179,5 +186,38 @@ public class MetaDataCache { } return null; } + + /* + * LDAP filters and network shares + */ + + private static final GenericDataCache predefinedData = new GenericDataCache( + CACHE_TIME_SHORT_MS) { + @Override + protected PredefinedData update() throws TException { + try { + return ThriftManager.getSatClient().getPredefinedData(Session.getSatelliteToken()); + } catch (TException e) { + LOGGER.warn("Could not get predefined Data from sat...", e); + } + return null; + } + }; + + public static List getPredefinedLdapFilters() { + PredefinedData pd = predefinedData.get(); + if (pd == null || pd.ldapFilter == null) + return new ArrayList(0); + return pd.ldapFilter; + } + + public static List getPredefinedNetshares() { + PredefinedData pd = predefinedData.get(); + if (pd == null || pd.ldapFilter == null) + return new ArrayList(0); + return pd.netShares; + } + + } \ No newline at end of file -- cgit v1.2.3-55-g7522