@Override protected boolean matchesSafely( Status item ) { return item.isError(); }
@Override protected boolean matchesSafely(Status item) { return item.isError(); }
/** * Indicates if the status is an error (client or server) status. * * @return True if the status is an error (client or server) status. */ public boolean isError() { return isError(getCode()); }
@Override protected boolean matchesSafely( Response resp ) { return resp.getStatus().isError(); }
/** * Indicates if the status is an error (client or server) status. * * @return True if the status is an error (client or server) status. */ public boolean isError() { return isError(getCode()); }
/** * Indicates if the status is an error (client or server) status. * * @return True if the status is an error (client or server) status. */ public boolean isError() { return isError(getCode()); }
@Override protected boolean matchesSafely(Response resp) { return resp.getStatus().isError(); }
/** * Generates a name for the response given the status code. * The generated name will be "Success" in case of success, "Error [statusCode]" in case of error and "Status * [statusCode] otherwise. * * @param statusCode * The status code of the response. * @return The generated name. */ public static String generateResponseName(int statusCode) { String autoGeneratedName = "Status " + statusCode; if (Status.isSuccess(statusCode)) { autoGeneratedName = "Success"; } else if (Status.isError(statusCode)) { autoGeneratedName = "Error " + statusCode; } return autoGeneratedName; }
/** * Generates a name for the response given the status code. * The generated name will be "Success" in case of success, "Error [statusCode]" in case of error and "Status * [statusCode] otherwise. * * @param statusCode * The status code of the response. * @return The generated name. */ public static String generateResponseName(int statusCode) { String autoGeneratedName = "Status " + statusCode; if (Status.isSuccess(statusCode)) { autoGeneratedName = "Success"; } else if (Status.isError(statusCode)) { autoGeneratedName = "Error " + statusCode; } return autoGeneratedName; }
/** * Generates a name for the response given the status code. * The generated name will be "Success" in case of success, "Error [statusCode]" in case of error and "Status * [statusCode] otherwise. * * @param statusCode * The status code of the response. * @return The generated name. */ public static String generateResponseName(int statusCode) { String autoGeneratedName = "Status " + statusCode; if (Status.isSuccess(statusCode)) { autoGeneratedName = "Success"; } else if (Status.isError(statusCode)) { autoGeneratedName = "Error " + statusCode; } return autoGeneratedName; }
/** * Generates a name for the response given the status code. * The generated name will be "Success" in case of success, "Error [statusCode]" in case of error and "Status * [statusCode] otherwise. * * @param statusCode * The status code of the response. * @return The generated name. */ public static String generateResponseName(int statusCode) { String autoGeneratedName = "Status " + statusCode; if (Status.isSuccess(statusCode)) { autoGeneratedName = "Success"; } else if (Status.isError(statusCode)) { autoGeneratedName = "Error " + statusCode; } return autoGeneratedName; }
/** * Generates a name for the response given the status code. * The generated name will be "Success" in case of success, "Error [statusCode]" in case of error and "Status * [statusCode] otherwise. * * @param statusCode * The status code of the response. * @return The generated name. */ public static String generateResponseName(int statusCode) { String autoGeneratedName = "Status " + statusCode; if (Status.isSuccess(statusCode)) { autoGeneratedName = "Success"; } else if (Status.isError(statusCode)) { autoGeneratedName = "Error " + statusCode; } return autoGeneratedName; }
@Override public Representation handleInbound(Response response) { Representation result = null; // Verify that the request was synchronous if (response.getRequest().isSynchronous()) { if (response.getStatus().isError()) { doError(response.getStatus()); // DO NOT DISPOSE THE RESPONSE. }/* else { */ result = (response == null) ? null : response.getEntity(); /* } */ } return result; }
/** * Handles the inbound call. Note that only synchronous calls are processed. * * @param response * @return The response's entity, if any. */ public Representation handleInbound(Response response) { if (response == null) { return null; } // Verify that the request was synchronous if (response.getRequest().isSynchronous()) { if (response.getStatus().isError()) { doError(response.getStatus()); return null; } return response.getEntity(); } return null; }
protected Metadata downloadMetadataFromRepository(Gav gav, String repoId) throws IOException, XmlPullParserException { String url = String.format("%s%s%s/%s/%s/maven-metadata.xml", getBaseNexusUrl(), REPOSITORY_RELATIVE_URL, repoId, gav.getGroupId(), gav.getArtifactId()); Response response = null; try { response = RequestFacade.sendMessage(new URL(url), Method.GET, null); if (response.getStatus().isError()) { return null; } try (InputStream stream = response.getEntity().getStream()) { MetadataXpp3Reader metadataReader = new MetadataXpp3Reader(); return metadataReader.read(stream); } } finally { RequestFacade.releaseResponse(response); } }
if (response.getStatus().isError() && ((response.getEntity() == null) || isOverwriting())) { response.setEntity(getStatusService().toRepresentation(
@Override public void sendResponse(Response response) throws IOException { // Add call headers Parameter header; for (final Iterator<Parameter> iter = getResponseHeaders().iterator(); iter .hasNext();) { header = iter.next(); getConnection().getResponse().addHeader(header.getName(), header.getValue()); } // Set the status code in the response. We do this after adding the // headers because when we have to rely on the 'sendError' method, // the Servlet containers are expected to commit their response. if (Status.isError(getStatusCode()) && (response.getEntity() == null)) { try { getConnection().getResponse().sendError(getStatusCode(), getReasonPhrase()); } catch (IOException ioe) { getLogger().log(Level.WARNING, "Unable to set the response error status", ioe); } } else { // Send the response entity getConnection().getResponse().setStatus(getStatusCode()); super.sendResponse(response); } } }
@Override public void sendResponse(Response response) throws IOException { // Add call headers Parameter header; for (final Iterator<Parameter> iter = getResponseHeaders().iterator(); iter .hasNext();) { header = iter.next(); getConnection().getResponse().addHeader(header.getName(), header.getValue()); } // Set the status code in the response. We do this after adding the // headers because when we have to rely on the 'sendError' method, // the Servlet containers are expected to commit their response. if (Status.isError(getStatusCode()) && (response.getEntity() == null)) { try { getConnection().getResponse().sendError(getStatusCode(), getReasonPhrase()); } catch (IOException ioe) { getLogger().log(Level.WARNING, "Unable to set the response error status", ioe); } } else { // Send the response entity getConnection().getResponse().setStatus(getStatusCode()); super.sendResponse(response); } } }
@SuppressWarnings("unchecked") public void handle(Request request, Response response) { if (response.getStatus().isError()) { rCallback.onFailure(new ResourceException(response.getStatus())); } else { if (actualType != null) { Object result = null; try { result = getClientResource().toObject(response.getEntity(), actualType); rCallback.onSuccess(result); } catch (Exception e) { rCallback.onFailure(new ResourceException(e)); } } else { rCallback.onSuccess(null); } } } };
@SuppressWarnings("unchecked") public void handle(Request request, Response response) { if (response.getStatus().isError()) { rCallback .onFailure(new ResourceException(