List of usage examples for java.util Map putAll
void putAll(Map<? extends K, ? extends V> m);
From source file:io.apiman.gateway.engine.policies.auth.LDAPIdentityValidator.java
/** * Formats the configured DN by replacing any properties it finds. * @param dnPattern//from w w w. j a v a 2s . c o m * @param username * @param request */ private String formatDn(String dnPattern, String username, ServiceRequest request) { Map<String, String> valuesMap = new HashMap<String, String>(); valuesMap.putAll(request.getHeaders()); valuesMap.put("username", username); //$NON-NLS-1$ StrSubstitutor sub = new StrSubstitutor(valuesMap); return sub.replace(dnPattern); }
From source file:com.screenslicer.webapp.ScreenSlicerClient.java
@Path("create") @POST/* w w w .ja v a 2 s . co m*/ @Consumes("application/json") @Produces("application/json") public static final Response create(String reqString) { if (reqString != null) { final String reqDecoded = Crypto.decode(reqString, CommonUtil.ip()); if (reqDecoded != null) { final Map<String, Object> args = CommonUtil.gson.fromJson(reqDecoded, CommonUtil.objectType); final Request request = CommonUtil.gson.fromJson(reqDecoded, Request.class); Field[] fields = request.getClass().getFields(); for (Field field : fields) { args.remove(field.getName()); } new Thread(new Runnable() { @Override public void run() { String myInstance = null; AtomicBoolean myDone = null; try { CommonFile.writeStringToFile( new File("./data/" + request.runGuid + "-meta" + request.appId), request.jobId + "\n" + request.jobGuid + "\n" + Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTimeInMillis(), false); CommonFile.writeStringToFile(new File("./data/" + request.runGuid + "-context"), Crypto.encode(reqDecoded), false); Map<String, AtomicBoolean> myDoneMap = new HashMap<String, AtomicBoolean>(); synchronized (doneMapLock) { for (int i = 0; i < request.instances.length; i++) { if (!doneMap.containsKey(request.instances[i])) { doneMap.put(request.instances[i], new AtomicBoolean(true)); } } myDoneMap.putAll(doneMap); } long myThread = latestThread.incrementAndGet(); while (true) { if (isCancelled(request.runGuid)) { curThread.incrementAndGet(); throw new CancellationException(); } if (myThread == curThread.get() + 1) { for (Map.Entry<String, AtomicBoolean> done : myDoneMap.entrySet()) { if (done.getValue().compareAndSet(true, false)) { if (ScreenSlicer.isBusy(done.getKey())) { done.getValue().set(true); } else { myInstance = done.getKey(); myDone = done.getValue(); break; } } } if (myInstance != null) { break; } } try { Thread.sleep(WAIT); } catch (Exception e) { Log.exception(e); } } curThread.incrementAndGet(); int outputNumber = 0; request.instances = new String[] { myInstance }; Map<String, List<List<String>>> tables = customApp.tableData(request, args); Map<String, Map<String, Object>> jsons = customApp.jsonData(request, args); Map<String, byte[]> binaries = customApp.binaryData(request, args); request.emailExport.attachments = new LinkedHashMap<String, byte[]>(); if (tables != null) { for (Map.Entry<String, List<List<String>>> table : tables.entrySet()) { if (table.getKey().toLowerCase().endsWith(".xls")) { byte[] result = Spreadsheet.xls(table.getValue()); CommonFile.writeByteArrayToFile( new File("./data/" + request.runGuid + "-result" + outputNumber), result, false); CommonFile.writeStringToFile( new File("./data/" + request.runGuid + "-result-names"), escapeName(table.getKey()) + "\n", true); ++outputNumber; if (request.emailResults) { request.emailExport.attachments.put(table.getKey(), result); } } else if (table.getKey().toLowerCase().endsWith(".csv")) { String result = Spreadsheet.csv(table.getValue()); CommonFile.writeStringToFile( new File("./data/" + request.runGuid + "-result" + outputNumber), result, false); CommonFile.writeStringToFile( new File("./data/" + request.runGuid + "-result-names"), escapeName(table.getKey()) + "\n", true); ++outputNumber; if (request.emailResults) { request.emailExport.attachments.put(table.getKey(), result.getBytes("utf-8")); } } else if (table.getKey().toLowerCase().endsWith(".xcsv")) { String result = Spreadsheet.csv(table.getValue()); CommonUtil.internalHttpCall(CommonUtil.ip(), "https://" + CommonUtil.ip() + ":8000/_/" + Crypto.fastHash(table.getKey() + ":" + request.runGuid), "PUT", CommonUtil.asMap("Content-Type", "text/csv; charset=utf-8"), result.getBytes("utf-8"), null); CommonFile.writeStringToFile( new File("./data/" + request.runGuid + "-result-names"), escapeName(table.getKey()) + "\n", true); ++outputNumber; if (request.emailResults) { request.emailExport.attachments.put(table.getKey(), result.getBytes("utf-8")); } } else { String result = CommonUtil.gson.toJson(table.getValue(), table.getValue().getClass()); CommonFile.writeStringToFile( new File("./data/" + request.runGuid + "-result" + outputNumber), result, false); CommonFile.writeStringToFile( new File("./data/" + request.runGuid + "-result-names"), escapeName(table.getKey()) + "\n", true); ++outputNumber; if (request.emailResults) { request.emailExport.attachments.put(table.getKey(), result.getBytes("utf-8")); } } } } if (jsons != null) { for (Map.Entry<String, Map<String, Object>> json : jsons.entrySet()) { String result = CommonUtil.gson.toJson(json.getValue(), CommonUtil.objectType); CommonFile.writeStringToFile( new File("./data/" + request.runGuid + "-result" + outputNumber), result, false); CommonFile.writeStringToFile( new File("./data/" + request.runGuid + "-result-names"), escapeName(json.getKey()) + "\n", true); ++outputNumber; if (request.emailResults) { request.emailExport.attachments.put(json.getKey(), result.getBytes("utf-8")); } } } if (binaries != null) { for (Map.Entry<String, byte[]> binary : binaries.entrySet()) { CommonFile.writeByteArrayToFile( new File("./data/" + request.runGuid + "-result" + outputNumber), binary.getValue(), false); CommonFile.writeStringToFile( new File("./data/" + request.runGuid + "-result-names"), escapeName(binary.getKey()) + "\n", true); ++outputNumber; if (request.emailResults) { request.emailExport.attachments.put(binary.getKey(), binary.getValue()); } } } if (request.emailResults) { ScreenSlicer.export(request, request.emailExport); } } catch (Throwable t) { Log.exception(t); } finally { try { CommonFile.writeStringToFile( new File("./data/" + request.runGuid + "-meta" + request.appId), "\n" + Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTimeInMillis(), true); } catch (Throwable t) { Log.exception(t); } myDone.set(true); synchronized (cancelledLock) { cancelledJobs.remove(request.runGuid); } } } }).start(); return Response.ok(Crypto.encode(request.runGuid, CommonUtil.ip())).build(); } } return null; }
From source file:com.ejisto.util.collector.MockedFieldCollector.java
@Override public BinaryOperator<Map<String, List<MockedField>>> combiner() { return (m1, m2) -> { Map<String, List<MockedField>> result = new TreeMap<>(); result.putAll(m1); m2.entrySet().stream().forEach(e -> result.merge(e.getKey(), e.getValue(), ListUtils::union)); return result; };//from w w w .j a v a 2s .c om }
From source file:org.logicblaze.lingo.DefaultResultJoinStrategy.java
public RemoteInvocationResult mergeResponses(RemoteInvocationResult currentResult, RemoteInvocationResult newResult, int responseCount) { Object value = currentResult.getValue(); Object newValue = newResult.getValue(); if (value instanceof Collection) { Collection coll = (Collection) value; if (newValue instanceof Collection) { coll.addAll((Collection) newValue); } else {// w w w. j a va2 s. co m coll.add(newValue); } } else if (value instanceof Map && newValue instanceof Map) { Map map = (Map) value; map.putAll((Map) newValue); } return currentResult; }
From source file:com.lrs.servelt.RestDispacherServlet.java
public Map buildParams(HttpServletRequest request, UrlMapping mapping) { Map params = new LinkedHashMap<>(); params.putAll(RequestUtils.buildParams(request)); params.putAll(mapping.getParamas()); return params; }
From source file:uk.co.christhomson.sibyl.cache.connectors.HashMapConnector.java
public void putAll(String cacheName, Map<?, ?> data) throws CacheException { Map<Object, Object> cache = getCache(cacheName); cache.putAll(data); }
From source file:com.github.fge.jsonschema.syntax.checkers.helpers.DependenciesSyntaxChecker.java
@Override protected final void checkValue(final Collection<JsonPointer> pointers, final ProcessingReport report, final SchemaTree tree) throws ProcessingException { final JsonNode node = getNode(tree); final Map<String, JsonNode> map = Maps.newTreeMap(); map.putAll(JacksonUtils.asMap(node)); String key;/*from w w w .ja v a 2s. c om*/ JsonNode value; for (final Map.Entry<String, JsonNode> entry : map.entrySet()) { key = entry.getKey(); value = entry.getValue(); if (value.isObject()) pointers.add(JsonPointer.of(keyword, key)); else checkDependency(report, entry.getKey(), tree); } }
From source file:net.jawr.web.bundle.processor.spring.SpringControllerBundleProcessor.java
/** * Initialize the servlets which will handle the request to the JawrSpringController * @param servletContext the servlet context * @return the list of servlet definition for the JawrSpringControllers * @throws ServletException if a servlet exception occurs *//*from w w w . j a v a2 s .co m*/ @SuppressWarnings("rawtypes") public List<ServletDefinition> initJawrSpringServlets(ServletContext servletContext) throws ServletException { List<ServletDefinition> jawrServletDefinitions = new ArrayList<ServletDefinition>(); ContextLoader contextLoader = new ContextLoader(); WebApplicationContext applicationCtx = contextLoader.initWebApplicationContext(servletContext); Map<?, ?> jawrControllersMap = applicationCtx.getBeansOfType(JawrSpringController.class); Iterator<?> entrySetIterator = jawrControllersMap.entrySet().iterator(); while (entrySetIterator.hasNext()) { JawrSpringController jawrController = (JawrSpringController) ((Map.Entry) entrySetIterator.next()) .getValue(); Map<String, Object> initParams = new HashMap<String, Object>(); initParams.putAll(jawrController.getInitParams()); ServletConfig servletConfig = new MockServletConfig(SPRING_DISPATCHER_SERVLET, servletContext, initParams); MockJawrSpringServlet servlet = new MockJawrSpringServlet(jawrController, servletConfig); ServletDefinition servletDefinition = new ServletDefinition(servlet, servletConfig); jawrServletDefinitions.add(servletDefinition); } contextLoader.closeWebApplicationContext(servletContext); return jawrServletDefinitions; }
From source file:com.alibaba.ims.web.module.screen.System.java
/** * // w ww .j a v a 2s . com * * @return */ public ActionResult<Map<String, Object>> doLoadContext() { Map<String, Object> context = new LinkedHashMap<String, Object>(); context.putAll(DictManager.getAll()); return new ActionResult<Map<String, Object>>(ResultCode.SUCCESS, context); }
From source file:com.netflix.spinnaker.clouddriver.kubernetes.v2.op.handler.KubernetesEventHandler.java
@Override public void addRelationships(Map<KubernetesKind, List<KubernetesManifest>> allResources, Map<KubernetesManifest, List<KubernetesManifest>> relationshipMap) { relationshipMap.putAll(allResources.getOrDefault(EVENT, new ArrayList<>()).stream() .map(m -> ImmutablePair.of(m, KubernetesCacheDataConverter.getResource(m, V1Event.class))) .collect(Collectors.toMap(ImmutablePair::getLeft, p -> Collections.singletonList(involvedManifest(p.getRight()))))); }