Marshall the {@link PutMediaRequest} to a {@link Request}.

@param request POJO request to marshall.
@return Marshalled request object.
320256
private Request<PutMediaRequest> marshall(PutMediaRequest request) {
        Request<PutMediaRequest> marshalled = new PutMediaRequestProtocolMarshaller(protocolFactory).marshall(request);
        marshalled.setEndpoint(endpoint);
        marshalled.addHeader(HttpHeaderNames.TRANSFER_ENCODING.toString(), HttpHeaderValues.CHUNKED.toString());
        return marshalled;
    }
146375
public static ScopedRequest unwrapRequest( ServletRequest request )
    {
        // Unwrap the multipart request, if there is one.
        if ( request instanceof MultipartRequestWrapper )
        {
            request = ( ( MultipartRequestWrapper ) request ).getRequest();
        }

        while ( request instanceof ServletRequestWrapper )
        {
            if ( request instanceof ScopedRequest )
            {
                return ( ScopedRequest ) request;
            }
            else
            {
                request = ( ( ServletRequestWrapper ) request ).getRequest();
            }
        }
        
        return null;
    }
1286753
@Override
	public void handleRequest(final Request request) {
		if (plainBtn.isPressed()) {
			WMessages.getInstance(this).info("Plain button pressed.");
		}

		if (linkBtn.isPressed()) {
			WMessages.getInstance(this).info("Link button pressed.");
		}
	}
372210
private void addPostParams(final Request request) {
        if (read != null) {
            request.addPostParam("Read", read.toString());
        }

        if (write != null) {
            request.addPostParam("Write", write.toString());
        }

        if (manage != null) {
            request.addPostParam("Manage", manage.toString());
        }
    }
1231609
public synchronized void setRequest(HttpServletRequest request) {

        if (perThreadRequest == null) {
            perThreadRequest = new ThreadLocal<HttpServletRequest>();
        }
        perThreadRequest.set(request);
    }
322940
public synchronized void put(WmsRequest request, byte[] image) {
        synchronized (this) {
            String key = getKey(request);
            // make sure it's the last on the list of keys so won't be dropped
            // from cache
            keys.remove(key);
            keys.add(key);
            if (keys.size() > maxSize)
                remove(keys.get(0));
            if (maxSize > 0 && layers.containsAll(request.getLayers())) {
                cache.put(key, image);
                log.info("cached image with key=" + key);
            }
        }
    }
1154413
private static ByteBuf contentFromWriteRequest(BinaryRequest request) {
        ByteBuf content = null;
        if (request instanceof BinaryStoreRequest) {
            content = ((BinaryStoreRequest) request).content();
        } else if (request instanceof AppendRequest) {
            content = ((AppendRequest) request).content();
        } else if (request instanceof PrependRequest) {
            content = ((PrependRequest) request).content();
        } else if (request instanceof BinarySubdocRequest) {
            content = ((BinarySubdocRequest) request).content();
        } else if (request instanceof BinarySubdocMultiLookupRequest) {
            content = ((BinarySubdocMultiLookupRequest) request).content();
        } else if (request instanceof BinarySubdocMultiMutationRequest) {
            content = ((BinarySubdocMultiMutationRequest) request).content();
        }
        return content;
    }
207049
public void doWithRequest(
                    final ClientHttpRequest request
                    )
    throws IOException
    {
        HttpHeaders  headers = request.getHeaders();
        headers.setContentType( _mediaType );

        long  size = IoUtil.copy( new StringReader( _string.toString() ),
                        new OutputStreamWriter( request.getBody() ) );
        headers.setContentLength( size );
    }
