/** * Constructor. * * @param status * The status to associate. * @param cause * The wrapped cause error or exception. */ public ResourceException(final Status status, final Throwable cause) { super((status == null) ? null : status.getDescription(), cause); this.status = status; }
public OntopiaRestException(Status status) { super(status.getDescription()); 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 name of the status followed by its HTTP code. * * @return The name of the status followed by its HTTP code. */ @Override public String toString() { return getName() + " (" + 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. The default status code is {@link Status#SUCCESS_OK}. */ public Response() { setCode(Status.SUCCESS_OK.getCode()); setMessage(Status.SUCCESS_OK.getDescription()); }
public Representation getRepresentation(final Status status, final Request request, final Response response) { final HashMap<String, Object> dataModel = new HashMap<String, Object>(); final SystemStatus systemStatus = applicationStatusSource.getSystemStatus(); dataModel.put("request", request); dataModel.put("nexusVersion", systemStatus.getVersion()); dataModel.put("nexusRoot", BaseUrlHolder.get()); dataModel.put("statusCode", status.getCode()); dataModel.put("statusName", status.getName()); dataModel.put("errorDescription", StringEscapeUtils.escapeHtml(status.getDescription())); if (null != status.getThrowable()) { dataModel.put("errorStackTrace", StringEscapeUtils.escapeHtml(ExceptionUtils.getStackTrace(status.getThrowable()))); } final VelocityRepresentation representation = new VelocityRepresentation(Context.getCurrent(), "/templates/errorPageContentHtml.vm", getClass().getClassLoader(), dataModel, MediaType.TEXT_HTML); return representation; } }
/** * Constructor. The default status code is {@link Status#SUCCESS_OK}. */ public Response() { setCode(Status.SUCCESS_OK.getCode()); setMessage(Status.SUCCESS_OK.getDescription()); }
/** * Constructor. The default status code is {@link Status#SUCCESS_OK}. */ public Response() { setCode(Status.SUCCESS_OK.getCode()); setMessage(Status.SUCCESS_OK.getDescription()); }
/** * Constructor. The default status code is {@link Status#SUCCESS_OK}. */ public Response() { setCode(Status.SUCCESS_OK.getCode()); setMessage(Status.SUCCESS_OK.getDescription()); }
/** * Constructor. The default status code is {@link Status#SUCCESS_OK}. */ public Response() { setCode(Status.SUCCESS_OK.getCode()); setMessage(Status.SUCCESS_OK.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(final Status status, final Request request, final Response response) { final Map<String, Object> dataModel = RestletUtils.getBaseDataModel(request); dataModel.put("contentTemplate", this.propertyUtil.get(OasProps.PROP_TMPL_ERROR, OasProps.DEF_TMPL_ERROR)); dataModel.put("pageTitle", "An error occurred : HTTP " + status.getCode()); if(status.getThrowable() != null) { dataModel.put("errorMessage", status.getThrowable().getMessage()); } else { dataModel.put("errorMessage", status.getDescription()); } // TODO: Support non-HTML error representations return RestletUtils.getHtmlRepresentation( this.propertyUtil.get(OasProps.PROP_TMPL_BASE, OasProps.DEF_TMPL_BASE), dataModel, MediaType.TEXT_HTML, this.freemarkerConfiguration); }
public static void removeAllTarget() throws IOException { List<RepositoryTargetListResource> targets = getList(); for ( RepositoryTargetListResource target : targets ) { Status status = RequestFacade.sendMessage( "service/local/repo_targets/" + target.getId(), Method.DELETE ).getStatus(); Assert.assertTrue( "Failt to delete: " + status.getDescription(), status.isSuccess() ); } }
@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); }
public static void removeAllRoutes() throws IOException { List<RepositoryRouteListResource> routes = getList(); for ( RepositoryRouteListResource route : routes ) { Status status = delete( route.getResourceURI() ).getStatus(); Assert.assertTrue( "Unable to delete route: '" + route.getResourceURI() + "', due to: " + status.getDescription(), status.isSuccess() ); } }
/** * 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()); }
public static void removeAllTarget() throws IOException { List<RepositoryTargetListResource> targets = getList(); for (RepositoryTargetListResource target : targets) { Status status = RequestFacade.sendMessage("service/local/repo_targets/" + target.getId(), Method.DELETE).getStatus(); Assert.assertTrue("Failt to delete: " + status.getDescription(), status.isSuccess()); } }
public static void removeAllRoutes() throws IOException { List<RepositoryRouteListResource> routes = getList(); for (RepositoryRouteListResource route : routes) { Status status = delete(route.getResourceURI()).getStatus(); Assert.assertTrue("Unable to delete route: '" + route.getResourceURI() + "', due to: " + status.getDescription(), status.isSuccess()); } }
@SuppressWarnings( "unchecked" ) public static List<RepositoryRouteListResource> getList() throws IOException { String serviceURI = "service/local/repo_routes"; Response response = RequestFacade.doGetRequest( serviceURI ); Status status = response.getStatus(); Assert.assertTrue( "Unable to get routes: " + status.getDescription(), status.isSuccess() ); XStreamRepresentation representation = new XStreamRepresentation( XStreamFactory.getXmlXStream(), response.getEntity().getText(), MediaType.APPLICATION_XML ); RepositoryRouteListResourceResponse resourceResponse = (RepositoryRouteListResourceResponse) representation.getPayload( new RepositoryRouteListResourceResponse() ); return resourceResponse.getData(); }