/** * ctor */ public Request(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Route.HttpMethod method, ServletConfig servletConfig) { this.httpServletRequest = httpServletRequest; this.servletConfig = servletConfig; this.method = method; headers = new Headers(httpServletRequest, httpServletResponse); cookies = new Cookies(httpServletRequest, httpServletResponse); }
public String getName() { return plugin.getName(); }
/** * search for i8N string across providers */ public String text(String locale, String name) throws PragmatachException { if (null != i8nProviders) { for (final I8NProvider iI8NProvider : i8nProviders) { final String r = iI8NProvider.getString(locale, name); if (null != r) { return r; } } } return null; } }
/** * get username */ private String getUsername() throws PragmatachException { try { return Application.getConfiguration().getParameter("jcr.username"); } catch (final Exception e) { throw new PragmatachException("Exception in getUsername", e); } }
public RedirectController(String uri) throws PragmatachException { try { this.uri = new URI(uri); } catch (final Exception e) { throw new PragmatachException(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); } }
/** * get a resource using the servlet's class loader */ protected InputStream getResource(String resource) throws PragmatachException { try { final ResourceLoader resourceLoader = new DefaultResourceLoaderImpl(request.getServletContext()); return resourceLoader.getResource(resource); } catch (final Exception e) { throw new PragmatachException("Exception in getResource", e); } }
/** * get the instance of a session-bound controller */ @SuppressWarnings("unchecked") public <T> T getSessionScopedController(Class<T> clazz) { return (T) SessionScopedControllers.getController(request.getSession(), clazz); }
@Route(uri = "/pragmatach/admin/cookies/clearCookies", method = HttpMethod.post) public Response clearCookies() throws PragmatachException { getRequest().getCookies().clearAll(); return super.render(); }
/** * encrypt cookie */ private String encryptCookie(String cookie) throws Exception { final String key = getCryptoKey(); if (null != key) { return AES.encrypt(cookie, key); } else { return cookie; } }
/** * get localized date */ public String date(String locale, Date date) throws PragmatachException { if (null != i8nProviders) { for (final I8NProvider iI8NProvider : i8nProviders) { final String d = iI8NProvider.getDate(locale, date); if (null != d) { return d; } } } return null; }
/** * get url */ private String getURL() throws PragmatachException { try { return Application.getConfiguration().getParameter("jcr.url"); } catch (final Exception e) { throw new PragmatachException("Exception in getUsername", 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); } }
private Map<String, String> getPostFieldValues() throws PragmatachException { try { return PragmatachYAML.parseYAML(getRequest().getInputStream()); } catch (final Exception e) { throw new PragmatachException("Exception in getPostFieldValues", e); } }
/** * decrypt cookie */ private String decryptCookie(String cookie) throws Exception { final String key = getCryptoKey(); if (null != key) { return AES.decrypt(cookie, key); } else { return cookie; } }
/** * get workspace */ private String getWorkspace() throws PragmatachException { try { return Application.getConfiguration().getParameter("jcr.workspace"); } catch (final Exception e) { throw new PragmatachException("Exception in getUsername", 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); } }
/** * 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); } }
/** * 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); } } }
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); } }