Java Code Examples for org.apache.commons.lang.StringUtils.deleteWhitespace()

The following are Jave code examples for showing how to use deleteWhitespace() of the org.apache.commons.lang.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: DogTags   File: PlaceholderAPIHook.java   Source Code and License Vote up 5 votes
@Override
public String onPlaceholderRequest(Player p, String identifier) {
    if(identifier.equals("current_tag")){
        String storageTag = StorageHandler.getPlayerTag(p);

        String tag = storageTag != null ? storageTag : "";

        DogTag dt = DogTags.getTag(tag);
        if(dt == null){
            return StringUtils.deleteWhitespace("");
        }else return dt.getPrefix();

    }
    return null;
}
 
Example 2
Project: incubator-servicecomb-java-chassis   File: ConfigCenterClient.java   Source Code and License Vote up 4 votes
public void doWatch(String configCenter)
    throws URISyntaxException, UnsupportedEncodingException, InterruptedException {
  CountDownLatch waiter = new CountDownLatch(1);
  IpPort ipPort = NetUtils.parseIpPortFromURI(configCenter);
  String url = URIConst.REFRESH_ITEMS + "?dimensionsInfo="
      + StringUtils.deleteWhitespace(URLEncoder.encode(serviceName, "UTF-8"));
  Map<String, String> headers = new HashMap<>();
  headers.put("x-domain-name", tenantName);
  if (ConfigCenterConfig.INSTANCE.getToken() != null) {
    headers.put("X-Auth-Token", ConfigCenterConfig.INSTANCE.getToken());
  }

  HttpClientWithContext vertxHttpClient = clientMgr.findThreadBindClientPool();
  vertxHttpClient.runOnContext(client -> {
    Map<String, String> authHeaders = new HashMap<>();
    authHeaderProviders.forEach(provider -> authHeaders.putAll(provider.getSignAuthHeaders(
        createSignRequest(null, configCenter + url, headers, null))));

    client.websocket(refreshPort, ipPort.getHostOrIp(), url,
        new CaseInsensitiveHeaders().addAll(headers)
            .addAll(authHeaders),
        ws -> {
          ws.exceptionHandler(e -> {
            LOGGER.error("watch config read fail", e);
            stopHeartBeatThread();
            isWatching = false;
          });
          ws.closeHandler(v -> {
            LOGGER.warn("watching config connection is closed accidentally");
            stopHeartBeatThread();
            isWatching = false;
          });
          ws.handler(action -> {
            LOGGER.info("watching config recieved {}", action);
            Map<String, Object> mAction = action.toJsonObject().getMap();
            if ("CREATE".equals(mAction.get("action"))) {
              refreshConfig(configCenter);
            } else if ("MEMBER_CHANGE".equals(mAction.get("action"))) {
              refreshMembers(memberdis);
            } else {
              parseConfigUtils.refreshConfigItemsIncremental(mAction);
            }
          });
          startHeartBeatThread(ws);
          isWatching = true;
          waiter.countDown();
        },
        e -> {
          LOGGER.error("watcher connect to config center {} failed: {}", serverUri, e.getMessage());
          waiter.countDown();
        });
  });
  waiter.await();
}