Example usage for org.apache.http.util Args notNull

List of usage examples for org.apache.http.util Args notNull

Introduction

In this page you can find the example usage for org.apache.http.util Args notNull.

Prototype

public static <T> T notNull(T t, String str) 

Source Link

Usage

From source file:com.serphacker.serposcope.scraper.http.extensions.CloseableBasicHttpClientConnectionManager.java

@Override
public void upgrade(final HttpClientConnection conn, final HttpRoute route, final HttpContext context)
        throws IOException {
    Args.notNull(conn, "Connection");
    Args.notNull(route, "HTTP route");
    Asserts.check(conn == this.conn, "Connection not obtained from this manager");
    this.connectionOperator.upgrade(this.conn, route.getTargetHost(), context);
}

From source file:com.serphacker.serposcope.scraper.http.extensions.CloseableBasicHttpClientConnectionManager.java

@Override
public synchronized void closeIdleConnections(final long idletime, final TimeUnit tunit) {
    Args.notNull(tunit, "Time unit");
    if (this.isShutdown.get()) {
        return;//from  ww w  . j  a v a  2s . c  o m
    }
    if (!this.leased) {
        long time = tunit.toMillis(idletime);
        if (time < 0) {
            time = 0;
        }
        final long deadline = System.currentTimeMillis() - time;
        if (this.updated <= deadline) {
            closeConnection();
        }
    }
}

From source file:com.wudaosoft.net.httpclient.Request.java

/**
 * //  w w  w  . j  a v  a  2s  .c om
 * @param params
 * @return
 */
public static List<NameValuePair> buildUrlNameValuePair(Map<String, String> params) {
    Args.notNull(params, "params");

    List<NameValuePair> parameters = new ArrayList<NameValuePair>(params.size());

    for (Map.Entry<String, String> entry : params.entrySet()) {
        parameters.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
    }

    return parameters;
}

From source file:io.apiman.gateway.platforms.servlet.connectors.ssl.SSLSessionStrategyFactory.java

private static SSLContextBuilder loadTrustMaterial(SSLContextBuilder builder, final File file, final char[] tsp,
        final TrustStrategy trustStrategy)
        throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException {
    Args.notNull(file, "Truststore file"); //$NON-NLS-1$
    final KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
    final FileInputStream instream = new FileInputStream(file);
    try {//from  ww w  .  j  a  v  a 2  s  .  c  om
        trustStore.load(instream, tsp);
    } finally {
        instream.close();
    }
    return builder.loadTrustMaterial(trustStore, trustStrategy);
}

From source file:com.wudaosoft.net.httpclient.Request.java

/**
 * @param params//  ww  w  .j  a  va2  s . co m
 * @param charset
 * @return
 */
public UrlEncodedFormEntity buildUrlEncodedFormEntity(Map<String, String> params, Charset charset) {
    Args.notNull(params, "params");

    List<NameValuePair> parameters = new ArrayList<NameValuePair>(params.size());

    for (Map.Entry<String, String> entry : params.entrySet()) {
        parameters.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
    }

    return new UrlEncodedFormEntity(parameters, charset);
}

From source file:me.ixfan.wechatkit.message.MessageManager.java

/**
 * ? OpenId ??//from  w  ww .  j ava 2 s  .c  o  m
 * @param content ?
 * @param openIds OpenId 
 * @return ???? {@link WeChatApiResult#getMsgId()} ????ID
 * ??? {@link WeChatApiResult#getErrcode()}  {@link WeChatApiResult#getErrmsg()}
 * ??
 */
public WeChatApiResult sendMassTextMessageToUsers(String content, String... openIds) {
    Args.notEmpty(content, "?");
    Args.notNull(openIds, "OpenId");
    Args.notEmpty(Arrays.asList(openIds), "OpenId");

    final String url = WeChatConstants.WECHAT_POST_MESSAGE_MASS_SNED_BY_OPENIDS.replace("${ACCESS_TOKEN}",
            super.getTokenManager().getAccessToken());
    MessageForMassSend msg = new MessageForMassSend(OutMessageType.TEXT, content, Arrays.asList(openIds));
    try {
        JsonObject jsonResponse = HttpClientUtil.sendPostRequestWithJsonBody(url, msg.toJsonString());
        return WeChatApiResult.instanceOf(jsonResponse);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}