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.ok2c.lightmtp.impl.protocol.ServiceReadyCodec.java

@Override
public void produceData(final IOSession iosession, final ServerState sessionState)
        throws IOException, SMTPProtocolException {
    Args.notNull(iosession, "IO session");
    Args.notNull(sessionState, "Session state");

    SessionOutputBuffer buf = this.iobuffers.getOutbuf();

    if (this.pendingReply != null) {
        this.writer.write(this.pendingReply, buf);
        this.pendingReply = null;
    }/*from w w w .j  a va2  s.  c om*/

    if (buf.hasData()) {
        buf.flush(iosession.channel());
    }
    if (!buf.hasData()) {
        this.completed = true;
        iosession.setEventMask(SelectionKey.OP_READ);
    }
}

From source file:nl.nn.adapterframework.http.mime.MultipartEntityBuilder.java

public MultipartEntityBuilder setContentType(ContentType contentType) {
    Args.notNull(contentType, "Content type");
    this.contentType = contentType;
    return this;
}

From source file:pl.allegro.tech.hermes.consumers.consumer.sender.http.ByteBufferEntity.java

public ByteBufferEntity(final ByteBuffer buffer, final ContentType contentType) {
    super();//from w  w w.  j a va2  s  .c  o  m
    Args.notNull(buffer, "Source byte buffer");
    this.buffer = buffer;
    if (contentType != null) {
        setContentType(contentType.toString());
    }
}

From source file:com.ok2c.lightmtp.impl.protocol.ReceiveDataCodec.java

public ReceiveDataCodec(final SMTPBuffers iobuffers, final File workingDir, final DeliveryHandler handler,
        final DataAckMode mode) {
    super();/*from   w  ww.j  a v  a 2 s  .  c  o m*/
    Args.notNull(iobuffers, "IO buffers");
    Args.notNull(workingDir, "Working directory");
    Args.notNull(handler, "Devliry handler");
    this.iobuffers = iobuffers;
    this.workingDir = workingDir;
    this.handler = handler;
    this.mode = mode != null ? mode : DataAckMode.SINGLE;
    this.writer = new SMTPReplyWriter(true);
    this.pendingReplies = new LinkedList<SMTPReply>();
    this.lineBuf = new CharArrayBuffer(LINE_SIZE);
    this.contentBuf = new SMTPOutputBuffer(BUF_SIZE, LINE_SIZE, SMTPConsts.ISO_8859_1);

    this.dataReceived = false;
    this.pendingDelivery = null;
    this.completed = false;
}

From source file:gov.ic.geoint.bulleit.apache.UriPatternMatcher.java

/**
 * @deprecated (4.1) do not use/*from  w  w w.j a  va 2 s  . com*/
 */
@Deprecated
public synchronized void setObjects(final Map<String, T> map) {
    Args.notNull(map, "Map of handlers");
    this.map.clear();
    this.map.putAll(map);
}

From source file:com.ok2c.lightmtp.impl.pool.MailIOSessionManager.java

public Future<LeasedSession> leaseSession(final SessionEndpoint endpoint, final long connectTimeout,
        final TimeUnit tunit, final FutureCallback<LeasedSession> callback) {
    Args.notNull(endpoint, "Session endpoint");
    if (this.log.isDebugEnabled()) {
        this.log.debug("Session request: " + format(endpoint, null) + formatStats(endpoint));
    }/*from w ww.  j a  v a2 s  .  c  o  m*/
    final BasicFuture<LeasedSession> future = new BasicFuture<LeasedSession>(callback);
    this.pool.lease(endpoint, null, connectTimeout, tunit != null ? tunit : TimeUnit.MILLISECONDS,
            new InternalPoolEntryCallback(future));
    return future;
}

From source file:com.ok2c.lightmtp.impl.protocol.ExtendedSendHeloCodec.java

@Override
public void produceData(final IOSession iosession, final ClientState sessionState)
        throws IOException, SMTPProtocolException {
    Args.notNull(iosession, "IO session");
    Args.notNull(sessionState, "Session state");

    SessionOutputBuffer buf = this.iobuffers.getOutbuf();

    String myHelo = heloName;/*from   ww  w  . ja  v a2  s  . co  m*/
    if (myHelo == null) {
        myHelo = AddressUtils.resolveLocalDomain(iosession.getLocalAddress());
    }
    switch (this.codecState) {
    case EHLO_READY:
        SMTPCommand ehlo = new SMTPCommand("EHLO", myHelo);
        this.writer.write(ehlo, buf);
        this.codecState = CodecState.EHLO_RESPONSE_EXPECTED;
        break;
    case HELO_READY:
        SMTPCommand helo = new SMTPCommand("HELO", myHelo);
        this.writer.write(helo, buf);
        this.codecState = CodecState.HELO_RESPONSE_EXPECTED;
        break;
    }

    if (buf.hasData()) {
        buf.flush(iosession.channel());
    }
    if (!buf.hasData()) {
        iosession.clearEvent(SelectionKey.OP_WRITE);
    }
}

From source file:com.amos.tool.SelfRedirectStrategy.java

public boolean isRedirected(final HttpRequest request, final HttpResponse response, final HttpContext context)
        throws ProtocolException {
    Args.notNull(request, "HTTP request");
    Args.notNull(response, "HTTP response");

    final int statusCode = response.getStatusLine().getStatusCode();
    final String method = request.getRequestLine().getMethod();
    final Header locationHeader = response.getFirstHeader("location");
    switch (statusCode) {
    case HttpStatus.SC_MOVED_TEMPORARILY:
        return isRedirectable(method) && locationHeader != null;
    case HttpStatus.SC_MOVED_PERMANENTLY:
    case HttpStatus.SC_TEMPORARY_REDIRECT:
        return isRedirectable(method);
    case HttpStatus.SC_SEE_OTHER:
        return true;
    default://from   ww  w  .j  a  v a 2s . c  o m
        return false;
    } //end of switch
}

From source file:com.ok2c.lightmtp.impl.protocol.SendQuitCodec.java

@Override
public void consumeData(final IOSession iosession, final ClientState sessionState)
        throws IOException, SMTPProtocolException {
    Args.notNull(iosession, "IO session");
    Args.notNull(sessionState, "Session state");

    SessionInputBuffer buf = this.iobuffers.getInbuf();

    int bytesRead = buf.fill(iosession.channel());
    SMTPReply reply = this.parser.parse(buf, bytesRead == -1);

    if (reply != null) {
        switch (this.codecState) {
        case QUIT_RESPONSE_EXPECTED:
            iosession.close();//from ww  w. java2 s. c o  m
            this.codecState = CodecState.COMPLETED;
            sessionState.setReply(reply);
            break;
        default:
            throw new SMTPProtocolException("Unexpected reply: " + reply);
        }
    }
}