List of usage examples for java.util Collections emptyMap
@SuppressWarnings("unchecked") public static final <K, V> Map<K, V> emptyMap()
From source file:com.example.app.profile.ui.user.LoginLandingLinks.java
/** * Get the link.//from ww w . jav a 2s . c o m * * @param memberships Membership list. * @param lc the LocaleContext. * * @return the link. */ public Optional<Link> getLink(List<Membership> memberships, LocaleContext lc) { DAOs daos = new DAOs(); if (canAccessMenuLink(getOperation(daos), memberships)) { ApplicationFunction func = daos.applicationRegistry.getApplicationFunctionByName(getFunctionName()); Link link = daos.applicationRegistry.createLink(Event.getRequest(), Event.getResponse(), func, Collections.emptyMap()); link.putAdditionalAttribute("label", getLabel(daos, lc)); return Optional.of(link); } return Optional.empty(); }
From source file:org.osiam.security.authentication.OsiamClientDetails.java
@Override public Map<String, Object> getAdditionalInformation() { return Collections.emptyMap(); }
From source file:edu.cornell.mannlib.vitro.webapp.utils.pageDataGetter.PageDataGetterUtils.java
public static Map<String, Object> getAdditionalData(String pageUri, String dataGetterName, Map<String, Object> page, VitroRequest vreq, PageDataGetter getter, ServletContext context) { if (dataGetterName == null || dataGetterName.isEmpty()) return Collections.emptyMap(); if (getter != null) { try {/*from w w w .j av a 2s .c om*/ log.debug("Retrieve data for this data getter for " + pageUri); return getter.getData(context, vreq, pageUri, page); } catch (Throwable th) { log.error(th, th); return Collections.emptyMap(); } } else { return Collections.emptyMap(); } }
From source file:org.elasticsearch.smoketest.MonitoringWithWatcherRestIT.java
public void testThatHttpExporterAddsWatches() throws Exception { String watchId = createMonitoringWatch(); String httpHost = getHttpHost(); String body = BytesReference.bytes(jsonBuilder().startObject().startObject("transient") .field("xpack.monitoring.exporters.my_http_exporter.type", "http") .field("xpack.monitoring.exporters.my_http_exporter.host", httpHost) .field("xpack.monitoring.exporters.my_http_exporter.cluster_alerts.management.enabled", true) .endObject().endObject()).utf8ToString(); adminClient().performRequest("PUT", "_cluster/settings", Collections.emptyMap(), new StringEntity(body, ContentType.APPLICATION_JSON)); assertTotalWatchCount(ClusterAlertsUtil.WATCH_IDS.length); assertMonitoringWatchHasBeenOverWritten(watchId); }
From source file:facebook4j.internal.json.TaggedJSONImpl.java
private void init(JSONObject json) throws FacebookException { try {/*from w w w . j av a 2 s . c o m*/ id = getRawString("id", json); type = getRawString("type", json); if (type.equals("photo")) { photo = new PhotoJSONImpl(json); } else if (type.equals("video")) { video = new VideoJSONImpl(json); } else { post = new PostJSONImpl(json); } if (!json.isNull("message")) { message = getRawString("message", json); } if (!json.isNull("message_tags")) { JSONObject messageTagsJSONObject = json.getJSONObject("message_tags"); messageTags = new HashMap<String, Tag[]>(); @SuppressWarnings("unchecked") Iterator<String> keys = messageTagsJSONObject.keys(); while (keys.hasNext()) { String key = (String) keys.next(); JSONArray messageTagsJSONArray = messageTagsJSONObject.getJSONArray(key); Tag[] tags = new Tag[messageTagsJSONArray.length()]; for (int i = 0; i < messageTagsJSONArray.length(); i++) { JSONObject tag = messageTagsJSONArray.getJSONObject(i); tags[i] = new TagJSONImpl(tag); } messageTags.put(key, tags); } } else { messageTags = Collections.emptyMap(); } if (!json.isNull("object_id")) { objectId = getRawString("object_id", json); } privacy = new PrivacyJSONImpl(json.getJSONObject("privacy")); if (!json.isNull("to")) { JSONArray toJSONArray = json.getJSONObject("to").getJSONArray("data"); to = new ArrayList<Category>(); for (int i = 0; i < toJSONArray.length(); i++) { JSONObject toJSONObject = toJSONArray.getJSONObject(i); to.add(new CategoryJSONImpl(toJSONObject)); } } else { to = Collections.emptyList(); } updatedTime = getISO8601Datetime("updated_time", json); } catch (JSONException jsone) { throw new FacebookException(jsone); } }
From source file:com.epam.reportportal.auth.TokenServicesFacade.java
public OAuth2AccessToken createToken(ReportPortalClient client, String username, Authentication userAuthentication) { return createToken(client, username, userAuthentication, Collections.emptyMap()); }
From source file:org.callimachusproject.test.WebResource.java
public WebResource create(String type, byte[] body) throws IOException { Map<String, String> headers = Collections.emptyMap(); return create(headers, type, body); }
From source file:io.github.carlomicieli.footballdb.starter.parsers.PlayerProfileParser.java
protected static Map<String, String> extractHighSchool(Optional<String> str) { return str.map(val -> { String s = normalize(val); List<String> tokens = Stream .of(s.replace("High School: ", "").replace("]", "").replace("[", ",").split(",")) .map(String::trim).collect(Collectors.toList()); if (tokens.size() < 2) { return Collections.<String, String>emptyMap(); }/*from www .j ava 2s . com*/ Map<String, String> v = newMap(); v.put("high_school", tokens.get(0)); if (tokens.size() == 2) v.put("state", tokens.get(1)); else { v.put("city", tokens.get(1)); v.put("state", tokens.get(2)); } return unmodifiableMap(v); }).orElse(Collections.emptyMap()); }
From source file:com.github.horrorho.inflatabledonkey.KeyBagManager.java
public KeyBagManager(BiFunction<HttpClient, String, Optional<KeyBag>> keyBagFactory) { this(keyBagFactory, Collections.emptyMap()); }
From source file:com.iflytek.android.framework.volley.toolbox.BasicNetwork.java
@Override public NetworkResponse performRequest(Request<?> request) throws VolleyError { long requestStart = SystemClock.elapsedRealtime(); while (true) { VolleyLog.e("NetworkResponse performRequest"); HttpResponse httpResponse = null; byte[] responseContents = null; Map<String, String> responseHeaders = Collections.emptyMap(); try {//from ww w .j a v a2s .c o m // Gather headers. Map<String, String> headers = new HashMap<String, String>(); addCacheHeaders(headers, request.getCacheEntry()); httpResponse = mHttpStack.performRequest(request, headers); StatusLine statusLine = httpResponse.getStatusLine(); int statusCode = statusLine.getStatusCode(); responseHeaders = convertHeaders(httpResponse.getAllHeaders()); // Handle cache validation. if (statusCode == HttpStatus.SC_NOT_MODIFIED) { Entry entry = request.getCacheEntry(); if (entry == null) { return new NetworkResponse(HttpStatus.SC_NOT_MODIFIED, null, responseHeaders, true, SystemClock.elapsedRealtime() - requestStart); } // A HTTP 304 response does not have all header fields. We // have to use the header fields from the cache entry plus // the new ones from the response. // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.5 entry.responseHeaders.putAll(responseHeaders); return new NetworkResponse(HttpStatus.SC_NOT_MODIFIED, entry.data, entry.responseHeaders, true, SystemClock.elapsedRealtime() - requestStart); } // Handle moved resources if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY) { String newUrl = responseHeaders.get("Location"); request.setRedirectUrl(newUrl); } // Some responses such as 204s do not have content. We must check. if (httpResponse.getEntity() != null) { responseContents = entityToBytes(httpResponse.getEntity()); } else { // Add 0 byte response as a way of honestly representing a // no-content request. responseContents = new byte[0]; } // if the request is slow, log it. long requestLifetime = SystemClock.elapsedRealtime() - requestStart; logSlowRequests(requestLifetime, request, responseContents, statusLine); if (statusCode < 200 || statusCode > 299) { throw new IOException(); } return new NetworkResponse(statusCode, responseContents, responseHeaders, false, SystemClock.elapsedRealtime() - requestStart); } catch (SocketTimeoutException e) { VolleyLog.e("NetworkResponse performRequest SocketTimeoutException"); attemptRetryOnException("socket", request, new TimeoutError()); } catch (ConnectTimeoutException e) { VolleyLog.e("NetworkResponse performRequest ConnectTimeoutException"); attemptRetryOnException("connection", request, new TimeoutError()); } catch (MalformedURLException e) { throw new RuntimeException("Bad URL " + request.getUrl(), e); } catch (IOException e) { int statusCode = 0; NetworkResponse networkResponse = null; if (httpResponse != null) { statusCode = httpResponse.getStatusLine().getStatusCode(); } else { throw new NoConnectionError(e); } if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY) { VolleyLog.e("Request at %s has been redirected to %s", request.getOriginUrl(), request.getUrl()); } else { VolleyLog.e("Unexpected response code %d for %s", statusCode, request.getUrl()); } if (responseContents != null) { VolleyLog.e("NetworkResponse performRequest responseContents != null"); networkResponse = new NetworkResponse(statusCode, responseContents, responseHeaders, false, SystemClock.elapsedRealtime() - requestStart); if (statusCode == HttpStatus.SC_UNAUTHORIZED || statusCode == HttpStatus.SC_FORBIDDEN) { VolleyLog.e("NetworkResponse performRequest responseContents != null 1111111"); attemptRetryOnException("auth", request, new AuthFailureError(networkResponse)); } else if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY) { VolleyLog.e("NetworkResponse performRequest responseContents != null 22222222"); attemptRetryOnException("redirect", request, new RedirectError(networkResponse)); } else { // TODO: Only throw ServerError for 5xx status codes. throw new ServerError(networkResponse); } } else { throw new NetworkError(e); } } } }