112905
public CreateClusterResponse createCluster(CreateClusterRequest request) {
        checkNotNull(request, "request should not be null.");
        checkStringNotEmpty(request.getImageType(), "The imageType should not be null or empty string.");
        checkStringNotEmpty(request.getImageVersion(), "The imageVersion should not be null or empty string.");
        checkNotNull(request.getInstanceGroups(), "The instanceGroups should not be null.");

        StringWriter writer = new StringWriter();
        try {
            JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(writer);
            jsonGenerator.writeStartObject();
            jsonGenerator.writeStringField("imageType", request.getImageType());
            jsonGenerator.writeStringField("imageVersion", request.getImageVersion());
            jsonGenerator.writeArrayFieldStart("instanceGroups");
            for (InstanceGroupConfig instanceGroup : request.getInstanceGroups()) {
                jsonGenerator.writeStartObject();
                if (instanceGroup.getName() != null) {
                    jsonGenerator.writeStringField("name", instanceGroup.getName());
                }
                jsonGenerator.writeStringField("type", instanceGroup.getType());
                jsonGenerator.writeStringField("instanceType", instanceGroup.getInstanceType());
                jsonGenerator.writeNumberField("instanceCount", instanceGroup.getInstanceCount());
                jsonGenerator.writeEndObject();
            }
            jsonGenerator.writeEndArray();
            if (request.getName() != null) {
                jsonGenerator.writeStringField("name", request.getName());
            }
            if (request.getLogUri() != null) {
                jsonGenerator.writeStringField("logUri", request.getLogUri());
            }
            jsonGenerator.writeBooleanField("autoTerminate", request.getAutoTerminate());

            if (request.getApplications() != null) {
                jsonGenerator.writeArrayFieldStart("applications");
                for (ApplicationConfig application : request.getApplications()) {
                    jsonGenerator.writeStartObject();
                    jsonGenerator.writeStringField("name", application.getName());
                    jsonGenerator.writeStringField("version", application.getVersion());
                    if (application.getProperties() != null) {
                        jsonGenerator.writeObjectFieldStart("properties");
                        for (Map.Entry<String, Object> entry : application.getProperties().entrySet()) {
                            jsonGenerator.writeObjectField(entry.getKey(), entry.getValue());
                        }
                        jsonGenerator.writeEndObject();
                    }
                    jsonGenerator.writeEndObject();
                }
                jsonGenerator.writeEndArray();
            }

            if (request.getSteps() != null) {
                jsonGenerator.writeArrayFieldStart("steps");
                for (StepConfig step : request.getSteps()) {
                    jsonGenerator.writeStartObject();
                    if (step.getName() != null) {
                        jsonGenerator.writeStringField("name", step.getName());
                    }
                    jsonGenerator.writeStringField("type", step.getType());
                    jsonGenerator.writeStringField("actionOnFailure", step.getActionOnFailure());
                    jsonGenerator.writeObjectFieldStart("properties");
                    for (Map.Entry<String, String> entry : step.getProperties().entrySet()) {
                        jsonGenerator.writeStringField(entry.getKey(), entry.getValue());
                    }
                    jsonGenerator.writeEndObject();
                    jsonGenerator.writeEndObject();
                }
                jsonGenerator.writeEndArray();
            }

            jsonGenerator.writeEndObject();
            jsonGenerator.close();
        } catch (IOException e) {
            throw new BceClientException("Fail to generate json", e);
        }

        byte[] json = null;
        try {
            json = writer.toString().getBytes(DEFAULT_ENCODING);
        } catch (UnsupportedEncodingException e) {
            throw new BceClientException("Fail to get UTF-8 bytes", e);
        }

        InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, CLUSTER);
        internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length));
        internalRequest.addHeader(Headers.CONTENT_TYPE, "application/json");
        internalRequest.setContent(RestartableInputStream.wrap(json));

        if (request.getClientToken() != null) {
            internalRequest.addParameter("clientToken", request.getClientToken());
        }

        return this.invokeHttpClient(internalRequest, CreateClusterResponse.class);
    }
