@Override public void getResource(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { ServletLifecycle.beginRequest(request); try { ServletContexts.instance().setRequest(request); ConversationPropagation.instance().restoreConversationId(request.getParameterMap()); Manager.instance().restoreConversation(); ServletLifecycle.resumeConversation(request); final ReportResult reportResult = (ReportResult) Contexts.getConversationContext().get("user.reportResult"); if (reportResult != null) { response.setContentType("text/csv"); response.setCharacterEncoding("UTF-8"); final PrintWriter out = response.getWriter(); boolean first = true; for (final ColumnDefinition column : reportResult.getGroupByColumns()) { if (!first) { out.print(DELIM); } out.print(toCSVString(column.getHeader())); first = false; } for (final ColumnDefinition column : reportResult.getColumns()) { if (!first) { out.print(DELIM); } out.print(toCSVString(column.getHeader())); first = false; } out.println(); for (final ReportResultGroup group : reportResult.getGroups()) { writeReportGroup(0, group, out); } for (final ReportRow row : reportResult.getRows()) { writeReportRow(row, reportResult.getColumns(), out); } out.close(); } } finally { ServletLifecycle.endRequest(request); } }
private void redirectUrl(byte[] d) { String viewId = Pages.getViewId(FacesContext.getCurrentInstance()); String baseName = Pages.getCurrentBaseName(); ExcelWorkbook e = ExcelFactory.instance().getExcelWorkbook(""); DocumentData documentData = new ByteArrayDocumentData(baseName, e.getDocumentType(), d); String id = DocumentStore.instance().newId(); String url = DocumentStore.instance() .preferredUrlForContent(baseName, e.getDocumentType().getExtension(), id); url = Manager.instance().encodeConversationId(url, viewId); DocumentStore.instance().saveData(id, documentData); try { FacesContext.getCurrentInstance().getExternalContext().redirect(url); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } }
@Test public void testLogin() throws Exception { Identity identity = Identity.instance(); assertFalse(identity.isLoggedIn()); identity.setUsername("gavin"); identity.setPassword("foobar"); identity.login(); User user = (User) Component.getInstance("user"); assertEquals("Gavin King", user.getName()); assertEquals("gavin", user.getUsername()); assertEquals("foobar", user.getPassword()); assertFalse(Manager.instance().isLongRunningConversation()); assertTrue(identity.isLoggedIn()); identity.logout(); assertTrue(Session.instance().isInvalid()); assertFalse(identity.isLoggedIn()); }
public String getParameterValue() { return Manager.instance().getCurrentConversationId(); }
public String getParameterName() { return Manager.instance().getConversationIdParameter(); }