List of usage examples for java.util Map putAll
void putAll(Map<? extends K, ? extends V> m);
From source file:com.google.enterprise.connector.otex.LivelinkConnectorFactory.java
public static LivelinkConnector getConnector(String prefix) throws RepositoryException { Map<String, String> p = new HashMap<String, String>(); p.putAll(emptyProperties); Properties system = System.getProperties(); Enumeration<?> names = system.propertyNames(); boolean prefixFound = false; while (names.hasMoreElements()) { String name = (String) names.nextElement(); if (name.startsWith(prefix)) { prefixFound = true;// ww w . j av a2 s . c o m LOGGER.config("PROPERTY: " + name); p.put(name.substring(prefix.length()), system.getProperty(name)); } } // If there is no connector configured by this name, bail early. if (!prefixFound) { throw new RepositoryException("No javatest." + prefix + "* properties specified for connector."); } return (LivelinkConnector) instance.makeConnector(p); }
From source file:io.fabric8.maven.core.extenvvar.ExternalEnvVarHandler.java
public static Map<String, String> getExportedEnvironmentVariables(MavenProject project, Map<String, String> envVars) { Map<String, String> ret = getEnvironmentVarsFromJsonSchema(project, envVars); ret.putAll(envVars); return ret;//from w w w . j a va 2 s . com }
From source file:com.arellomobile.android.push.DeviceFeature2_5.java
static void sendPushStat(Context context, String hash) { final Map<String, Object> data = new HashMap<String, Object>(); data.putAll(RequestHelper.getSendPushStatData(context, hash, NetworkUtils.PUSH_VERSION)); Log.w(TAG, "Try To sent PushStat"); NetworkUtils.NetworkResult res = new NetworkUtils.NetworkResult(-1, null); Exception exception = new Exception(); for (int i = 0; i < NetworkUtils.MAX_TRIES; ++i) { try {/*from w w w .jav a 2 s . com*/ res = NetworkUtils.makeRequest(data, PUSH_STAT); if (200 == res.getResultCode()) { Log.w(TAG, "Send PushStat success"); return; } } catch (Exception e) { exception = e; } } Log.e(TAG, "ERROR: Try To sent PushStat " + exception.getMessage() + ". Response = " + res.getResultData(), exception); }
From source file:com.arellomobile.android.push.DeviceFeature2_5.java
static void sendAppOpen(Context context) { final Map<String, Object> data = new HashMap<String, Object>(); data.putAll(RequestHelper.getSendAppOpenData(context, NetworkUtils.PUSH_VERSION)); Log.w(TAG, "Try To sent AppOpen"); NetworkUtils.NetworkResult res = new NetworkUtils.NetworkResult(-1, null); Exception exception = new Exception(); for (int i = 0; i < NetworkUtils.MAX_TRIES; ++i) { try {/*from www.j a va 2s . co m*/ res = NetworkUtils.makeRequest(data, APP_OPEN); if (200 == res.getResultCode()) { Log.w(TAG, "Send AppOpen success"); return; } } catch (Exception e) { exception = e; } } Log.e(TAG, "ERROR: Try To sent AppOpen " + exception.getMessage() + ". Response = " + res.getResultData(), exception); }
From source file:com.arellomobile.android.push.DeviceFeature2_5.java
public static PushZoneLocation getNearestZone(Context context, Location location) throws Exception { final Map<String, Object> data = new HashMap<String, Object>(); data.putAll(RequestHelper.getNearestZoneData(context, location, NetworkUtils.PUSH_VERSION)); Log.w(TAG, "Try To Sent Nearest Zone"); NetworkUtils.NetworkResult res = new NetworkUtils.NetworkResult(-1, null); Exception exception = new Exception(); for (int i = 0; i < NetworkUtils.MAX_TRIES; ++i) { try {//from www . j a v a 2 s . c o m res = NetworkUtils.makeRequest(data, NEAREST_ZONE); if (200 == res.getResultCode()) { Log.w(TAG, "Send Nearest Zone success"); return RequestHelper.getPushZoneLocationFromData(res.getResultData(), NetworkUtils.PUSH_VERSION); } } catch (Exception e) { exception = e; } } Log.e(TAG, "ERROR: sent Nearest Zon " + exception.getMessage() + ". Response = " + res, exception); throw exception; }
From source file:Main.java
@SafeVarargs public static <K, V> Map<K, V> merge(Map<K, V>... maps) { if (maps == null) { return null; }/*www.ja va 2s.c o m*/ Map<K, V> result = null; for (Map<K, V> map : maps) { if (map != null) { if (result == null) { result = new LinkedHashMap<K, V>(); } result.putAll(map); } } return result; }
From source file:ext.sns.service.OAuth2Service.java
/** * ??URI/* w w w . j a v a 2s. c o m*/ * * @param providerName ???? * @param type ???nullempty * @param backExtParam ???????nullempty * @param specialParamKey ?Key?providerkey???????null * @return ?URI */ public static String getRequestAuthURI(String providerName, String type, Map<String, String> backExtParam, String specialParamKey) { if (!ConfigManager.getProviderConfigByName(providerName).getTypes().contains(type)) { throw new IllegalArgumentException(providerName + "?" + type + "?."); } if (StringUtils.isBlank(type)) { throw new IllegalArgumentException("type can't be blank."); } Map<String, String> callbackParam = new HashMap<String, String>(); if (MapUtils.isNotEmpty(backExtParam)) { callbackParam.putAll(backExtParam); } return OAuth2Client.getAuthRequestURI(providerName, type, callbackParam, specialParamKey); }
From source file:com.alibaba.jstorm.utils.LoadConf.java
public static Map LoadProperty(String prop) { InputStream in = null;/*w ww. j a v a2 s .c om*/ Properties properties = new Properties(); try { in = getConfigFileInputStream(prop); properties.load(in); } catch (FileNotFoundException e) { throw new RuntimeException("No such file " + prop); } catch (Exception e1) { throw new RuntimeException("Failed to read config file"); } finally { if (null != in) { try { in.close(); } catch (IOException e) { throw new RuntimeException(e); } } } Map ret = new HashMap(); ret.putAll(properties); return ret; }
From source file:org.jhk.pulsing.web.service.prod.helper.PulseServiceUtil.java
public static Map<Long, String> processTrendingPulseSubscribe(Set<String> tps, ObjectMapper objMapper) { @SuppressWarnings("unchecked") Map<Long, String> tpSubscriptions = Collections.EMPTY_MAP; final Map<String, Integer> count = new HashMap<>(); tps.parallelStream().forEach(tpsIdValueCounts -> { try {//from w w w .j a va2s. c o m _LOGGER.debug( "PulseServiceUtil.processTrendingPulseSubscribe: trying to convert " + tpsIdValueCounts); Map<String, Integer> converted = objMapper.readValue(tpsIdValueCounts, _TRENDING_PULSE_SUBSCRIPTION_TYPE_REF); _LOGGER.debug("PulseServiceUtil.processTrendingPulseSubscribe: sucessfully converted " + converted.size()); //Structure is <id>0x07<value>0x13<timestamp> -> count; i.e. {"10020x07Mocked 10020x13<timestamp>" -> 1} //Need to split the String content, gather the count for the searched interval //and return the sorted using Java8 stream //TODO impl better Map<String, Integer> computed = converted.entrySet().stream().reduce(new HashMap<String, Integer>(), (Map<String, Integer> mapped, Entry<String, Integer> entry) -> { String[] split = entry.getKey() .split(CommonConstants.TIME_INTERVAL_PERSIST_TIMESTAMP_DELIM); Integer value = entry.getValue(); mapped.compute(split[0], (key, val) -> { return val == null ? value : val + value; }); return mapped; }, (Map<String, Integer> result, Map<String, Integer> aggregated) -> { result.putAll(aggregated); return result; }); computed.entrySet().parallelStream().forEach(entry -> { Integer value = entry.getValue(); count.compute(entry.getKey(), (key, val) -> { return val == null ? value : val + value; }); }); } catch (Exception cException) { cException.printStackTrace(); } }); if (count.size() > 0) { tpSubscriptions = count.entrySet().stream() .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())) .collect(Collectors.toMap( entry -> Long.parseLong( entry.getKey().split(CommonConstants.TIME_INTERVAL_ID_VALUE_DELIM)[0]), entry -> entry.getKey().split(CommonConstants.TIME_INTERVAL_ID_VALUE_DELIM)[1], (x, y) -> { throw new AssertionError(); }, LinkedHashMap::new)); } return tpSubscriptions; }
From source file:com.arellomobile.android.push.DeviceFeature2_5.java
static JSONArray sendTags(Context context, Map<String, Object> tags) throws Exception { final Map<String, Object> data = new HashMap<String, Object>(); data.putAll(RequestHelper.getSendTagsData(context, NetworkUtils.PUSH_VERSION)); JSONObject tagsObject = new JSONObject(); for (String key : tags.keySet()) { Object value = tags.get(key); if (value instanceof String || value instanceof Integer) { tagsObject.put(key, value);//w w w . j ava 2 s.c om } else if (value instanceof List) { JSONArray values = new JSONArray(); for (Object item : (List<?>) value) { if (item instanceof String || item instanceof Integer) { values.put(String.valueOf(item)); } else { throw new RuntimeException("wrong type for tag: " + key); } } tagsObject.put(key, values); } else { throw new RuntimeException("wrong type for tag: " + key); } } data.put("tags", tagsObject); Log.w(TAG, "Try To sent Tags"); NetworkUtils.NetworkResult res = new NetworkUtils.NetworkResult(-1, null); Exception exception = new Exception(); for (int i = 0; i < NetworkUtils.MAX_TRIES; ++i) { try { res = NetworkUtils.makeRequest(data, TAGS_PATH); if (200 == res.getResultCode()) { Log.w(TAG, "Send Tags success"); return res.getResultData().getJSONObject("response").getJSONArray("skipped"); } } catch (Exception e) { exception = e; } } Log.e(TAG, "ERROR: sent Tags " + exception.getMessage() + ". Response = " + res, exception); throw exception; }