List of usage examples for org.apache.http.util Args notNull
public static <T> T notNull(T t, String str)
From source file:com.github.tomakehurst.wiremock.testsupport.MultipartBody.java
MultipartBody(String name, byte[] body) { super(ContentType.APPLICATION_OCTET_STREAM); Args.notEmpty(name, "Name was empty"); Args.notNull(body, "Body was null"); this.name = name; this.body = body; }
From source file:org.jenkinsci.plugins.relution_publisher.net.requests.ZeroCopyFileRequest.java
public ZeroCopyFileRequest(final String uri, final File file) { super(Method.POST, uri); Args.notNull(file, "file"); this.mFile = file; }
From source file:com.wudaosoft.net.httpclient.FileResponseHandler.java
public FileResponseHandler(final File file) { this.file = Args.notNull(file, "file"); }
From source file:org.fcrepo.client.MoveBuilder.java
/** * Instantiate builder/*www .j a v a 2s .c om*/ * * @param sourceUrl uri of the resource * @param destinationUrl uri for the new path for the moved resource * @param client the client */ protected MoveBuilder(final URI sourceUrl, final URI destinationUrl, final FcrepoClient client) { super(sourceUrl, client); Args.notNull(destinationUrl, "Destination URL"); // Add the required destination header to the request request.addHeader(DESTINATION, destinationUrl.toString()); }
From source file:com.messagemedia.restapi.client.v1.internal.http.interceptors.RequestDateInterceptor.java
@Override public void process(HttpRequest request, HttpContext context) throws HttpException, IOException { Args.notNull(request, "HTTP request"); if (!request.containsHeader(HTTP.DATE_HEADER)) { final String httpdate = DATE_GENERATOR.getCurrentDate(); request.setHeader(HTTP.DATE_HEADER, httpdate); }/*from www . j av a2 s. c o m*/ }
From source file:com.messagemedia.restapi.client.v1.internal.http.interceptors.ContentTypeInterceptor.java
@Override public void process(HttpRequest request, HttpContext context) throws HttpException, IOException { Args.notNull(request, "HTTP request"); if ((request instanceof HttpEntityEnclosingRequest) && !request.containsHeader(HTTP.CONTENT_TYPE)) { request.setHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); }/* ww w .j a v a 2 s . c o m*/ }
From source file:com.ok2c.lightmtp.impl.protocol.LocalClientSessionFactory.java
public LocalClientSessionFactory(final DeliveryRequestHandler deliveryRequestHandler, final String heloName) { super();//from w ww . j a v a2 s. c o m Args.notNull(deliveryRequestHandler, "Delivery request handler"); this.deliveryRequestHandler = deliveryRequestHandler; this.heloName = heloName; }
From source file:com.wudaosoft.net.httpclient.OutputStreamResponseHandler.java
/** * always return null./*ww w .j a va 2 s . c om*/ */ @Override public Object handleResponse(HttpResponse response) throws ClientProtocolException, IOException { Args.notNull(out, "OutputStream"); int status = response.getStatusLine().getStatusCode(); if (status != 200) { throw new ClientProtocolException("Unexpected response status: " + status); } HttpEntity entity = response.getEntity(); if (entity == null || !entity.isStreaming()) { throw new ClientProtocolException("Response contains no content"); } InputStream inputStream = entity.getContent(); try { byte[] buff = new byte[4096]; int l = -1; while ((l = inputStream.read(buff)) != -1) { out.write(buff, 0, l); } out.flush(); return null; } finally { try { out.close(); } catch (IOException e) { } } }
From source file:com.ok2c.lightmtp.impl.pool.MailIOSessionManager.java
public MailIOSessionManager(final ConnectingIOReactor ioreactor) { super();/*from w ww. ja va 2s . c o m*/ Args.notNull(ioreactor, "I/O reactor"); this.pool = new CPool(ioreactor, 20, 50); }
From source file:com.wudaosoft.net.httpclient.SSLContextBuilder.java
public SSLContext buildPKCS12() { Args.notEmpty(password, "password"); Args.notNull(cert, "cert"); char[] pwd = password.toCharArray(); try {//from w w w . j av a 2 s . c o m KeyStore ks = KeyStore.getInstance("PKCS12"); ks.load(cert.openStream(), pwd); // & ? KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmf.init(ks, pwd); // SSLContext SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(kmf.getKeyManagers(), null, new SecureRandom()); return sslContext; } catch (Exception e) { if (e instanceof RuntimeException) throw (RuntimeException) e; throw new RuntimeException(e); } }