Example usage for org.apache.commons.collections MultiHashMap keySet

List of usage examples for org.apache.commons.collections MultiHashMap keySet

Introduction

In this page you can find the example usage for org.apache.commons.collections MultiHashMap keySet.

Prototype

public Set<K> keySet() 

Source Link

Document

Returns a Set view of the keys contained in this map.

Usage

From source file:it.geosolutions.geobatch.catalog.impl.BaseCatalog.java

/**
 *
 *//*from www . ja v a 2  s. com*/
@SuppressWarnings("unchecked")
<R extends Resource> List<R> lookup(final Class<R> clazz, final MultiHashMap map) {
    final List<R> result = new ArrayList<R>();

    for (final Class<R> key : (Iterable<Class<R>>) map.keySet()) {
        // for (final Iterator<Class<T>> k = map.keySet().iterator();
        // k.hasNext();) {
        // final Class<T> key = k.next();
        if (clazz.isAssignableFrom(key)) {
            result.addAll(map.getCollection(key));
        }
    }

    return result;
}

From source file:org.geoserver.catalog.impl.CatalogImpl.java

List lookup(Class clazz, MultiHashMap map) {
    ArrayList result = new ArrayList();
    for (Iterator k = map.keySet().iterator(); k.hasNext();) {
        Class key = (Class) k.next();
        if (clazz.isAssignableFrom(key)) {
            result.addAll(map.getCollection(key));
        }/*from w w w .ja v a 2 s .c  o m*/
    }

    return result;
}

From source file:org.geoserver.catalog.impl.DefaultCatalogFacade.java

<T> List<T> lookup(Class<T> clazz, MultiHashMap map) {
    ArrayList<T> result = new ArrayList<T>();
    for (Iterator k = map.keySet().iterator(); k.hasNext();) {
        Class key = (Class) k.next();
        if (clazz.isAssignableFrom(key)) {
            Collection value = map.getCollection(key);
            // the map could have been modified in the meantime and the collection removed,
            // check before adding 
            if (value != null) {
                result.addAll(value);//  w ww . j a  v a 2s.c  o m
            }
        }
    }

    return result;
}

From source file:org.infoscoop.service.AuthCredentialService.java

public String addCredential(String uid, String authType, String authUid, String authPasswd, String authDomain,
        String targetUrl, MultiHashMap headerMap) {
    if (authType != null && "ntlm".equalsIgnoreCase(authType))
        authUid = authUid.toLowerCase();

    ProxyRequest proxy = new ProxyRequest(targetUrl, "NoOperation");
    proxy.setPortalUid(uid);//from w w  w  . j  a v  a2  s .  co m
    Set<String> keys = headerMap.keySet();
    for (String key : keys) {
        Collection<String> headers = (Collection<String>) headerMap.get(key);
        for (String header : headers) {
            proxy.putRequestHeader(key, header);
        }
    }
    proxy.putRequestHeader("authType", authType);
    proxy.putRequestHeader("authUserid", authUid);
    proxy.putRequestHeader("authpassword", authPasswd);
    int status = 0;
    try {
        if (authType != null && authType.indexOf("post") == 0) {
            status = proxy.executePost();
        } else {
            status = proxy.executeGet();
        }
    } catch (Exception e) {
        log.warn(e.getMessage());
    }
    if (status == 401) {
        return null;
    } else if (status < 200 || status >= 300) {
        throw new RuntimeException("Status " + status + " returned from " + targetUrl + ".");
    }

    AuthCredential c = new AuthCredential();
    c.setUid(uid);
    c.setAuthType(authType);
    c.setAuthUid(authUid);
    c.setAuthPasswd(authPasswd);
    c.setAuthDomain(authDomain);

    return authCredentialDAO.add(c).toString();
}

From source file:org.infoscoop.service.TabLayoutService.java

/**
 * Return map of Customization information related to role information.
 * Return default Customization information if role can not be found.
 *
 * @param resource/*from   www  .j  a  va  2s .c o  m*/
 * @return Map
 * <UL>
 *    <LI>key      : tabId</LI>
 *    <LI>value   : XmlObject</LI>
 * </UL>
 * @throws DataResourceException
 */
public Map getMyTabLayout(String tabId) {
    Map resultMap = new HashMap();
    Subject loginUser = SecurityController.getContextSubject();
    if (loginUser == null) {
        // Return default
        resultMap = getDefaultTabLayout(null);
    } else {
        long start = System.currentTimeMillis();
        MultiHashMap map = this.tabLayoutDAO.getTabLayout(tabId);
        Iterator ite = map.keySet().iterator();

        while (ite.hasNext()) {
            boolean isEmpty = true;
            String key = (String) ite.next();
            List layoutList = (List) map.get(key);

            Iterator docIte = layoutList.iterator();
            while (docIte.hasNext()) {
                TabLayout layout = (TabLayout) docIte.next();

                try {
                    if (RoleUtil.isPermitted(layout.getPrincipaltype(), layout.getRole())) {
                        isEmpty = false;
                        resultMap.put(key, layout);
                        break;
                    }
                } catch (ClassNotFoundException e) {
                    log.error("", e);
                }
            }

            if (isEmpty) {
                // Default of tab is obtained if tab information can not be found.
                putDefaultTabLayout(key, layoutList, resultMap);
            }
        }
    }
    Map map = sortMapBySortId(resultMap);
    return map;
}

From source file:org.infoscoop.service.TabLayoutService.java

/**
 * Obtain default tablayout information.
 *
 * @param resource/*  w ww. j av a2 s .  c  om*/
 * @param layoutMap
 * @return Map
 * <UL>
 *    <LI>key      : tabId</LI>
 *    <LI>value   : XmlObject</LI>
 * </UL>
 * @throws DataResourceException
 */
public Map getDefaultTabLayout(MultiHashMap layoutMap) {
    Map resultMap = new HashMap();
    if (layoutMap == null) {
        layoutMap = this.tabLayoutDAO.getTabLayout(null);
        //         layoutMap = TabLayoutDAO.newInstance().getTabLayout(null);
    }

    Iterator ite = layoutMap.keySet().iterator();
    while (ite.hasNext()) {
        String key = (String) ite.next();
        List tabList = (List) layoutMap.get(key);
        putDefaultTabLayout(key, tabList, resultMap);
    }
    return resultMap;
}