Example usage for java.util Map putAll

List of usage examples for java.util Map putAll

Introduction

In this page you can find the example usage for java.util Map putAll.

Prototype

void putAll(Map<? extends K, ? extends V> m);

Source Link

Document

Copies all of the mappings from the specified map to this map (optional operation).

Usage

From source file:ac.elements.io.Signature.java

/**
 * Calculate String to Sign for SignatureVersion 1.
 * /*from www .  j a v a2s  .co m*/
 * @param parameters
 *            request parameters
 * 
 * @return String to Sign
 * 
 * @throws java.security.SignatureException
 */
private static String calculateStringToSignV1(Map<String, String> parameters) {
    StringBuilder data = new StringBuilder();
    Map<String, String> sorted = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
    sorted.putAll(parameters);
    Iterator<Entry<String, String>> pairs = sorted.entrySet().iterator();
    while (pairs.hasNext()) {
        Map.Entry<String, String> pair = pairs.next();
        data.append(pair.getKey());
        data.append(pair.getValue());
    }
    return data.toString();
}

From source file:com.egt.core.db.util.Reporter.java

private static Map getReportParametersMap(File file, String format, Long userid, String usercode,
        String username, Map parametros) {
    Map parameters = getReportParametersMap(file, format, userid, usercode, username);
    if (parametros != null && !parametros.isEmpty()) {
        parameters.putAll(parametros);
    }/*from  w ww . java 2s.co  m*/
    return parameters;
}

From source file:edu.cornell.mannlib.vitro.webapp.utils.pageDataGetter.PageDataGetterUtils.java

public static Map<String, Object> getDataForPage(String pageUri, VitroRequest vreq, ServletContext context)
        throws InstantiationException, IllegalAccessException, ClassNotFoundException {
    //Based on page type get the appropriate data getter
    Map<String, Object> page = vreq.getWebappDaoFactory().getPageDao().getPage(pageUri);

    Map<String, Object> data = new HashMap<String, Object>();
    List<PageDataGetter> dataGetters = getPageDataGetterObjects(vreq, pageUri);
    for (PageDataGetter getter : dataGetters) {
        try {//from  w  w  w  .j  a v a2  s  .c  o m
            Map<String, Object> moreData = null;
            moreData = getAdditionalData(pageUri, getter.getType(), page, vreq, getter, context);
            if (moreData != null)
                data.putAll(moreData);
        } catch (Throwable th) {
            log.error(th, th);
        }
    }
    return data;
}

From source file:ac.elements.io.Signature.java

/**
 * Gets the parameters.//from  ww  w. java 2  s  . co m
 * 
 * @param keyValuePairs
 *            the key value pairs
 * @param id
 *            the id
 * @param key
 *            the key
 * 
 * @return the parameters
 * @throws SignatureException
 */
private static Map<String, String> getParameters(Map<String, String> keyValuePairs, String id, String key)
        throws SignatureException {

    Map<String, String> parameters = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);

    parameters.putAll(keyValuePairs);

    addRequiredParametersToRequest(parameters, id, key);

    return parameters;
}

From source file:Main.java

public static Map<String, String> XmlAsMap(Node node) {
    Map<String, String> map = new HashMap<String, String>();
    NodeList nodeList = node.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node currentNode = nodeList.item(i);
        if (currentNode.hasAttributes()) {
            for (int j = 0; j < currentNode.getAttributes().getLength(); j++) {
                Node item = currentNode.getAttributes().item(i);
                if (item != null)
                    map.put(item.getNodeName(), prepare(item.getTextContent()));
            }//from w w  w  .  j a  va2  s.  co m
        }
        if (currentNode.getFirstChild() != null) {
            if (currentNode.getFirstChild().getNodeType() == Node.ELEMENT_NODE) {
                map.putAll(XmlAsMap(currentNode));
            } else if (currentNode.getFirstChild().getNodeType() == Node.TEXT_NODE) {
                map.put(currentNode.getLocalName(), prepare(currentNode.getTextContent()));
            }
        }
    }
    return map;
}

From source file:com.dtolabs.rundeck.core.tasks.net.SSHTaskBuilder.java

