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:com.github.etorres.codexposed.ArgValidator.java

/**
 * Example: set valid values to method parameters. Internally uses Guava immutable maps.
 * @param required - required parameter, empty map is allowed
 * @param optional - optional parameter/*from  www  . j ava 2 s. co  m*/
 * @return A new map combining both input parameters.
 * @throws NullPointerException When a required parameter has <code>null</code> value.
 */
public Map<String, String> immutableMapParams(final Map<String, String> required,
        final @Nullable Map<String, String> optional) {
    final ImmutableMap<String, String> required2 = ImmutableMap
            .copyOf(checkNotNull(required, "Uninitialized list"));
    final ImmutableMap<String, String> optional2 = (optional != null ? ImmutableMap.copyOf(optional)
            : ImmutableMap.<String, String>of());
    // operate on the canonicalized version of the parameters
    final Map<String, String> response = new Hashtable<>(required2);
    response.putAll(optional2);
    return response;
}

From source file:com.jaspersoft.jasperserver.war.action.WebflowReportContextAccessor.java

public void initFlowScope(RequestContext requestContext) {
    Map flowValues = new HashMap();

    requestContext.getRequestParameters().asMap();
    flowValues.putAll(requestContext.getRequestParameters().asMap());

    // try to preserve REQUEST_PARAMETER_REPORT_CONTEXT_ID
    Map oldFlowMap = (Map) requestContext.getFlowScope().get(parameterFlowReportContext);
    if (oldFlowMap != null) {
        flowValues.put(requestParameterReportContextId, oldFlowMap.get(requestParameterReportContextId));
    }/*  w w w. ja  v a2s .  co  m*/

    requestContext.getFlowScope().put(parameterFlowReportContext, flowValues);//FIXMEJIVE
}

From source file:com.opengamma.integration.copier.snapshot.writer.FileSnapshotWriter.java

private void writeUnstructuredMarketDataSnapshot(Map<String, String> prefixes,
        UnstructuredMarketDataSnapshot snapshot) {

    for (ExternalIdBundle eib : snapshot.getTargets()) {
        Map<String, String> tempRow = new HashMap<>();
        tempRow.putAll(prefixes);
        tempRow.put(SnapshotColumns.ID_BUNDLE.get(), StringUtils.join(eib.getExternalIds(), '|'));
        //Row written by writeValueSnapshot
        writeValueSnapshot(tempRow, snapshot.getTargetValues(eib));
    }/*from ww w .j av a2 s. c om*/
}

From source file:cn.org.once.cstack.cli.utils.ModuleUtils.java

public String runScript(String moduleName, File file) {
    applicationUtils.checkConnectedAndApplicationSelected();

    Module module = findModule(moduleName);

    Map<String, Object> parameters = new HashMap<>();
    parameters.put("file", new FileSystemResource(file));
    parameters.putAll(authenticationUtils.getMap());

    String url = String.format("%s%s%s/run-script", authenticationUtils.finalHost, urlLoader.modulePrefix,
            module.getName());/*w  w w.j ava2s. c  om*/

    log.info("Running script...");

    restUtils.sendPostForUpload(url, parameters);

    return "Done";
}

From source file:storage.StorageServiceWrapperController.java

@ResponseBody
@RequestMapping(value = "/", method = RequestMethod.GET)
public String listStorageServices() {

    final Map<String, StorageService> storageServices = new HashMap<>();
    storageServices.putAll(appContext.getBeansOfType(StorageService.class));
    storageServices.putAll(appContext.getParent().getBeansOfType(StorageService.class));

    if (log.isDebugEnabled()) {
        for (final Map.Entry<String, StorageService> entry : storageServices.entrySet()) {
            log.debug("Storage service '{}' : '{}'", entry.getKey(), entry.getValue());
        }//from  w  w  w . j  ava  2  s  .  com
    }

    return storageServices.toString();
}

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

