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

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

Introduction

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

Prototype

boolean remove(Object object);

Source Link

Document

(Violation) Removes all occurrences of the given object from the bag.

Usage

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

private void forceRemoveLocalMaterial(String username, String projectName, String materializationDirectory) {
    ReentrantReadWriteLock.WriteLock lock = null;
    try {//from   ww w .  j  a v a  2s . co  m
        materializationDirectory = materializationDirectory != null ? materializationDirectory : transientDir;
        MaterialKey key = new MaterialKey(username, projectName);
        lock = getWriteLockForKey(key);
        lock.lock();
        // First remove from File Removers list
        Map<String, LocalFileRemover> materialRemovers = fileRemovers.get(key);
        if (materialRemovers != null) {
            LocalFileRemover fileRemover = materialRemovers.remove(materializationDirectory);
            if (fileRemover != null) {
                fileRemover.scheduledFuture.cancel(true);
            }
            if (materialRemovers.isEmpty()) {
                fileRemovers.remove(key);
            }
        }

        // Then remove from material Map and maybe from Cache
        Bag materialBag = materializedCerts.get(key);
        if (materialBag != null) {
            materialBag.remove(materializationDirectory);
            if (materialBag.isEmpty()) {
                materializedCerts.remove(key);
                CryptoMaterial material = materialCache.remove(key);
                if (material != null) {
                    material.wipePassword();
                }
            }
        }

        // Then from local FS
        deleteMaterialFromLocalFs(key, materializationDirectory);
        removeLockForKey(key);
    } finally {
        lock.unlock();
    }
}