private static void configureSSHBase(final INodeEntry nodeentry, final Project project,
        final SSHConnectionInfo sshConnectionInfo, final SSHBaseInterface sshbase, final double loglevel,
        final PluginLogger logger) throws BuilderException {

    sshbase.setFailonerror(true);/*from  w  w w  .j  a  v a 2s.  com*/
    sshbase.setTrust(true); // set this true to avoid  "reject HostKey" errors
    sshbase.setProject(project);
    sshbase.setVerbose(loglevel >= Project.MSG_VERBOSE);
    sshbase.setHost(nodeentry.extractHostname());
    // If the node entry contains a non-default port, configure the connection to use it.
    if (nodeentry.containsPort()) {
        final int portNum;
        try {
            portNum = Integer.parseInt(nodeentry.extractPort());
        } catch (NumberFormatException e) {
            throw new BuilderException("Port number is not valid: " + nodeentry.extractPort(), e);
        }
        sshbase.setPort(portNum);
    }
    final String username = sshConnectionInfo.getUsername();
    if (null == username) {
        throw new BuilderException("username was not set");
    }
    sshbase.setUsername(username);

    final AuthenticationType authenticationType = sshConnectionInfo.getAuthenticationType();
    if (null == authenticationType) {
        throw new BuilderException("SSH authentication type undetermined");
    }
    switch (authenticationType) {
    case privateKey:
        /**
         * Configure keybased authentication
         */
        final String sshKeypath = sshConnectionInfo.getPrivateKeyfilePath();
        final String sshKeyResource = sshConnectionInfo.getPrivateKeyResourcePath();
        if (null != sshKeyResource) {
            if (!PathUtil.asPath(sshKeyResource).getPath().startsWith("keys/")) {
                throw new BuilderException(
                        "SSH Private key path is expected to start with \"keys/\": " + sshKeyResource);
            }
            logger.log(Project.MSG_DEBUG, "Using ssh key storage path: " + sshKeyResource);
            try {
                InputStream privateKeyResourceData = sshConnectionInfo.getPrivateKeyResourceData();
                sshbase.setSshKeyData(privateKeyResourceData);
            } catch (StorageException e) {
                logger.log(Project.MSG_ERR,
                        "Failed to read SSH Private key stored at path: " + sshKeyResource + ": " + e);
                throw new BuilderException("Failed to read SSH Private key stored at path: " + sshKeyResource,
                        e);
            } catch (IOException e) {
                logger.log(Project.MSG_ERR,
                        "Failed to read SSH Private key stored at path: " + sshKeyResource + ": " + e);
                throw new BuilderException("Failed to read SSH Private key stored at path: " + sshKeyResource,
                        e);
            }
        } else if (null != sshKeypath && !"".equals(sshKeypath)) {
            if (!new File(sshKeypath).exists()) {
                throw new BuilderException("SSH Keyfile does not exist: " + sshKeypath);
            }
            logger.log(Project.MSG_DEBUG, "Using ssh keyfile: " + sshKeypath);
            sshbase.setKeyfile(sshKeypath);
        } else {
            throw new BuilderException(
                    "SSH Keyfile or storage path must be set to use privateKey " + "authentication");
        }
        final String passphrase = sshConnectionInfo.getPrivateKeyPassphrase();
        if (null != passphrase) {
            sshbase.setPassphrase(passphrase);
        } else {
            sshbase.setPassphrase(""); // set empty otherwise password will be required
        }
        break;
    case password:
        final String password = sshConnectionInfo.getPassword();
        final boolean valid = null != password && !"".equals(password);
        if (!valid) {
            throw new BuilderException("SSH Password was not set");
        }
        sshbase.setPassword(password);
        break;
    }
    Map<String, String> sshConfig = sshConnectionInfo.getSshConfig();
    Map<String, String> baseConfig = new HashMap<String, String>(getDefaultSshConfig());
    if (null != sshConfig) {
        baseConfig.putAll(sshConfig);
    }
    sshbase.setSshConfig(baseConfig);
    sshbase.setPluginLogger(logger);
}

From source file:com.netflix.spinnaker.clouddriver.kubernetes.v2.caching.agent.KubernetesCacheDataConverter.java