709764
public <R extends Request<T>, T> R add(R request) {
        //Listener factories should be first so client can listen to events
        for (ListenerFactory listenerFactory : listenerFactories) {
            RequestListener.ResponseListener qResponseListener = listenerFactory
                    .getResponseListener(request);
            RequestListener.ErrorListener qErrorListener = listenerFactory.getErrorListener
                    (request);
            RequestListener.MarkerListener qMarkerListener = listenerFactory.getMarkerListener
                    (request);

            if (qMarkerListener != null) {
                request.addMarkerListener(qMarkerListener);
            }
            if (qResponseListener != null) {
                request.addResponseListener(qResponseListener);
            }
            if (qErrorListener != null) {
                request.addErrorListener(qErrorListener);
            }
        }
        if (JusLog.ErrorLog.isOn()) {
            request.addErrorListener(JusLog.ErrorLog.getLogger(request));
        }

        if (JusLog.ResponseLog.isOn()) {
            request.addResponseListener(JusLog.ResponseLog.getLogger(request));
        }

        if (JusLog.MarkerLog.isOn()) {
            request.addMarkerListener(JusLog.MarkerLog.getLogger(request));
        }
        request.addMarker(Request.EVENT_PRE_ADD_TO_QUEUE);
        Authenticator serverAuthenticator = null;
        Authenticator proxyAuthenticator = null;
        for (Authenticator.Factory factory : authenticatorFactories) {

            if (serverAuthenticator == null) {
                serverAuthenticator = factory.forServer(request.getUrl(), request
                        .getNetworkRequest());
                if (serverAuthenticator != null)
                    request.setServerAuthenticator(serverAuthenticator);
            }

            if (proxyAuthenticator == null) {
                proxyAuthenticator = factory.forProxy(request.getUrl(), request.getNetworkRequest
                        ());
                if (proxyAuthenticator != null)
                    request.setProxyAuthenticator(proxyAuthenticator);
            }

            if (proxyAuthenticator != null && serverAuthenticator != null) {
                break;
            }

        }

        for (Transformer.RequestTransformer transformer : requestTransformers) {
            if (transformer.filter == null || transformer.filter.apply(request)) {
                request.setNetworkRequest(transformer.transform(request.getNetworkRequest()));
            }
        }

        if (retryPolicyFactory != null) {
            request.setRetryPolicy(retryPolicyFactory.get(request));
        }
        if (redirectPolicyFactory != null) {
            request.setRedirectPolicy(redirectPolicyFactory.get(request));
        }

        if (connectivityManagerFactory != null) {
            request.setConnectivityManager(connectivityManagerFactory.get(request));
        }
        if (noConnectionPolicyFactory != null) {
            request.setNoConnectionPolicy(noConnectionPolicyFactory.get(request));
        }

        synchronized (currentRequests) {
            //check if not already cancelled
            if (request.isCanceled()) {
                request.finish(Request.EVENT_ADD_DISCARD_CANCELED);
            }
            // Process requests in the order they are added.
            request.setSequence(getSequenceNumber());
            // Tag the request as belonging to this queue and add it to the set of current requests.
            request.setRequestQueue(this);
            currentRequests.add(request);
        }
        request.addMarker(Request.EVENT_ADD_TO_QUEUE);

        // If the request is uncacheable, skip the cache queue and go straight to the network.
        if (!request.shouldCache()) {
            networkQueue.add(request);
            return request;
        }

        // Insert request into stage if there's already a request with the same cache key in flight.
        synchronized (waitingRequests) {
            String cacheKey = request.getCacheKey();
            if (waitingRequests.containsKey(cacheKey)) {
                // There is already a request in flight. Queue up.
                Queue<Request<?>> stagedRequests = waitingRequests.get(cacheKey);
                if (stagedRequests == null) {
                    stagedRequests = new LinkedList<>();
                }
                stagedRequests.add(request);
                waitingRequests.put(cacheKey, stagedRequests);
//                if (JusLog.DEBUG) {
//                    JusLog.v("Request for cacheKey=%s is in flight, putting on hold.", cacheKey);
//                }
                //todo add queue markers
            } else {
                // Insert 'empty list' queue for this cacheKey, indicating there is now a request in
                // flight.
                waitingRequests.put(cacheKey, new LinkedList<Request<?>>());
                cacheQueue.add(request);
            }
            return request;
        }
    }
440762
public void doWithRequest(
                    final ClientHttpRequest request
                    )
    throws IOException
    {
        HttpHeaders  headers = request.getHeaders();
        headers.setContentType( _mediaType );

        long  size = IoUtil.copy( _input, new OutputStreamWriter( request.getBody() ) );
        headers.setContentLength( size );
    }
19109
public void setRequest(Object request)
    {
        ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
        
        if (ctx == null)
        {
            throw new UnsupportedOperationException();
        }
        
        ctx.setRequest(request);
    }
508729
public void marshall(MarshallLocation marshallLocation, Object val, String paramName) {
        marshallerRegistry().getMarshaller(marshallLocation, val).marshall(val, this, paramName);
    }
1013150
public SocialTaiRequest createSocialTaiRequestAndSetRequestAttribute(HttpServletRequest request) {
        SocialTaiRequest socialTaiRequest = new SocialTaiRequest(request);
        request.setAttribute(Constants.ATTRIBUTE_TAI_REQUEST, socialTaiRequest);
        return socialTaiRequest;
    }
121619
private void addPostParams(final Request request) {
        if (to != null) {
            request.addPostParam("To", to);
        }

        if (mediaUrl != null) {
            request.addPostParam("MediaUrl", mediaUrl.toString());
        }

        if (quality != null) {
            request.addPostParam("Quality", quality.toString());
        }

        if (statusCallback != null) {
            request.addPostParam("StatusCallback", statusCallback.toString());
        }

        if (from != null) {
            request.addPostParam("From", from);
        }

        if (sipAuthUsername != null) {
            request.addPostParam("SipAuthUsername", sipAuthUsername);
        }

        if (sipAuthPassword != null) {
            request.addPostParam("SipAuthPassword", sipAuthPassword);
        }

        if (storeMedia != null) {
            request.addPostParam("StoreMedia", storeMedia.toString());
        }

        if (ttl != null) {
            request.addPostParam("Ttl", ttl.toString());
        }
    }
508047
public void addRequest(RecordRequest request) {
        if (request.getRequestSize() + getRequestSize() > 248) {
            throw new IllegalArgumentException();
        }

        if (records == null) {
            records = new RecordRequest[1];
        }
        else {
            RecordRequest old[] = records;
            records = new RecordRequest[old.length + 1];

            System.arraycopy(old, 0, records, 0, old.length);
        }
        records[records.length - 1] = request;

        setDataLength(getRequestSize());
    }
202748
private void addPostParams(final Request request) {
        if (to != null) {
            request.addPostParam("To", to);
        }

        if (channel != null) {
            request.addPostParam("Channel", channel);
        }

        if (customMessage != null) {
            request.addPostParam("CustomMessage", customMessage);
        }
    }