Example usage for org.apache.commons.collections Bag contains

List of usage examples for org.apache.commons.collections Bag contains

Introduction

In this page you can find the example usage for org.apache.commons.collections Bag contains.

Prototype

boolean contains(Object o);

Source Link

Document

Returns true if this collection contains the specified element.

Usage

From source file:io.hops.hopsworks.common.security.CertificateMaterializer.java

/**
 * Check if certificates have been materialized in the *local* filesystem in the directory specified
 *
 * @param username Username of the user/*from  w ww  .jav  a  2 s.  co  m*/
 * @param projectName Name of the project
 * @param directory Directory to check if the certificates have been materialized
 * @return True if the material exists in the cache, otherwise false
 */
public boolean existsInLocalStore(String username, String projectName, String directory) {
    directory = directory != null ? directory : transientDir;
    MaterialKey key = new MaterialKey(username, projectName);
    ReentrantReadWriteLock.ReadLock lock = null;
    try {
        lock = getReadLockForKey(key);
        if (lock == null) {
            LOG.log(Level.WARNING, "Could not find read lock for key " + key.getExtendedUsername());
            return false;
        }
        lock.lock();
        Bag materializedPaths = materializedCerts.get(key);
        if (materializedPaths == null) {
            return false;
        }

        return materializedPaths.contains(directory);
    } finally {
        if (lock != null) {
            lock.unlock();
        }
    }
}