public RedirectController(String uri) throws PragmatachException { try { this.uri = new URI(uri); } catch (final Exception e) { throw new PragmatachException(e); } }
@Override public void render(HttpServletResponse httpServletResponse) throws PragmatachException { try { if (null != resourceInputStream) { IOUtils.copy(resourceInputStream, httpServletResponse.getOutputStream()); } } catch (final Exception e) { throw new PragmatachException("Exception in render", e); } } }
private String getTemplateAsString(InputStream templateInputStream) throws PragmatachException { try { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); IOUtils.copy(templateInputStream, baos); return baos.toString("UTF-8"); } catch (final Exception e) { throw new PragmatachException("Exception in getTemplateAsString", e); } }
@Override public void render(HttpServletResponse httpServletResponse) throws PragmatachException { try { final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(json.getBytes()); IOUtils.copy(byteArrayInputStream, httpServletResponse.getOutputStream()); } catch (final Exception e) { throw new PragmatachException("Exception in render", e); } } }
@Override public void render(HttpServletResponse httpServletResponse) throws PragmatachException { try { streamingController.render(inputStream, httpServletResponse.getOutputStream()); } catch (final Exception e) { throw new PragmatachException("Exception in render", e); } } }
/** * get the HTTP POST body */ public String getPostBody() throws PragmatachException { try { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); IOUtils.copy(getInputStream(), baos); return baos.toString("UTF-8"); } catch (final Exception e) { throw new PragmatachException("Exception in getRequestBody", e); } }
public static String serialize(PragmatachController pragmatachController) throws PragmatachException { try { final JSONObject jSONObject = new JSONObject(); for (final Field field : pragmatachController.getClass().getDeclaredFields()) { final String fieldValue = serializeField(PropertyUtils.getProperty(pragmatachController, field.getName())); jSONObject.put(field.getName(), fieldValue); } return jSONObject.toString(); } catch (final Exception e) { throw new PragmatachException("Exception in serialize", e); } }
/** * parse YAML to map */ public static Map<String, String> parseYAML(InputStream inputStream) throws PragmatachException { try { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); IOUtils.copy(inputStream, baos); return parseYAML(baos.toString()); } catch (final Exception e) { throw new PragmatachException("Exception in parseYAML", e); } }
/** * the annotation scanner will have run; we can just query for annotated classes */ protected static Set<Class<?>> getEntityClasses() throws PragmatachException { try { return AnnotationScanner.getAllClasses(Entity.class); } catch (final Exception e) { throw new PragmatachException("Exception in getAnnotatedClasses", e); } }
/** * delete */ @Override public void delete(T t) throws PragmatachException { try { ebeanServer.delete(t); } catch (final Exception e) { throw new PragmatachException("Exception in delete", e); } }
/** * update object */ @Override public void update(T t) throws PragmatachException { try { ebeanServer.update(t); } catch (final Exception e) { throw new PragmatachException("Exception in save", e); } } }
private static void scanClassPath() throws PragmatachException { try { final URL[] urls = ClasspathUrlFinder.findClassPaths(); annotationDB.scanArchives(urls); } catch (final Exception e) { throw new PragmatachException("Exception in scanClassPath", e); } }
protected InputStream getStaticResourceInputStream(String[] imageResource) throws PragmatachException { try { final String resourceUri = buildWildcardResourceURI(imageResource); return getResource(PUBLIC_RESOURCE_DIR + resourceUri); } catch (final Exception e) { throw new PragmatachException("Exception in getStaticResourceInputStream", e); } }
@Override public void populateController() throws PragmatachException { try { ControllerBeanUtil.populateController(this, getPostFieldValues()); } catch (final Exception e) { throw new PragmatachException("Exception in populateController", e); } } }
private Map<String, String> getPostFieldValues() throws PragmatachException { try { return PragmatachYAML.parseYAML(getRequest().getInputStream()); } catch (final Exception e) { throw new PragmatachException("Exception in getPostFieldValues", e); } }
@Route(uri = "/*") public Response render(String[] resource) throws PragmatachException { try { return redirect("/public" + buildWildcardResourceURI(resource)); } catch (final Exception e) { throw new PragmatachException("Exception in render", e); } } }
/** * render the response */ public Response render() throws PragmatachException { try { return new StreamingResponse(getCacheHeaders(), this, getRequest().getInputStream()); } catch (final Exception e) { throw new PragmatachException("Exception in render", e); } }
/** * render */ public Response render() throws PragmatachException { try { final Template template = getFreemarkerTemplate(); return new FreemarkerResponse(getCacheHeaders(), template, getTemplateContext()); } catch (final Exception e) { throw new PragmatachException("Exception in render", e); } }
public Response doLogin() throws PragmatachException { final String sessionID = getRequest().getSession().getId(); if (sessionID != getRequest().getSession().getId()) { throw new PragmatachException("CSRF Exception"); } accessToken = getGoogleAccessToken(code); getUserInfo(accessToken); return super.render(); }
@Route(uri = "/public/*") public Response render(String[] imageResource) throws PragmatachException { try { final InputStream is = getStaticResourceInputStream(imageResource); return new StaticResourceResponse(getCacheHeaders(), is); } catch (final Exception e) { throw new PragmatachException("Exception in render", e); } } }