diff options
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/thrift/cache/MetaDataCache.java | 48 |
1 files changed, 44 insertions, 4 deletions
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<List<OperatingSystem>> osCache = new GenericDataCache<List<OperatingSystem>>( - CACHE_TIME_MS) { + CACHE_TIME_LONG_MS) { @Override protected List<OperatingSystem> update() throws TException { try { @@ -35,7 +42,7 @@ public class MetaDataCache { }; private static final GenericDataCache<List<Virtualizer>> virtualizerCache = new GenericDataCache<List<Virtualizer>>( - CACHE_TIME_MS) { + CACHE_TIME_LONG_MS) { @Override protected List<Virtualizer> update() throws TException { try { @@ -50,7 +57,7 @@ public class MetaDataCache { private static int locationFails = 0; private static final GenericDataCache<List<Location>> locationCache = new GenericDataCache<List<Location>>( - CACHE_TIME_MS) { + CACHE_TIME_SHORT_MS) { @Override protected List<Location> 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> predefinedData = new GenericDataCache<PredefinedData>( + 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<LdapFilter> getPredefinedLdapFilters() { + PredefinedData pd = predefinedData.get(); + if (pd == null || pd.ldapFilter == null) + return new ArrayList<LdapFilter>(0); + return pd.ldapFilter; + } + + public static List<NetShare> getPredefinedNetshares() { + PredefinedData pd = predefinedData.get(); + if (pd == null || pd.ldapFilter == null) + return new ArrayList<NetShare>(0); + return pd.netShares; + } + + }
\ No newline at end of file |