/** * Constructor. * * @param status * The status to associate. * @param cause * The wrapped cause error or exception. */ public ResourceException(Status status, Throwable cause) { super((status == null) ? null : status.getReasonPhrase(), cause); this.status = status; }
/** * Returns the reason phrase of the status followed by its HTTP code. * * @return The reason phrase of the status followed by its HTTP code. */ @Override public String toString() { return getReasonPhrase() + " (" + this.code + ")" + ((getDescription() == null) ? "" : " - " + getDescription()); }
/** * Returns the reason phrase of the status followed by its HTTP code. * * @return The reason phrase of the status followed by its HTTP code. */ @Override public String toString() { return getReasonPhrase() + " (" + this.code + ")" + ((getDescription() == null) ? "" : " - " + getDescription()); }
/** * Constructor. * * @param status * The represented status. * @param contactEmail * The email address of the administrator to contact in case of * error. * @param homeRef * The home URI to propose in case of error. */ public StatusInfo(Status status, String contactEmail, String homeRef) { this(status.getCode(), status.getDescription(), status .getReasonPhrase(), status.getUri(), contactEmail, homeRef); }
@Override public Representation getRepresentation(Status status, Request request, Response response) { // Create the data model Map<String, String> dataModel = new ConcurrentHashMap<String, String>(); dataModel.put("applicationName", Application.getCurrent().getName()); dataModel.put("statusDescription", response.getStatus() .getDescription()); dataModel.put("statusReasonPhrase", response.getStatus() .getReasonPhrase()); // Load the FreeMarker template Representation mailFtl = new ClientResource( LocalReference.createClapReference(getClass().getPackage()) + "/MailStatus.ftl").get(); // Wraps the bean with a FreeMarker representation return new TemplateRepresentation(mailFtl, dataModel, MediaType.TEXT_HTML); }
@Override public Representation getRepresentation(Status status, Request request, Response response) { // Create the data model Map<String, String> dataModel = new TreeMap<String, String>(); dataModel.put("applicationName", Application.getCurrent().getName()); dataModel.put("statusReasonPhrase", response.getStatus() .getReasonPhrase()); dataModel.put("statusDescription", response.getStatus() .getDescription()); // Load the FreeMarker template Representation mailFtl = new ClientResource( LocalReference.createClapReference(getClass().getPackage()) + "/MailStatus.ftl").get(); // Wraps the bean with a FreeMarker representation return new TemplateRepresentation(mailFtl, dataModel, MediaType.TEXT_HTML); }
/** * Constructor. * * @param status * The status to copy. * @param throwable * The related error or exception. * @param description * The description to associate. */ public Status(Status status, Throwable throwable, String description) { this(status.getCode(), (throwable == null) ? status.getThrowable() : throwable, status.getReasonPhrase(), (description == null) ? status.getDescription() : description, status.getUri()); }
/** * Constructor. * * @param status * The status to copy. * @param throwable * The related error or exception. * @param reasonPhrase * The short reason phrase displayed next to the status code in a * HTTP response. * @param description * The description to associate. */ public Status(Status status, Throwable throwable, String reasonPhrase, String description) { this(status.getCode(), (throwable == null) ? status.getThrowable() : throwable, (reasonPhrase == null) ? status.getReasonPhrase() : reasonPhrase, (description == null) ? status.getDescription() : description, status.getUri()); }
response.setName(Status.valueOf(code).getReasonPhrase()); if (!StringUtils.isNullOrEmpty(apiResponse.message())) { response.setDescription(apiResponse.message());
response.setName(Status.SUCCESS_OK.getReasonPhrase()); response.setDescription(""); response.setMessage(Status.SUCCESS_OK.getDescription()); } else { response.setCode(Status.SUCCESS_NO_CONTENT.getCode()); response.setName(Status.SUCCESS_NO_CONTENT.getReasonPhrase()); response.setDescription(""); response.setMessage(Status.SUCCESS_NO_CONTENT.getDescription());
response.setName(Status.SUCCESS_OK.getReasonPhrase()); response.setDescription(""); response.setMessage(Status.SUCCESS_OK.getDescription()); } else { response.setCode(Status.SUCCESS_NO_CONTENT.getCode()); response.setName(Status.SUCCESS_NO_CONTENT.getReasonPhrase()); response.setDescription(""); response.setMessage(Status.SUCCESS_NO_CONTENT.getDescription());
response.setName(Status.SUCCESS_OK.getReasonPhrase()); response.setDescription(""); response.setMessage(Status.SUCCESS_OK.getDescription()); } else { response.setCode(Status.SUCCESS_NO_CONTENT.getCode()); response.setName(Status.SUCCESS_NO_CONTENT.getReasonPhrase()); response.setDescription(""); response.setMessage(Status.SUCCESS_NO_CONTENT.getDescription());
response.setName(Status.SUCCESS_OK.getReasonPhrase()); response.setDescription(""); response.setMessage(Status.SUCCESS_OK.getDescription()); } else { response.setCode(Status.SUCCESS_NO_CONTENT.getCode()); response.setName(Status.SUCCESS_NO_CONTENT.getReasonPhrase()); response.setDescription(""); response.setMessage(Status.SUCCESS_NO_CONTENT.getDescription());
response.setName(Status.SUCCESS_OK.getReasonPhrase()); response.setDescription(""); response.setMessage(Status.SUCCESS_OK.getDescription()); } else { response.setCode(Status.SUCCESS_NO_CONTENT.getCode()); response.setName(Status.SUCCESS_NO_CONTENT.getReasonPhrase()); response.setDescription(""); response.setMessage(Status.SUCCESS_NO_CONTENT.getDescription());
/** * Adds the response headers for the handled uniform call. * * @param response * The response returned. */ protected void addResponseHeaders(HttpResponse response) { try { // Add all the necessary headers HeaderUtils.addGeneralHeaders(response, response.getHttpCall() .getResponseHeaders()); HeaderUtils.addResponseHeaders(response, response.getHttpCall() .getResponseHeaders()); // Set the status code in the response if (response.getStatus() != null) { response.getHttpCall().setStatusCode( response.getStatus().getCode()); response.getHttpCall().setReasonPhrase( response.getStatus().getReasonPhrase()); } } catch (Exception e) { getLogger().log(Level.WARNING, "Exception intercepted while adding the response headers", e); response.getHttpCall().setStatusCode( Status.SERVER_ERROR_INTERNAL.getCode()); response.getHttpCall().setReasonPhrase( Status.SERVER_ERROR_INTERNAL.getReasonPhrase()); } }
response.setCode(statusCode); response.setName(Status.valueOf(statusCode) .getReasonPhrase()); response.setMessage("Status " + statusCode);
response.setCode(statusCode); response.setName(Status.valueOf(statusCode) .getReasonPhrase()); response.setMessage("Status " + statusCode);
response.setCode(statusCode); response.setName(Status.valueOf(statusCode) .getReasonPhrase()); response.setMessage("Status " + statusCode);
response.setCode(statusCode); response.setName(Status.valueOf(statusCode) .getReasonPhrase()); response.setMessage("Status " + statusCode);
response.setCode(statusCode); response.setName(Status.valueOf(statusCode) .getReasonPhrase()); response.setMessage("Status " + statusCode);