Package org.jitterbit.integration.ldap.client.cache

Examples of org.jitterbit.integration.ldap.client.cache.LdapStructureCache


        }
        askServer(oids, ldapLoc, callback, waitSvc);
    }

    private boolean checkCache(NumericOid[] oids, LdapLocation ldapLoc, GetLdapStructuresCallback callback) {
        LdapStructureCache cache = ldapCache.getCache(ldapLoc.getServer());
        List<ObjectClassStructure> structs = new ArrayList<ObjectClassStructure>();
        for (NumericOid oid : oids) {
            // TODO: Instead of downloading all requested structures from the server
            // if one of them is missing in the cache, we could ask for only the ones
            // that are missing.
            ObjectClassStructure struct = cache.getClassStructure(oid);
            if (struct == null) {
                return false;
            }
            structs.add(struct);
        }


        @Override
        public void run() {
            if (acquireLock()) {
                ObjectClassDefinition[] classes;
                try {
                    LdapStructureCache cache = ldapCache.getCache(loc.getServer());
                    classes = cache.getObjectClasses();
                } finally {
                    lock.release();
                }
                updateModel(classes);
            }

        GetObjectClassesCallback filtered = new FilteredCallback(requestedOids, callback);
        askServer(ldapLoc, filtered, waitSvc);
    }

    private boolean checkCache(LdapLocation ldapLoc, GetObjectClassesCallback callback) {
        LdapStructureCache cache = ldapCache.getCache(ldapLoc.getServer());
        ObjectClassDefinition[] classDefs = cache.getObjectClasses();
        if (classDefs.length > 0) {
            callback.objectClassesRetrieved(classDefs);
            return true;
        }
        return false;

        }
        return false;
    }

    private boolean checkCache(LdapLocation ldapLoc, NumericOid[] oids, GetObjectClassesCallback callback) {
        LdapStructureCache cache = ldapCache.getCache(ldapLoc.getServer());
        ObjectClassDefinition[] classDefs = cache.getObjectClasses(oids);
        if (classDefs.length == oids.length && !ArrayUtils.contains(classDefs, null)) {
            callback.objectClassesRetrieved(classDefs);
            return true;
        }
        return false;

        this.classes = classes;
        checkCache();
    }

    private void checkCache() {
        LdapStructureCache cache = getCache();
        ObjectClassDefinition[] cachedClasses = cache.getObjectClasses();
        Set<ObjectClassDefinition> s1 = Sets.newHashSet(classes);
        Set<ObjectClassDefinition> s2 = Sets.newHashSet(cachedClasses);
        System.out.println("Everything is fine and dandy: " + s1.equals(s2));
    }

        public void caught(Throwable t) {
            externalCallback.caught(t);
        }

        private void updateCache(ObjectClassDefinition[] classes) {
            LdapStructureCache cache = LdapLocationStructureCacheAccessor.getCache(ldapLoc);
            cache.storeObjectClasses(classes);
        }

        public void caught(Throwable t) {
            externalCallback.caught(t);
        }

        private void updateCache(ObjectClassStructure[] structs) {
            LdapStructureCache cache = LdapLocationStructureCacheAccessor.getCache(ldapLoc);
            cache.storeClassStructures(structs);
        }

TOP

Related Classes of org.jitterbit.integration.ldap.client.cache.LdapStructureCache

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.