public static CacheData convertAsResource(String account, KubernetesManifest manifest,
        List<KubernetesManifest> resourceRelationships) {
    KubernetesCachingProperties cachingProperties = KubernetesManifestAnnotater.getCachingProperties(manifest);
    if (cachingProperties.isIgnore()) {
        return null;
    }/*  w w  w. j av  a  2s  .c o  m*/

    logMalformedManifest(() -> "Converting " + manifest + " to a cached resource", manifest);

    KubernetesKind kind = manifest.getKind();
    boolean hasClusterRelationship = false;
    boolean isNamespaced = true;
    if (kind != null) {
        hasClusterRelationship = kind.hasClusterRelationship();
        isNamespaced = kind.isNamespaced();
    }

    KubernetesApiVersion apiVersion = manifest.getApiVersion();
    String name = manifest.getName();
    String namespace = manifest.getNamespace();
    Namer<KubernetesManifest> namer = account == null ? new KubernetesManifestNamer()
            : NamerRegistry.lookup().withProvider(KubernetesCloudProvider.getID()).withAccount(account)
                    .withResource(KubernetesManifest.class);
    Moniker moniker = namer.deriveMoniker(manifest);

    Map<String, Object> attributes = new ImmutableMap.Builder<String, Object>().put("kind", kind)
            .put("apiVersion", apiVersion).put("name", name).put("namespace", namespace)
            .put("fullResourceName", manifest.getFullResourceName()).put("manifest", manifest)
            .put("moniker", moniker).build();

    KubernetesManifestSpinnakerRelationships relationships = KubernetesManifestAnnotater
            .getManifestRelationships(manifest);
    Artifact artifact = KubernetesManifestAnnotater.getArtifact(manifest);
    KubernetesManifestMetadata metadata = KubernetesManifestMetadata.builder().relationships(relationships)
            .moniker(moniker).artifact(artifact).build();

    Map<String, Collection<String>> cacheRelationships = new HashMap<>();

    String application = moniker.getApp();
    if (StringUtils.isEmpty(application)) {
        log.debug(
                "Encountered not-spinnaker-owned resource " + namespace + ":" + manifest.getFullResourceName());
    } else {
        cacheRelationships.putAll(annotatedRelationships(account, metadata, hasClusterRelationship));
    }

    // TODO(lwander) avoid overwriting keys here
    cacheRelationships.putAll(ownerReferenceRelationships(account, namespace, manifest.getOwnerReferences()));
    cacheRelationships.putAll(implicitRelationships(manifest, account, resourceRelationships));

    if (isNamespaced) {
        cacheRelationships.putAll(namespaceRelationship(account, namespace));
    }

    String key = Keys.infrastructure(kind, account, namespace, name);
    return new DefaultCacheData(key, infrastructureTtlSeconds, attributes, cacheRelationships);
}

From source file:com.cloudera.whirr.cm.CmServerClusterInstance.java

public static Map<String, String> getDeviceMappings(ClusterSpec specification, Set<Instance> instances) {
    Map<String, String> deviceMappings = new HashMap<String, String>();
    if (specification != null && instances != null && !instances.isEmpty()) {
        deviceMappings
                .putAll(new VolumeManager().getDeviceMappings(specification, instances.iterator().next()));
    }/*from   w  w w  .  j ava 2  s  .c o m*/
    return deviceMappings;
}

From source file:com.samczsun.helios.Helios.java

public static Map<String, byte[]> getAllLoadedData() {
    Map<String, byte[]> data = new HashMap<>();
    for (LoadedFile loadedFile : files.values()) {
        data.putAll(loadedFile.getData());
    }// www  .j  av a2  s.  com
    for (LoadedFile loadedFile : path.values()) {
        data.putAll(loadedFile.getData());
    }
    return data;
}

From source file:de.micromata.mgc.jpa.hibernatesearch.impl.SearchEmgrFactoryRegistryUtils.java

private static void addCustomSearchFields(ISearchEmgr<?> emgr, EntityMetadata entm,
        Map<String, SearchColumnMetadata> ret) {
    List<HibernateSearchInfo> cil = ClassUtils.findClassAnnotations(entm.getJavaType(),
            HibernateSearchInfo.class);
    for (HibernateSearchInfo ci : cil) {
        HibernateSearchFieldInfoProvider fip = PrivateBeanUtils.createInstance(ci.fieldInfoProvider());
        Map<String, SearchColumnMetadata> sm = fip.getAdditionallySearchFields(entm, ci.param());
        if (sm != null) {
            ret.putAll(sm);
        }/* ww  w.java 2 s. com*/
    }
}