/** * Indicates if a content is available and can be sent. Several conditions * must be met: the content must exists and have some available data. * * @return True if a content is available and can be sent. */ @Override public boolean isEntityAvailable() { return getWrappedResponse().isEntityAvailable(); }
/** * Indicates if the application and all its resources can be described using * WADL. * * @param remainingPart * The URI remaining part. * @param request * The request to handle. * @param response * The response to update. */ protected boolean canDescribe(String remainingPart, Request request, Response response) { return isAutoDescribing() && Method.OPTIONS.equals(request.getMethod()) && (response.getStatus().isClientError() || !response .isEntityAvailable()) && ("/".equals(remainingPart) || "".equals(remainingPart)); }
@Override protected void afterHandle(Request request, Response response) { if (response.isEntityAvailable() && response.getEntity().getEncodings() .contains(Encoding.FREEMARKER)) { TemplateRepresentation representation = new TemplateRepresentation( response.getEntity(), this.configuration, response .getEntity().getMediaType()); representation.setDataModel(createDataModel(request, response)); response.setEntity(representation); } }
/** * Prints the resource's representation. * * @param clientResource * The Restlet client resource. * @throws IOException * @throws ResourceException */ public static void get(ClientResource clientResource) throws IOException, ResourceException { clientResource.get(); if (clientResource.getStatus().isSuccess() && clientResource.getResponse().isEntityAvailable()) { clientResource.getResponseEntity().write(System.out); } }
if (!response.isEntityAvailable() || Status.REDIRECTION_NOT_MODIFIED.equals(response.getStatus()) || Status.SUCCESS_NO_CONTENT.equals(response.getStatus())
.handle(new Request(Method.GET, targetDescriptor)); if (response.getStatus().isSuccess() && response.isEntityAvailable()) { final Representation representation = response.getEntity();
/** * Indicates if the Component hosted by this Servlet is the default one or * one provided by the user. * * @return True if the Component is the default one, false otherwise. */ private boolean isDefaultComponent() { // The Component is provided via an XML configuration file. Client client = createWarClient(new Context(), getServletConfig()); Response response = client.handle(new Request(Method.GET, "war:///WEB-INF/restlet.xml")); if (response.getStatus().isSuccess() && response.isEntityAvailable()) { return false; } // The Component is provided via a context parameter in the "web.xml" // file. String componentAttributeName = getInitParameter(COMPONENT_KEY, null); if (componentAttributeName != null) { return false; } return true; }
&& response.isEntityAvailable()) { try { result = new StreamSource(response.getEntity().getStream());
&& response.isEntityAvailable()) { try { result = new StreamSource(response.getEntity().getStream());
@Override protected void afterHandle(Request request, Response response) { if (response.isEntityAvailable() && response.getEntity().getEncodings().contains(THYMELEAF)) { try { final TemplateRepresentation representation = new TemplateRepresentation( (TemplateRepresentation) response.getEntity(), getLocale(), response.getEntity().getMediaType()); if ((this.mapDataModel == null) && (this.resolverDataModel == null)) { representation.setDataModel(request, response); } else { if (this.mapDataModel == null) { representation.setDataModel(this.resolverDataModel); } else { representation.setDataModel(this.mapDataModel); } } response.setEntity(representation); } catch (IOException e) { response.setStatus(Status.SERVER_ERROR_INTERNAL, e); } } }
@Override protected void afterHandle(Request request, Response response) { if (response.isEntityAvailable() && response.getEntity().getEncodings().contains( Encoding.VELOCITY)) {
if (response.isEntityAvailable()) { response.setStatus(Status.SUCCESS_OK);
&& response.isEntityAvailable()) { t = (Throwable) getClientResource().toObject( response.getEntity(), throwableClazz); if (response.isEntityAvailable()) { StatusInfo si = getClientResource() .toObject(response.getEntity(),
&& response.isEntityAvailable()) { t = (Throwable) getClientResource().toObject( response.getEntity(), throwableClazz); if (response.isEntityAvailable()) { StatusInfo si = getClientResource().toObject( response.getEntity(), StatusInfo.class);
/** * Attaches an application created from a WADL description document * available at a given URI reference. * * @param wadlRef * The URI reference to the WADL description document. * @return The created WADL application. */ public WadlApplication attach(Reference wadlRef) { WadlApplication result = null; // Adds some common client connectors to load the WADL documents if (!getClients().contains(wadlRef.getSchemeProtocol())) { getClients().add(wadlRef.getSchemeProtocol()); } // Get the WADL document final Response response = getContext().getClientDispatcher().handle( new Request(Method.GET, wadlRef)); if (response.getStatus().isSuccess() && response.isEntityAvailable()) { result = attach(response.getEntity()); } return result; }
response.getServerInfo().setAcceptingRanges(true); if (request.getMethod().isSafe() && response.isEntityAvailable()) { Range responseRange = response.getEntity().getRange(); boolean rangedEntity = responseRange != null && isBytesRange(responseRange);