protected Map<String, Object> doAllClassGroupsDisplay(Map params, Map<String, Object> page,
        VitroRequest request, ServletContext context) {
    Map<String, Object> body = new HashMap<String, Object>();
    body.putAll(getCommonValues(context, request));
    body.putAll(getAllClassGroupData(request, params, page, context));

    return body;/*  ww  w.j  a v a  2s  .com*/
}

From source file:io.wcm.config.core.impl.ParameterOverrideProviderBridge.java

@Override
public void changed() {
    Map<String, String> overrideMap = new HashMap<>();
    for (ParameterOverrideProvider provider : parameterOverrideProviders) {
        overrideMap.putAll(provider.getOverrideMap());
    }/*from ww w .  j  av a2  s.  c o m*/
    if (overrideMap.isEmpty()) {
        overrideStrings = ImmutableList.of();
        return;
    }

    List<String> overrideStringList = new ArrayList<>();
    ConfigurationMetadata configMetadata = configManager
            .getConfigurationMetadata(ParameterProviderBridge.DEFAULT_CONFIG_NAME);
    for (Map.Entry<String, String> entry : overrideMap.entrySet()) {
        String item = toCaConfigOverrideString(entry.getKey(), entry.getValue(), configMetadata);
        if (item != null) {
            overrideStringList.add(item);
        }
    }
    overrideStrings = ImmutableList.copyOf(overrideStringList);
}

From source file:org.openrepose.commons.utils.http.ServiceClient.java

public ServiceClientResponse post(String uri, Map<String, String> headers, String body,
        MediaType contentMediaType) {/*  w w  w.  j a va2  s  .  com*/
    HttpPost post = new HttpPost(uri);

    Map<String, String> requestHeaders = new HashMap<>();
    requestHeaders.putAll(headers);
    String localContentType = contentMediaType.getType() + "/" + contentMediaType.getSubtype();
    requestHeaders.put(CommonHttpHeader.CONTENT_TYPE.toString(), localContentType);

    // TODO: Remove setting the accept type to XML by default
    if (!requestHeaders.containsKey(CommonHttpHeader.ACCEPT.toString())) {
        requestHeaders.put(CommonHttpHeader.ACCEPT.toString(), MediaType.APPLICATION_XML);
    }

    setHeaders(post, requestHeaders);

    if (body != null && !body.isEmpty()) {
        post.setEntity(new InputStreamEntity(new ByteArrayInputStream(body.getBytes()), body.length()));
    }
    return execute(post);
}

From source file:com.alibaba.jstorm.daemon.supervisor.SandBoxMaker.java

/**
 * Generate command string//from w  w  w.  j  av a  2  s.co m
 * 
 * @param workerId
 * @return
 * @throws IOException
 */
public String sandboxPolicy(String workerId, Map<String, String> replaceMap) throws IOException {
    if (isEnable == false) {
        return "";
    }

    replaceMap.putAll(replaceBaseMap);

    String tmpPolicy = generatePolicyFile(replaceMap);

    File file = new File(tmpPolicy);
    String policyPath = StormConfig.worker_root(conf, workerId) + File.separator + SANBOX_TEMPLATE_NAME;
    File dest = new File(policyPath);
    file.renameTo(dest);

    StringBuilder sb = new StringBuilder();
    sb.append(" -Djava.security.manager -Djava.security.policy=");
    sb.append(policyPath);

    return sb.toString();

}

From source file:com.nesscomputing.testing.ServiceDefinitionBuilder.java

private Config getConfig(final Map<String, String> config) {
    final Map<String, String> configTweaks = Maps.newHashMap();
    for (TweakedModule tweakedModule : tweakedModules) {
        configTweaks.putAll(tweakedModule.getServiceConfigTweaks());
    }/*from w  w w.  j ava 2 s .c o  m*/

    return Config.getOverriddenConfig(baseConfig, new MapConfiguration(config),
            new MapConfiguration(configKeys));
}