private static void startOrFinish(Object resource, Method m, Class<?>[] p, HttpServletRequest req, HttpServletResponse res) throws RestException, InternalServerError { if (m != null) { Object[] args = new Object[p.length]; for (int i = 0; i < p.length; i++) { if (p[i] == HttpServletRequest.class) args[i] = req; else if (p[i] == HttpServletResponse.class) args[i] = res; } try { m.invoke(resource, args); } catch (RestException e) { throw e; } catch (Exception e) { throw new InternalServerError(e); } } }
/** * Constructor. * * @param msg The message. Can be <jk>null</jk>. */ public InternalServerError(String msg) { super(msg); setStatus(CODE); }
private static void startOrFinish(Object resource, Method m, Class<?>[] p, HttpServletRequest req, HttpServletResponse res) throws RestException, InternalServerError { if (m != null) { Object[] args = new Object[p.length]; for (int i = 0; i < p.length; i++) { if (p[i] == HttpServletRequest.class) args[i] = req; else if (p[i] == HttpServletResponse.class) args[i] = res; } try { m.invoke(resource, args); } catch (RestException e) { throw e; } catch (Exception e) { throw new InternalServerError(e); } } }
/** * Constructor. * * @param msg The message. Can be <jk>null</jk>. */ public InternalServerError(String msg) { super(msg); setStatus(CODE); }
private static void startOrFinish(Object resource, Method m, Class<?>[] p, HttpServletRequest req, HttpServletResponse res) throws RestException, InternalServerError { if (m != null) { Object[] args = new Object[p.length]; for (int i = 0; i < p.length; i++) { if (p[i] == HttpServletRequest.class) args[i] = req; else if (p[i] == HttpServletResponse.class) args[i] = res; } try { m.invoke(resource, args); } catch (RestException e) { throw e; } catch (Exception e) { throw new InternalServerError(e); } } }
/** * Constructor. * * @param msg The message. Can be <jk>null</jk>. */ public InternalServerError(String msg) { super(msg); setStatus(CODE); }
private void postInitOrDestroy(Object r, Method m, Class<?>[] p) { if (m != null) { Object[] args = new Object[p.length]; for (int i = 0; i < p.length; i++) { if (p[i] == RestContext.class) args[i] = this; else if (p[i] == RestContextBuilder.class) args[i] = this.builder; else if (p[i] == ServletConfig.class) args[i] = this.builder.inner; } try { m.invoke(r, args); } catch (RestException e) { throw e; } catch (Exception e) { throw new InternalServerError(e); } } }
private void postInitOrDestroy(Object r, Method m, Class<?>[] p) { if (m != null) { Object[] args = new Object[p.length]; for (int i = 0; i < p.length; i++) { if (p[i] == RestContext.class) args[i] = this; else if (p[i] == RestContextBuilder.class) args[i] = this.builder; else if (p[i] == ServletConfig.class) args[i] = this.builder.inner; } try { m.invoke(r, args); } catch (RestException e) { throw e; } catch (Exception e) { throw new InternalServerError(e); } } }
private void postInitOrDestroy(Object r, Method m, Class<?>[] p) { if (m != null) { Object[] args = new Object[p.length]; for (int i = 0; i < p.length; i++) { if (p[i] == RestContext.class) args[i] = this; else if (p[i] == RestContextBuilder.class) args[i] = this.builder; else if (p[i] == ServletConfig.class) args[i] = this.builder.inner; } try { m.invoke(r, args); } catch (RestException e) { throw e; } catch (Exception e) { throw new InternalServerError(e); } } }
protected ResponseObject(Method m, int i, PropertyStore ps) { super(RESPONSE, m, i); this.meta = ResponseBeanMeta.create(m, i, ps); if (getTypeClass() != Value.class) throw new InternalServerError("Invalid type {0} specified with @Response annotation. It must be Value.", type); }
protected ResponseObject(Method m, int i, PropertyStore ps) { super(RESPONSE, m, i); this.meta = ResponseBeanMeta.create(m, i, ps); if (getTypeClass() != Value.class) throw new InternalServerError("Invalid type {0} specified with @Response annotation. It must be Value.", type); }
protected ResponseStatusObject(Method m, Type t) { super(RESPONSE_STATUS, t); if (getTypeClass() != Value.class || Value.getParameterType(t) != Integer.class) throw new InternalServerError("Invalid type {0} specified with @ResponseStatus annotation. It must Value<Integer>.", type); }
protected ResponseObject(Method m, int i, PropertyStore ps) { super(RESPONSE, m, i); this.meta = ResponseBeanMeta.create(m, i, ps); if (getTypeClass() != Value.class) throw new InternalServerError("Invalid type {0} specified with @Response annotation. It must be Value.", type); }
protected ResponseStatusObject(Method m, Type t) { super(RESPONSE_STATUS, t); if (getTypeClass() != Value.class || Value.getParameterType(t) != Integer.class) throw new InternalServerError("Invalid type {0} specified with @ResponseStatus annotation. It must Value<Integer>.", type); }
protected ResponseStatusObject(Method m, Type t) { super(RESPONSE_STATUS, t); if (getTypeClass() != Value.class || Value.getParameterType(t) != Integer.class) throw new InternalServerError("Invalid type {0} specified with @ResponseStatus annotation. It must Value<Integer>.", type); }
private <T> T getInner(ClassMeta<T> cm) throws BadRequest, UnsupportedMediaType, InternalServerError { try { return parse(cm); } catch (UnsupportedMediaType e) { throw e; } catch (SchemaValidationException e) { throw new BadRequest("Validation failed on request body. " + e.getLocalizedMessage()); } catch (ParseException e) { throw new BadRequest(e, "Could not convert request body content to class type ''{0}''.", cm); } catch (IOException e) { throw new InternalServerError(e, "I/O exception occurred while parsing request body."); } catch (Exception e) { throw new InternalServerError(e, "Exception occurred while parsing request body."); } }
private <T> T getInner(ClassMeta<T> cm) throws BadRequest, UnsupportedMediaType, InternalServerError { try { return parse(cm); } catch (UnsupportedMediaType e) { throw e; } catch (SchemaValidationException e) { throw new BadRequest("Validation failed on request body. " + e.getLocalizedMessage()); } catch (ParseException e) { throw new BadRequest(e, "Could not convert request body content to class type ''{0}''.", cm); } catch (IOException e) { throw new InternalServerError(e, "I/O exception occurred while parsing request body."); } catch (Exception e) { throw new InternalServerError(e, "Exception occurred while parsing request body."); } }
private <T> T getInner(ClassMeta<T> cm) throws BadRequest, UnsupportedMediaType, InternalServerError { try { return parse(cm); } catch (UnsupportedMediaType e) { throw e; } catch (SchemaValidationException e) { throw new BadRequest("Validation failed on request body. " + e.getLocalizedMessage()); } catch (ParseException e) { throw new BadRequest(e, "Could not convert request body content to class type ''{0}''.", cm); } catch (IOException e) { throw new InternalServerError(e, "I/O exception occurred while parsing request body."); } catch (Exception e) { throw new InternalServerError(e, "Exception occurred while parsing request body."); } }
/** * Returns the localized method description. * * <p> * Equivalent to calling {@link RestInfoProvider#getMethodDescription(Method, RestRequest)} with this object. * * @return The localized method description. * @throws RestException * @throws InternalServerError */ public String getMethodDescription() throws RestException, InternalServerError { try { return context.getInfoProvider().getMethodDescription(javaMethod, this); } catch (RestException e) { throw e; } catch (Exception e) { throw new InternalServerError(e); } }
/** * Returns the localized resource title. * * <p> * Equivalent to calling {@link RestInfoProvider#getTitle(RestRequest)} with this object. * * @return The localized resource title. * @throws RestException * @throws InternalServerError */ public String getResourceTitle() { try { return context.getInfoProvider().getTitle(this); } catch (RestException e) { throw e; } catch (Exception e) { throw new InternalServerError(e); } }