本文整理汇总了Java中org.restlet.Response.getEntity方法的典型用法代码示例。如果您正苦于以下问题:Java Response.getEntity方法的具体用法?Java Response.getEntity怎么用?Java Response.getEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.restlet.Response
的用法示例。
在下文中一共展示了Response.getEntity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populateRestletProducerException
import org.restlet.Response; //导入方法依赖的package包/类
protected RestletOperationException populateRestletProducerException(Exchange exchange, Response response, int responseCode) {
RestletOperationException exception;
String uri = response.getRequest().getResourceRef().toString();
String statusText = response.getStatus().getDescription();
Map<String, String> headers = parseResponseHeaders(response, exchange);
String copy;
if (response.getEntity() != null) {
try {
copy = response.getEntity().getText();
} catch (Exception ex) {
copy = ex.toString();
}
} else {
copy = response.toString();
}
if (responseCode >= 300 && responseCode < 400) {
String redirectLocation;
if (response.getStatus().isRedirection()) {
redirectLocation = response.getLocationRef().getHostIdentifier();
exception = new RestletOperationException(uri, responseCode, statusText, redirectLocation, headers, copy);
} else {
//no redirect location
exception = new RestletOperationException(uri, responseCode, statusText, null, headers, copy);
}
} else {
//internal server error(error code 500)
exception = new RestletOperationException(uri, responseCode, statusText, null, headers, copy);
}
return exception;
}
示例2: readResponse
import org.restlet.Response; //导入方法依赖的package包/类
@Override
public Object readResponse( Response response, Class<?> resultType )
{
if (resultType.equals(Representation.class))
return response.getEntity();
for (ResponseReader responseReader : responseReaders)
{
Object result = responseReader.readResponse( response, resultType );
if (result != null)
return result;
}
return null;
}
示例3: toRepresentation
import org.restlet.Response; //导入方法依赖的package包/类
@Override
public Representation toRepresentation( Status status, Request request, Response response )
{
if( isEnabled() )
{
ConcurrentMap<String, Object> attributes = response.getAttributes();
Object passthrough = attributes.get( PASSTHROUGH_ATTRIBUTE );
if( ( passthrough != null ) && (Boolean) passthrough )
// Pass through
return response.getEntity();
Restlet handler = handlers.get( status.getCode() );
if( handler != null )
{
// Reset the response
response.setStatus( Status.SUCCESS_OK );
response.setEntity( null );
// Clean up saved information
CachingUtil.clearExistingValidDocumentName( request );
// Delegate
handler.handle( request, response );
// Return the status
response.setStatus( status );
Representation representation = response.getEntity();
if( representation != null )
{
// Avoid client caching, which would require other
// interchanges with the client that we can't handle from
// here
representation.setExpirationDate( null );
representation.setModificationDate( null );
representation.setTag( null );
}
attributes.put( PASSTHROUGH_ATTRIBUTE, true );
return representation;
}
if( isFallback )
// Fallbacks don't override the entity if there are no handlers
return response.getEntity();
if( isDebugging() && ( status.getThrowable() != null ) )
{
// Use the debug representation for exceptions
attributes.put( PASSTHROUGH_ATTRIBUTE, true );
if( debugHeader != null )
RestletUtil.getResponseHeaders( response ).set( debugHeader, "error" );
return createDebugRepresentation( status, request, response );
}
}
return super.toRepresentation( status, request, response );
}