Java Code Examples for org.osgl.http.H#Status
The following examples show how to use
org.osgl.http.H#Status .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActError.java From actframework with Apache License 2.0 | 6 votes |
public static String errorMessage(H.Status status, String message, Object ... args) { if (S.notBlank(message)) { return S.fmt(message, args); } if (Act.isProd()) { return MvcConfig.errorMessage(status); } ActionContext ctx = ActionContext.current(); if (null == ctx) { return MvcConfig.errorMessage(status); } RequestHandler handler = ctx.handler(); if (null == handler) { return MvcConfig.errorMessage(status); } if (H.Status.NOT_FOUND == status) { return I18n.i18n(Act.class, "e404.null_value_returned", handler); } return I18n.i18n(Act.class, "error.on_invoking", MvcConfig.errorMessage(status), handler); }
Example 2
Source File: EndpointTester.java From actframework with Apache License 2.0 | 6 votes |
protected final void checkResponseCode(Response resp) { if (resp.code() < 300 && resp.code() > 199) { return; } switch (resp.code()) { case HttpURLConnection.HTTP_NOT_FOUND: throw NotFound.INSTANCE; case HttpURLConnection.HTTP_BAD_REQUEST: throw BadRequest.INSTANCE; case HttpURLConnection.HTTP_FORBIDDEN: throw Forbidden.INSTANCE; case HttpURLConnection.HTTP_UNAUTHORIZED: throw Unauthorized.INSTANCE; case HttpURLConnection.HTTP_NOT_MODIFIED: throw NotModified.INSTANCE; case HttpURLConnection.HTTP_CONFLICT: throw Conflict.INSTANCE; default: H.Status status = H.Status.of(resp.code()); if (status.isError()) { throw new ErrorResult(status); } } }
Example 3
Source File: ActErrorResult.java From actframework with Apache License 2.0 | 5 votes |
public static ErrorResult of(H.Status status, int errorCode, String message, Object... args) { E.illegalArgumentIf(!status.isClientError() && !status.isServerError()); if (Act.isDev()) { return new ActErrorResult(status, errorCode, message, args); } else { return ErrorResult.of(status, errorCode, message, args); } }
Example 4
Source File: ActErrorResult.java From actframework with Apache License 2.0 | 5 votes |
public static ErrorResult of(H.Status status, int errorCode) { E.illegalArgumentIf(!status.isClientError() && !status.isServerError()); if (Act.isDev()) { return new ActErrorResult(status, errorCode); } else { return ErrorResult.of(status, errorCode); } }
Example 5
Source File: ActErrorResult.java From actframework with Apache License 2.0 | 5 votes |
public static ErrorResult of(H.Status status, String message, Object... args) { E.illegalArgumentIf(!status.isClientError() && !status.isServerError()); if (Act.isDev()) { return new ActErrorResult(status, message, args); } else { return ErrorResult.of(status, message, args); } }
Example 6
Source File: ActErrorResult.java From actframework with Apache License 2.0 | 5 votes |
public static ErrorResult of(H.Status status) { E.illegalArgumentIf(!status.isClientError() && !status.isServerError()); if (Act.isDev()) { return new ActErrorResult(status); } else { return ErrorResult.of(status); } }
Example 7
Source File: ActionContext.java From actframework with Apache License 2.0 | 4 votes |
public H.Status successStatus() { if (null != forceResponseStatus) { return forceResponseStatus; } return H.Method.POST == req().method() ? H.Status.CREATED : H.Status.OK; }
Example 8
Source File: FilteredRenderXML.java From actframework with Apache License 2.0 | 4 votes |
public FilteredRenderXML(H.Status status, Object v, PropertySpec.MetaInfo spec, ActContext context) { super(status, render(v, spec, context), H.Format.XML); }
Example 9
Source File: ResponseCache.java From actframework with Apache License 2.0 | 4 votes |
@Override public H.Response status(H.Status s) { realResponse.status(s); this.status = s; return this; }
Example 10
Source File: Interaction.java From actframework with Apache License 2.0 | 4 votes |
private H.Status expectedStatus() { return null == response ? null : response.status; }
Example 11
Source File: ActErrorResult.java From actframework with Apache License 2.0 | 4 votes |
public ActErrorResult(H.Status status, int errorCode, Throwable cause, String message, Object... args) { super(status, errorCode, cause, errorMessage(status, message, args)); init(); populateSourceInfo(cause); }
Example 12
Source File: ActErrorResult.java From actframework with Apache License 2.0 | 4 votes |
public ActErrorResult(H.Status status, Throwable cause, String message, Object... args) { super(status, cause, errorMessage(status, message, args)); init(); populateSourceInfo(cause); }
Example 13
Source File: ActErrorResult.java From actframework with Apache License 2.0 | 4 votes |
public ActErrorResult(H.Status status, Throwable cause) { super(status, cause, errorMessage(status)); init(); populateSourceInfo(cause); }
Example 14
Source File: ActErrorResult.java From actframework with Apache License 2.0 | 4 votes |
public ActErrorResult(H.Status status, int errorCode, String message, Object... args) { super(status, errorCode, errorMessage(status, message, args)); init(); populateSourceInfo(); }
Example 15
Source File: ActErrorResult.java From actframework with Apache License 2.0 | 4 votes |
public ActErrorResult(H.Status status, int errorCode) { super(status, errorCode, errorMessage(status)); init(); populateSourceInfo(); }
Example 16
Source File: ActErrorResult.java From actframework with Apache License 2.0 | 4 votes |
public ActErrorResult(H.Status status, String message, Object... args) { super(status, errorMessage(status, message, args)); init(); populateSourceInfo(); }
Example 17
Source File: ActionContext.java From actframework with Apache License 2.0 | 4 votes |
public ActionContext forceResponseStatus(H.Status status) { this.forceResponseStatus = $.requireNotNull(status); return this; }
Example 18
Source File: FilteredRenderJSON.java From actframework with Apache License 2.0 | 4 votes |
public static FilteredRenderJSON of(H.Status status, final Object v, final PropertySpec.MetaInfo spec, final ActionContext context) { touchPayload().status(status); return of(v, spec, context); }
Example 19
Source File: FilteredRenderJSON.java From actframework with Apache License 2.0 | 4 votes |
public FilteredRenderJSON(H.Status status, final Object v, final PropertySpec.MetaInfo spec, final ActContext context) { super(status, new JsonUtilConfig.JsonWriter(v, spec, false, context)); }
Example 20
Source File: RenderTemplate.java From actframework with Apache License 2.0 | 4 votes |
public static RenderTemplate of(H.Status status, Map<String, Object> args) { touchPayload().status(status); renderArgsBag.set(args); return INSTANCE; }